none
USB Device Name

    Question

  •  

    I am experimenting with the example bulkusb driver and it enumerates the USB device by class and sub-class as defined by the driver assigned GUID. My device currently looks like a CDC ACM device, but it will change to a proprietary device. When I have multiple devices attached I can't tell which device I opened from the application. I have a requirement to assign a device to each application instance and always have the device enumerate the same device name for the application to open. This is similar to assigning a serial port to a specific COM port.

    How can I have my application open a specific USB device when there are more than one device attached to the system?

    I would like to assign a device name during the first installation when the device is enumerated, so the application can always opens the same device.

    I am looking for a way that the device serial number can be used to determine the device name. Any example would be appreciated.

    Wednesday, April 06, 2011 12:46 AM

Answers

  • SSSTAUBLY wrote:
    >
    >I have used the SetupDi API's. I also experimented with
    >IoCreateSymbolicLink, but I understand it is not used with the
    >WDM drivers because they do not name their device objects.
     
    Your conclusion does not follow from your premise.  You can certainly use
    symbolic links with WDM drivers.  You just have to be careful to create
    unique names in the case of multiple instances.
     
    >However, I didn't know if I would run into trouble down
    >the road or if the symbolic link name could be completed
    >outside of AddDevice.
     
    You can create a symbolic link any time after the device is created, but
    AddDevice is almost always the right spot.  When else would it make sense?
     
    >I displayed the device path and it is rather ugly. Does it
    > simplify when I use my serial number.?
     
    Why do you care?  You aren't going to be typing it by hand.  You'll just
    save it and restore it in your code.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, DDK MVP Providenza & Boekelheide, Inc.
    Saturday, April 09, 2011 5:53 AM

All replies

  • SSSTAUBLY wrote:
    >
    >I am experimenting with the example bulkusb driver and it enumerates
    >the USB device by class and sub-class as defined by the driver assigned
    >GUID. My device currently looks like a CDC ACM device, but it will
    >change to a proprietary device. When I have multiple devices attached
    >I can't tell which device I opened from the application.
     
    How would you tell which is which?  USB ports are not numbered.
     
    >I have a requirement to assign a device to each application instance
    >and always have the device enumerate the same device name for the
    >application to open. This is similar to assigning a serial port to
    >a specific COM port.
     
    Not quite, because COM ports are externally labeled.
     
    >How can I have my application open a specific USB device when there
    >are more than one device attached to the system?
     
    The right way to do this is to have unique serial numbers in your device,
    and look for the serial number when you open it.  That's tricky with CDC
    because you don't have access to the descriptors, but with a proprietary
    driver you certainly do.
     
    >I am looking for a way that the device serial number can be used to
    >determine the device name. Any example would be appreciated.
     
    How are you opening the driver right now?  Once you go proprietary, you'll
    want to use the SetupDi APIs to search the devices in your class.  That
    returns the device path, which has the serial number embedded.  You can
    cache that device path name, and open that every time.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, DDK MVP Providenza & Boekelheide, Inc.
    Wednesday, April 06, 2011 6:31 AM
  •  

    I think I am on my way and I need to do a few more experiments with serial numbers to work out the details. 

    "Not quite, because COM ports are externally labeled."

     Yes, but this is confusing because virtual COM ports (CDC ACM devices) seem to always enumerate a unique COM number.  

    I have used the SetupDi API's. I also experimented with IoCreateSymbolicLink, but I understand it is not used with the WDM drivers because they do not name their device objects. In my case, I would like to name them. However, I didn't know if I would run into trouble down the road or if the symbolic link name could be completed outside of AddDevice.

    I displayed the device path and it is rather ugly. Does it simplify when I use my serial number.?

     

    Thursday, April 07, 2011 12:28 AM
  • SSSTAUBLY wrote:
    >
    >I have used the SetupDi API's. I also experimented with
    >IoCreateSymbolicLink, but I understand it is not used with the
    >WDM drivers because they do not name their device objects.
     
    Your conclusion does not follow from your premise.  You can certainly use
    symbolic links with WDM drivers.  You just have to be careful to create
    unique names in the case of multiple instances.
     
    >However, I didn't know if I would run into trouble down
    >the road or if the symbolic link name could be completed
    >outside of AddDevice.
     
    You can create a symbolic link any time after the device is created, but
    AddDevice is almost always the right spot.  When else would it make sense?
     
    >I displayed the device path and it is rather ugly. Does it
    > simplify when I use my serial number.?
     
    Why do you care?  You aren't going to be typing it by hand.  You'll just
    save it and restore it in your code.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, DDK MVP Providenza & Boekelheide, Inc.
    Saturday, April 09, 2011 5:53 AM