📄 library_16.html
字号:
<P><DT><CODE>CREAD</CODE><DD>If this bit is set, input can be read from the terminal. Otherwise,input is discarded when it arrives.<A NAME="IDX1126"></A><P><DT><CODE>CSTOPB</CODE><DD>If this bit is set, two stop bits are used. Otherwise, only one stop bitis used.<A NAME="IDX1127"></A><P><DT><CODE>PARENB</CODE><DD>If this bit is set, generation and detection of a parity bit are enabled.See section <A HREF="library_16.html#SEC276" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC276">Input Modes</A>, for information on how input parity errors are handled.<P>If this bit is not set, no parity bit is added to output characters, andinput characters are not checked for correct parity.<A NAME="IDX1128"></A><P><DT><CODE>PARODD</CODE><DD>This bit is only useful if <CODE>PARENB</CODE> is set. If <CODE>PARODD</CODE> is set,odd parity is used, otherwise even parity is used.</DL><P>The control mode flags also includes a field for the number of bits percharacter. You can use the <CODE>CSIZE</CODE> macro as a mask to extract thevalue, like this: <CODE>settings.c_cflag & CSIZE</CODE>.<P><A NAME="IDX1129"></A><DL COMPACT><DT><CODE>CSIZE</CODE><DD>This is a mask for the number of bits per character.<A NAME="IDX1130"></A><P><DT><CODE>CS5</CODE><DD>This specifies five bits per byte.<A NAME="IDX1131"></A><P><DT><CODE>CS6</CODE><DD>This specifies six bits per byte.<A NAME="IDX1132"></A><P><DT><CODE>CS7</CODE><DD>This specifies seven bits per byte.<A NAME="IDX1133"></A><P><DT><CODE>CS8</CODE><DD>This specifies eight bits per byte.<A NAME="IDX1134"></A><P><DT><CODE>CCTS_OFLOW</CODE><DD>If this bit is set, enable flow control of output based on the CTS wire(RS232 protocol).<A NAME="IDX1135"></A><P><DT><CODE>CRTS_IFLOW</CODE><DD>If this bit is set, enable flow control of input based on the RTS wire(RS232 protocol).<A NAME="IDX1136"></A><P><DT><CODE>MDMBUF</CODE><DD>If this bit is set, enable carrier-based flow control of output.</DL><P><H3><A NAME="SEC279" HREF="library_toc.html#SEC279" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC279">Local Modes</A></H3><P>This section describes the flags for the <CODE>c_lflag</CODE> member of the<CODE>struct termios</CODE> structure. These flags generally controlhigher-level aspects of input processing than the input modes flagsdescribed in section <A HREF="library_16.html#SEC276" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC276">Input Modes</A>, such as echoing, signals, and the choiceof canonical or noncanonical input.<P>The <CODE>c_lflag</CODE> member itself is an integer, and you change the flagsand fields using the operators <CODE>&</CODE>, <CODE>|</CODE>, and <CODE>^</CODE>. Don'ttry to specify the entire value for <CODE>c_lflag</CODE>---instead, changeonly specific flags and leave the rest untouched (see section <A HREF="library_16.html#SEC275" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC275">Setting Terminal Modes Properly</A>).<P><A NAME="IDX1137"></A><DL COMPACT><DT><CODE>ICANON</CODE><DD>This bit, if set, enables canonical input processing mode. Otherwise,input is processed in noncanonical mode. See section <A HREF="library_16.html#SEC271" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC271">Two Styles of Input: Canonical or Not</A>.<A NAME="IDX1138"></A><P><DT><CODE>ECHO</CODE><DD>If this bit is set, echoing of input characters back to the terminalis enabled.<A NAME="IDX1139"></A><A NAME="IDX1140"></A><P><DT><CODE>ECHOE</CODE><DD>If this bit is set, echoing indicates erasure of input with the ERASEcharacter by erasing the last character in the current line from thescreen. Otherwise, the character erased is re-echoed to show what hashappened (suitable for a printing terminal).<P>This bit only controls the display behavior; the <CODE>ICANON</CODE> bit byitself controls actual recognition of the ERASE character and erasure ofinput, without which <CODE>ECHOE</CODE> is simply irrelevant.<A NAME="IDX1141"></A><P><DT><CODE>ECHOK</CODE><DD>This bit enables special display of the KILL character. There are twoways this can be done. The better way is by erasing on the screen theentire line that has been killed. The worse way is by moving to a newline after echoing the KILL character normally. Some systems do one,some systems do the other, and some let you choose either way.<P>If this bit is not set, the KILL character echoes just as it would if itwere not the KILL character. Then it is up to the user to remember thatthe KILL character has erased the preceding input; there is noindication of this on the screen.<P>This bit only controls the display behavior; the <CODE>ICANON</CODE> bit byitself controls actual recognition of the KILL character and erasure ofinput, without which <CODE>ECHOK</CODE> is simply irrelevant.<A NAME="IDX1142"></A><P><DT><CODE>ECHONL</CODE><DD>If this bit is set and the <CODE>ICANON</CODE> bit is also set, then thenewline (<CODE>'\n'</CODE>) character is echoed even if the <CODE>ECHO</CODE> bitis not set.<A NAME="IDX1143"></A><P><DT><CODE>ISIG</CODE><DD>This bit controls whether the INTR, QUIT, and SUSP characters arerecognized. The functions associated with these characters are performedif and only if this bit is set. Being in canonical or noncanonicalinput mode has no affect on the interpretation of these characters.<P>You should use caution when disabling recognition of these characters.Programs that cannot be interrupted interactively are veryuser-unfriendly. If you clear this bit, your program should providesome alternate interface that allows the user to interactively send thesignals associated with these characters, or to escape from the program.<A NAME="IDX1144"></A><P>See section <A HREF="library_16.html#SEC284" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC284">Characters that Cause Signals</A>.<A NAME="IDX1145"></A><P><DT><CODE>IEXTEN</CODE><DD>This bit is similar to <CODE>ISIG</CODE>, but controls implementation-definedspecial characters. If it is set, it might override the default behaviorfor the <CODE>ICANON</CODE> and <CODE>ISIG</CODE> local mode flags, and the <CODE>IXON</CODE>and <CODE>IXOFF</CODE> input mode flags.<A NAME="IDX1146"></A><P><DT><CODE>NOFLSH</CODE><DD>Normally, the INTR, QUIT, and SUSP characters cause input and outputqueues for the terminal to be cleared. If this bit is set, the queuesare not cleared.<A NAME="IDX1147"></A><P><DT><CODE>TOSTOP</CODE><DD>If this bit is set and the system supports job control, then<CODE>SIGTTOU</CODE> signals are generated by background processes thatattempt to write to the terminal. See section <A HREF="library_24.html#SEC415" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_24.html#SEC415">Access to the Controlling Terminal</A>.</DL><P>The following bits are BSD extensions; the GNU library defines thesesymbols on any system if you ask for them, but the settings of the bitshave no effect except on BSD systems.<P><A NAME="IDX1148"></A><DL COMPACT><DT><CODE>ECHOKE</CODE><DD>On BSD systems, this bit selects between the two alternative ways ofdisplaying the KILL character, when <CODE>ECHOK</CODE> is set. If<CODE>ECHOKE</CODE> is set, then the KILL character erases the whole screenline; otherwise, the KILL character moves to the next screen line.The setting of <CODE>ECHOKE</CODE> has no effect when <CODE>ECHOK</CODE> is clear.<P><A NAME="IDX1149"></A><DT><CODE>ECHOPRT</CODE><DD>This bit enables display of the ERASE character in a way that is gearedto a hardcopy terminal.<A NAME="IDX1150"></A><P><DT><CODE>ECHOCTL</CODE><DD>If this bit is set, echo control characters with <SAMP>`^'</SAMP> followed bythe corresponding text character. Thus, control-A echoes as <SAMP>`^A'</SAMP>.<A NAME="IDX1151"></A><P><DT><CODE>ALTWERASE</CODE><DD>This bit determines how far the WERASE character should erase. TheWERASE character erases back to the beginning of a word; the questionis, where do words begin?<P>If this bit is clear, then the beginning of a word is a nonwhitespacecharacter following a whitespace character. If the bit is set, then thebeginning of a word is an alphanumeric character or underscore followinga character which is none of those.<A NAME="IDX1152"></A><P><DT><CODE>FLUSHO</CODE><DD>This is the bit that toggles when the user types the DISCARD character.While this bit is set, all output is discarded. See section <A HREF="library_16.html#SEC286" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC286">Other Special Characters</A>.<A NAME="IDX1153"></A><P><DT><CODE>NOKERNINFO</CODE><DD>Setting this bit disables handling of the STATUS character.See section <A HREF="library_16.html#SEC286" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC286">Other Special Characters</A>.<A NAME="IDX1154"></A><P><DT><CODE>PENDIN</CODE><DD>If this bit is set, it indicates that there is a line of input thatneeds to be reprinted. Typing the REPRINT character sets this bit; thebit remains set until reprinting is finished. See section <A HREF="library_16.html#SEC283" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_16.html#SEC283">BSD Extensions to Editing Characters</A>.</DL><P><A NAME="IDX1155"></A><A NAME="IDX1156"></A><A NAME="IDX1157"></A><A NAME="IDX1158"></A><H3><A NAME="SEC280" HREF="library_toc.html#SEC280" tppabs="http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_toc.html#SEC280">Line Speed</A></H3><P>The terminal line speed tells the computer how fast to read and writedata on the terminal.<P>If the terminal is connected to a real serial line, the terminal speedyou specify actually controls the line--if it doesn't match theterminal's own idea of the speed, communication does not work. Realserial ports accept only certain standard speeds. Also, particularhardware may not support even all the standard speeds. Specifying aspeed of zero hangs up a dialup connection and turns off modem controlsignals.<P>If the terminal is not a real serial line (for example, if it is anetwork connection), then the line speed won't really affect datatransmission speed, but some programs will use it to determine theamount of padding needed. It's best to specify a line speed value thatmatches the actual speed of the actual terminal, but you can safelyexperiment with different values to vary the amount of padding.<P>There are actually two line speeds for each terminal, one for input andone for output. You can set them independently, but most oftenterminals use the same speed for both directions.<P>The speed values are stored in the <CODE>struct termios</CODE> structure, butdon't try to access them in the <CODE>struct termios</CODE> structuredirectly. Instead, you should use the following functions to read andstore them:<P><A NAME="IDX1159"></A><U>Function:</U> speed_t <B>cfgetospeed</B> <I>(const struct termios *<VAR>termios_p</VAR>)</I><P>This function returns the output line speed stored in the structure<CODE>*<VAR>termios_p</VAR></CODE>.<P><A NAME="IDX1160"></A><U>Function:</U> speed_t <B>cfgetispeed</B> <I>(const struct termios *<VAR>termios_p</VAR>)</I><P>This function returns the input line speed stored in the structure<CODE>*<VAR>termios_p</VAR></CODE>.<P><A NAME="IDX1161"></A><U>Function:</U> int <B>cfsetospeed</B> <I>(struct termios *<VAR>termios_p</VAR>, speed_t <VAR>speed</VAR>)</I><P>This function stores <VAR>speed</VAR> in <CODE>*<VAR>termios_p</VAR></CODE> as the outputspeed. The normal return value is <CODE>0</CODE>; a value of <CODE>-1</CODE>indicates an error. If <VAR>speed</VAR> is not a speed, <CODE>cfsetospeed</CODE>returns <CODE>-1</CODE>.<P><A NAME="IDX1162"></A><U>Function:</U> int <B>cfsetispeed</B> <I>(struct termios *<VAR>termios_p</VAR>, speed_t <VAR>speed</VAR>)</I><P>This function stores <VAR>speed</VAR> in <CODE>*<VAR>termios_p</VAR></CODE> as the inputspeed. The normal return value is <CODE>0</CODE>; a value of <CODE>-1</CODE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -