[net.unix-wizards] attaching non-terminals to DZ ports

tom (04/19/83)

There really isn't much of a problem connecting non-terminals (printers,
plotters, digitizers, and the like) onto a DZ or any other device
using UNIX's "tty" driver code.  The main tricks are:  (1) turning off
what you don't want, and (2) turning on what you do want.

The first thing that you don't want is "getty" doing a "login" on the
device.  This is easily turned off by manipulating your /etc/ttys file
or /etc/inittab file (depending on your UNIX version) to ignore that
particular line.  The process using the device now simply opens that
line like any other file.

Once this is accomplished, you must set your own "stty" options.
You will probably want "raw" or "cbreak", most input/output
"cooking" turned off, the right baud rate, and so on.  NOTE:  be careful
of "raw" which turns off your XON/XOFF processing, which many of these
devices require.  Likewise you may want "tandem" mode so
UNIX can shut off the data it receives before overrunning its buffers.

Warning here:  on earlier versions of UNIX (I don't know about SYS4),
if no process is running on a DZ line, the DZ driver re-set the "stty"
settings to some fixed values, usually undesireable.  This means that
every time a process opens the line after everyone else had already closed
it, the "stty" needs to be re-done.  This can be dealt with by the
process in question, which then needs to know what the proper settings
are.  If this isn't possible, the commonest solution I've found is to have
a program started up by /etc/rc which opens the port and does nothing but
sit around, keeping the port open.  Once this is started, you can "stty"
the line once and the driver will not re-set them back. An example is:

	while true
	do sleep some-very-large-number
	done > /dev/ttya &
	stty your-settings-here > /dev/ttya

Using C, doing an open() and pause() is more efficient.

Note:  The above notes are very general, covering virtually all known
UNIX systems (even V6!) and may well be overkill on some.  It looks to
me that in later UNIX versions, /etc/inittab provides the capability
to start the desired program on the desired port without messing
with /etc/rc.  I have not tried it myself.

- Tom Beres
{we13, seismo, mcnc}!rlgvax!tom