man-pages/man3/termios.3

808 lines
23 KiB
Groff
Raw Normal View History

2004-11-03 13:51:07 +00:00
.\" Hey Emacs! This file is -*- nroff -*- source.
.\"
.\" Copyright (c) 1993 Michael Haardt
.\" (michael@moria.de)
.\" Fri Apr 2 11:32:09 MET DST 1993
.\"
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, write to the Free
.\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
.\" USA.
.\"
.\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
.\" Modified 1995-02-25 by Jim Van Zandt <jrv@vanzandt.mv.com>
.\" Modified 1995-09-02 by Jim Van Zandt <jrv@vanzandt.mv.com>
.\" moved to man3, aeb, 950919
.\" Modified 2001-09-22 by Michael Kerrisk <mtk-manpages@gmx.net>
2004-11-03 13:51:07 +00:00
.\" Modified 2001-12-17, aeb
.\" Modified 2004-10-31, aeb
.\" 2006-12-28, mtk:
.\" Added .SS headers to give some structure to this page; and a
.\" small amount of reordering.
.\" Added a section on canonical and non-canonical mode.
.\" Enhanced the discussion of "raw" mode for cfmakeraw().
.\" Document CMSPAR.
2004-11-03 13:51:07 +00:00
.\"
.TH TERMIOS 3 2004-10-31 "Linux" "Linux Programmer's Manual"
.SH NAME
termios, tcgetattr, tcsetattr, tcsendbreak, tcdrain, tcflush, tcflow,
cfmakeraw, cfgetospeed, cfgetispeed, cfsetispeed, cfsetospeed, cfsetspeed \-
get and set terminal attributes, line control, get and set baud rate
.SH SYNOPSIS
.ad l
.ft B
#include <termios.h>
.br
#include <unistd.h>
.sp
.BI "int tcgetattr(int " fd ", struct termios *" termios_p );
.sp
.BI "int tcsetattr(int " fd ", int " optional_actions ", const struct termios *" termios_p );
.sp
.BI "int tcsendbreak(int " fd ", int " duration );
.sp
.BI "int tcdrain(int " fd );
.sp
.BI "int tcflush(int " fd ", int " queue_selector );
.sp
.BI "int tcflow(int " fd ", int " action );
.sp
.BI "void cfmakeraw(struct termios *" termios_p );
.sp
.BI "speed_t cfgetispeed(const struct termios *" termios_p );
.sp
.BI "speed_t cfgetospeed(const struct termios *" termios_p );
.sp
.BI "int cfsetispeed(struct termios *" termios_p ", speed_t " speed );
.sp
.BI "int cfsetospeed(struct termios *" termios_p ", speed_t " speed );
.ft P
.ad b
.SH DESCRIPTION
The termios functions describe a general terminal interface that is
provided to control asynchronous communications ports.
.SS "The termios structure"
2004-11-03 13:51:07 +00:00
.LP
Many of the functions described here have a \fItermios_p\fP argument
that is a pointer to a \fItermios\fP structure.
This structure contains at least the following members:
2004-11-03 13:51:07 +00:00
.ne 9
.sp
.RS
.nf
tcflag_t \fIc_iflag\fP; /* input modes */
tcflag_t \fIc_oflag\fP; /* output modes */
tcflag_t \fIc_cflag\fP; /* control modes */
tcflag_t \fIc_lflag\fP; /* local modes */
cc_t \fIc_cc\fP[\fBNCCS\fP]; /* control chars */
2004-11-03 13:51:07 +00:00
.fi
.RE
.PP
The values that may be assigned to these fields are described below.
In the case of the first four bit-mask fields,
the definitions of some of the associated flags that may be set are
only exposed if a specific feature test macro (see
2006-05-15 09:13:10 +00:00
.BR feature_test_macros (7))
is defined, as noted in brackets ("[]").
.PP
In the descriptions below, "not in POSIX" means that the
value is not specified in POSIX.1-2001,
and "XSI" means that the value is specified in POSIX.1-2001
as part of the XSI extension.
.PP
2004-11-03 13:51:07 +00:00
\fIc_iflag\fP flag constants:
.TP
.B IGNBRK
Ignore BREAK condition on input.
.TP
.B BRKINT
If \fBIGNBRK\fP is set, a BREAK is ignored.
If it is not set
2004-11-03 13:51:07 +00:00
but \fBBRKINT\fP is set, then a BREAK causes the input and output
queues to be flushed, and if the terminal is the controlling
terminal of a foreground process group, it will cause a
\fBSIGINT\fP to be sent to this foreground process group.
When neither \fBIGNBRK\fP nor \fBBRKINT\fP are set, a BREAK
reads as a null byte ('\\0'), except when \fBPARMRK\fP is set,
2004-11-03 13:51:07 +00:00
in which case it reads as the sequence \\377 \\0 \\0.
.TP
.B IGNPAR
Ignore framing errors and parity errors.
.TP
.B PARMRK
If \fBIGNPAR\fP is not set, prefix a character with a parity error or
framing error with \\377 \\0.
If neither \fBIGNPAR\fP nor \fBPARMRK\fP
2004-11-03 13:51:07 +00:00
is set, read a character with a parity error or framing error
as \\0.
.TP
.B INPCK
Enable input parity checking.
.TP
.B ISTRIP
Strip off eighth bit.
.TP
.B INLCR
Translate NL to CR on input.
.TP
.B IGNCR
Ignore carriage return on input.
.TP
.B ICRNL
Translate carriage return to newline on input (unless \fBIGNCR\fP is set).
.TP
.B IUCLC
(not in POSIX) Map uppercase characters to lowercase on input.
.TP
.B IXON
Enable XON/XOFF flow control on output.
.TP
.B IXANY
(XSI) Typing any character will restart stopped output.
(The default is to allow just the START character to restart output.)
2004-11-03 13:51:07 +00:00
.TP
.B IXOFF
Enable XON/XOFF flow control on input.
.TP
.B IMAXBEL
(not in POSIX) Ring bell when input queue is full.
Linux does not implement this bit, and acts as if it is always set.
2006-09-25 07:27:38 +00:00
.TP
.BR IUTF8 " (since Linux 2.6.4)"
(not in POSIX) Input is UTF8;
2006-09-25 07:27:38 +00:00
this allows character-erase to be correctly performed in cooked mode.
2004-11-03 13:51:07 +00:00
.PP
\fIc_oflag\fP flag constants defined in POSIX.1:
.TP
.B OPOST
Enable implementation-defined output processing.
.PP
2006-08-03 13:57:30 +00:00
The remaining \fIc_oflag\fP flag constants are defined in POSIX.1-2001,
2004-11-03 13:51:07 +00:00
unless marked otherwise.
.TP
.B OLCUC
(not in POSIX) Map lowercase characters to uppercase on output.
.TP
.B ONLCR
(XSI) Map NL to CR-NL on output.
.TP
.B OCRNL
Map CR to NL on output.
.TP
.B ONOCR
Don't output CR at column 0.
.TP
.B ONLRET
Don't output CR.
.TP
.B OFILL
Send fill characters for a delay, rather than using a timed delay.
.TP
.B OFDEL
(not in POSIX) Fill character is ASCII DEL (0177).
If unset, fill character is ASCII NUL ('\\0').
(Not implemented on Linux.)
2004-11-03 13:51:07 +00:00
.TP
.B NLDLY
Newline delay mask.
Values are \fBNL0\fP and \fBNL1\fP.
[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B CRDLY
Carriage return delay mask.
Values are \fBCR0\fP, \fBCR1\fP, \fBCR2\fP, or \fBCR3\fP.
[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B TABDLY
Horizontal tab delay mask.
Values are \fBTAB0\fP, \fBTAB1\fP, \fBTAB2\fP, \fBTAB3\fP (or \fBXTABS\fP).
A value of TAB3, that is, XTABS, expands tabs to spaces
(with tab stops every eight columns).
[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B BSDLY
Backspace delay mask.
Values are \fBBS0\fP or \fBBS1\fP.
2004-11-03 13:51:07 +00:00
(Has never been implemented.)
[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B VTDLY
Vertical tab delay mask.
Values are \fBVT0\fP or \fBVT1\fP.
2004-11-03 13:51:07 +00:00
.TP
.B FFDLY
Form feed delay mask.
Values are \fBFF0\fP or \fBFF1\fP.
[requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
2004-11-03 13:51:07 +00:00
.PP
\fIc_cflag\fP flag constants:
.TP
.B CBAUD
(not in POSIX) Baud speed mask (4+1 bits).
[requires _BSD_SOURCE or _SVID_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B CBAUDEX
(not in POSIX) Extra baud speed mask (1 bit), included in CBAUD.
[requires _BSD_SOURCE or _SVID_SOURCE]
.sp
(POSIX says that the baud speed is stored in the
.I termios
structure without specifying where precisely, and provides
.BR cfgetispeed ()
2004-11-03 13:51:07 +00:00
and
.BR cfsetispeed ()
for getting at it.
Some systems use bits selected by CBAUD in
2004-11-03 13:51:07 +00:00
.IR c_cflag ,
other systems use separate fields, e.g.
.I sg_ispeed
and
.IR sg_ospeed .)
.TP
.B CSIZE
Character size mask.
Values are \fBCS5\fP, \fBCS6\fP, \fBCS7\fP, or \fBCS8\fP.
.TP
.B CSTOPB
Set two stop bits, rather than one.
.TP
.B CREAD
Enable receiver.
.TP
.B PARENB
Enable parity generation on output and parity checking for input.
.TP
.B PARODD
If set, then parity for input and output is odd;
otherwise even parity is used.
2004-11-03 13:51:07 +00:00
.TP
.B HUPCL
Lower modem control lines after last process closes the device (hang up).
.TP
.B CLOCAL
Ignore modem control lines.
.TP
.B LOBLK
(not in POSIX) Block output from a noncurrent shell layer.
For use by \fBshl\fP (shell layers). (Not implemented on Linux.)
2004-11-03 13:51:07 +00:00
.TP
.B CIBAUD
2006-12-28 05:04:17 +00:00
(not in POSIX) Mask for input speeds.
The values for the CIBAUD bits are
the same as the values for the CBAUD bits, shifted left IBSHIFT bits.
[requires _BSD_SOURCE or _SVID_SOURCE]
(Not implemented on Linux.)
2004-11-03 13:51:07 +00:00
.TP
2006-12-28 04:33:54 +00:00
.B CMSPAR
2006-12-28 04:36:23 +00:00
(not in POSIX)
Use "stick" (mark/space) parity (supported on certain serial
2006-12-28 05:04:17 +00:00
devices): if
.B PARODD
2006-12-28 04:33:54 +00:00
is set, the parity bit is always 1; if
.B PARODD
2006-12-28 04:33:54 +00:00
is not set, then the parity bit is always 0).
2006-12-28 04:36:23 +00:00
[requires _BSD_SOURCE or _SVID_SOURCE]
2006-12-28 04:33:54 +00:00
.TP
2004-11-03 13:51:07 +00:00
.B CRTSCTS
(not in POSIX) Enable RTS/CTS (hardware) flow control.
[requires _BSD_SOURCE or _SVID_SOURCE]
2004-11-03 13:51:07 +00:00
.PP
\fIc_lflag\fP flag constants:
.TP
.B ISIG
When any of the characters INTR, QUIT, SUSP, or DSUSP are received,
generate the corresponding signal.
.TP
.B ICANON
Enable canonical mode (described below).
2004-11-03 13:51:07 +00:00
.TP
.B XCASE
(not in POSIX; not supported under Linux)
If \fBICANON\fP 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.
.\" [requires _BSD_SOURCE or _SVID_SOURCE or _XOPEN_SOURCE]
.\" glibc is probably now wrong to allow _XOPEN_SOURCE to expose XCASE.
2004-11-03 13:51:07 +00:00
.TP
.B ECHO
Echo input characters.
.TP
.B ECHOE
If \fBICANON\fP is also set, the ERASE character erases the preceding
input character, and WERASE erases the preceding word.
.TP
.B ECHOK
If \fBICANON\fP is also set, the KILL character erases the current line.
.TP
.B ECHONL
If \fBICANON\fP is also set, echo the NL character even if ECHO is not set.
.TP
.B ECHOCTL
(not in POSIX) If \fBECHO\fP 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
2004-11-03 13:51:07 +00:00
0x08 (BS) is echoed as ^H.
[requires _BSD_SOURCE or _SVID_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B ECHOPRT
(not in POSIX) If \fBICANON\fP and \fBIECHO\fP are also set, characters
are printed as they are being erased.
[requires _BSD_SOURCE or _SVID_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B ECHOKE
(not in POSIX) If \fBICANON\fP is also set, KILL is echoed by erasing
each character on the line, as specified by \fBECHOE\fP and \fBECHOPRT\fP.
[requires _BSD_SOURCE or _SVID_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B DEFECHO
(not in POSIX) Echo only when a process is reading.
(Not implemented on Linux.)
2004-11-03 13:51:07 +00:00
.TP
.B FLUSHO
(not in POSIX; not supported under Linux)
Output is being flushed.
This flag is toggled by typing
2004-11-03 13:51:07 +00:00
the DISCARD character.
[requires _BSD_SOURCE or _SVID_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B NOFLSH
Disable flushing the input and output queues when generating the SIGINT,
SIGQUIT and SIGSUSP signals.
.\" Stevens lets SIGSUSP only flush the input queue
.TP
.B TOSTOP
Send the SIGTTOU signal to the process group of a background process
which tries to write to its controlling terminal.
.TP
.B PENDIN
(not in POSIX; not supported under Linux)
All characters in the input queue are reprinted when
the next character is read.
(\fBbash\fP handles typeahead this way.)
[requires _BSD_SOURCE or _SVID_SOURCE]
2004-11-03 13:51:07 +00:00
.TP
.B IEXTEN
Enable implementation-defined input processing.
This flag, as well as \fBICANON\fP must be enabled for the
special characters EOL2, LNEXT, REPRINT, WERASE to be interpreted,
and for the \fBIUCLC\fP flag to be effective.
.PP
The \fIc_cc\fP array defines the special control characters.
The symbolic indices (initial values) and meaning are:
.TP
.B VINTR
(003, ETX, Ctrl-C, or also 0177, DEL, rubout)
Interrupt character.
Send a SIGINT signal.
2004-11-03 13:51:07 +00:00
Recognized when ISIG is set, and then not passed as input.
.TP
.B VQUIT
(034, FS, Ctrl-\e)
Quit character.
Send SIGQUIT signal.
2004-11-03 13:51:07 +00:00
Recognized when ISIG is set, and then not passed as input.
.TP
.B VERASE
(0177, DEL, rubout, or 010, BS, Ctrl-H, or also #)
Erase character.
This erases the previous not-yet-erased character,
2004-11-03 13:51:07 +00:00
but does not erase past EOF or beginning-of-line.
Recognized when ICANON is set, and then not passed as input.
.TP
.B VKILL
(025, NAK, Ctrl-U, or Ctrl-X, or also @)
Kill character.
This erases the input since the last EOF or beginning-of-line.
2004-11-03 13:51:07 +00:00
Recognized when ICANON is set, and then not passed as input.
.TP
.B VEOF
(004, EOT, Ctrl-D)
End-of-file character.
More precisely: this character causes the pending tty buffer to be sent
to the waiting user program without waiting for end-of-line.
If it is the first character of the line, the \fIread\fP() in the
2004-11-03 13:51:07 +00:00
user program returns 0, which signifies end-of-file.
Recognized when ICANON is set, and then not passed as input.
.TP
.B VMIN
Minimum number of characters for non-canonical read.
.TP
.B VEOL
(0, NUL)
Additional end-of-line character.
Recognized when ICANON is set.
.TP
.B VTIME
Timeout in deciseconds for non-canonical read.
.TP
.B VEOL2
(not in POSIX; 0, NUL)
Yet another end-of-line character.
Recognized when ICANON is set.
.TP
.B VSWTCH
(not in POSIX; not supported under Linux; 0, NUL)
Switch character.
(Used by \fBshl\fP only.)
2004-11-03 13:51:07 +00:00
.TP
.B VSTART
(021, DC1, Ctrl-Q)
Start character.
Restarts output stopped by the Stop character.
2004-11-03 13:51:07 +00:00
Recognized when IXON is set, and then not passed as input.
.TP
.B VSTOP
(023, DC3, Ctrl-S)
Stop character.
Stop output until Start character typed.
2004-11-03 13:51:07 +00:00
Recognized when IXON is set, and then not passed as input.
.TP
.B VSUSP
(032, SUB, Ctrl-Z)
Suspend character.
Send SIGTSTP signal.
2004-11-03 13:51:07 +00:00
Recognized when ISIG is set, and then not passed as input.
.TP
.B VDSUSP
(not in POSIX; not supported under Linux; 031, EM, Ctrl-Y)
Delayed suspend character:
send SIGTSTP signal when the character is read by the user program.
Recognized when IEXTEN and ISIG are set, and the system supports
job control, and then not passed as input.
.TP
.B VLNEXT
(not in POSIX; 026, SYN, Ctrl-V)
Literal next.
Quotes the next input character, depriving it of
2004-11-03 13:51:07 +00:00
a possible special meaning.
Recognized when IEXTEN is set, and then not passed as input.
.TP
.B VWERASE
(not in POSIX; 027, ETB, Ctrl-W)
Word erase.
Recognized when ICANON and IEXTEN are set, and then not passed as input.
.TP
.B VREPRINT
(not in POSIX; 022, DC2, Ctrl-R)
Reprint unread characters.
Recognized when ICANON and IEXTEN are set, and then not passed as input.
.TP
.B VDISCARD
(not in POSIX; not supported under Linux; 017, SI, Ctrl-O)
Toggle: start/stop discarding pending output.
Recognized when IEXTEN is set, and then not passed as input.
.TP
.B VSTATUS
(not in POSIX; not supported under Linux;
status request: 024, DC4, Ctrl-T).
.LP
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.
For an explanation of VMIN and VTIME, see the description of
non-canonical mode below.
.SS "Retrieving and changing terminal settings"
2004-11-03 13:51:07 +00:00
.PP
.BR tcgetattr ()
2004-11-03 13:51:07 +00:00
gets the parameters associated with the object referred by \fIfd\fP and
stores them in the \fItermios\fP structure referenced by
\fItermios_p\fP.
This function may be invoked from a background process;
2004-11-03 13:51:07 +00:00
however, the terminal attributes may be subsequently changed by a
foreground process.
.LP
.BR tcsetattr ()
2004-11-03 13:51:07 +00:00
sets the parameters associated with the terminal (unless support is
required from the underlying hardware that is not available) from the
\fItermios\fP structure referred to by \fItermios_p\fP.
2004-11-03 13:51:07 +00:00
\fIoptional_actions\fP specifies when the changes take effect:
.IP \fBTCSANOW\fP
the change occurs immediately.
.IP \fBTCSADRAIN\fP
the change occurs after all output written to
.I fd
has been transmitted.
This function should be used when changing
2004-11-03 13:51:07 +00:00
parameters that affect output.
.IP \fBTCSAFLUSH\fP
the change occurs after all output written to the object referred by
.I fd
has been transmitted, and all input that has been received but not read
will be discarded before the change is made.
.SS "Canonical and non-canonical mode"
The setting of the
.B ICANON
canon flag in
.I c_lflag
determines whether the terminal is operating in canonical mode
.RB ( ICANON
set) or
non-canonical mode
.RB ( ICANON
unset).
By default,
.B ICANON
set.
In canonical mode:
.IP * 2
Input is made available line by line.
An input line is available when one of the line delimiters
is typed (NL, EOL, EOL2; or EOF at the start of line).
Except in the case of EOF, the line delimiter is included
in the buffer returned by
.BR read (2).
.IP * 2
Line editing is enabled (ERASE, KILL;
and if the
.B IEXTEN
flag is set: WERASE, REPRINT, LNEXT).
A
.BR read ()
returns at most one line of input; if the
.BR read ()
requested fewer bytes than are available in the current line of input,
then only as many bytes as requested are read,
and the remaining characters will be available for a future
.BR read ().
.PP
In non-canonical mode input is available immediately (without
the user having to type a line-delimiter character),
and line editing is disabled.
The settings of MIN
.RI ( c_cc[VMIN] )
and
.RI ( c_cc[VTIME] )
determine the circumstances in which a
.BR read (2)
completes; there are four distinct cases:
.IP * 2
MIN == 0; TIME == 0:
If data is available,
.BR read ()
returns immediately, with the lesser of the number of bytes
available, or the number of bytes requested.
If no data is available,
.BR read ()
returns 0.
.IP * 2
MIN > 0; TIME == 0:
.BR read ()
blocks until the lesser of MIN bytes or the number of bytes requested
are available, and returns the lesser of these two values.
.IP * 2
MIN == 0; TIME > 0:
TIME specifies the limit for a timer in tenths of a second.
The timer is started when
.BR read ()
is called.
.BR read ()
returns either when at least one byte of data is available,
or when the timer expires.
If the timer expires without any input becoming available,
.BR read ()
returns 0.
.IP * 2
MIN > 0; TIME > 0:
TIME specifies the limit for a timer in tenths of a second.
Once an initial byte of input becomes available,
the timer is restarted after each further byte is received.
.BR read ()
returns either when the lesser of the number of bytes requested or
MIN byte have been read,
or when the inter-byte timeout expires.
Because the timer is only started after the initial byte
becomes available, at least one byte will be read.
.SS "Raw mode"
.LP
\fBcfmakeraw\fP() sets the terminal to something like the
2007-03-01 01:12:16 +00:00
"raw" mode of the old Version 7 terminal driver:
input is available character by character,
echoing is disabled, and all special processing of
terminal input and output characters is disabled.
The terminal attributes are set as follows:
.nf
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;
.fi
.SS "Line control"
2004-11-03 13:51:07 +00:00
.LP
.BR tcsendbreak ()
2004-11-03 13:51:07 +00:00
transmits a continuous stream of zero-valued bits for a specific
duration, if the terminal is using asynchronous serial data
transmission.
If \fIduration\fP is zero, it transmits zero-valued bits
for at least 0.25 seconds, and not more that 0.5 seconds.
If \fIduration\fP is not zero, it sends zero-valued bits for some
2004-11-03 13:51:07 +00:00
implementation-defined length of time.
.LP
If the terminal is not using asynchronous serial data transmission,
\fBtcsendbreak\fP() returns without taking any action.
2004-11-03 13:51:07 +00:00
.LP
.BR tcdrain ()
2004-11-03 13:51:07 +00:00
waits until all output written to the object referred to by
.I fd
has been transmitted.
.LP
.BR tcflush ()
2004-11-03 13:51:07 +00:00
discards data written to the object referred to by
.I fd
but not transmitted, or data received but not read, depending on the
value of
.IR queue_selector :
.IP \fBTCIFLUSH\fP
flushes data received but not read.
.IP \fBTCOFLUSH\fP
flushes data written but not transmitted.
.IP \fBTCIOFLUSH\fP
flushes both data received but not read, and data written but not
transmitted.
.LP
.BR tcflow ()
2004-11-03 13:51:07 +00:00
suspends transmission or reception of data on the object referred to by
.IR fd ,
depending on the value of
.IR action :
.IP \fBTCOOFF\fP
suspends output.
.IP \fBTCOON\fP
restarts suspended output.
.IP \fBTCIOFF\fP
transmits a STOP character, which stops the terminal device from
2006-12-27 03:54:41 +00:00
transmitting data to the system.
2004-11-03 13:51:07 +00:00
.IP \fBTCION\fP
transmits a START character, which starts the terminal device
2006-12-27 03:54:41 +00:00
transmitting data to the system.
2004-11-03 13:51:07 +00:00
.LP
The default on open of a terminal file is that neither its input nor its
output is suspended.
.SS "Line speed"
The baud rate functions are provided for getting and setting the values
of the input and output baud rates in the \fItermios\fP structure.
The new values do not take effect
until \fBtcsetattr\fP() is successfully called.
Setting the speed to \fBB0\fP instructs the modem to "hang up".
The actual bit rate corresponding to \fBB38400\fP may be altered with
2007-04-05 13:29:41 +00:00
\fBsetserial\fP(8).
.LP
The input and output baud rates are stored in the \fItermios\fP
structure.
2004-11-03 13:51:07 +00:00
.LP
.BR cfgetospeed ()
returns the output baud rate stored in the \fItermios\fP structure
2004-11-03 13:51:07 +00:00
pointed to by
.IR termios_p .
.LP
.BR cfsetospeed ()
sets the output baud rate stored in the \fItermios\fP structure pointed
2004-11-03 13:51:07 +00:00
to by \fItermios_p\fP to \fIspeed\fP, which must be one of these constants:
.nf
2004-11-03 13:51:07 +00:00
.ft B
B0
B50
B75
B110
B134
B150
B200
B300
B600
B1200
B1800
B2400
B4800
B9600
B19200
B38400
B57600
B115200
B230400
.ft P
2004-11-03 13:51:07 +00:00
.fi
The zero baud rate, \fBB0\fP,
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. \fBCBAUDEX\fP is a mask
2004-11-03 13:51:07 +00:00
for the speeds beyond those defined in POSIX.1 (57600 and above).
2005-06-15 13:32:34 +00:00
Thus, \fBB57600\fP & \fBCBAUDEX\fP is non-zero.
2004-11-03 13:51:07 +00:00
.LP
.BR cfgetispeed ()
returns the input baud rate stored in the \fItermios\fP structure.
2004-11-03 13:51:07 +00:00
.LP
.BR cfsetispeed ()
sets the input baud rate stored in the \fItermios\fP structure to
.IR speed ,
which must be specified as one of the \fBBnnn\fP constants listed above for
.BR cfsetospeed ().
2004-11-03 13:51:07 +00:00
If the input baud rate is set to zero, the input baud rate will be
equal to the output baud rate.
.LP
.BR cfsetspeed ()
is a 4.4BSD extension.
It takes the same arguments as
.BR cfsetispeed (),
and sets both input and output speed.
2004-11-03 13:51:07 +00:00
.SH "RETURN VALUE"
.LP
.BR cfgetispeed ()
2004-11-03 13:51:07 +00:00
returns the input baud rate stored in the
\fItermios\fP
2004-11-03 13:51:07 +00:00
structure.
.LP
.BR cfgetospeed ()
returns the output baud rate stored in the \fItermios\fP structure.
2004-11-03 13:51:07 +00:00
.LP
All other functions return:
.IP 0
on success.
.IP \-1
on failure and set
.I errno
to indicate the error.
.LP
Note that
2005-10-19 16:30:05 +00:00
.BR tcsetattr ()
2004-11-03 13:51:07 +00:00
returns success if \fIany\fP of the requested changes could be
successfully carried out.
Therefore, when making multiple changes
2004-11-03 13:51:07 +00:00
it may be necessary to follow this call with a further call to
2005-10-19 16:30:05 +00:00
.BR tcgetattr ()
2004-11-03 13:51:07 +00:00
to check that all changes have been performed successfully.
.SH NOTES
Unix V7 and several later systems have a list of baud rates
where after the fourteen values B0, ..., B9600 one finds the
two constants EXTA, EXTB ("External A" and "External B").
Many systems extend the list with much higher baud rates.
.LP
The effect of a non-zero \fIduration\fP with \fBtcsendbreak\fP() varies.
SunOS specifies a break of
2004-11-03 13:51:07 +00:00
.IB duration * N
seconds, where \fIN\fP is at least 0.25, and not more than 0.5.
Linux, AIX, DU, Tru64 send a break of
.I duration
milliseconds.
FreeBSD and NetBSD and HP-UX and MacOS ignore the value of
.IR duration .
Under Solaris and Unixware,
.BR tcsendbreak ()
2005-06-15 13:32:34 +00:00
with non-zero
2004-11-03 13:51:07 +00:00
.I duration
behaves like
.BR tcdrain ().
2004-11-03 13:51:07 +00:00
.\" libc4 until 4.7.5, glibc for sysv: EINVAL for duration > 0.
.\" libc4.7.6, libc5, glibc for unix: duration in ms.
.\" glibc for bsd: duration in us
.\" glibc for sunos4: ignore duration
.SH "SEE ALSO"
.BR stty (1),
.BR console_ioctl (4),
.BR tty_ioctl (4),
2006-05-15 09:13:10 +00:00
.BR feature_test_macros (7),
2004-11-03 13:51:07 +00:00
.BR setserial (8)