---
name: "TIOCMSET"
section: "2const"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/TIOCMSET"
---

# TIOCMSET(2const)

modem control

## NAME

TIOCMGET, TIOCMSET, TIOCMBIC, TIOCMBIS, TIOCMIWAIT, TIOCGICOUNT - modem control

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#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;**

## 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 <asm/termbits.h>
#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);
}
```

## SEE ALSO

[**ioctl**(2)](/ioctl/2.md), [**ioctl\_tty**(2)](/ioctl_tty/2.md)
