Isis software documentation
This document explains the routines for configuring terminal
attributes and doing RS-232 serial communication in Isis.
Opening and initializing a serial port
(initialize-serial-port port baud databits stopbits parity flow)
In Unix, you can open a serial port on your machine for reading and
writing simply by opening a file in the "/dev" directory of
the filesystem using the Isis open- routines.
Usually, the first serial port on your computer will correspond to the
file name "/dev/ttyS0", and the second will be
"/dev/ttyS1", and so on, but check with your system
administrator if you are unsure.
After you open the file, you can initialize the RS-232 attributes of
the port using initialize-serial-port. The port
argument should be the newly-obtained Isis port that connects to that
serial port. baud should be an integer baud rate (only
standard baud rates are allowed, so check what your computer is
capable of). databits should be an integer number of data
bits, and stopbits should be the number of stop bits.
parity should be Null for no parity, the string
"even" for even parity, or "odd" for odd parity.
Finally, flow should be either True or
False indicating whether RTS-CTS flow control should be used.
The following example opens the serial port for reading and writing,
and then configures it for 9600 baud, 8 data bits, 1 stop bit, no
parity, and no flow control.
(set sport (open-update "/dev/ttyS0"))
(initialize-serial-port sport 9600 8 1 Null False)
Other terminal control routines
(send-break port milliseconds)
(set-tty-mode port iflags oflags cflags lflags ispeed ospeed)
send-break sends a break condition to the terminal connected
to port for the specified number of milliseconds.
drain waits for all pending output to the given terminal to
be transmitted and then returns True if successful.
get-tty-mode and set-tty-mode are very similar to
the C routines tcgetattr and tcsetattr. However,
the initialize-serial-port routine described above should be
satisfactory for almost all RS-232 applications. If you need to use
these functions for more control, please read the termios man
page before doing so.
get-tty-mode returns the terminal attributes associated with
the given file handle as a list of 6 integers [iflags oflags
cflags lflags ispeed ospeed]. set-tty-mode sets the
values of these attributes.
iflags, oflags, cflags, and lflags
are all bit-fields whose values are obtained by bit-or-ing
together the constants listed below. ispeed and
ospeed should be integer baud rates that are supported by
your machine. For explanations on the meaning of each constant,
see the termios man page.
Constants for use in iflags (input attributes):
Constants for use in oflags (output attributes):
Constants for use in cflags (control attributes):
Constants for use in lflags (local attributes):