STTY(2)

NAME
stty, gtty - set and retrieve terminal modes

SYNOPSIS
#include <sgtty.h>

stty(fildes, arg)
struct sgttyb *arg;

gtty(fildes, arg)
struct sgttyb *arg;

DESCRIPTION
Gtty stores in the structure pointed to by arg status information about the terminal whose file descriptor is in r0 (in the first argument).

Stty delays until the terminal is quiescent, then sets its status to agree with the structure pointed to by arg.

The input and output speeds are set from the first two bytes Both system calls use the structure defined in <sgtty.h>:

struct sgttyb {
	char	sg_ispeed;
	char	sg_ospeed;
	char	sg_erase;
	char	sg_kill;
	short	sg_flags;
};

The sg_ispeed and sg_ospeed fields describe the input and output speeds of the device according to the following table, which corresponds to the DH-11 interface. If DC-11, DL-11 or KL-11 interfaces are used, impossible speed changes are ignored. Symbolic values in the table are as defined in <sgtty.h>.

B0	0	(hang up dataphone)
B50	1	50 baud
B75	2	75 baud
B110	3	110 baud
B134	4	134.5 baud
B150	5	150 baud
B200	6	200 baud
B300	7	300 baud
B600	8	600 baud
B1200	9	1200 baud
B1800	10	1800 baud
B2400	11	2400 baud
B4800	12	4800 baud
B9600	13	9600 baud
EXTA	14	External A
EXTB	15	External B

In the current configuration, only 110, 150, 300 and 1200 baud are really supported on dial-up lines. Code conversion and line control required for IBM 2741's (134.5 baud) must be implemented by the user's program. The half-duplex line discipline required for the 202 dataset (1200 baud) is not supplied; full-duplex 212 datasets work fine.

The sg_erase and sg_kill fields of the argument structure specify the erase and kill characters respectively. (Defaults are # and @.)

The sg_flags field of the argument structure contains several bits which determine the system's treatment of the terminal:

ALLDELAY	0177400	Delay algorithm selection
BSDELAY	0100000	Select backspace delays:
BS0	0
BS1	0100000
VTDELAY	0040000	Select form-feed and vertical-tab delays:
FF0	0
FF1	0040000
CRDELAY	0030000	Select carriage-return delays:
CR0	0
CR1	0010000
CR2	0020000
CR3	0030000
TBDELAY	0006000	Select tab delays:
TAB0	0
TAB1	0002000
TAB2	0004000
TAB3	0006000
NLDELAY	0001400	Select new-line delays:
NL0	0
NL1	0000400
NL2	0001000
NL3	0001400
EVENP	0000200	Even parity allowed on input (e. g. for M37s)
ODDP	0000100	Odd parity allowed on input
RAW	0000040	Raw mode: wake up on all characters
CRMOD	0000020	Map CR into LF; echo LF or CR as CR-LF
ECHO	0000010	Echo (full duplex)
LCASE	0000004	Map upper case to lower on input (e. g. M33)
CBREAK	0000002	Return each character as soon as it is tped
HUPCL	0000001	Hang up (remove `data terminal ready') on last close

The delay bits specify how long transmission stops to allow for mechanical or other movement when certain characters are sent to the terminal. In all cases a value of 0 indicates no delay.

Backspace delays are currently ignored but will be used for Terminet 300's.

If a form-feed/vertical tab delay is specified, it lasts for about 2 seconds.

Carriage-return delay type 1 lasts about .08 seconds and is suitable for the Terminet 300. Delay type 2 lasts about .16 seconds and is suitable for the VT05 and the TI 700. Delay type 3 is suitable for the Concept 100.

New-line delay type 1 is dependent on the current column and is tuned for Teletype model 37's. Type 2 is useful for the VT05 and is about .10 seconds. Type 3 is unimplemented and is 0.

Tab delay type 1 is dependent on the amount of movement and is tuned to the Teletype model 37. Other types are unimplemented and are 0.

Characters with the wrong parity, as determined by bits 200 and 100, are ignored.

In raw mode, every character is passed immediately to the program without waiting until a full line has been typed. No erase or kill processing is done; the end-of-file character (EOT), the interrupt character (DEL) and the quit character (FS) are not treated specially.

Mode 020 causes input carriage returns to be turned into new-lines; input of either CR or LF causes LF-CR both to be echoed (used for GE TermiNet 300's and other terminals without the newline function).

The hangup mode 01 causes the line to be disconnected when the last process with the line open closes it or terminates. It is useful when a port is to be used for some special purpose; for example, if it is associated with an ACU used to place outgoing calls.

This system call is also used with certain special files other than terminals, but since none of them are part of the standard system the specifications will not be given.

SEE ALSO
stty(1), tty(4), ioctl(2)

DIAGNOSTICS
Zero is returned if the call was successful; -1 if the file descriptor does not refer to a terminal.

ASSEMBLER (PDP-11)
(stty = 31.)
(file descriptor in r0)
sys stty; arg

(gtty = 32.)
(file descriptor in r0) sys gtty; arg