| TIOCMGET | Get the status of modem bits. |
| TIOCMSET | Set the status of modem bits. |
| TIOCMBIC | Clear the indicated modem bits. |
| TIOCMBIS | Set the indicated modem bits. |
| 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 arg, by ORing together any of the bit values, TIOCM_RNG, TIOCM_DSR, TIOCM_CD, and TIOCM_CTS. The caller should use TIOCGICOUNT to see which bit has changed. |
| TIOCGICOUNT | Get counts of input serial line interrupts (DCD, RI, DSR, CTS). The counts are written to the serial_icounter_struct structure pointed to by argp. |
NAME
TIOCMGET, TIOCMSET, TIOCMBIC, TIOCMBIS, TIOCMIWAIT, TIOCGICOUNT - modem control
LIBRARY
Standard C library (libc, -lc)
SYNOPSIS
#include <asm/termbits.h>\n /* Definition of \nTIOC*\n constants */
\n#include <sys/ioctl.h>int ioctl(int \nfd\n, TIOCMGET, int *\nargp\n);\n
\nint ioctl(int \nfd\n, TIOCMSET, const int *\nargp\n);\n
\nint ioctl(int \nfd\n, TIOCMBIC, const int *\nargp\n);\n
\nint ioctl(int \nfd\n, TIOCMBIS, const int *\nargp\n);\n
\nint ioctl(int \nfd\n, TIOCMIWAIT, int \narg\n);\n
\nint ioctl(int \nfd\n, TIOCGICOUNT, struct serial_icounter_struct *\nargp\n);#include <linux/serial.h>struct serial_icounter_struct;DESCRIPTION
- TIOCMGET
Get the status of modem bits.
- TIOCMSET
Set the status of modem bits.
- TIOCMBIC
Clear the indicated modem bits.
- TIOCMBIS
Set the indicated modem bits.
The following bits are used by the above ioctls:
| 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) |
- 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 arg, by ORing together any of the bit values, TIOCM_RNG, TIOCM_DSR, TIOCM_CD, and TIOCM_CTS. The caller should use TIOCGICOUNT to see which bit has changed.
- TIOCGICOUNT
Get counts of input serial line interrupts (DCD, RI, DSR, CTS). The counts are written to the serial_icounter_struct structure pointed to by argp.
Note: both 1->0 and 0->1 transitions are counted, except for RI, where only 0->1 transitions are counted.
RETURN VALUE
On success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error.
EXAMPLES
Check the condition of DTR on the serial port.
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
int
main(void)
{
\n
int fd, serial;
\n
fd = open("/dev/ttyS0", O_RDONLY);
\n
ioctl(fd, TIOCMGET, &serial);
\n
if (serial & TIOCM_DTR)
\n
puts("TIOCM_DTR is set");
\n
else
\n
puts("TIOCM_DTR is not set");
\n
close(fd);
}SEE ALSO
ioctl(2), ioctl_tty(2)