Debian Codegraph @

upstream/debian-trixie/man2/TIOCMSET.2const

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