⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 termios.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<h4><a name = "tag_008_002_001">&nbsp;</a>The termios Structure</h4>Routines that need to control certainterminal I/O characteristics do so by using the<b>termios</b> structure as defined in the header<i><a href="../xsh/termios.h.html">&lt;termios.h&gt;</a></i>.The members of this structure include (but are not limited to):<pre><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Member Type</b><th align=center><b>Array Size</b><th align=center><b>Member Name</b><th align=center><b>Description</b><tr valign=top><td align=left>tcflag_t<td align=left>&nbsp;<td align=left>c_iflag<td align=left>Input modes.<tr valign=top><td align=left>tcflag_t<td align=left>&nbsp;<td align=left>c_oflag<td align=left>Output modes.<tr valign=top><td align=left>tcflag_t<td align=left>&nbsp;<td align=left>c_cflag<td align=left>Control modes.<tr valign=top><td align=left>tcflag_t<td align=left>&nbsp;<td align=left>c_lflag<td align=left>Local modes.<tr valign=top><td align=left>cc_t<td align=left>NCCS<td align=left>c_cc[]<td align=left>Control characters.</table></pre><p>The types<b>tcflag_t</b>and<b>cc_t</b>are defined in the header<i><a href="../xsh/termios.h.html">&lt;termios.h&gt;</a></i>.They areunsigned integral types.<h4><a name = "tag_008_002_002">&nbsp;</a>Input Modes</h4><xref type="3" name="inmodes"></xref>Values of the<b>c_iflag</b>field describe the basicterminal input control, and are composed of thebitwise inclusive OR of the masks shown, which will bebitwise distinct.The mask name symbols in this table are defined in<i><a href="../xsh/termios.h.html">&lt;termios.h&gt;</a></i>:<p><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Mask Name</b><th align=center><b>Description</b><tr valign=top><td align=left>BRKINT<td align=left>Signal interrupt on break.<tr valign=top><td align=left>ICRNL<td align=left>Map CR to NL on input.<tr valign=top><td align=left>IGNBRK<td align=left>Ignore break condition.<tr valign=top><td align=left>IGNCR<td align=left>Ignore CR.<tr valign=top><td align=left>IGNPAR<td align=left>Ignore characters with parity errors.<tr valign=top><td align=left>INLCR<td align=left>Map NL to CR on input.<tr valign=top><td align=left>INPCK<td align=left>Enable input parity check.<tr valign=top><td align=left>ISTRIP<td align=left>Strip character.<tr valign=top><td align=left>IUCLC<td align=left>Map upper case to lower case on input. (<b>LEGACY</b>)  <tr valign=top><td align=left>IXANY<td align=left>Enable any character to restart output.  <tr valign=top><td align=left>IXOFF<td align=left>Enable start/stop input control.<tr valign=top><td align=left>IXON<td align=left>Enable start/stop output control.<tr valign=top><td align=left>PARMRK<td align=left>Mark parity errors.</table><p>In the context of asynchronous serialdata transmission, a break condition is defined as asequence of zero-valued bits that continuesfor more than the time to send one byte.Theentire sequence of zero-valued bits isinterpreted as a single break condition, even if itcontinues for a time equivalent tomore than one byte.In contexts other thanasynchronous serial data transmission, the definitionof a break condition isimplementation-dependent.<p>If IGNBRK is set, a break condition detected on input is ignored thatis, not put on the input queue and therefore not read by any process.If IGNBRK is not set and BRKINT is set, the break condition willflush the input and output queues, and if the terminal is thecontrolling terminal of a foreground process group, the breakcondition will generate a single SIGINT signal to that foregroundprocess group.If neither IGNBRK nor BRKINT is set, a break conditionis read as a single0x00, or if PARMRK is set,as 0xff 0x00 0x00.<p>If IGNPAR is set, a bytewith a framing or parity error (other than break) is ignored.<p>If PARMRK is set,and IGNPAR is not set, a byte with a framing or parity error (otherthan break) is given to theapplication as the three-byte sequence0xff 0x00 X,where 0xff 0x00 is a two-byteflag preceding each sequence and X is the data ofthe byte received in error.To avoid ambiguity in this case, if ISTRIP is not set, avalid byte of 0xff is givento the application as 0xff 0xff.If neitherPARMRK nor IGNPAR is set, aframing or parity error (other than break) is given to theapplication as a single byte 0x00.<p>If INPCK is set, input paritychecking is enabled.If INPCK is not set, input paritychecking is disabled, allowing output paritygeneration without input parity errors.Notethat whether input parity checking isenabled or disabled is independent of whether paritydetection is enabled or disabled (see<xref href=conmodes><a href="#tag_008_002_004">Control Modes</a></xref>).If parity detection isenabled but input parity checking isdisabled, the hardware to which the terminal isconnected will recognise the parity bitbut the terminal special file will not checkwhether or not this bit is correctly set.<p>If ISTRIP is set, valid inputbytes are first stripped to seven bits, otherwise all eight bitsare processed.<p>If INLCR is set, a receivedNL character is translated into a CRcharacter.If IGNCR is set,a received CR character is ignored(not read).If IGNCR is not set and ICRNL is set, areceived CR character is translated intoan NL character.<p>If IUCLC is set,upper- to lower-case mappings are performedon the received character.In locales other than the POSIX locale,the mapping is unspecified. (<b>LEGACY</b>)<p>If IXANY is set, any input character will restart outputthat has been suspended.<p>If IXON is set, start/stop output control is enabled.A received STOP character suspends output and a received STARTcharacter restarts output.When IXON is set, START and STOP characters are notread, but merely perform flow control functions.When IXON is not set, the START and STOP characters are read.<p>If IXOFF is set, start/stop inputcontrol is enabled.The system transmits STOPcharacters, which are intended to causethe terminal device to stop transmitting data, asneeded to prevent theinput queue fromoverflowing and causing undefined behaviour,and transmits START characters,which are intended to cause theterminal device to resume transmitting data,as soon as the device can continuetransmitting data without risk of overflowingthe input queue.The precise conditionsunder which STOP and START charactersare transmitted are implementation-dependent.<p>The initial input control value after<i><a href="../xsh/open.html">open()</a></i>is implementation-dependent.<h4><a name = "tag_008_002_003">&nbsp;</a>Output Modes</h4><xref type="3" name="outmodes"></xref>The<b>c_oflag</b>field specifies the terminalinterface's treatment of output, and is composed of thebitwise inclusive OR of the masks shown, which will bebitwise distinct.The mask name symbols in this table are definedin<i><a href="../xsh/termios.h.html">&lt;termios.h&gt;</a></i>:<br><p><table  bordercolor=#000000 border=1 align=center><tr valign=top><th align=center><b>Mask Name</b><th align=center><b>Description</b><tr valign=top><td align=left>OPOST<td align=left><i>Perform output processing.</i><tr valign=top><td align=left>OLCUC<td align=left><i>Map lower case to upper on output. (<b>LEGACY</b>)</i><tr valign=top><td align=left>ONLCR<td align=left><i>Map NL to CR-NL on output.</i><tr valign=top><td align=left>OCRNL<td align=left><i>Map CR to NL on output.</i><tr valign=top><td align=left>ONOCR<td align=left><i>No CR output at column 0.</i><tr valign=top><td align=left>ONLRET<td align=left><i>NL performs CR function.</i><tr valign=top><td align=left>OFILL<td align=left><i>Use fill characters for delay.</i><tr valign=top><td align=left>OFDEL<td align=left><i>Fill is DEL, else NUL.</i><tr valign=top><td align=left>NLDLY<td align=left><i>Select newline delays:</i><tr valign=top><td align=left>NL0<td align=left><i>Newline character type 0</i><tr valign=top><td align=left>NL1<td align=left><i>Newline character type 1.</i><tr valign=top><td align=left>CRDLY<td align=left><i>Select carriage-return delays:</i><tr valign=top><td align=left>CR0<td align=left><i>Carriage-return delay type 0</i><tr valign=top><td align=left>CR1<td align=left><i>Carriage-return delay type 1</i><tr valign=top><td align=left>CR2<td align=left><i>Carriage-return delay type 2</i><tr valign=top><td align=left>CR3<td align=left><i>Carriage-return delay type 3.</i><tr valign=top><td align=left>TABDLY<td align=left><i>Select horizontal-tab delays:</i><tr valign=top><td align=left>TAB0<td align=left><i>Horizontal-tab delay type 0</i><tr valign=top><td align=left>TAB1<td align=left><i>Horizontal-tab delay type 1</i><tr valign=top><td align=left>TAB2<td align=left><i>Horizontal-tab delay type 2.</i><tr valign=top><td align=left>TAB3<td align=left><i>Expand tabs to spaces.</i><tr valign=top><td align=left>BSDLY<td align=left><i>Select backspace delays:</i><tr valign=top><td align=left>BS0<td align=left><i>Backspace-delay type 0</i><tr valign=top><td align=left>BS1<td align=left><i>Backspace-delay type 1.</i><tr valign=top><td align=left>VTDLY<td align=left><i>Select vertical-tab delays:</i><tr valign=top><td align=left>VT0<td align=left><i>Vertical-tab delay type 0</i><tr valign=top><td align=left>VT1<td align=left><i>Vertical-tab delay type 1.</i><tr valign=top><td align=left>FFDLY<td align=left><i>Select form-feed delays:</i><tr valign=top><td align=left>FF0<td align=left><i>Form-feed delay type 0</i><tr valign=top><td align=left>FF1<td align=left><i>Form-feed delay type 1.</i></table><p>If OPOST is set, output datais post-processedas described below, so thatlines of text are modified toappear appropriately on the terminal device; otherwise,characters are transmitted without change.<p>If OLCUC is set,lower- to upper-case mappings are performedon the characters before they are transmitted.In locales other than the POSIX locale,the mapping is unspecified.(<b>LEGACY</b>) <p>If ONLCR is set, the NLcharacter is transmitted as the CR-NLcharacter pair.If OCRNLis set, the CR character is transmitted as the NL character.If ONOCR is set, no CRcharacter is transmitted when at column 0 (first position).If ONLRET is set, the NLcharacter is assumed to do the carriage-return function;the column pointer will be set to 0 and the delays specifiedfor CR will be used.Otherwise the NLcharacter is assumedto do just the line-feed function;the column pointer will remain unchanged.The column pointer is also set to 0 if the CRcharacter is actually transmitted.<p>The delay bits specify how longtransmission stops to allow for mechanical or other movementwhen certain characters are sent to the terminal.In all cases a value of 0 indicates no delay.If OFILLis set,fill characters will be transmittedfor delay instead of a timed delay.This is useful for high baud rate terminalswhich need only a minimal delay.If OFDELis set,the fill character is DEL,otherwise NUL.<p>If a form-feed or vertical-tab delay is specified,it lasts for about 2 seconds.<p>New-line delay lasts about 0.10 seconds.If ONLRETis set, the carriage-return delays areused instead of the newline delays.If OFILLis set,two fill characters will be transmitted.<p>Carriage-return delay type 1 is dependent on the current columnposition,type 2 is about 0.10 seconds,and type 3 is about 0.15 seconds.If OFILL is set,delay type 1 transmits two fill characters,and type 2, four fill characters.<p>Horizontal-tab delay type 1 is dependent on the currentcolumn position.Type 2 is about 0.10 seconds.Type 3 specifies that tabs are to be expanded into spaces.If OFILLis set,two fill characters will be transmitted for any delay.<p>Backspace delay lasts about 0.05 seconds.If OFILLis set,one fill character will be transmitted.<p>The actual delays depend on line speed and system load.<p>The initial output control value after<i><a href="../xsh/open.html">open()</a></i>is implementation-dependent.<h4><a name = "tag_008_002_004">&nbsp;</a>Control Modes</h4><xref type="3" name="conmodes"></xref>The<b>c_cflag</b>field describes the hardware control of the terminal,and is composed of the bitwise inclusive OR of the masks shown, which will bebitwise distinct.The mask name symbols in this table are defined in<i><a href="../xsh/termios.h.html">&lt;termios.h&gt;</a></i>;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -