Next: , Previous: , Up: The termios and miscellaneous library   [Contents][Index]


5.7.2 Standard termios functions

The #<termios> type is an opaque type that can contain information about a general terminal interface. This information is in the form of several boolean

Procedure: new-termios

This procedure creates and returns a new #<termios> variable. A newly created #<termios> do not represent any specific port’s behavior. It is set to a generic behavior for a raw terminal: no echoing or special processing and with 8-bit characters allowed.

Procedure: termios? x

This procedure returns #t if x is of the #<termios> type./

Procedure: %termios-debug term

This procedure, when given term of type #<termios>, writes to the standard output port some useful debugging information about the current state of term.

Procedure: termios-flag-set! term flag-or-flags

Given term of type #<termios> and flag-or-flags which is either a symbol or a list of symbols of termios boolean properties, this procedure sets those properties to be active.

Procedure: termios-flag-clear! term flag-or-flags

Given term of type #<termios> and flag-or-flags which is either a symbol or a list of symbols of termios boolean properties, this procedure sets those properties to be disabled.

Procedure: termios-flag-get term

Given term of type #<termios>, this returns a list of symbols of the boolean properties of term that are active.

Procedure: termios-flag-test term prop

Given term of type #<termios>, and prop, which is a symbol indicating a boolean property of term, this returns #t if that property is set, or #f otherwise.

The boolean properties are in the table below.

IGNBRK

Ignore a BREAK condition on input.

BRKINT

If IGNBRK is set, a BREAK is ignored. If it is not set but BRKINT is set, then a BREAK causes the input and output queues to be flushed, and if the terminal is the controlling terminal of a foreground process group, it will cause a SIGINT to be sent to this foreground process group. When neither IGNBRK nor BRKINT are set, a BREAK reads as a null byte (’\0’), except when PARMRK is set, in which case it reads as the sequence \377 \0 \0.

IGNPAR

Ignore framing errors and parity errors.

PARMRK

If this bit is set, input bytes with parity or framing errors are marked when passed to the program. This bit is meaningful only when INPCK is set and IGNPAR is not set. The way erroneous bytes are marked is with two preceding bytes, \377 and \0. Thus, the program actually reads three bytes for one erroneous byte received from the terminal. If a valid byte has the value \377, and ISTRIP (see below) is not set, the program might confuse it with the prefix that marks a parity error. Therefore, a valid byte \377 is passed to the program as two bytes, \377 \377, in this case.

If neither IGNPAR nor PARMRK is set, read a character with a parity error or framing error as \0.

INPCK

Enable input parity checking.

ISTRIP

Strip off eighth bit.

INLCR

Translate NL to CR on input.

IGNCR

Ignore carriage return on input.

ICRNL

Translate carriage return to newline on input (unless IGNCR is set).

IXON

Enable XON/XOFF flow control on output.

IXANY

Typing any character will restart stopped output. (The default is to allow just the START character to restart output.)

IXOFF

Enable XON/XOFF flow control on input.

OPOST

Enable output postprocessing.

ONLCR

If OPOST is set, map NL to CR-NL on output.

OCRNL

If OPOST is set, map CR to NL on output.

ONOCR

If OPOST is set, don’t output CR at column 0.

ONLRET

If OPOST is set, NL is assumed to do the carriage return function. Carriage returns are not emitted.

CSTOPB

Set two stop bits, rather than one.

CREAD

Enable receiver.

PARENB

Enable parity generation on output and parity checking for input.

PARODD

If set, then parity for input and output is odd; otherwise even parity is used.

HUPCL

Lower modem control lines after last process closes the device (hang up).

CLOCAL

Ignore modem control lines.

ISIG

When any of the characters INTR, QUIT, SUSP, or DSUSP are received, generate the corresponding signal.

ICANON

Enable canonical mode (described below).

ECHO

Echo input characters.

ECHOE

If ICANON is also set, the ERASE character erases the preceding input character.

ECHOK

If ICANON is also set, the KILL character erases the current line.

ECHONL

If ICANON is also set, echo the NL character even if ECHO is not set.

NOFLSH

