UNIX Serial Port Programming Examples

Written by Paul Bourke
Original: April 1997, Updated: April 2001


Latest example for Tru64 on Digital XP1000s

This version should be fully POSIX compliant (I hope). The source code is provided here: tru64.c, the XP1000 this was tested on has two serial ports, /dev/tty00 and /dev/tty01. It also illustrates how to turn terminal IO, for example fgetc(), into no blocking versions.

Original SGI Example

Since I had so many problems the first time I wanted to talk to a modem over a serial port from an SGI, perhaps others do also. Here is my test source code (sgi.c) for opening a serial device (/dev/ttym2), configuring it, writing to it, reading from it, and finally closing it. Please note that this is not a serial library but rather the testing procedure I went through before writing a small library (seriallib.c, seriallib.h)