A serial communication interface for R.
This R package provides the functionality to use the serial communication ports "COM" or "tty" to use the RS232/RS422/RS485 functionality of the corresponding hardware. Also virtual COM-ports via USB do work, as long as they are mapped to COM[n] (win) or tty[n] (Linux) in the operating system.
opens a serial connection
closes the serial connection
byte wise read from the interface as long as the buffer is empty
writes a string to the serial interface
test a connection, whether it is open or not
list all available ports on the system
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
# for this example I used the 'null-modem' emulator 'com0com' for Windows # which is available on 'http://com0com.sourceforge.net/' # Here the pair of com-ports is 'CNCA0' <-> 'CNCB0' # Test the functionality: # ====================== # # first: install the virtual null-modem connection like # com0com (win) or tty0tty (linux) # Hint: Some unix insist on port names like 'ttyS[n]'. # # second: setup a terminal program (like HTerm or gtkterm) and listen to # com-port 'CNCB0' (or what ever you have installed) # or (for unix only) 'cat /dev/tnt1' will output tnt1 to console ## Not run: # Now configure one of the com-ports with appropriate connection properties con <- serialConnection(name = "testcon",port = "CNCA0" ,mode = "115200,n,8,1" ,newline = 1 ,translation = "crlf" ) # let's open the serial interface open(con) # write some stuff write.serialConnection(con,"Hello World!") # read, in case something came in read.serialConnection(con) # close the connection close(con) ## End(Not run)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.