> On 1/14/2011 8:09 AM, Bill Olson wrote:
> […] I will have up to 5 USB devices attached to the system with the
> same Manufacturer ID, Product ID and driver.
On 01/13/11 11:59 PM, Hagen Patzke wrote:
No worries:
Windows identifies any USB device either via its iSerialNumber (actually
the String Descriptor value referenced by this), or via its position
in the “USB tree”.
To get a feeling how this is done, use the WDK tools “usbview” or
“UVCview” and have a look at your PC’s devices.
I’ve used USBView. I knew there was some way to find out that
information, I just couldn’t find what it was.
> The application needs to open the driver and access all instances out
> there.
>
> How do I find each instance of the device and how do I access them?
> All the examples I’ve seen only access one instance of a device.
On the application side, you call SetupDiGetClassDevs, then iterate
through all devices with SetupDiEnumDeviceInterfaces.
SetupDiGetClassDevs can select a set of devices based on their driver’s
(device) interface class GUID and the flags DIGCF_PRESENT |
DIGCF_INTERFACEDEVICE (=this gets only the devices that are currently
connected, usually this is what you want).
If you need to uniquely identify the USB devices (e.g. a user needs to
select one USB device from a list), there are several possibilities:
-
you could use a “device number”, i.e. use the order in which the
devices were enumerated. (But a switched-off device “drops” from the
list, and the next available one assumes its position.)
-
you could e.g. use the iSerialNumber string descriptor to tell the
devices apart. Note you MUST make sure, never ever two device have the
same “USB serial number” string set, otherwise Windows can BSOD.
-
you could use a “vendor-specific string descriptor” (=a USB string
descriptor whose index is not listed in any configuration entry) that
contains a “device name” the users can set (=we do this).
The user won’t have to select any devices from a list, but the
application will need to track what is in each chassis and which USB its
attached to. The device number would probably work fine for this
application. The external chassis are card cages and all should be on
and connected at the same time. If one or more are not connected when
the others are, something is seriously wrong with the system.
The way the system works now, all the chassis together appear as one
peripheral to the PC. The USB architecture doesn’t support that, but
I’m going to take care of the individual chassis in the lowest level
portion of the application at the device driver interface. Fortunately
this ancient application was written with a layered stack model. One of
the few things about it that isn’t completely antiquated.
Thank you both for your quick response,
Bill
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer