Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop USB buffering?

Tags:

linux

windows

usb

I'm reading real-time data over USB, but the data is buffered. How do I stop the buffering?

like image 549
cape1232 Avatar asked Jul 16 '10 16:07

cape1232


1 Answers

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.

like image 111
cape1232 Avatar answered Sep 22 '22 23:09

cape1232