7

The specification for termios.h includes a facility for controlling the number of bits per character sent over the serial line, the CSIZE and CSn constants. You can request five, six, seven, or eight bits per character.

Nowadays, of course, five- and six-bit-per-character serial protocols are thoroughly obsolete. It seems logical that there must have, historically, been Unixes that did implement five- or six-bit terminal I/O, because the constants wouldn't exist if not, but I've browsed through the serial drivers of contemporary, Linux and FreeBSD and I have the impression that most of them either ignore or refuse a request to put a serial line into five- or six-bit mode. (Every driver has its own implementation of tcsetattr, which makes it extremely tedious to try to find out if any driver still supports these modes.) Coming at it from the other end, the Teletype Model 33 was already a seven-bit terminal in 1963, and all the references I can find for five- and six-bit codes still in use in the 1970s make them sound like they were only used for special purposes and not for general serial communication.

Furthermore, the termios interface doesn't give you any way to specify what character encoding to use in five- or six-bit mode, despite the many competing standards and the apparent necessity of translating from ASCII, so I'm guessing this isn't a case of "we have one computer and several hundred terminals of various models -- make it work with all of them", as the story goes re the development of the higher-level termcap/terminfo system.

So, the question is, what historical implementations of Unix did implement five- and/or six-bit terminal I/O, for use with what peripherals, and which character encodings?

7
  • 2
    Many old teletypes (not the Model 33 ASR; it was the first ASCII teletype) were 5-bit. Thus, I'd bet it was added the first time someone at Bell needed to use an old tty (which weren't that old in the early 1970s).
    – RonJohn
    Mar 16, 2023 at 18:18
  • ia800606.us.archive.org/17/items/enf-ascii/ascii.pdf has interesting info that may be useful.
    – Jon Custer
    Mar 16, 2023 at 19:17
  • And en.wikipedia.org/wiki/Teletype_Corporation lists various models. Baudot varieties were around for some time, even if only as printers.
    – Jon Custer
    Mar 16, 2023 at 19:21
  • 3
    The chain of thought may be a bit longer. The drivers have support for UART features, and UARTs commonly have had support for 5 to 8 bit frames, and UARTs were designed support those values to either be compatible with existing equipment, or allow making new equipment that use 5 bit frames.
    – Justme
    Mar 16, 2023 at 19:31
  • 6
    If you look at early 1970s line interfaces for the PDP-11, they mostly come with programmable support for 5, 6, 7, 8 bit frames. So I suspect that it was less a matter of 'what terminals do we have' than 'what line cards do we support'.
    – dave
    Mar 17, 2023 at 0:56

2 Answers 2

6

They were supported by Unix System III with the DH11 and DZ11 asynchronous multiplexers (serial line interfaces for DEC systems).

While termios.h is only in POSIX systems, the constants come from the similarly-named termio.h in the AT&T operating system. The DH11 driver passes the bits to the register like so (the DZ11 driver is mostly the same):

    lpr = (flags&CBAUD)<<10;
    if (flags&CREAD)
        lpr |= (flags&CBAUD)<<6;
    if (flags&CS6)
        lpr |= BITS6;
    if (flags&CS7)
        lpr |= BITS7;
    if (flags&PARENB) {
        lpr |= PENABLE;
        if (flags&PARODD)
            lpr |= OPAR;
    }
    if (flags&CSTOPB)
        lpr |= TWOSB;

Note that termio.h defines the size constants like so:

#define CSIZE   0000060
#define CS5 0
#define CS6 0000020
#define CS7 0000040
#define CS8 0000060

It doesn't seem that this affects anything other than what is passed to the register for the particular serial line.

4

While many types of peripheral assumed fewer than 7-bits per character (i.e. did not support 7-bit ASCII), I think it's important to appreciate that just because termios supports a setting doesn't mean that it's intended for an interactive shell session.

So even today you would use termios to set up a non-standard (e.g. six-bit 110-BPS) connection to /dev/ttyUSB0 talking to an Arduino outputting nothing but numbers to a display device.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .