Linux - Limit Usb Device Bandwidth

USB Port Speed Linux

You can read /sys/bus/usb/devices/usb?/speed - it'll give you the bus speed of the root hub(s) in Mbps: either 1.5, 12, 480, 5000 or 10000. The first two indicate USB1 (low speed or full speed), the third USB2 and the fourth and fifth USB3.

Bursty writes to SD/USB stalling my time-critical apps on embedded Linux

For the record, there turned out to be two main aspects that seem to have eliminated the problem in all but the most extreme cases. This system is still in development and hasn't been thoroughly torture-tested yet but is working fairly well (touch wood).

The big win came from making the userland writer app multi-threaded. It is the calls to write() that block sometimes: other processes and threads still run. So long as I have a thread servicing the device driver and updating frame counts and other data to sychronise with other apps that are running, the data can be buffered and written out a few seconds later without breaking any deadlines. I tried a simple ping-pong double buffer first but that wasn't enough; small buffers would be overwhelmed and big ones just caused bigger pauses while the filesystem digested the writes. A pool of 10 1MB buffers queued between threads is working well now.

The other aspect is keeping an eye on ultimate write throughput to physical media. For this I am keeping an eye on the stat Dirty: reported by /proc/meminfo. I have some rough and ready code to throttle the encoder if Dirty: climbs above a certain threshold, seems to vaguely work. More testing and tuning needed later. Fortunately I have lots of RAM (128M) to play with giving me a few seconds to see my backlog building up and throttle down smoothly.

I'll try to remember to pop back and update this answer if I find I need to do anything else to deal with this issue. Thanks to the other answerers.

Redirect data traffic from and to USB devices on Mac OS/Unix/Linux

With "USB dongles" you mean: Software license dongles?

First of all you should know that USB is not a stream of data such as RS232 but a very complex bus transferring a lot of different control and data messages.

On Linux you can use Wireshark to monitor the data on the USB bus. There are similar tools for Windows (up to Windows XP only) but the Windows version of Wireshark does only support Ethernet and not USB. Windows 7 has a built-in command line tool that does the same job.

If you really want to redirect data you might use something like "usbip" that allows sharing USB ports over network. You may simulate an USB dongle device by programming a server that simulates the dongle... However doing this is very tricky and requires a lot of programming experience!



Related Topics



Leave a reply



Submit