1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
|
'\" t
.\" Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
.\" Copyright 2002, Andries Brouwer <aeb@cwi.nl>
.\" Copyright 2024, Alejandro Colomar <alx@kernel.org>
.\"
.\" SPDX-License-Identifier: GPL-1.0-or-later
.\"
.TH TIOCMSET 2const 2024-06-13 "Linux man-pages (unreleased)"
.SH NAME
TIOCMGET,
TIOCMSET,
TIOCMBIC,
TIOCMBIS,
TIOCMIWAIT,
TIOCGICOUNT
\-
modem control
.SH LIBRARY
Standard C library
.RI ( libc ", " \-lc )
.SH SYNOPSIS
.nf
.BR "#include <asm/termbits.h>" " /* Definition of " TIOC* " constants */"
.B #include <sys/ioctl.h>
.P
.BI "int ioctl(int " fd ", TIOCMGET, int *" argp );
.BI "int ioctl(int " fd ", TIOCMSET, const int *" argp );
.BI "int ioctl(int " fd ", TIOCMBIC, const int *" argp );
.BI "int ioctl(int " fd ", TIOCMBIS, const int *" argp );
.BI "int ioctl(int " fd ", TIOCMIWAIT, int " arg );
.BI "int ioctl(int " fd ", TIOCGICOUNT, struct serial_icounter_struct *" argp );
.P
.B #include <linux/serial.h>
.P
.B struct serial_icounter_struct;
.fi
.SH DESCRIPTION
.TP
.B TIOCMGET
Get the status of modem bits.
.TP
.B TIOCMSET
Set the status of modem bits.
.TP
.B TIOCMBIC
Clear the indicated modem bits.
.TP
.B TIOCMBIS
Set the indicated modem bits.
.P
The following bits are used by the above ioctls:
.P
.TS
lb l.
TIOCM_LE DSR (data set ready/line enable)
TIOCM_DTR DTR (data terminal ready)
TIOCM_RTS RTS (request to send)
TIOCM_ST Secondary TXD (transmit)
TIOCM_SR Secondary RXD (receive)
TIOCM_CTS CTS (clear to send)
TIOCM_CAR DCD (data carrier detect)
TIOCM_CD see TIOCM_CAR
TIOCM_RNG RNG (ring)
TIOCM_RI see TIOCM_RNG
TIOCM_DSR DSR (data set ready)
.TE
.TP
.B TIOCMIWAIT
Wait for any of the 4 modem bits (DCD, RI, DSR, CTS) to change.
The bits of interest are specified as a bit mask in
.IR arg ,
by ORing together any of the bit values,
.BR TIOCM_RNG ,
.BR TIOCM_DSR ,
.BR TIOCM_CD ,
and
.BR TIOCM_CTS .
The caller should use
.B TIOCGICOUNT
to see which bit has changed.
.TP
.B TIOCGICOUNT
Get counts of input serial line interrupts (DCD, RI, DSR, CTS).
The counts are written to the
.I serial_icounter_struct
structure pointed to by
.IR argp .
.IP
Note: both 1->0 and 0->1 transitions are counted, except for
RI, where only 0->1 transitions are counted.
.SH RETURN VALUE
On success,
0 is returned.
On error,
\-1 is returned, and
.I errno
is set to indicate the error.
.SH EXAMPLES
Check the condition of DTR on the serial port.
.P
.\" SRC BEGIN (tiocmget.c)
.EX
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
\&
int
main(void)
{
int fd, serial;
\&
fd = open("/dev/ttyS0", O_RDONLY);
ioctl(fd, TIOCMGET, &serial);
if (serial & TIOCM_DTR)
puts("TIOCM_DTR is set");
else
puts("TIOCM_DTR is not set");
close(fd);
}
.EE
.\" SRC END
.SH SEE ALSO
.BR ioctl (2),
.BR ioctl_tty (2)
|