Re: low_latency flag
From: Chuck Messenger <hidden>
Date: 2003-11-21 23:26:54
Jan-Benedict Glaw wrote:
On Fri, 2003-11-21 16:59:50 -0500, Chuck Messenger [off-list ref] wrote in message [ref]:quoted
Luckily, I happened to notice a recent message on this list with the word "low_latency". This led me to discover the low_latency flag, which you can set with "setserial /dev/ttyS0 low_latency". This sets a special mode on the port, which defeats some kernel-level buffering. I don't (yet) know how to set this mode programmatically -- I just call system("...") from my code (yech!).Looking at setserial's sources, something like this: struct serial_struct serinfo; fd = open ("/dev/ttySxx"); ioctl (fd, TIOCGSERIAL, &serinfo); serinfo.flags |= 0x4000; ioctl (fd, TIOCSSERIAL, &serinfo); close (fd); should do. Of course, not tested and missing all error handling:-( MfG, JBG
Thanks for the idea. Looking into it, I see in
/usr/include/linux/serial.h, the definition for serial_struct. The
comments show these values for the flags member:
/*
* Definitions for async_struct (and serial_struct) flags field
*/
...
#define ASYNC_LOW_LATENCY 0x2000 /* Request low latency behaviour */
#define ASYNC_BUGGY_UART 0x4000 /* This is a buggy UART, skip some safety
* checks. Note: can be dangerous! */
...
So, it looks like 0x2000 is the right value -- better, just use
ASYNC_LOW_LATENCY.
To save some future reader some time, you need:
#include <sys/ioctl.h>
#include <linux/ioctl.h>
#include <linux/serial.h>
I tried it out and it works. Thanks!
- Chuck