TERMIOS.3
资源名称:os_source.zip [点击查看]
上传用户:datang2001
上传日期:2007-02-01
资源大小:53269k
文件大小:4k
源码类别:
操作系统开发
开发平台:
C/C++
- .TH TERMIOS 3
- .SH NAME
- termios, tcgetattr, tcsetattr, cfgetispeed, cfgetospeed, cfsetispeed, cfsetospeed, tcsendbreak, tcdrain, tcflush, tcflow - change terminal attributes
- .SH SYNOPSIS
- .ft B
- .nf
- #include <termios.h>
- int tcgetattr(int fIfdfP, struct termios *fItpfP)
- int tcsetattr(int fIfdfP, int fIactionfP, const struct termios *fItpfP)
- speed_t cfgetispeed(const struct termios *fItpfP)
- speed_t cfgetospeed(const struct termios *fItpfP)
- int cfsetispeed(struct termios *fItpfP, speed_t fIspeedfP)
- int cfsetospeed(struct termios *fItpfP, speed_t fIspeedfP)
- int tcsendbreak(int fIfdfP, int fIdurationfP)
- int tcdrain(int fIfdfP)
- int tcflush(int fIfdfP, int fIqueue_selectorfP)
- int tcflow(int fIfdfP, int fIactionfP)
- .fi
- .ft P
- .SH DESCRIPTION
- .de SP
- .if t .sp 0.4
- .if n .sp
- ..
- These are the user functions that modify the tty attributes mentioned in
- .BR tty (4).
- In the following,
- .I fd
- refers to an open terminal device file,
- .I tp
- is the address of a
- .BR "struct termios" ,
- and
- .I speed
- and values of type
- .B speed_t
- are equal to one of the
- .BR B0 ,
- .BR B50 ,
- etc. baud rate symbols. All functions, symbols, and types are declared in
- .BR <termios.h> .
- .PP
- The effects of the tty functions are:
- .TP
- .B tcgetattr(fIfdfP, fItpfP)
- Get the current settings of the tty attributes.
- .TP
- .B tcsetattr(fIfdfP, TCSANOW, fItpfP)
- Set the terminal attributes. The change occurs immediately.
- .TP
- .B tcsetattr(fIfdfP, TCSADRAIN, fItpfP)
- 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.
- .TP
- .B tcsetattr(fIfdfP, TCSAFLUSH, fItpfP)
- 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
- .B TCSANOW
- instead. s-2POSIXs+2 may not guarantee good results, but in practice most
- systems make the canonical input available in raw mode.)
- .TP
- .B cfgetispeed(fItpfP)
- Return the input baud rate encoded in the termios structure.
- .TP
- .B cfgetospeed(fItpfP)
- Return the output baud rate encoded in the termios structure.
- .TP
- .B cfsetispeed(fItpfP, fIspeedfP)
- Encode the new input baud rate into the termios structure.
- .TP
- .B cfsetospeed(fItpfP, fIspeedfP)
- Encode the new output baud rate into the termios structure.
- .TP
- .B tcsendbreak(fIfdfP, fIdurationfP)
- Emit a break condition on a serial line for a time indicated by
- .IR duration .
- (Always 0.4 seconds under Minix,
- .I duration
- is ignored.)
- .TP
- .B tcdrain(fIfdfP)
- Wait until all output waiting in the output queues has been transmitted.
- .TP
- .B tcflush(fIfdfP, TCIFLUSH)
- Flush the input queue. (I.e. discard it.)
- .TP
- .B tcflush(fIfdfP, TCOFLUSH)
- Flush the output queue.
- .TP
- .B tcflush(fIfdfP, TCIOFLUSH)
- Flush the input and output queues.
- .TP
- .B tcflow(fIfdfP, TCOOFF)
- Suspend output. (Like the effect of
- .BR STOP .)
- .TP
- .B tcflow(fIfdfP, TCOON)
- Restart output. (Like the effect of
- .BR START .)
- .TP
- .B tcflow(fIfdfP, TCIOFF)
- Transmit a
- .B STOP
- character intended to make the remote device stop transmitting data.
- .TP
- .B tcflow(fIfdfP, TCION)
- Transmit a
- .B START
- character to restart the remote device.
- .SH "SEE ALSO"
- .BR stty (1),
- .BR tty (4).
- .SH DIAGNOSTICS
- All functions return 0 unless otherwise specified, and -1 on error with
- .B errno
- set to indicate the type of error. The most notable errors are
- .B ENOTTY
- if
- .I fd
- does not refer to a terminal device, and
- .B EINTR
- if one of the functions waiting for output to drain is interrupted.
- .SH NOTES
- It may be interesting to know that the functions operating on the tty are
- directly translated into the following Minix
- .B ioctl
- requests:
- .BR TCGETS ,
- .BR TCSETS
- (now),
- .BR TCSETSW
- (drain),
- .BR TCSETSF ,
- (flush),
- .BR TCSBRK ,
- .BR TCDRAIN ,
- .BR TCFLSH ,
- and
- .BR TCFLOW .
- You should only use this knowledge when trying to understand the tty driver
- code, of course.
- .SH BUGS
- .SH AUTHOR
- Kees J. Bot (kjb@cs.vu.nl)