TIOCMSET(2const)
β¨ TIOCMSET β¨ (that's the page name bestie, from the (2const) section π
)
okay so like. this one is titled TIOCMSET, and honestly the whole squad is here: TIOCMGET, TIOCMSET, TIOCMBIC, TIOCMBIS, TIOCMIWAIT, TIOCGICOUNT β they're all about modem control. yep. modem. control. the little wires in your serial port that talk to each other. it's giving vintage tech but she still ate πΈ
π LIBRARY
Standard C library β that's libc, linked with -lc. your bestie libc has been carrying this whole thing, no cap π«Ά
π 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;
like yes, it's ioctl six different ways, they're all serving their own little purpose π
π DESCRIPTION
π TIOCMGET
Grab the status of the modem bits. just. read the vibe check of your modem bits, that's it.
π TIOCMSET
Set the status of the modem bits. you're the main character now, you decide what the bits are doing.
π TIOCMBIC
Clear the indicated modem bits. girl, clear it. set those specific bits to off.
π TIOCMBIS
Set the indicated modem bits. opposite energy, we're turning them ON now β¨
The following bits are the ones these ioctls use β memorize them, they're iconic:
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β seeTIOCM_CARTIOCM_RNGβ RNG (ring)TIOCM_RIβ seeTIOCM_RNGTIOCM_DSRβ DSR (data set ready)
π TIOCMIWAIT
Wait for any of the 4 modem bits (DCD, RI, DSR, CTS) to change. the way that you just sit there and wait for something to happenβ¦ relatable honestly π
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. iykyk β you don't get told who moved, you just know someone did.
π 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. receipts, basically. we keep track of everything here π
Note: both 1->0 and 0->1 transitions are counted, except for RI, where only 0->1 transitions are counted. bestie RI is different. RI always is. π
β RETURN VALUE
On success, 0 is returned. slay. On error, -1 is returned, and errno is set to indicate the error. so like, check errno if things went sideways π
π§ EXAMPLES
Check the condition of DTR on the serial port. that's it, that's the whole mission:
#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 how simple? open /dev/ttyS0, ask, check the bit, close. chef's kiss π
π SEE ALSO
okay that's the page!! ily, go forth and control those modem bits π this little manual page is from Linux man-pages 6.20, dated 2026-02-08 β and it's theTIOCMSET(2const)page, so like, tag yourself, I'mTIOCMSETππ
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: GPL-1.0-or-later
- Copyright 2002, Walter Harms <walter.harms@informatik.uni-oldenburg.de>
- Copyright 2002, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms