07-14-2008 04:53 PM
These two chapters will help you understand what you are seeing on your USB sniffer. Depending on your specific application, you may decide to dive into chapter 5 - USB Data Flow Model, chapter 8 - Protocol Layer, or chapter 10 - USB Host: Hardware and Software.
Figure out what class your device is and ignore the rest. Mice, for example, are part of the HID class. Since they are simple devices there is a lot of the spec that simply does not apply to them. Generally mice don't do isochronous or bulk data transfers instead limiting themselves to control and interrupt transfers. They use a limited number of device requests and many listed in chapter 9 won't be applicable. Oh, and be sure to get the device class definition for your device class. The one for HID devices is here. There are other documents that may be useful here.
Here's a vi I put together to read USB descriptors. I used this for a specific problem concerning USB-8451s to get the Vendor ID and Product ID. You may be able to adapt it to suit your needs. You should be able to read the device descriptor of any USB RAW device as is. Refer to USB Spec chapters 9.4, 9.5, and 9.6 if you start poking around in it. Specifically, you may need to change the request type and descriptor index if you try other bRequests or Descriptor Types.
07-14-2008 05:24 PM
07-14-2008 05:54 PM - edited 07-14-2008 05:55 PM
If you are asking about supporting multiple mouse models, I think it would be fairly straightforward. Mice have to conform to the requirements set out in the HID Class Definition which defines the position reporting packet. It covers 3 mouse buttons and x-y position. If you need to implement additional buttons or a scroll wheel you'd probably want to have a child class inherit from it.
If you're asking about creating a class hierarchy that can support all USB devices, that's something else entirely. For instance, in your first post you listed all the different device classes. At first glance you would have a generic USB Device class as the base class with each 'USB Device Class' (as defined in the USB spec) inherit from it. However, as I understand it the device classes are more like interfaces than hardware-based divisions. A force-feedback joystick fits in both the HID device class and the physical device class, and as such implements features of both of them. It certainly would be an ambitious project.
07-15-2008 01:10 AM
LabVIEW realtime?
@Intaris wrote:PPS: The code shown here may be useful as an introduction to USB, but can anyone think of any actual application which can benefit from a non-system pointing device or keyboard?
Message Edited by Intaris on 07-14-2008 11:34 AM
07-15-2008 02:44 AM
07-15-2008 02:45 AM
07-15-2008 06:46 AM
07-15-2008 07:26 AM
07-15-2008 07:45 AM
Daklu posted
"Here's a vi I put together to read USB descriptors. I used this for a specific problem concerning USB-8451s to get the Vendor ID and Product ID. "
I have to acknowledge that is much better than some of the approaches I have used to handle the issue of NI USB DAQ devices chaning their address. My solutions were "Try to do an I/O and see if it works" or "Read the device serail number". Both of these were very crude or too tightly coupled to the hardware.
Nice Daklu!
Ben
07-15-2008 08:11 AM