Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Hardware & Devices
  4. SetupDiGetDeviceRegistryProperty(..SDRP_ADDRESS...) gets USB hub port?

SetupDiGetDeviceRegistryProperty(..SDRP_ADDRESS...) gets USB hub port?

Scheduled Pinned Locked Moved Hardware & Devices
data-structuresjsonperformancehelpquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Roger Stoltz
    wrote on last edited by
    #1

    I've spent more than a week on a problem with getting the serial number string descriptor from a USB device that uses USBSER as driver. The USBSER driver doesn't seem to support any kind of functionality for getting the serial number directly and in some cases the device is a composite device which adds to the problem. So I've tried another way... I get the symbolic link for my device either through WM_DEVICECHANGE or by enumeration with the Setup API. I enumerate the USB device tree and get hold of the parent hub on which my device is connected and then ask the hub for the string descriptor. So far so good, but... There are two scenarios where I'm afraid this may fail: 1. If a hub with multiple devices attached is inserted, the order of device notifications may not be in "port" order although it seems that way 2. When enumerating devices at application start the enumeration order may not be in "port" order When I iterate through the ports of the parent hub and I find a new device I assume it is the one I got the notification for, but this method fails under the circumstances mentioned above. Mapping the original symbolic link for my device to a specific port number in the parent hub would solve my problem. I think I have found a solution for this, but I cannot find any information that verifies this as a reliable method even though I've google'ed like insane. I use SetupDiGetDeviceRegistryProperty() and get the "address". The address seems to correspond to the port number of the parent hub. I've tried this on my machine (XP SP3) and it works all right, even if I move things around, add hubs in between and so on. Can anyone verify this as reliable or unreliable, or point me toward some Microsoft-ish information about using SDRP_ADDRESS on USB devices? Is it an undocumented feature or pure coincidence? Thanks -- Rog

    "It's supposed to be hard, otherwise anybody could do it!" - selfquote
    "High speed never compensates for wrong direction!" - unknown

    L 1 Reply Last reply
    0
    • R Roger Stoltz

      I've spent more than a week on a problem with getting the serial number string descriptor from a USB device that uses USBSER as driver. The USBSER driver doesn't seem to support any kind of functionality for getting the serial number directly and in some cases the device is a composite device which adds to the problem. So I've tried another way... I get the symbolic link for my device either through WM_DEVICECHANGE or by enumeration with the Setup API. I enumerate the USB device tree and get hold of the parent hub on which my device is connected and then ask the hub for the string descriptor. So far so good, but... There are two scenarios where I'm afraid this may fail: 1. If a hub with multiple devices attached is inserted, the order of device notifications may not be in "port" order although it seems that way 2. When enumerating devices at application start the enumeration order may not be in "port" order When I iterate through the ports of the parent hub and I find a new device I assume it is the one I got the notification for, but this method fails under the circumstances mentioned above. Mapping the original symbolic link for my device to a specific port number in the parent hub would solve my problem. I think I have found a solution for this, but I cannot find any information that verifies this as a reliable method even though I've google'ed like insane. I use SetupDiGetDeviceRegistryProperty() and get the "address". The address seems to correspond to the port number of the parent hub. I've tried this on my machine (XP SP3) and it works all right, even if I move things around, add hubs in between and so on. Can anyone verify this as reliable or unreliable, or point me toward some Microsoft-ish information about using SDRP_ADDRESS on USB devices? Is it an undocumented feature or pure coincidence? Thanks -- Rog

      "It's supposed to be hard, otherwise anybody could do it!" - selfquote
      "High speed never compensates for wrong direction!" - unknown

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Jan Axelson has written books and articles on this stuff. http://www.lvr.com/[^] Hope the link helps.

      R 1 Reply Last reply
      0
      • L Lost User

        Jan Axelson has written books and articles on this stuff. http://www.lvr.com/[^] Hope the link helps.

        R Offline
        R Offline
        Roger Stoltz
        wrote on last edited by
        #3

        Thanks Richard, it's a good link but unfortunately this was the first resource I tried to find information in. Moreover I have in front of me Jan's all editions of "USB Complete" plus the "Serial Port Complete". Her books are very good, as well as her site, but I haven't found anything that clearly states "calling SetupDiGetDeviceRegistryProperty with SDRP_ADDRESS gets the hub port number the device is connected to"... :| I was hoping that someone would have found a similar statement from Microsoft, or someone who has successfully used a similar technique.

        "It's supposed to be hard, otherwise anybody could do it!" - selfquote
        "High speed never compensates for wrong direction!" - unknown

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups