Copyright (C) 2000-2012 |
Manpages TERMIOSSection: Linux Programmer's Manual (3)Updated: 1995-09-02 Index Return to Main Contents NAMEtermios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow, cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, tcgetpgrp, tcsetpgrp - get and set terminal attributes, line control, get and set baud rate, get and set terminal foreground process group IDSYNOPSIS#include <termios.h>#include <unistd.h> int tcgetattr ( int fd, struct termios *termios_p ); int tcsetattr ( int fd, int optional_actions, struct termios *termios_p ); int tcsendbreak ( int fd, int duration ); int tcdrain ( int fd ); int tcflush ( int fd, int queue_selector ); int tcflow ( int fd, int action ); int cfmakeraw ( struct termios *termios_p ); speed_t cfgetospeed ( struct termios *termios_p ); int cfsetospeed ( struct termios *termios_p, speed_t speed ); speed_t cfgetispeed ( struct termios *termios_p ); int cfsetispeed ( struct termios *termios_p, speed_t speed ); pid_t tcgetpgrp ( int fd ); int tcsetpgrp ( int fd, pid_t pgrpid ); DESCRIPTIONThe termios functions describe a general terminal interface that is provided to control asynchronous communications ports.Many of the functions described here have a termios_p argument that is a pointer to a termios structure. This structure contains the following members:
c_iflag flag constants:
c_oflag flag constants:
c_cflag flag constants:
c_lflag flag constants:
The c_cc array defines the special control characters. The symbolic indices (and meaning: initial values) are: VINTR (interrupt character: 0177, DEL, rubout), VQUIT (quit character: 034, FS, Ctrl-\), VERASE (erase character: 010, BS, Ctrl-H), VKILL (kill character: 025, NAK, Ctrl-U), VEOF (end-of-file character: 004, EOT, Ctrl-D), VMIN, VEOL (additional end-of-line character: 0, NUL), VTIME, VEOL2 (yet another end-of-line character: 0, NUL), VSWTCH (switch character: 0, NUL), VSTART (start character: 021, DC1, Ctrl-Q), VSTOP (stop character: 023, DC3, Ctrl-S), VSUSP (suspend character: 032, SUB, Ctrl-Z), VDSUSP (delayed suspend character: 031, EM, Ctrl-Y), VLNEXT (literal next: 026, SYN, Ctrl-V), VWERASE (word erase: 027, ETB, Ctrl-W), VREPRINT (reprint unread characters: 022, DC2, Ctrl-R), VDISCARD (discard pending output: 017, SI, Ctrl-O). These symbolic subscript values are all different, except that VTIME, VMIN may have the same value as VEOL, VEOF, respectively. (In non-canonical mode the special character meaning is replaced by the timeout meaning. MIN represents the minimum number of characters that should be received to satisfy the read. TIME is a decisecond-valued timer. When both are set, a read will wait until at least one character has been received, and then return as soon as either MIN characters have been received or time TIME has passed since the last character was received. If only MIN is set, the read will not return before MIN characters have been received. If only TIME is set, the read will return as soon as either at least one character has been received, or the timer times out. If neither is set, the read will return immediately, only giving the currently already available characters.) tcgetattr() gets the parameters associated with the object referred by fd and stores them in the termios structure referenced by termios_p. This function may be invoked from a background process; however, the terminal attributes may be subsequently changed by a foreground process. tcsetattr() sets the parameters associated with the terminal (unless support is required from the underlying hardware that is not available) from the termios structure referred to by termios_p. optional_actions specifies when the changes take effect:
tcsendbreak() transmits a continuous stream of zero-valued bits for a specific duration, if the terminal is using asynchronous serial data transmission. If duration is zero, it transmits zero-valued bits for at least 0.25 seconds, and not more that 0.5 seconds. If duration is not zero, it sends zero-valued bits for duration*N seconds, where N is at least 0.25, and not more than 0.5. If the terminal is not using asynchronous serial data transmission, tcsendbreak() returns without taking any action. tcdrain() waits until all output written to the object referred to by fd has been transmitted. tcflush() discards data written to the object referred to by fd but not transmitted, or data received but not read, depending on the value of queue_selector:
tcflow() suspends transmission or reception of data on the object referred to by fd, depending on the value of action:
The default on open of a terminal file is that neither its input nor its output is suspended. The baud rate functions are provided for getting and setting the values of the input and output baud rates in the termios structure. The new values do not take effect until tcsetattr() is successfully called.
Setting the speed to B0 instructs the modem to "hang up".
The actual bit rate corresponding to B38400 may be altered with
setserial(8). The input and output baud rates are stored in the termios structure. cfmakeraw sets the terminal attributes as follows: termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP |INLCR|IGNCR|ICRNL|IXON); termios_p->c_oflag &= ~OPOST; termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN); termios_p->c_cflag &= ~(CSIZE|PARENB); termios_p->c_cflag |= CS8; cfgetospeed() returns the output baud rate stored in the termios structure pointed to by termios_p. cfsetospeed() sets the output baud rate stored in the termios structure pointed to by termios_p to speed, which must be one of these constants: B0 B50 B75 B110 B134 B150 B200 B300 B600 B1200 B1800 B2400 B4800 B9600 B19200 B38400 B57600 B115200 B230400The zero baud rate, B0, is used to terminate the connection. If B0 is specified, the modem control lines shall no longer be asserted. Normally, this will disconnect the line. CBAUDEX is a mask for the speeds beyond those defined in POSIX.1 (57600 and above). Thus, B57600 & CBAUDEX is nonzero. cfgetispeed() returns the input baud rate stored in the termios structure. cfsetispeed() sets the input baud rate stored in the termios structure to speed. If the input baud rate is set to zero, the input baud rate will be equal to the output baud rate. tcgetpgrp() returns process group ID of foreground processing group, or -1 on error. tcsetpgrp() sets process group ID to pgrpid. pgrpid must be the ID of a process group in the same session. RETURN VALUEcfgetispeed() returns the input baud rate stored in the termios structure. cfgetospeed() returns the output baud rate stored in the termios structure. tcgetpgrp() returns process group ID of foreground processing group, or -1 on error. All other functions return:
SEE ALSOsetserial(8)
IndexThis document was created by man2html, using the manual pages. Time: 16:52:31 GMT, December 02, 2024 |