int ttiocom(struct tty tp, int cmd, int arg, int mode);
The ttiocom routine is the general purpose
interpreter for use with serial drivers.
In most cases, a device driver's
routine calls ttiocom to send a
ttiocom may then in turn call the driver's
routine to send an I/O control command
to the TTY device.
Pointer to an instance of the
tty structure for a TTY device.
I/O control command
passed through from the user program.
Valid values of the cmd argument are as follows:
Determines if a character can be read from or written to a
TTY device without blocking (going to sleep in the
process). mode can be SELREAD or
SELWRITE. IOC_SELECT calls the
Query for line discipline type
by setting u.u_rval1 to the value TIOC.
rval1 is returned from the system call.
Checks to see if characters are waiting to be read. 1 is returned if
characters are waiting in t_canq. If ICANON is
set, it is also possible for 1 to be returned when characters are
not in t_canq, but there are characters in
t_delct. If there are no characters in t_canq
and ICANON is not set, and if there are characters in
t_rawq, 1 is returned. If none of the queues have
characters, 0 (zero) is returned. FIORDCHK causes
to be called.
Waits for the UART to empty (waits 11 bit times depending
on the terminal's baud rate). I_XCSETAW is a
POSIX extension to termio.
Waits until the UART empties and then flushes all read and
write buffers (calls
I_XCSETAF is a POSIX extension to
Sets terminal parameters from the tty structure specified
by the arg argument to ttiocom.
I_XCSETA is a POSIX extension to
Gets terminal parameters from a terminal's tty structure
and puts them into the tty structure specified by the
arg argument to ttiocom.
Argument to the I/O control command,
also passed through from the user program.
Indicates the mode by which the file
was opened. The modes are assigned by the kernel and are interpreted
into flag values that are defined in <sys/file.h>.
Possible values are FNDELAY, FREAD,
FSTOPIO, and FWRITE.
ttiocom returns 0 if an error is set in u.u_error;
otherwise it returns 1.