R/nBytes.R

Defines functions nBytesInQueue

Documented in nBytesInQueue

#' Reads out the number of characters / bytes pending in the input and output buffer
#' 
#' @param con serial connection
#' 
#' @return named vector with number of bytes
#' @seealso \code{\link{serial}}
#' @examples
#'  # See the top package documentation
#' @export
nBytesInQueue <- function(con)
{
  if(!isOpen(con))
    stop(simpleError(paste(con$port,'is not open!')))
  
  tryCatch({
    tmp <- tclvalue(.Tcl( paste( 'fconfigure ${sdev_', con$var,'} -queue', sep = '' ) ) )
  } 
  ,error = function(e) stop(simpleError(e$message))
  )
  
  res <- as.numeric(strsplit(tmp," ")[[1]])
  names(res) <- c("n_in","n_out")
  return(res)
}

Try the serial package in your browser

Any scripts or data that you put into this service are public.

serial documentation built on July 1, 2020, 10:53 p.m.