diff options
Diffstat (limited to 'pcserialport.c')
| -rw-r--r-- | pcserialport.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pcserialport.c b/pcserialport.c index 5134a6d..8cbe281 100644 --- a/pcserialport.c +++ b/pcserialport.c @@ -25,6 +25,11 @@ #include <sys/types.h> #include <string.h> +#if defined(__linux__) +//needed for setting low latency +#include <linux/serial.h> +#endif + #if defined(__APPLE__) #include <CoreFoundation/CoreFoundation.h> #include <IOKit/IOKitLib.h> @@ -178,6 +183,20 @@ smint32 serialPortOpen(const char * port_device_name, smint32 baudrate_bps) return -1; } #endif + + #if defined(TIOCGSERIAL) && defined(ASYNC_LOW_LATENCY) + struct serial_struct serial; + if(ioctl(port_handle, TIOCGSERIAL, &serial)!=-1) + { + serial.flags |= ASYNC_LOW_LATENCY; + if(ioctl(port_handle, TIOCSSERIAL, &serial) == -1 ) + { + smDebug(-1, Low, "Serial port warning: unable to set low latency mode, maybe try running with root permissions."); + } + } + else + smDebug(-1, Low, "Serial port warning: unable to read TIOCGSERIAL for low latency mode, maybe try running with root permissions."); + #endif //flush any stray bytes from device receive buffer that may reside in it //note: according to following page, delay before this may be necessary http://stackoverflow.com/questions/13013387/clearing-the-serial-ports-buffer |
