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

Construct an Iterator

language-agnostic oop iterator

Let's say you want to construct an Iterator that spits out File objects. What type of data do you usually provide to the constructor of such an Iterator?

Disposing of SQL Connection

c# destructor dispose

I have a SQL class that connects to the DB and retreives a DataTable. I am aware that the SqlConnection must be disposed when finished. I know this can be done using a using block, but is it also

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.