set ASYNC_LOW_LATENCY flag on serial device just like setserial does to fix huge latency found on recent kernel versions
This commit is contained in:
@@ -53,6 +53,7 @@ set(CMAKE_REQUIRED_LIBRARIES pthread rt)
|
||||
check_function_exists(pthread_setname_np HAVE_PTHREAD_SETNAME_NP)
|
||||
check_function_exists(pselect HAVE_PSELECT)
|
||||
check_function_exists(ppoll HAVE_PPOLL)
|
||||
check_include_file(linux/serial.h HAVE_LINUX_SERIAL -DHAVE_LINUX_SERIAL=1)
|
||||
check_function_exists(argp_parse HAVE_ARGP)
|
||||
if(NOT HAVE_ARGP)
|
||||
find_library(LIB_ARGP argp)
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
/* Defined if pselect() is available. */
|
||||
#cmakedefine HAVE_PSELECT
|
||||
|
||||
/* Defined if linux/serial.h is available. */
|
||||
#cmakedefine HAVE_LINUX_SERIAL
|
||||
|
||||
/* Defined if pthread_setname_np is available. */
|
||||
#cmakedefine HAVE_PTHREAD_SETNAME_NP
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ AC_SUBST(EXTRA_LIBS)
|
||||
|
||||
AC_CHECK_FUNC([pselect], [AC_DEFINE(HAVE_PSELECT, [1], [Defined if pselect() is available.])])
|
||||
AC_CHECK_FUNC([ppoll], [AC_DEFINE(HAVE_PPOLL, [1], [Defined if ppoll() is available.])])
|
||||
AC_CHECK_HEADER([linux/serial.h], [AC_DEFINE(HAVE_LINUX_SERIAL, [1], [Defined if linux/serial.h is available.])])
|
||||
|
||||
AC_ARG_ENABLE(coverage, AS_HELP_STRING([--enable-coverage], [enable code coverage tracking]), [CXXFLAGS+=" -coverage -O0"], [])
|
||||
AC_ARG_WITH(contrib, AS_HELP_STRING([--without-contrib], [disable inclusion of contributed sources]), [], [with_contrib=yes])
|
||||
|
||||
@@ -27,6 +27,9 @@
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#ifdef HAVE_LINUX_SERIAL
|
||||
# include <linux/serial.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_PPOLL
|
||||
# include <poll.h>
|
||||
@@ -190,6 +193,14 @@ result_t SerialDevice::open() {
|
||||
return RESULT_ERR_DEVICE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LINUX_SERIAL
|
||||
struct serial_struct serial;
|
||||
if (ioctl(m_fd, TIOCGSERIAL, &serial) == 0) {
|
||||
serial.flags |= ASYNC_LOW_LATENCY;
|
||||
ioctl(m_fd, TIOCSSERIAL, &serial);
|
||||
}
|
||||
#endif
|
||||
|
||||
// save current settings
|
||||
tcgetattr(m_fd, &m_oldSettings);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user