178 lines
7.4 KiB
HTML
178 lines
7.4 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>termios(3)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>termios(3)</H1>
|
|
<HR>
|
|
<PRE>
|
|
|
|
</PRE>
|
|
<H2>NAME</H2><PRE>
|
|
termios, tcgetattr, tcsetattr, cfgetispeed, cfgetospeed, cfsetispeed,
|
|
cfsetospeed, tcsendbreak, tcdrain, tcflush, tcflow - change terminal
|
|
attributes
|
|
|
|
|
|
</PRE>
|
|
<H2>SYNOPSIS</H2><PRE>
|
|
<STRONG>#include</STRONG> <STRONG><termios.h></STRONG>
|
|
|
|
<STRONG>int</STRONG> <STRONG>tcgetattr(int</STRONG> <EM>fd</EM><STRONG>,</STRONG> <STRONG>struct</STRONG> <STRONG>termios</STRONG> <STRONG>*</STRONG><EM>tp</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>tcsetattr(int</STRONG> <EM>fd</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>action</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>struct</STRONG> <STRONG>termios</STRONG> <STRONG>*</STRONG><EM>tp</EM><STRONG>)</STRONG>
|
|
|
|
<STRONG>speed_t</STRONG> <STRONG>cfgetispeed(const</STRONG> <STRONG>struct</STRONG> <STRONG>termios</STRONG> <STRONG>*</STRONG><EM>tp</EM><STRONG>)</STRONG>
|
|
<STRONG>speed_t</STRONG> <STRONG>cfgetospeed(const</STRONG> <STRONG>struct</STRONG> <STRONG>termios</STRONG> <STRONG>*</STRONG><EM>tp</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>cfsetispeed(struct</STRONG> <STRONG>termios</STRONG> <STRONG>*</STRONG><EM>tp</EM><STRONG>,</STRONG> <STRONG>speed_t</STRONG> <EM>speed</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>cfsetospeed(struct</STRONG> <STRONG>termios</STRONG> <STRONG>*</STRONG><EM>tp</EM><STRONG>,</STRONG> <STRONG>speed_t</STRONG> <EM>speed</EM><STRONG>)</STRONG>
|
|
|
|
<STRONG>int</STRONG> <STRONG>tcsendbreak(int</STRONG> <EM>fd</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>duration</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>tcdrain(int</STRONG> <EM>fd</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>tcflush(int</STRONG> <EM>fd</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>queue</EM>_<EM>selector</EM><STRONG>)</STRONG>
|
|
<STRONG>int</STRONG> <STRONG>tcflow(int</STRONG> <EM>fd</EM><STRONG>,</STRONG> <STRONG>int</STRONG> <EM>action</EM><STRONG>)</STRONG>
|
|
|
|
|
|
</PRE>
|
|
<H2>DESCRIPTION</H2><PRE>
|
|
These are the user functions that modify the tty attributes mentioned in
|
|
<STRONG><A HREF="../man4/tty.4.html">tty(4)</A></STRONG>. In the following, <EM>fd</EM> refers to an open terminal device file, <EM>tp</EM>
|
|
is the address of a <STRONG>struct</STRONG> <STRONG>termios</STRONG>, and <EM>speed</EM> and values of type <STRONG>speed_t</STRONG>
|
|
are equal to one of the <STRONG>B0</STRONG>, <STRONG>B50</STRONG>, etc. baud rate symbols. All functions,
|
|
symbols, and types are declared in <STRONG><termios.h></STRONG>.
|
|
|
|
The effects of the tty functions are:
|
|
|
|
<STRONG>tcgetattr(</STRONG><EM>fd</EM><STRONG>,</STRONG> <EM>tp</EM><STRONG>)</STRONG>
|
|
Get the current settings of the tty attributes.
|
|
|
|
<STRONG>tcsetattr(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCSANOW,</STRONG> <EM>tp</EM><STRONG>)</STRONG>
|
|
Set the terminal attributes. The change occurs immediately.
|
|
|
|
<STRONG>tcsetattr(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCSADRAIN,</STRONG> <EM>tp</EM><STRONG>)</STRONG>
|
|
Set the terminal attributes. The change occurs once all the output
|
|
waiting in the output queues has been transmitted. This should be
|
|
used when options affecting output are changed.
|
|
|
|
<STRONG>tcsetattr(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCSAFLUSH,</STRONG> <EM>tp</EM><STRONG>)</STRONG>
|
|
Set the terminal attributes. But first wait until all the output
|
|
waiting in the output queues has been transmitted. All input
|
|
waiting in the input queues is then discarded and the change is
|
|
made. This should be used when switching from canonical to non-
|
|
canonical mode or vice-versa. (Oddly enough, this is seldom what
|
|
you want, because it discards typeahead. An editing shell does the
|
|
Right Thing if it uses <STRONG>TCSANOW</STRONG> instead. POSIX may not guarantee
|
|
good results, but in practice most systems make the canonical input
|
|
available in raw mode.)
|
|
|
|
<STRONG>cfgetispeed(</STRONG><EM>tp</EM><STRONG>)</STRONG>
|
|
Return the input baud rate encoded in the termios structure.
|
|
|
|
<STRONG>cfgetospeed(</STRONG><EM>tp</EM><STRONG>)</STRONG>
|
|
Return the output baud rate encoded in the termios structure.
|
|
|
|
<STRONG>cfsetispeed(</STRONG><EM>tp</EM><STRONG>,</STRONG> <EM>speed</EM><STRONG>)</STRONG>
|
|
Encode the new input baud rate into the termios structure.
|
|
|
|
<STRONG>cfsetospeed(</STRONG><EM>tp</EM><STRONG>,</STRONG> <EM>speed</EM><STRONG>)</STRONG>
|
|
Encode the new output baud rate into the termios structure.
|
|
|
|
<STRONG>tcsendbreak(</STRONG><EM>fd</EM><STRONG>,</STRONG> <EM>duration</EM><STRONG>)</STRONG>
|
|
Emit a break condition on a serial line for a time indicated by
|
|
<EM>duration</EM>. (Always 0.4 seconds under Minix, <EM>duration</EM> is ignored.)
|
|
|
|
<STRONG>tcdrain(</STRONG><EM>fd</EM><STRONG>)</STRONG>
|
|
Wait until all output waiting in the output queues has been
|
|
transmitted.
|
|
|
|
<STRONG>tcflush(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCIFLUSH)</STRONG>
|
|
Flush the input queue. (I.e. discard it.)
|
|
|
|
<STRONG>tcflush(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCOFLUSH)</STRONG>
|
|
Flush the output queue.
|
|
|
|
<STRONG>tcflush(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCIOFLUSH)</STRONG>
|
|
Flush the input and output queues.
|
|
|
|
<STRONG>tcflow(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCOOFF)</STRONG>
|
|
Suspend output. (Like the effect of <STRONG>STOP</STRONG>.)
|
|
|
|
<STRONG>tcflow(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCOON)</STRONG>
|
|
Restart output. (Like the effect of <STRONG>START</STRONG>.)
|
|
|
|
<STRONG>tcflow(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCIOFF)</STRONG>
|
|
Transmit a <STRONG>STOP</STRONG> character intended to make the remote device stop
|
|
transmitting data.
|
|
|
|
<STRONG>tcflow(</STRONG><EM>fd</EM><STRONG>,</STRONG> <STRONG>TCION)</STRONG>
|
|
Transmit a <STRONG>START</STRONG> character to restart the remote device.
|
|
|
|
|
|
</PRE>
|
|
<H2>SEE ALSO</H2><PRE>
|
|
<STRONG><A HREF="../man1/stty.1.html">stty(1)</A></STRONG>, <STRONG><A HREF="../man4/tty.4.html">tty(4)</A></STRONG>.
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
<H2>DIAGNOSTICS</H2><PRE>
|
|
All functions return 0 unless otherwise specified, and -1 on error with
|
|
<STRONG>errno</STRONG> set to indicate the type of error. The most notable errors are
|
|
<STRONG>ENOTTY</STRONG> if <EM>fd</EM> does not refer to a terminal device, and <STRONG>EINTR</STRONG> if one of the
|
|
functions waiting for output to drain is interrupted.
|
|
|
|
|
|
</PRE>
|
|
<H2>NOTES</H2><PRE>
|
|
It may be interesting to know that the functions operating on the tty are
|
|
directly translated into the following Minix <STRONG>ioctl</STRONG> requests: <STRONG>TCGETS</STRONG>,
|
|
<STRONG>TCSETS</STRONG> (now), <STRONG>TCSETSW</STRONG> (drain), <STRONG>TCSETSF</STRONG>, (flush), <STRONG>TCSBRK</STRONG>, <STRONG>TCDRAIN</STRONG>, <STRONG>TCFLSH</STRONG>,
|
|
and <STRONG>TCFLOW</STRONG>. You should only use this knowledge when trying to understand
|
|
the tty driver code, of course.
|
|
|
|
|
|
</PRE>
|
|
<H2>BUGS</H2><PRE>
|
|
|
|
|
|
</PRE>
|
|
<H2>AUTHOR</H2><PRE>
|
|
Kees J. Bot (kjb@cs.vu.nl)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|