?? tcsetattr.3
字號:
.\" Copyright (c) 1991, 1993.\" The Regents of the University of California. All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)tcsetattr.3 8.3 (Berkeley) 1/2/94.\".Dd "January 2, 1994".Dt TCSETATTR 3.Os.Sh NAME.Nm cfgetispeed ,.Nm cfsetispeed ,.Nm cfgetospeed ,.Nm cfsetospeed ,.Nm cfsetspeed ,.Nm cfmakeraw ,.Nm tcgetattr ,.Nm tcsetattr.Nd manipulating the termios structure.Sh SYNOPSIS.Fd #include <termios.h>.Ft speed_t.Fn cfgetispeed "struct termios *t".Ft int.Fn cfsetispeed "struct termios *t" "speed_t speed".Ft speed_t.Fn cfgetospeed "struct termios *t".Ft int.Fn cfsetospeed "struct termios *t" "speed_t speed".Ft int.Fn cfsetspeed "struct termios *t" "speed_t speed".Ft void.Fn cfmakeraw "struct termios *t".Ft int.Fn tcgetattr "int fd" "struct termios *t".Ft int.Fn tcsetattr "int fd" "int action" "struct termios *t".Sh DESCRIPTIONThe.Nm cfmakeraw ,.Nm tcgetattrand.Nm tcsetattrfunctions are provided for getting and setting the termios structure..PpThe.Nm cfgetispeed ,.Nm cfsetispeed ,.Nm cfgetospeed ,.Nm cfsetospeedand.Nm cfsetspeedfunctions are provided for getting and setting the baud rate values inthe termios structure.The effects of the functions on the terminal as described belowdo not become effective, nor are all errors detected, until the.Nm tcsetattrfunction is called.Certain values for baud rates set in the termios structure and passed to.Nm tcsetattrhave special meanings.These are discussed in the portion of the manual page that describes the.Nm tcsetattrfunction..Sh GETTING AND SETTING THE BAUD RATEThe input and output baud rates are found in the termios structure.The unsigned integer.Li speed_tis typdef'd in the include file.Aq Pa termios.h .The value of the integer corresponds directly to the baud rate beingrepresented, however, the following symbolic values are defined..Bd -literal#define B0 0#define B50 50#define B75 75#define B110 110#define B134 134#define B150 150#define B200 200#define B300 300#define B600 600#define B1200 1200#define B1800 1800#define B2400 2400#define B4800 4800#define B9600 9600#define B19200 19200#define B38400 38400#ifndef _POSIX_SOURCE#define EXTA 19200#define EXTB 38400#endif /*_POSIX_SOURCE */.Ed.PpThe.Nm cfgetispeedfunction returns the input baud rate in the termios structure referenced by.Fa tp ..PpThe.Nm cfsetispeedfunction sets the input baud rate in the termios structure referenced by.Fa tpto.Fa speed ..PpThe.Nm cfgetospeedfunction returns the output baud rate in the termios structure referenced by.Fa tp ..PpThe.Nm cfsetospeedfunction sets the output baud rate in the termios structure referenced by.Fa tpto.Fa speed ..PpThe.Nm cfsetspeedfunction sets both the input and output baud rate in the termios structurereferenced by.Fa tpto.Fa speed ..PpUpon successful completion, the functions.Nm cfsetispeed ,.Nm cfsetospeed ,and.Nm cfsetspeedreturn a value of 0.Otherwise, a value of -1 is returned and the global variable.Va errnois set to indicate the error..Sh GETTING AND SETTING THE TERMIOS STATEThis section describes the functions that are used to control the generalterminal interface.Unless otherwise noted for a specific command, these functions are restrictedfrom use by background processes.Attempts to perform these operations shall cause the process group to be senta SIGTTOU signal.If the calling process is blocking or ignoring SIGTTOU signals, the processis allowed to perform the operation and the SIGTTOU signal is not sent..PpIn all the functions, although.Fa fdis an open file descriptor, the functions affect the underlying terminalfile, not just the open file description associated with the particularfile descriptor..PpThe.Nm cfmakerawfunction sets the flags stored in the termios structure to a state disablingall input and output processing, giving a.Dq raw I/O path.It should be noted that there is no function to reverse this effect.This is because there are a variety of processing options that could bere-enabled and the correct method is for an application to snapshot thecurrent terminal state using the function.Nm tcgetattr ,setting raw mode with.Nm cfmakerawand the subsequent.Nm tcsetattr ,and then using another.Nm tcsetattrwith the saved state to revert to the previous terminal state..PpThe.Nm tcgetattrfunction copies the parameters associated with the terminal referencedby.Fa fdin the termios structure referenced by.Fa tp .This function is allowed from a background process, however, the terminalattributes may be subsequently changed by a foreground process..PpThe.Nm tcsetattrfunction sets the parameters associated with the terminal from thetermios structure referenced by.Fa tp .The.Fa actionfield is created by.Em or Ns 'ingthe following values, as specified in the include file.Aq Pa termios.h ..Bl -tag -width "TCSADRAIN".It Fa TCSANOWThe change occurs immediately..It Fa TCSADRAINThe change occurs after all output written to.Fa fdhas been transmitted to the terminal.This value of.Fa actionshould be used when changing parameters that affect output..It Fa TCSAFLUSHThe change occurs after all output written to.Fa fdhas been transmitted to the terminal.Additionally, any input that has been received but not read is discarded..It Fa TCSASOFTIf this value is.Em or Ns 'edinto the.Fa actionvalue, the values of the.Em c_cflag ,.Em c_ispeed ,and.Em c_ospeedfields are ignored..El.PpThe 0 baud rate is used to terminate the connection.If 0 is specified as the output speed to the function.Nm tcsetattr ,modem control will no longer be asserted on the terminal, disconnectingthe terminal..PpIf zero is specified as the input speed to the function.Nm tcsetattr ,the input baud rate will be set to the same value as that specified bythe output baud rate..PpIf.Nm tcsetattris unable to make any of the requested changes, it returns -1 andsets errno.Otherwise, it makes all of the requested changes it can.If the specified input and output baud rates differ and are a combinationthat is not supported, neither baud rate is changed..PpUpon successful completion, the functions.Nm tcgetattrand.Nm tcsetattrreturn a value of 0.Otherwise, theyreturn -1 and the global variable.Va errnois set to indicate the error, as follows:.Bl -tag -width Er.It Bq Er EBADFThe.Fa fdargument to.Nm tcgetattror.Nm tcsetattrwas not a valid file descriptor..It Bq Er EINTRThe.Nm tcsetattrfunction was interrupted by a signal..It Bq Er EINVALThe.Fa actionargument to the.Nm tcsetattrfunction was not valid, or an attempt was made to change an attributerepresented in the termios structure to an unsupported value..It Bq Er ENOTTYThe file associated with the.Fa fdargument to.Nm tcgetattror.Nm tcsetattris not a terminal..El.Sh SEE ALSO.Xr tcsendbreak 3 ,.Xr termios 4.Sh STANDARDSThe.Nm cfgetispeed ,.Nm cfsetispeed ,.Nm cfgetospeed ,.Nm cfsetospeed ,.Nm tcgetattrand.Nm tcsetattrfunctions are expected to be compliant with the.St -p1003.1-88specification.The.Nm cfmakerawand.Nm cfsetspeedfunctions,as well as the.Li TCSASOFToption to the.Nm tcsetattrfunction are extensions to the.St -p1003.1-88specification.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -