Multiple USB Devices

I’ve written before about this system I’m converting to USB. The
current system has an ISA card in the PC that connects via a daisy chain
cable to up to 5 external chassis. Each chassis has an ISA interface
card in it (DIP switches on the cards downstream prevent conflicts on
the daisy chain bus).

The ISA interface cards in the external chassis will be replaced with a
USB card and there will be a hub co-located with the external chassis,
then one cable back to the PC. What will happen is I will have up to 5
USB devices attached to the system with the same Manufacturer ID,
Product ID and driver. 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.

Thanks,
Bill

the just registers and enables the device interface guid. each instance will show up when you enumerate the device interface guid in user mode. most samples stop at the first instance they find and exit the enumeration loop, but you can easily continue the loop, opening a handle to each instance you find.

d

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.

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.

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).

  • etc.

> 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

  • etc.

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