Subject: defaults for tty open
To: None <tech-kern@NetBSD.ORG>
From: Bill Studenmund <wrstuden@loki.stanford.edu>
List: tech-kern
Date: 01/29/1996 17:40:17
As part of porting Gordon Ross's M.I. Z8530 scc driver to the
mac68k port, I have a question about setting the defaults
on a tty port upon open.

Basically the question is whether or not the defaults are always
enforced upon open.

The old mac68k driver, the pmax, alpha, atari, and amiga (different
chip) drivers all look to see if (tp->t_ispeed == 0) before setting
the t_iflag, t_cflag, t_lflag, and t_oflag values to the defaults,
TTYDEF_xFLAG.

The sun and sparc ssc drivers, and the isa/com driver have no such
test. They'll reset the port to TTYDEF_xFLAG every time. Oh, the
default speed also gets set. Additionally, it seems this latter
behavior might be POSIX-required. ??

So what? The reason I've dug into the serial driver for the mac68k port
is to get my DeskWriter to work. It transmits at 57600, and sends the
mac a status byte every 2 seconds. Thus I have two problems using
the printer:

1) 57600 is not a baud rate which lpd supports. Also, it was not clear
how to get the equivelant of "stty raw crtscts" in the printcap
flags. :-(

2) If we EVER get echo turned on, then we get all these status bytes
sent back to the printer. They print out as white-on-black characters,
waste lots of ink, and look quite ugly.

Thus I can't use lpd to set up the serial port. I thought about hacking
on lpd, but I gather it needs lots of work, and don't want to get
into that mess. :-) Also, we need echo to ALWAYS be off.

My solution was to go with the (tp->t_ispeed == 0) test, and have a
stty -f /dev/tty01 57600 raw crtscts in my rc.local. Thus lpd wouldn't
change the defaults, and they'd be right on open.

Now we come to the new MI scc driver. It needs to blend both behaviors
thus placating the masses and enhancing accetance. :-) I have ideas,
but I want to know what y'all think.

First, adding a flag with the (tp->t_ispeed == 0) test would let ports
decide which way to behave.

If we run with this idea, an ioctl should be able to set this flag.
But to help me with my always wanting echo off, we can keep defaults
flags for each port. An ioctl can copy the current settings to the
defaults (if permitted), and then this open-behavior flag can enforce
them. Thus an admin with a shared device with weird defaults can
preset the correct defaults.

I've already coded this behavior in my copy of the tty unit from
the new scc driver.

What do people think? Note: I'm not suggesting that all the other
drivers must be re-written! I'm just asking about our desired
idiosyncracies. Is there a precedent for such behavior?

Take care,

Bill