High delay in RS232 communication on a PXA270

Thank you very much for your comments.

I was able to reduce the delay to ~0.4ms. The command setserial(8) was referenced in the AEL manual. And bingo, I found the low_latency flag there with the following description:

Minimize the receive latency of the
serial device at the cost of greater
CPU utilization. (Normally there is an
average of 5-10ms latency before
characters are handed off to the line
discpline to minimize overhead.) This
is off by default, but certain
real-time applications may find this
useful.

I then executed setserial /dev/ttyS1 low_latency and the delay was reduced to ~0.4ms 🙂

But I wanted to implement this behaviour in the C++ app, without setting this flag globally with setserial (this command is by default not included in all distros).

I’ve added the following code lines, which had the same effect as the low_latency flag from setserial:

#include <sys/ioctl.h> 
#include <linux/serial.h>
// Open RS232 on COM1
mPhysicalComPort = open(aPort, O_RDWR | O_NOCTTY | O_NDELAY);
struct serial_struct serial;
ioctl(mPhysicalComPort, TIOCGSERIAL, &serial); 
serial.flags |= ASYNC_LOW_LATENCY; // (0x2000)
ioctl(mPhysicalComPort, TIOCSSERIAL, &serial);

Leave a Comment