Pin | Description | Pin | Description | Pin | Description | Pin | Description | Pin | Description |
---|---|---|---|---|---|---|---|---|---|
1 | Earth Ground | 6 | DSR - Data Set Ready | 11 | Unassigned | 16 | Secondary RXD | 21 | Signal Quality Detect |
2 | TXD - Transmitted Data | 7 | GND - Logic Ground | 12 | Secondary DCD | 17 | Receiver Clock | 22 | Ring Detect |
3 | RXD - Received Data | 8 | DCD - Data Carrier Detect | 13 | Secondary CTS | 18 | Unassigned | 23 | Data Rate Select |
4 | RTS - Request To Send | 9 | Reserved | 14 | Secondary TXD | 19 | Secondary RTS | 24 | Transmit Clock |
5 | CTS - Clear To Send | 10 | Reserved | 15 | Transmit Clock | 20 | DTR - Data Terminal Ready | 25 | Unassigned |
Figure 1 - Asynchronous Data Transmission
System | Port 1 | Port 2 |
---|---|---|
IRIX® | /dev/ttyf1 | /dev/ttyf2 |
HP-UX | /dev/tty1p0 | /dev/tty2p0 |
Solaris®/SunOS® | /dev/ttya | /dev/ttyb |
Linux® | /dev/ttyS0 | /dev/ttyS1 |
Digital UNIX® | /dev/tty01 | /dev/tty02 |
sgi
® workstation running IRIX is: Member | Description |
---|---|
c_cflag | Control options |
c_lflag | Line options |
c_iflag | Input options |
c_oflag | Output options |
c_cc | Control characters |
c_ispeed | Input baud (new interface) |
c_ospeed | Output baud (new interface) |
Constant | Description |
---|---|
CBAUD | Bit mask for baud rate |
B0 | 0 baud (drop DTR) |
B50 | 50 baud |
B75 | 75 baud |
B110 | 110 baud |
B134 | 134.5 baud |
B150 | 150 baud |
B200 | 200 baud |
B300 | 300 baud |
B600 | 600 baud |
B1200 | 1200 baud |
B1800 | 1800 baud |
B2400 | 2400 baud |
B4800 | 4800 baud |
B9600 | 9600 baud |
B19200 | 19200 baud |
B38400 | 38400 baud |
B57600 | 57,600 baud |
B76800 | 76,800 baud |
B115200 | 115,200 baud |
EXTA | External rate clock |
EXTB | External rate clock |
CSIZE | Bit mask for data bits |
CS5 | 5 data bits |
CS6 | 6 data bits |
CS7 | 7 data bits |
CS8 | 8 data bits |
CSTOPB | 2 stop bits (1 otherwise) |
CREAD | Enable receiver |
PARENB | Enable parity bit |
PARODD | Use odd parity instead of even |
HUPCL | Hangup (drop DTR) on last close |
CLOCAL | Local line - do not change 'owner' of port |
LOBLK | Block job control output |
CNEW_RTSCTS CRTSCTS | Enable hardware flow control (not supported on all platforms) |
Constant | Description |
---|---|
TCSANOW | Make changes now without waiting for data to complete |
TCSADRAIN | Wait until everything has been transmitted |
TCSAFLUSH | Flush input and output buffers and make the change |
Constant | Description |
---|---|
ISIG | Enable SIGINTR, SIGSUSP, SIGDSUSP, and SIGQUIT signals |
ICANON | Enable canonical input (else raw) |
XCASE | Map uppercase lowercase (obsolete) |
ECHO | Enable echoing of input characters |
ECHOE | Echo erase character as BS-SP-BS |
ECHOK | Echo NL after kill character |
ECHONL | Echo NL |
NOFLSH | Disable flushing of input buffers after interrupt or quit characters |
IEXTEN | Enable extended functions |
ECHOCTL | Echo control characters as ^char and delete as ~? |
ECHOPRT | Echo erased character as character erased |
ECHOKE | BS-SP-BS entire line on line kill |
FLUSHO | Output being flushed |
PENDIN | Retype pending input at next read or input char |
TOSTOP | Send SIGTTOU for background output |
Constant | Description |
---|---|
INPCK | Enable parity check |
IGNPAR | Ignore parity errors |
PARMRK | Mark parity errors |
ISTRIP | Strip parity bits |
IXON | Enable software flow control (outgoing) |
IXOFF | Enable software flow control (incoming) |
IXANY | Allow any character to start flow again |
IGNBRK | Ignore break condition |
BRKINT | Send a SIGINT when a break condition is detected |
INLCR | Map NL to CR |
IGNCR | Ignore CR |
ICRNL | Map CR to NL |
IUCLC | Map uppercase to lowercase |
IMAXBEL | Echo BEL on input line too long |
Constant | Description |
---|---|
OPOST | Postprocess output (not set = raw output) |
OLCUC | Map lowercase to uppercase |
ONLCR | Map NL to CR-NL |
OCRNL | Map CR to NL |
NOCR | No CR output at column 0 |
ONLRET | NL performs CR function |
OFILL | Use fill characters for delay |
OFDEL | Fill character is DEL |
NLDLY | Mask for delay time needed between lines |
NL0 | No delay for NLs |
NL1 | Delay further output after newline for 100 milliseconds |
CRDLY | Mask for delay time needed to return carriage to left column |
CR0 | No delay for CRs |
CR1 | Delay after CRs depending on current column position |
CR2 | Delay 100 milliseconds after sending CRs |
CR3 | Delay 150 milliseconds after sending CRs |
TABDLY | Mask for delay time needed after TABs |
TAB0 | No delay for TABs |
TAB1 | Delay after TABs depending on current column position |
TAB2 | Delay 100 milliseconds after sending TABs |
TAB3 | Expand TAB characters to spaces |
BSDLY | Mask for delay time needed after BSs |
BS0 | No delay for BSs |
BS1 | Delay 50 milliseconds after sending BSs |
VTDLY | Mask for delay time needed after VTs |
VT0 | No delay for VTs |
VT1 | Delay 2 seconds after sending VTs |
FFDLY | Mask for delay time needed after FFs |
FF0 | No delay for FFs |
FF1 | Delay 2 seconds after sending FFs |
Constant | Description | Key |
---|---|---|
VINTR | Interrupt | CTRL-C |
VQUIT | Quit | CTRL-Z |
VERASE | Erase | Backspace (BS) |
VKILL | Kill-line | CTRL-U |
VEOF | End-of-file | CTRL-D |
VEOL | End-of-line | Carriage return (CR) |
VEOL2 | Second end-of-line | Line feed (LF) |
VMIN | Minimum number of characters to read | |
VTIME | Time to wait for data (tenths of seconds) |
<termios.h>
header file and is typically one of the following: Request | Description | tcgetattr | ||
---|---|---|---|---|
TCSETS | Sets the serial port settings immediately. | |||
TCSETSF | Sets the serial port settings after flushing the input and output buffers. | tcsetattr(fd, TCSANOW, &options) | ||
TCSBRK | Sends a break for the given time. | tcflow | ||
TCFLSH | Flushes the input and/or output queue. | None |
TIOCMGET
ioctl gets the current 'MODEM' status bits, which consist of all of the RS-232 signal lines except RXD and TXD: Constant | Description |
---|---|
TIOCM_LE | DSR (data set ready/line enable) |
TIOCM_DTR | DTR (data terminal ready) |
TIOCM_RTS | RTS (request to send) |
TIOCM_ST | Secondary TXD (transmit) |
TIOCM_SR | Secondary RXD (receive) |
TIOCM_CTS | CTS (clear to send) |
TIOCM_CAR | DCD (data carrier detect) |
TIOCM_CD | Synonym for TIOCM_CAR |
TIOCM_RNG | RNG (ring) |
TIOCM_RI | Synonym for TIOCM_RNG |
TIOCM_DSR | DSR (data set ready) |
TIOCMSET
ioctl sets the 'MODEM' status bits defined above. To drop the DTR signal you can do: FIONREAD
ioctl gets the number of bytes in the serial port input buffer. As with TIOCMGET
you pass in a pointer to an integer to hold the number of bytes: NULL
to disable monitoring for the corresponding condition. These sets are initialized using three macros: NULL
for the timeout pointer. Figure 2 - RS-232 Connector
Pin | Description | Pin | Description |
---|---|---|---|
1 | Earth Ground | 14 | Secondary TXD |
2 | TXD - Transmitted Data | 15 | Transmit Clock |
3 | RXD - Received Data | 16 | Secondary RXD |
4 | RTS - Request To Send | 17 | Receiver Clock |
5 | CTS - Clear To Send | 18 | Unassigned |
6 | DSR - Data Set Ready | 19 | Secondary RTS |
7 | GND - Logic Ground | 20 | DTR - Data Terminal Ready |
8 | DCD - Data Carrier Detect | 21 | Signal Quality Detect |
9 | Reserved | 22 | Ring Detect |
10 | Reserved | 23 | Data Rate Select |
11 | Unassigned | 24 | Transmit Clock |
12 | Secondary DCD | 25 | Unassigned |
13 | Secondary CTS |
Figure 3 - RS-422 Connector
Pin | Description | Pin | Description |
---|---|---|---|
1 | Earth Ground | 14 | TXD+ |
2 | TXD- - Transmitted Data | 15 | Transmit Clock- |
3 | RXD- - Received Data | 16 | RXD+ |
4 | RTS- - Request To Send | 17 | Receiver Clock- |
5 | CTS- - Clear To Send | 18 | Unassigned |
6 | DSR - Data Set Ready | 19 | RTS+ |
7 | GND - Logic Ground | 20 | DTR- - Data Terminal Ready |
8 | DCD- - Data Carrier Detect | 21 | Signal Quality Detect |
9 | Reserved | 22 | Unassigned |
10 | Reserved | 23 | DTR+ |
11 | Unassigned | 24 | Transmit Clock+ |
12 | DCD+ | 25 | Receiver Clock+ |
13 | CTS+ |
Figure 4 - RS-574 Connector
Pin | Description | Pin | Description |
---|---|---|---|
1 | DCD - Data Carrier Detect | 6 | Data Set Ready |
2 | RXD - Received Data | 7 | RTS - Request To Send |
3 | TXD - Transmitted Data | 8 | CTS - Clear To Send |
4 | DTR - Data Terminal Ready | 9 | Ring Detect |
5 | GND - Logic Ground |
Figure 5 - SGI 9-Pin Connector
Pin | Description | Pin | Description |
---|---|---|---|
1 | Earth Ground | 6 | DSR - Data Set Ready |
2 | TXD - Transmitted Data | 7 | GND - Logic Ground |
3 | RXD - Received Data | 8 | DCD - Data Carrier Detect |
4 | RTS - Request To Send | 9 | DTR - Data Terminal Ready |
5 | CTS - Clear To Send |
Figure 6 - SGI 8-Pin Connector
Pin | Description | Pin | Description |
---|---|---|---|
1 | DTR - Data Terminal Ready | 5 | RXD - Received Data |
2 | CTS - Clear To Send | 6 | RTS - Request To Send |
3 | TXD - Transmitted Data | 7 | DCD - Data Carrier Detect |
4 | GND - Logic Ground | 8 | GND - Logic Ground |
Name | Binary | Octal | Decimal | Hexadecimal |
---|---|---|---|---|
NUL | 00000000 | 000 | 0 | 00 |
SOH | 00000001 | 001 | 1 | 01 |
STX | 00000010 | 002 | 2 | 02 |
ETX | 00000011 | 003 | 3 | 03 |
EOT | 00000100 | 004 | 4 | 04 |
ENQ | 00000101 | 005 | 5 | 05 |
ACK | 00000110 | 006 | 6 | 06 |
BEL | 00000111 | 007 | 7 | 07 |
BS | 00001000 | 010 | 8 | 08 |
HT | 00001001 | 011 | 9 | 09 |
NL | 00001010 | 012 | 10 | 0A |
VT | 00001011 | 013 | 11 | 0B |
NP, FF | 00001100 | 014 | 12 | 0C |
CR | 00001101 | 015 | 13 | 0D |
SO | 00001110 | 016 | 14 | 0E |
SI | 00001111 | 017 | 15 | 0F |
DLE | 00010000 | 020 | 16 | 10 |
XON, DC1 | 00010001 | 021 | 17 | 11 |
DC2 | 00010010 | 022 | 18 | 12 |
XOFF, DC3 | 00010011 | 023 | 19 | 13 |
DC4 | 00010100 | 024 | 20 | 14 |
NAK | 00010101 | 025 | 21 | 15 |
SYN | 00010110 | 026 | 22 | 16 |
ETB | 00010111 | 027 | 23 | 17 |
CAN | 00011000 | 030 | 24 | 18 |
EM | 00011001 | 031 | 25 | 19 |
SUB | 00011010 | 032 | 26 | 1A |
ESC | 00011011 | 033 | 27 | 1B |
FS | 00011100 | 034 | 28 | 1C |
GS | 00011101 | 035 | 29 | 1D |
RS | 00011110 | 036 | 30 | 1E |
US | 00011111 | 037 | 31 | 1F |