API time resolution limiting USB bandwidth?

I have a device that I can control how fast I send data over it with USB. I am using Qt for the PC side processing of the data. I am reading from the device every so often based on a timer. The problem is the timer is documented to have a resolution of only 1 ms. Won't this limit how fast I read the data to 1ms? How am I supposed to take advantage of USB massive bandwidth capabilities if this timer is so slow?

Answers


There are a few things to note here.

First, timer resolution in user mode is very bad if you need more than 15ms of resoluton. For example, in Windows if you set a timer or sleep for only 1ms the actual time will amount to about 15-17ms.

This will be slow no matter what, but it might not present itself as a problem if you have a driver below you that is acquiring data faster. This is because the driver is executing on a much faster level, probably has a few ping-ponged outstanding reads and simply keeps a buffer full for you to read from. But it is up to your application to get at the data as fast as possible, and a timer could be too slow, it may be better to signal an event object when your data is available.

Second, with WinUSB and libusb there is now more control and need for user mode to issue the read, and the driver is simply the kernel mode pass through. In these case you should create a thread to do nothing but read and give data to a local buffer in your application. Similar to kernel mode you will always want to have a read outstanding, just waiting for data to come in.

You can then have an event that gets signaled to tell the business part of your application to grab data from that buffer.


Need Your Help

scraping using BS4 python

python web-scraping beautifulsoup screen-scraping

I am using the following code to scrape data from website.

setting multiple notifications at different times- android

android android-notifications android-alarms

I need to create multiple notifications at multiple times. The time when the notification is supposed to appear is fetched into the event_id,etc.time for notification is set in another class.