I'm reading real-time data over USB, but the data is buffered. How do I stop the buffering?
Linux
Use udev to change the latency_timer.
On ubuntu, create a rule in /etc/udev/rules.d
for your device. Eg 99-xsens.rules
Create a rule in that file to match your device and set the latency_timer. For example, for my device this is:
KERNEL=="ttyUSB[0-9]*", SUBSYSTEMS=="usb-serial", DRIVERS=="ftdi_sio", ATTR{device/latency_timer}="2"
This causes the device to wait a shorter time before deciding there's no more incoming data to buffer. In this case my device went from waiting 16ms to waiting 2ms.
Use udevadm info -a -n /dev/ttyUSB0
, for example, to find out what key-value pairs to match against in your rule. There are some tricky things to keep in mind, but finding resources to help with the ins and outs was easy once I knew to use udev rules.
Here's a good reference page on writing udev rules. It is old and the syntax of the udev tools has changed, but the concepts are still valid.
Windows
On Windows you use Device Manager->Ports->COM Port->Port Settings->Advanced->Latency Timer
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With