'serial.dll' is a fairly low-level library that is designed to do just four things:
1) Open a connection to a com serial port, e.g.:
; Open an RS232 connection on COM port 1 in Read/Write mode with 19200 baud rate,
; interpreting data as 7-bit values, using odd parity and 2 stop bits
comPortHandle = COMM_OPEN('COM1', BAUD=19200, DATA=7, $
MODE=3, PARITY='O', STOP=2
2) Write raw binary data to the port after connection
data = byte('Hello')
nBytesWritten = WRITE_COMM(comPortHandle, data)
if nBytesWritten ne 5 then print, 'ERROR: Not all bytes were sent!'
3) Read raw binary data from the port after connection
messageBuffer = bytarr(1024)
offset = 0
nBytes = COMM_READ(comPortHandle, BUFFER=messageBuffer, $
NMAX=n_elements(messageBuffer)
; Let's say we are expecting a 36-byte message
offset += nBytes
if offset lt 36 then $
nBytes = COMM_READ(comPortHandle, BUFFER=messageBuffer, $
OFFSET=offset, NMAX=n_elements(messageBuffer)-offset
; ... etc.
4) Terminate the connection in an orderly fashion
if COMM_CLOSE(comPortHandle) ne 1 then $
print, 'ERROR: Orderly termination of serial port connection failed!'
This is not to say that I have run any of these commands. But that is what I observe for logical coding approach and syntax based on the 'readme.txt' instructions that come with that User Contrib download.
Anyhow, that is all this library does. The protocol one uses for reading and writing on the serial port is completely outside the scope of this library. You must know exactly what the format will be of the various messages you might share with the device to which you are connected. And it is likely that you must know this protocol at a very primitive level.
Share with the group here what experiences you have.
Good luck,
James Jones
|