0

I have a C program which works with a normal terminal using this code:

int dtr_rts = TIOCM_DTR | TIOCM_RTS; /* out-of-band signal */
...
int comfd = open(COM_PORT, O_RDWR);
...
ioctl(comfd, TIOCMBIS, &dtr_rts);

Now I need to run this program on a pseudo-terminal. How do I read DTR/RTS on master side? Is DTR/RTS set to 1 or to 0 by default (i.e., on open()) on /dev/pts/X?

Is TIOCMGET ioctl implemented for pseudo-terminals?

1 Answer 1

1

No, it's not. A pseudo terminal has no way to pass through serial ioctls like TIOCMBIS or TIOCSET.

See also:

Virtual tty client for network telnet/RFC2217 server?

Run a serial connection over SSH

2
  • I have found a workaround (although slight changes in the program which uses the tty are needed): Those processes are on the same computer (as using a pseudo-terminal implies), so I can use IPC mechanisms for out-of-band signalling. For example, I will create a file in slave and poll it in master after starting slave (this file must be removed before slave is started). [The program sets dtr_rts to 1 only once after it starts when it is ready to accept data.] Aug 28, 2019 at 9:13
  • You can also use a LD_PRELOAD hack to run unmodified programs, and pass the modem bits by re-purposing some unused termios special character (eg c_cc[VEOL2]), and passing the changes using the trick from the 2nd link. I'll add a full example when I have time and a machine where I can build & test.
    – user313992
    Aug 28, 2019 at 9:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .