You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
USB serial ports can have a latency problem when you're trying to receive small packets of data, because they try to buffer data to put into one USB packet for efficiency. For example FTDI serial ports have a timeout of 16 milliseconds by default, and if you're only receiving a few bytes at a time, you will only receive data every 16ms.
Linux supports an ASYNC_LOW_LATENCY which asks drivers to have less latency (perhaps at the efficiency of transferring large amounts of data) which alleviates this problem. Windows also seems to have a similar thing using the COMMTIMEOUTS struct (not tested). I couldn't immediately find a similar setting for macOS.
Having a set_low_latency method on platforms that support it would be useful.
The text was updated successfully, but these errors were encountered:
We needed this functionality as well and created a separate small crate for it: https://github.com/michaellass/serialport_low_latency. It uses the TIOCGSERIAL and TIOCSSERIAL ioctls to change the serial line information and enable or disable low latency mode. This is basically the same as a setserial /dev/tty... low_latency would do.
It would be nice to incorporate this functionality directly into this crate. The reason why we haven't patched this into serialport-rs is portability and the necessity to run bindgen during build:
The numbers for the ioctls differ between CPU architectures. Hence, we are currently using bindgen on <asm/ioctls.h> to determine the correct values.
serialport-rs is cross-platform. I have no idea how to enable/disable the low latency mode on other Unixes or Windows.
Note that, if you have root permissions, it should also be possible to just write 1 into /sys/bus/usb-serial/devices/tty.../latency_timer. However, that file is typically writable only for root while the ioctls work for whoever can write to the tty device.
This issue was migrated from GitLab. The original issue can be found here:
https://gitlab.com/susurrus/serialport-rs/-/issues/55
USB serial ports can have a latency problem when you're trying to receive small packets of data, because they try to buffer data to put into one USB packet for efficiency. For example FTDI serial ports have a timeout of 16 milliseconds by default, and if you're only receiving a few bytes at a time, you will only receive data every 16ms.
Linux supports an
ASYNC_LOW_LATENCY
which asks drivers to have less latency (perhaps at the efficiency of transferring large amounts of data) which alleviates this problem. Windows also seems to have a similar thing using theCOMMTIMEOUTS
struct (not tested). I couldn't immediately find a similar setting for macOS.Having a
set_low_latency
method on platforms that support it would be useful.The text was updated successfully, but these errors were encountered: