| TIOCMSET(2const) | TIOCMSET(2const) |
TIOCMGET, TIOCMSET, TIOCMBIC, TIOCMBIS, TIOCMIWAIT, TIOCGICOUNT - modem control
Standard C library (libc, -lc)
#include <asm/termbits.h> /* Definition of TIOC* constants */ #include <sys/ioctl.h>
int ioctl(int fd, TIOCMGET, int *argp); int ioctl(int fd, TIOCMSET, const int *argp); int ioctl(int fd, TIOCMBIC, const int *argp); int ioctl(int fd, TIOCMBIS, const int *argp); int ioctl(int fd, TIOCMIWAIT, int arg); int ioctl(int fd, TIOCGICOUNT, struct serial_icounter_struct *argp);
#include <linux/serial.h>
struct serial_icounter_struct;
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) |
On success, 0 is returned. On error, -1 is returned, and errno is set to indicate the error.
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)
{
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);
}
| 2024-06-13 | Linux man-pages 6.9.1 |