# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393
#' Initiate a connection to the serial port
#'
#' @param serialport Name of the serial port (e.g. "/dev/tty.usbserial","COM1")
#' @param baud Baud rate (bps) in integer.
#'
#' @description This function sets up a connection to the serial port at the
#' specified port name and baud rate. The port is set in 8-N-1 mode and is
#' opened in fully raw mode so you can send binary data.
#'
#' @examples
#' \dontrun{
#' # On Windows
#' con <- ar_init("COM1")
#'
#' # On Mac
#' con <- ar_init("/dev/cu.SLAB_USBtoUART")
#' }
#'
#' @return If connection is setup successfully, this function will return the
#' file descriptor. If not, it will return -1.
#'
#' @export
ar_init <- function(serialport, baud = 9600L) {
.Call('_arduinor_ar_init', PACKAGE = 'arduinor', serialport, baud)
}
#' Check if a file descriptor is still open
#'
#' @description This function checks whether a stored file descriptor is still
#' open.
#'
#' @param fd File descriptor returned by `ar_init()`. Should be an integer.
#' @examples
#' \dontrun{
#' con <- ar_init("/dev/cu.SLAB_USBtoUART")
#' ar_is_open(con)
#' }
ar_is_open <- function(fd) {
.Call('_arduinor_ar_is_open', PACKAGE = 'arduinor', fd)
}
#' Close Connection to a serial port
#'
#' @description This function closes the connection opened by `ar_init()`.
#'
#' @param fd File descriptor returned by `ar_init()`. Should be an integer.
#'
#' @examples
#' \dontrun{
#' con <- ar_init("/dev/cu.SLAB_USBtoUART")
#' ar_close(con)
#' }
#'
#' @export
ar_close <- function(fd) {
.Call('_arduinor_ar_close', PACKAGE = 'arduinor', fd)
}
#' Read one entry of input from an opened serial connection
#'
#' @description This function reads one entry of input from an opened serial
#' port. Each line of entry is identified by the end of line character
#' `eolchar`.
#'
#' @param fd File descriptor returned by `ar_init()`. Should be an integer.
#' @param eolchar End of line character. Default value is `'\\n'`
#' @param buf_max Maximum length of one line of entry. Default is 256.
#' @param timeout Timeout for reads in millisecs. Default is 5000 ms.
#'
#' @examples
#' \dontrun{
#' con <- ar_init("/dev/cu.SLAB_USBtoUART")
#' ar_read(con)
#' }
#'
#' @export
ar_read <- function(fd, eolchar = '\n', buf_max = 256L, timeout = 5000L) {
.Call('_arduinor_ar_read', PACKAGE = 'arduinor', fd, eolchar, buf_max, timeout)
}
#' Flush serial port
#'
#' @description clearing the serial port's buffer
#'
#' @param fd File descriptor returned by `ar_init()`. Should be an integer.
#'
#' @examples
#' \dontrun{
#' con <- ar_init("/dev/cu.SLAB_USBtoUART")
#' ar_flush(con)
#' }
#'
#' @export
ar_flush <- function(fd) {
.Call('_arduinor_ar_flush', PACKAGE = 'arduinor', fd)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.