raw/cooked single char i/o
guy at rlgvax.UUCP
guy at rlgvax.UUCP
Fri Jun 17 06:50:25 AEST 1983
The USG tty driver's equivalent of these bits:
IN_8BIT /* 8 bit input */
Turn off ISTRIP (strip input characters to 7 bits) and INPCK (enable input
parity checking) in c_iflag.
OUT_8BIT /* 8 bit output */
Set the character size to CS8 (yes, it also supports CS5 and CS6 as well
as CS7) and turn off PARENB in c_cflag.
The ability to select 7+parity vs. 8 on input independly from on output
depends, of course, on the hardware supporting it; reading the "Terminals
and Communications Handbook", my interpretation is that if you set 7+parity
you will still get handed all 8 bits on input, but you can tell the receiver
not to check parity on input while it still generates parity on output. The
ISTRIP bit doesn't condition any hardware bits, it merely controls whether
the character is masked with 0177 or 0377.
ECHO /* echo all input */
Same name, in c_lflag.
CTLECHO /* echo control chars as ^x */
Not in the USG driver, but it should be; call it ECHOCTL (just like CRTERASE
is called ECHOE(!)) and put it in c_lflag.
CBREAK /* wake up on all input */
Turn off ICANON (canonical input - erase and kill processing) in
c_lflag.
the usual tab, CR, NL, FF delay/expansion
They are much the same, and are in c_oflag. All that processing
can be efficiently turned off by turning off OPOST (postprocess output)
in c_oflag - characters are moved from user space to the clist as directly
as possible.
ECHONL /* Echo NL after CR, for half-duplex with ~ECHO */
It's there, even under the same name, in c_lflag.
BREAKNULL /* Change BREAK to null instead of sending signal */
Turn off IGNBRK (ignore breaks), BRKINT (send SIGINT on breaks), and PARMRK
(mark parity errors framing errors, and overruns with "\377\000" in the
input stream) in c_iflag.
BREAKIGN /* Ignore BREAK completely */
Turn on IGNBRK in c_iflag. Note that the handling of a break in
V7, at least, is a bit of a kludge; it pretends that it received your
interrupt character (actually, the code is buggy and it pretends it received
a RUBOUT) and hands it to ttyinput(). The USG driver handles it separately,
so even if you turn off your interrupt and quit characters you can still send
a SIGINT to your process by hitting the BREAK key.
and all the special characters in one structure.
Which they are.
If you set neither, then BREAK should generate SIGINT in ANY mode.
Which it does.
End of commercial, but it would be nice, considering 4.2BSD has already
adopted the USG "open" system call, if the people at Berkeley would consider
adopting an enhanced version of the USG tty driver (including all their
additional modes and control characters) for 4.2BSD or a later release.
Note that the "ioctl" calls have different names - the modes are set by
TCSETA - so the old calls could be kept around for compatibility. There
are such backward compatibility features in the USG driver, but unfortunately
for those of us not within AT&T they're backwards compatible with UNIX/TS 1.0
rather than with V7 or 4.1BSD.
I can't see any legal arguments against it, since they've already put the
USG "open" system call in (and since you get the System III C compiler, the
PWB/UNIX 2.0? UUCP, the System IV? "sdb", "efl", and two pieces of the
Writer's Workbench with 4.1BSD), and the only technical argument I can see
against it (assuming the old "ioctl"s are left in for backward compatibility)
is that it would take time to design and implement. And it would probably
reduce the number of complaints about "I can't do this with the vanilla TTY
driver" nearly to zero; you can even talk to Baudot lines (doing your own
translation in your program) if you want.
Guy Harris
RLG Corporation
{seismo,mcnc,we13,brl-bmd,allegra}!rlgvax!guy
More information about the Comp.unix.wizards
mailing list