RS-232
Contents
RS-232
RS-232 is the serial communications protocol that won't die. It's been around since the 60's.
RS-232 is also known as RS232, RS-232-C, RS-232-D, EIA-232, TIA-232E, TIA-232-F -- and even V.28/V.24. These standards are not identical, but RS-232 will get you close to what you want. In theory, the RS-232C standard only specifies the signaling, not how you actually wire it up. The pinouts given in this article are common.
The RS-232C standard requires the transmitter to use +12V (0, logic low) and -12V (1, logic high). The receiver needs only see over +3V and under -3V. Most transmitting ports use only +5V and -5V. Those levels are compatible with most devices and host computers. Maxim is one of the more popular suppliers of RS-232 level shifters or level converters.
DE-9 pinout (AKA: D-sub9, TIA-574, DE-9, and DB-9)
Technically this connector is called a D-sub 9 or a DE-9, but it is often incorrectly referred to as a DB-9. The D refers to the shape of the connector. The E specifies the size of the connector shell. I'm not sure why you couldn't just get that from the number of pins, but whatever...
1 2 3 4 5 6 7 8 9 |
DB-25 pinout
The D specifies the shape of the connector. The B specifies the size of the connector shell. Note that DB-25 may carry two RS-232 lines, but this is rare.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
5-wire RS-232
This is the most common RS-232 connection wiring. It consists of data and hardware flow control lines: TxD, RxD, SGND, RTS, and CTS.
pins 3,2,5,7,8 on DE-9
pins 2,3,7,4,5 on DB-25
line | DE-9 pins | DB-25 pins |
---|---|---|
TxD | 3 | 2 |
RxD | 2 | 3 |
SGND | 5 | 7 |
RTS | 7 | 4 |
CTS | 8 | 5 |
3-wire RS-232
A minimal 3-wire RS-232 connection wiring. It consists only of TxD, RxD, and SGND. You see this in embedded systems a lot.
pins 3,2,5 on DE-9
pins 2,3,7 on DB-25
line | DE-9 pins | DB-25 pins |
---|---|---|
TxD | 3 | 2 |
RxD | 2 | 3 |
SGND | 5 | 7 |
RS-232 DB-25 to DE-9 pinout table
DB-25 |
DE-9 |
line |
description |
direction DTE is the computer DCE is the device |
---|---|---|---|---|
1 |
shield |
ground shield |
||
2 |
3 |
TxD |
Transmit Data |
OUT: DTE -> DCE |
3 |
2 |
RxD |
Receive Data |
IN: DTE <- DCE |
4 |
7 |
RTS |
Request To Send |
OUT: DTE -> DCE |
5 |
8 |
CTS |
Clear To Send |
IN: DTE <- DCE |
6 |
6 |
DSR |
Data Set Ready |
IN: DTE <- DCE |
7 |
5 |
SGND |
signal ground |
< - > |
8 |
1 |
DCD |
Data Carrier Detect |
IN: DTE <- DCE |
9 |
||||
10 |
||||
11 |
||||
12 |
||||
13 |
||||
14 |
||||
15 |
||||
16 |
||||
17 |
||||
18 |
||||
19 |
||||
20 |
4 |
DTR |
Data Terminal Ready |
OUT: DTE -> DCE |
21 |
||||
22 |
9 |
RI |
Rind Indicator |
IN: DTE <- DCE |
23 |
||||
24 |
||||
25 |
using screen as a serial terminal
Screen makes a very good RS-232serial terminal. You can connect a screen window to any serial device in /dev. Most serial devices in linux are named like /dev/ttyS0 and /dev/ttyS1 for a built-in RS-232 port; or for USB-to-RS-232 adapters the names are usually like /dev/ttyUSB0 and /dev/ttyUSB1.
The communication settings are a comma separated list of control modes as would be passed to `stty`. See the man page for `stty` for more info.
Old, slow-speed serial devices usually play nice with 9600 8N1 (9600 baud, 8-bits per character, no parity, and 1 stop bit):
screen /dev/ttyS0 9600,cs8,-parenb,-cstopb,-hupcl
The previous settings work with the Coyote Point E450si load balancers. The Coyote Point E450si manual calls for the following settings:
*9600 baud *8 data bits *no parity *one stop bit *VT100 terminal emulation *ignore hang-ups (if supported); this allows a single terminal session to continue running even if Equalizer restarts.
These settings are for the serial console of an embedded computer board (115200 8N1):
screen /dev/ttyS0 115200,cs8,-parenb,-cstopb,-hupcl
Linux serial TTY communications -- stty
This section shows various ways to watch the serial ports to see what is going on with the signals.
/proc/tty/driver/serial
watch -n 1 cat /proc/tty/driver/serial Every 1.0s: cat /proc/tty/driver/serial Tue Nov 17 11:39:23 2009 serinfo:1.0 driver revision: 0: uart:16550A port:000003F8 irq:4 tx:334 rx:214898 fe:2636 brk:254 RTS|DTR 1: uart:16550A port:000002F8 irq:3 tx:181 rx:12 RTS|CTS|DTR 2: uart:unknown port:000003E8 irq:4 3: uart:unknown port:000002E8 irq:3
`setserial`
watch -n 1 setserial -avg /dev/ttyS* Every 1.0s: setserial -avg /dev/ttyS0 /dev/ttyS1 /d... Tue Nov 17 11:40:02 2009 /dev/ttyS0, Line 0, UART: 16550A, Port: 0x03f8, IRQ: 4 Baud_base: 115200, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal skip_test /dev/ttyS1, Line 1, UART: 16550A, Port: 0x02f8, IRQ: 3 Baud_base: 115200, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal skip_test /dev/ttyS2, Line 2, UART: unknown, Port: 0x03e8, IRQ: 4 Baud_base: 115200, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal skip_test /dev/ttyS3, Line 3, UART: unknown, Port: 0x02e8, IRQ: 3 Baud_base: 115200, close_delay: 50, divisor: 0 closing_wait: 3000 Flags: spd_normal
`statserial`
statserial /dev/ttyS0 Device: /dev/ttyS0 Signal Pin Pin Direction Status Full Name (25) (9) (computer) Name ----- --- --- --------- ------ ----- FG 1 - - - Frame Ground TxD 2 3 out - Transmit Data RxD 3 2 in - Receive Data RTS 4 7 out 1 Request To Send CTS 5 8 in 0 Clear To Send DSR 6 6 in 0 Data Set Ready GND 7 5 - - Signal Ground DCD 8 1 in 0 Data Carrier Detect DTR 20 4 out 1 Data Terminal Ready RI 22 9 in 0 Ring Indicator