Serial Ports


SGI - Mac
Ive made a set of routines to access serial communications. Its of the basic "Open a port, write a buffer, read a buffer..." style, but now that its abstracted it saves me from thinking about ioctl() anymore. I dont promise robustness, but Ive used them for simple communication with a Faro Digitizing Arm, and a servo driver. Its making a lousy assumption about being on the second serialport on my indy, you'll probably have to change the device.

Another set of code also works on a mac, same API. Its not safe to use at interupt time though. Assumes modem port, but its easy to change. I turn off all flow control, but at the least the code is a reasonable example of useing the Serial Driver.

Note: The SGI software was IRIX 6.2. The serial interface has changed regarding setting bps, and is wrong for 6.3-6.5. The change is trivial, but I haven't fixed it in this code yet.


Serial_OpenPort() - Specify baud, etc...
Serial_Read() - no blocking
Serial_ReadBlocking() - block until at least 1 byte is avail
Serial_Write()
Serial_ClosePort()
Serial_BytesAvail() - boolean return value
Serial_FlushInput() - clear the input queue

Source and sample code for SGI - /u/jedavis/src/lib/serialport
Source and example for Mac (binhex) - /u/jedavis/src/lib/libmac/Examples/Serial.sit.hqx
Possibly newer versions of serial_mac.cp and serial_mac.h - /u/jedavis/src/lib/libmac


James Davis - jedavis@cs.stanford.edu