TERMIOS (3)
termios, 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 ID
SYNOPSIS
l
B
#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 );
P
b
DESCRIPTION
The 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:
9
tcflag_t c_iflag; /* input modes */
tcflag_t c_oflag; /* output modes */
tcflag_t c_cflag; /* control modes */
tcflag_t c_lflag; /* local modes */
cc_t c_cc[NCCS]; /* control chars */
c_iflag flag constants:
ignore BREAK condition on input
If IGNBRK is not set, generate SIGINT on BREAK condition,
else read BREAK as character \\0.
ignore framing errors and parity errors.
if IGNPAR is not set, prefix a character with a parity error or
framing error with \\377 \\0. If neither IGNPAR nor PARMRK
is set, read a character with a parity error or framing error
as \\0.
enable input parity checking
translate NL to CR on input
ignore carriage return on input
translate carriage return to newline on input (unless IGNCR is set)
map uppercase characters to lowercase on input
enable XON/XOFF flow control on output
enable any character to restart output
enable XON/XOFF flow control on input
ring bell when input queue is full
c_oflag flag constants:
enable implementation-defined output processing
map lowercase characters to uppercase on output
map NL to CR-NL on output
don't output CR at column 0
send fill characters for a delay, rather than using a timed delay
fill character is ASCII DEL. If unset, fill character is ASCII NUL
newline delay mask. Values are NL0 and NL1.
carriage return delay mask. Values are CR0, CR1, CR2, or CR3.
horizontal tab delay mask. Values are TAB0, TAB1, TAB2, TAB3, or XTABS.
A value of XTABS expands tabs to spaces (with tab stops every eight columns).
backspace delay mask. Values are BS0 or BS1.
vertical tab delay mask. Values are VT0 or VT1.
form feed delay mask. Values are FF0 or FF1.
c_cflag flag constants:
character size mask. Values are CS5, CS6, CS7, or CS8.
set two stop bits, rather than one.
enable parity generation on output and parity checking for input.
parity for input and output is odd.
lower modem control lines after last process closes the device (hang up).
ignore modem control lines
mask for input speeds (not used).
c_lflag flag constants:
when any of the characters INTR, QUIT, SUSP, or DSUSP are received,
generate the corresponding signal.
enable canonical mode. This enables the special characters
EOF, EOL, EOL2, ERASE, KILL, REPRINT, STATUS, and WERASE, and
buffers by lines.
if ICANON is also set, terminal is uppercase only.
Input is converted to lowercase, except for characters preceded by \\.
On output, uppercase characters are preceded by \\ and lowercase
characters are converted to uppercase.
if ICANON is also set, the ERASE character erases the preceding
input character, and WERASE erases the preceding word.
if ICANON is also set, the KILL character erases the current line.
if ICANON is also set, echo the NL character even if ECHO is not set.
if ECHO is also set, ASCII control signals other than TAB, NL, START, and STOP
are echoed as ^X, where X is the character with ASCII code 0x40 greater
than the control signal. For example, character 0x08 (BS) is echoed as ^H.
if ICANON and IECHO are also set, characters are printed as they
are being erased.
if ICANON is also set, KILL is echoed by erasing each character on the line,
as specified by ECHOE and ECHOPRT.
output is being flushed. This flag is toggled by typing the DISCARD character.
disable flushing the input and output queues when generating the SIGINT
and SIGQUIT signals, and flushing the input queue when generating
the SIGSUSP signal.
send the SIGTTOU signal to the process group of a background process
which tries to write to its controlling terminal.
all characters in the input queue are reprinted when the next character is
read. (bash handles typeahead this way.)
enable implementation-defined input processing.
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:
the change occurs immediately.
the change occurs after all output written to
fd
has been transmitted. This function should be used when changing
parameters that affect output.
the change occurs after all output written to the object referred by
fd
has been transmitted, and all input that has been received but not read
will be discarded before the change is made.
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 :
flushes data received but not read.
flushes data written but not transmitted.
flushes both data received but not read, and data written but not
transmitted.
tcflow()
suspends transmission or reception of data on the object referred to by
fd ,
depending on the value of
action :
restarts suspended output.
transmits a STOP character, which stops the terminal device from transmitting data to the
system.
transmits a START character, which starts the terminal device transmitting data to the
system.
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:
B
B0
B50
B75
B110
B134
B150
B200
B300
B600
B1200
B1800
B2400
B4800
B9600
B19200
B38400
B57600
B115200
B230400
P
The 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 VALUES
cfgetispeed()
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:
on failure and set
errno
to indicate the error.
SEE ALSO
setserial(8) ' " ' " Copyright(c) 1996 Sun Microsystems Inc ' " ' " See the file "license terms" for information on usage and redistribution ' " of this file and for a DISCLAIMER OF ALL WARRANTIES ' " ' " RCS: @(#) $Id: TextLayout 3 v 1 2 1998/09/14 18:22:54 stanton Exp $ ' " ' " The definitions below are for supplemental macros used in Tcl/Tk ' " manual entries ' " ' " AP type name in/out ?indent? ' " Start paragraph describing an argument to a library procedure ' " type is type of argument(int etc ) in/out is either "in" "out" ' " or "in/out" to describe whether procedure reads or modifies arg ' " and indent is equivalent to second arg of IP(shouldn't ever be ' " needed; use AS below instead) ' " ' " AS ?type? ?name? ' " Give maximum sizes of arguments for setting tab stops Type and ' " name are examples of largest possible arguments that will be passed ' " to AP later If args are omitted default tab stops are used ' " ' " BS ' " Start box enclosure From here until next BE everything will be ' " enclosed in one large box ' " ' " BE ' " End of box enclosure ' " ' " CS ' " Begin code excerpt ' " ' " CE ' " End code excerpt ' " ' " VS ?version? ?br? ' " Begin vertical sidebar for use in marking newly-changed parts ' " of man pages The first argument is ignored and used for recording ' " the version when the VS was added so that the sidebars can be ' " found and removed when they reach a certain age If another argument ' " is present then a line break is forced before starting the sidebar ' " ' " VE ' " End of vertical sidebar ' " ' " DS ' " Begin an indented unfilled display ' " ' " DE ' " End of indented unfilled display ' " ' " SO ' " Start of list of standard options for a Tk widget The ' " options follow on successive lines in four columns separated ' " by tabs ' " ' " SE ' " End of list of standard options for a Tk widget ' " ' " OP cmdName dbName dbClass ' " Start of description of a specific option cmdName gives the ' " option's name as specified in the class command dbName gives ' " the option's name in the option database and dbClass gives ' " the option's class in the option database ' " ' " UL arg1 arg2 ' " Print arg1 underlined then print arg2 normally ' " ' " RCS: @(#) $Id: man macros v 1 2 1998/09/14 18:39:54 stanton Exp $ ' " ' " # Set up traps and other miscellaneous stuff for Tcl/Tk man pages t wh -1 3i ^B ^l n( l b ' " # Start an argument description AP !" $4"" TP $4 { !" $2"" TP n()Cu 15
|