raw mode vs cooked mode
Guy Harris
guy at auspex.auspex.com
Wed Feb 27 06:19:19 AEST 1991
>>I would like to write a program which will get characters from the terminal
>>in "raw" mode. The default is "cooked" mode. Can someone point me in the
>>right direction? I am using a Sun Workstation running UNIX 4.2 BSD.
>
>This should be in a FAQ somewhere. If your system groks termio, then
>here is what you could have:
It's what he should have *if*, by "raw mode", he means "a mode in which
the parity and bits-per-character are the same as 'normal', characters
are made available to a program reading from the device as they're
typed, and the only characters that are treated specially are the XON
and XOFF characters."
That happens to be what a lot of people who want some flavor of "less
cooked" mode want. Others may want a raw 8-bit data path with *no*
characters treated specially (for, say, binary data transfer), or may
want the interrupt characters to be treated specially. I have no idea
what the person who asked the question wanted; they didn't give any
details, they just asked for "raw" mode.
The "old" tty driver (V7, and its pre-4.3-reno BSD descendant)
had RAW for the raw 8-bit data path, and CBREAK for "make characters
available as they're typed, and don't treat the erase/kill/<RETURN>/etc
characters specially." To turn of the interrupt characters as well, you
could set them to '\377', as in CBREAK mode input was stripped to 7 bits
(unless you turned PASS8 on, in 4.3BSD or later).
(RAW also turned off any special character handling on *output*.)
The "new" tty driver (S3, S5, 4.3-reno and successors, POSIX) does a
better job of specifying those modes; you have much finer control over
what the driver does.
(Also, since they said the Sun was running "UNIX 4.2 BSD", I suspect it
was running a SunOS release prior to 4.0, which means that, unless he
was working in the S5 environment, the system *doesn't* grok "termio" -
it has the "old" tty driver.)
More information about the Comp.unix.programmer
mailing list