Наши партнеры

Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

Next: Configuring TCP/IP Networking Up: Setting up the Serial Previous: Accessing Serial Devices

Serial Hardware

currently supports a wide variety of serial boards which use the RS-232 standard. RS-232 is currently the most common standard for serial communications in the PC world. It uses a number of circuits for transmitting single bits as well as for synchronization. Additional lines may be used for signaling the presence of a carrier (used by modems), and handshake.

Although hardware handshake is optional, it is very useful. It allows either of the two stations to signal whether it is ready to receive more data, or if the other station should pause until the receiver is done processing the incoming data. The lines used for this are called ``Clear to Send'' (CTS) and ``Ready to Send'' (RTS), respectively, which accounts for the colloquial name of hardware handshake, namely ``RTS/CTS''.

In PCs, the RS-232 interface is usually driven by a UART chip derived from the National Semiconductor-16450 chip, or a newer version thereof, the NSC-16550Agif. Some brands (most notably internal modems equipped with the Rockwell chipset) also use completely different chips that have been programmed to behave as if they were 16550's.

The main difference between 16450's and 16550's that the latter have a FIFO buffer of 16 Bytes, while the former only have a 1-Byte buffer. This makes 16450's suitable for speeds up to 9600-Baud, while higher speeds require a 16550-compatible chip. Besides these chips, also supports the 8250 chip, which was the original UART for the PC-AT.

In the default configuration, the kernel checks the four standard serial ports COM1 through COM4. These will be assigned device minor numbers 64 through 67, as described above.

If you want to configure your serial ports properly, you should install Ted Tso's setserial command along with the rc.serial script. This script should be invoked from /etc/rc at system boot time. It uses setserial to configure the kernel serial devices. A typical rc.serial script looks like this:

           # /etc/rc.serial - serial line configuration script.
           # Do wild interrupt detection
           /sbin/setserial -W /dev/cua*

           # Configure serial devices
           /sbin/setserial /dev/cua0 auto irq skip test autoconfig
           /sbin/setserial /dev/cua1 auto irq skip test autoconfig
           /sbin/setserial /dev/cua2 auto irq skip test autoconfig
           /sbin/setserial /dev/cua3 auto irq skip test autoconfig

           # Display serial device configuration
           /sbin/setserial -bg /dev/cua*
Please refer to the documentation that comes along with setserial for an explanation of the parameters.

If your serial card is not detected, or the setserial -bg command shows an incorrect setting, you will have to force the configuration by explicitly supplying the correct values. Users with internal modems equipped with the Rockwell chipset are reported to experience this problem. If, for example, the UART chip is reported to be a NSC-16450, while in fact it is NSC-16550-compatible, you have to change the configuration command for the offending port to

           /sbin/setserial  /dev/cua1  auto irq skip test autoconfig
           uart 16550
Similar options exist to force COM port, base address, and IRQ setting. Please refer to the setserial(8) manual page.

If your modem supports hardware handshake, you should make sure to enable it. Surprising as it is, most communication programs do not attempt to enable this by default; you have to set it manually instead. This is best performed in the rc.serial script, using the stty command:

           $ stty crtscts < /dev/cua1
To check if hardware handshake is in effect, use
           $ stty -a < /dev/cua1
This gives you the status of all flags for that device; a flag shown with a preceding minus as in -crtscts means that the flag has been turned off.
Next: Configuring TCP/IP Networking Up: Setting up the Serial Previous: Accessing Serial Devices

Andrew Anderson
Thu Mar 7 23:22:06 EST 1996