termios: XON/XOFF handshake

2.8k views Asked by At

I'm trying to send data using the XON/XOFF software handshake so the receiver may control the data flow by using control characters.

To enable the flow control for sending data I did this:

tcgetattr (fd, &options) ; // Read current options
options.c_cflag |= IXON ; // Enable XON flow control on output
tcsetattr (fd, TCSANOW, &options) ; // Set new options

The program takes a file and sends it byte by byte to the serial interface. Curiously, when receiving the default STOP (0x13) the program continues sending data. When checking VSTOP for its value it returns 0x09. But this (0x09) also doesn't work for a STOP.

Does anyone have an idea on how to get this XON/XOFF to work with termios?

Thanks!
-Sören

1

There are 1 answers

3
jofel On

The sender does not need immediately stop if XOFF is received. It can still flush its output puffer. Therefore, the receiver should send XOFF already when it has still enough space to receive some more data (e.g. 30 bytes free).

VSTOP is just a flag (therefore an arbitrary integer, varying on different platforms) and not the ASCII character for XOFF.