Disable flushing the input and output queues when generating signals for the INT, QUIT, and SUSP characters.

TOSTOP

Send the SIGTTOU signal to the process group of a background process which tries to write to its controlling terminal.

There are also some non-boolean properties of a #<termios> type. First up are a set of control characters that may operate on the terminal.

Procedure: termios-csize-get term
Procedure: termios-csize-set! term size

Given term of type #<termios>, these procedures get and set the number of bits in the character size: either 5, 6, 7, or 8.

Procedure: termios-veof-get term
Procedure: termios-veof-set! term char

Given term of type #<termios>, these procedures get and set the end-of-file character. The default end-of-file character is #\eot.

This character causes the pending tty buffer to be sent to the waiting user program without waiting for end-of-line. If it is the first character of the line, the a read of the associated port will return and end-of-file. This character is recognized when the ICANON property is set.

Procedure: termios-veol-get term
Procedure: termios-veol-set! term char

Given term of type #<termios>, these procedures get and set an additional end-of-line character. The default extra end-of-line character is #\nul. This is recognized when the ICANON property is set.

Procedure: termios-verase-get term
Procedure: termios-verase-set! term char

Given term of type #<termios>, these procedures get and set the erase character. It may be #\del or #\bs.

When this character is received, it erases the previous not-yet-erased character, but does not erase past EOF or beginning-of-line. Recognized when ICANON is set, and then not passed as input.

Procedure: termios-vintr-get term
Procedure: termios-vintr-set! term char

Given term of type #<termios>, these procedures get and set the interrupt character. This is usually #\etx aka control-C.

When this character is received, it sends a SIGINT signal. Recognized when ISIG is set, and then not passed as input.

Procedure: termios-vkill-get term
Procedure: termios-vkill-set! term char

Given term of type #<termios>, these procedures get and set the kill character. This is often #\nak.

When this character is received, this erases the input since the last EOF or beginning-of-line. Recognized when ICANON is set, and then not passed as input.

Procedure: termios-vquit-get term
Procedure: termios-vquit-set! term char

Given term of type #<termios>, these procedures get and set the quit character. This is often #\fs aka control-\.

When this character is received, this sends SIGQUIT signal. Recognized when ISIG is set, and then not passed as input.

Procedure: termios-vstart-get term
Procedure: termios-vstart-set! term char

Given term of type #<termios>, these procedures get and set the start character. This is usually #\dc1 aka control-Q.

When this character is received, it restarts output stopped by the Stop character. Recognized when IXON is set, and then not passed as input.

Procedure: termios-vstop-get term
Procedure: termios-vstop-set! term char

Given term of type #<termios>, these procedures get and set the stop character. This is usually #\dc3 aka control-S.

When this character is received, it stops output until the Start character is typed. Recognized when IXON is set, and then not passed as input.

Procedure: termios-vsusp-get term
Procedure: termios-vsusp-set! term char

Given term of type #<termios>, these procedures get and set the suspend character. This is usually #\sub aka control-Z.

When this character is received, the SIGTSTP signal is sent, and then is not passed as input.

There are input and output speed properties

Procedure: termios-ispeed-get term
Procedure: termios-ispeed-set! term bps
Procedure: termios-ospeed-get term
Procedure: termios-ospeed-set! term bps

These functions get and set the input and output speed of the line in bits-per-second. The bps value is an integer, and it should be one of the standard line speeds.

The standard line speeds are 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400. On some systems, they may also be 7200, 14400, 28800, 115200, 230400. If an input bps parameter doesn’t match an available line speed, it will be rounded down to the next available line speed.

There are also two numeric properties having to do with non-canonical reads.

Procedure: termios-vtime-get term
Procedure: termios-vtime-set! term delay

Given term of type #<termios>, these procedures get and set the time, in seconds, of a non-canonical read. delay is rounded to the nearest tenth of a second.

Procedure: termios-vmin-get term
Procedure: termios-vmin-set! term count

Given term of type #<termios>, these procedures get and set the minimum number of characters that need to be received for a non-canonical read.


Next: , Previous: , Up: The termios and miscellaneous library   [Contents][Index]