From: Patrik T. <pat...@st...> - 2010-02-19 10:55:30
|
Hi all, I am looking for a solution to identify the physical USB ports used by a device. I have looked at devcon in WDK to find the DeviceID eg. USB\VID_xxxx&PID_yyyy\6&6B42B9C&0&4. This seem to be a unique for the port used. I have successfully duplicated this to my application. By calling SetupDiGetDeviceRegistryProperty and SetupDiGetDeviceInstanceId. But I can't find a way to associate this to the driver handle. Can this be done? Any other suggestion on how identify the port is also welcome! Note that I can not use a serial number in the device it has to be unique for the USB port on the computer. Also note that I have several indentical units connected. Thanks in advance! Regards, Patrik Thalin |
From: Xiaofan C. <xia...@gm...> - 2010-02-19 14:47:31
|
On Fri, Feb 19, 2010 at 6:10 PM, Patrik Thalin <pat...@st...> wrote: > Hi all, > > I am looking for a solution to identify the physical USB ports used by a > device. I have looked at devcon in WDK to find the DeviceID eg. > USB\VID_xxxx&PID_yyyy\6&6B42B9C&0&4. This seem to be a unique for the > port used. I have successfully duplicated this to my application. By > calling SetupDiGetDeviceRegistryProperty and SetupDiGetDeviceInstanceId. > But I can't find a way to associate this to the driver handle. Can this > be done? > > > Any other suggestion on how identify the port is also welcome! Note that > I can not use a serial number in the device it has to be unique for the > USB port on the computer. Also note that I have several indentical units > connected. > I do not know the answer. You may have better luck trying out some other lists. The best one may be this newsgroup. microsoft.public.development.device.drivers http://groups.google.com/group/microsoft.public.development.device.drivers/topics But it is said to be non-trivial for any OS. http://old.nabble.com/Re%3A-how-to-get-device-info-from-mount-point-p16593540.html Some say it is not possible under Windows. http://www.winvistatips.com/uniquely-identify-usb-hid-device-t809662.html Might be possible under Linux or Mac OS X. http://old.nabble.com/How-to-get-the-Location-ID-and-Current-Available-information-on-linux--td25588308.html -- Xiaofan http://mcuee.blogspot.com |
From: Pete B. <pb...@gm...> - 2010-02-19 16:25:01
|
>> Any other suggestion on how identify the port is also welcome! I've been doing just that in the Windows backend for libusb 1.0. First of all, for hub enumeration, you use the ConnectionIndex attribute of the USB_NODE_CONNECTION_INFORMATION structure. This is pretty much a port index. Then, for the device themselves, you can use SetupDiGetDeviceRegistryProperty with SPDRP_ADDRESS to get the port. If you want to build the usb tree, you will then need to match the parent as well using the SetupDi or CM functions. This is pretty much what we use internally to build the USB tree in the libusb 1.0 Windows backend. If you have a look at http://git.libusb.org/?p=libusb-pbatard.git;a=blob;f=libusb/os/windows_usb.c, the usb_enumerate_hub() and set_device_paths() functions might be of interest to you. Regards, /Pete |
From: Patrik T. <pat...@st...> - 2010-03-08 09:21:07
|
Pete! Thanks for your help! I got it working now. To match the hub node information to a device handle i had to make a few additions in the driver to get the "DevicePropertyDriverKeyName" with the function "IoGetDeviceProperty". Any comments on this solution is welcome! I have posted the patch here: http://sourceforge.net/tracker/?func=detail&aid=2962463&group_id=78138&a tid=552264 /Patrik -----Original Message----- From: Pete Batard [mailto:pb...@gm...] Sent: den 19 februari 2010 17:25 To: lib...@li... Subject: Re: [Libusb-win32-devel] Identify the physical USB ports used by a driver handle >> Any other suggestion on how identify the port is also welcome! I've been doing just that in the Windows backend for libusb 1.0. First of all, for hub enumeration, you use the ConnectionIndex attribute of the USB_NODE_CONNECTION_INFORMATION structure. This is pretty much a port index. Then, for the device themselves, you can use SetupDiGetDeviceRegistryProperty with SPDRP_ADDRESS to get the port. If you want to build the usb tree, you will then need to match the parent as well using the SetupDi or CM functions. This is pretty much what we use internally to build the USB tree in the libusb 1.0 Windows backend. If you have a look at http://git.libusb.org/?p=libusb-pbatard.git;a=blob;f=libusb/os/windows_u sb.c, the usb_enumerate_hub() and set_device_paths() functions might be of interest to you. Regards, /Pete ------------------------------------------------------------------------ ------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Libusb-win32-devel mailing list Lib...@li... https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel |
From: Xiaofan C. <xia...@gm...> - 2010-03-08 12:58:39
|
On Mon, Mar 8, 2010 at 5:05 PM, Patrik Thalin <pat...@st...> wrote: > Pete! Thanks for your help! I got it working now. > > To match the hub node information to a device handle i had to make a few > additions in the driver to get the "DevicePropertyDriverKeyName" with > the function "IoGetDeviceProperty". Any comments on this solution is > welcome! > > I have posted the patch here: > > http://sourceforge.net/tracker/?func=detail&aid=2962463&group_id=78138&a > tid=552264 > Not so sure why you need to use libusb-win32 driver here. I am under the impression that you do not need any driver for this based on the approach of Pete. But Pete can comment better. -- Xiaofan http://mcuee.blogspot.com |
From: Pete B. <pb...@gm...> - 2010-03-08 17:02:30
|
>> To match the hub node information to a device handle i had to make a few >> additions in the driver to get the "DevicePropertyDriverKeyName" with >> the function "IoGetDeviceProperty". Did you have to do that because SetupDiGetDeviceRegistryProperty with SPDRP_ADDRESS did not work against devices driven by libusb0.sys? From testing the libusb0.sys driver against the libusb 1.0 Windows backend, it looks to me like the SPDRP_ADDRESS is retrievable with the existing libusb0.sys, so I'm not sure I understand why you need a new IOCTL in linusb-win32. As Xiaofan mentioned, you shouldn't have to install a specific driver to gain access to the port information. Regards, /Pete |
From: Patrik T. <pat...@st...> - 2010-03-09 07:16:55
|
My application talks to the devices with the libusb driver and I need to know the physical location of the port in my application. I have several "usb_dev_handle" I need to map those to physical ports or an ID for that port. SetupDiGetDeviceRegistryProperty with SPDRP_ADDRESS does work but I need to match that to one of the libusb open usb device handers (i have several identical units). I also get SetupDiGetDeviceInstanceId to get the Device Instance ID. SPDRP_ADDRESS give me something like: "{eb781aaf-9c70-4523-a5df-642a87eca567}\0009" and that has Device Instance ID 5&3B8933DC&1&5 "{eb781aaf-9c70-4523-a5df-642a87eca567}\0010" and that has Device Instance ID 5&3B8933DC&1&2 ... Then I get that same from the driver with IOCTL DevicePropertyDriverKeyName: Handler A has "{eb781aaf-9c70-4523-a5df-642a87eca567}\0009" Handler B has "{eb781aaf-9c70-4523-a5df-642a87eca567}\0010" ... Now I can tell that Handler A has Device Instance ID 5&3B8933DC&1&5. Can I get that without a IOCTL? /Patrik -----Original Message----- From: Pete Batard [mailto:pb...@gm...] Sent: den 8 mars 2010 18:03 To: lib...@li... Subject: Re: [Libusb-win32-devel] Identify the physical USB ports used by a driver handle >> To match the hub node information to a device handle i had to make a >> few additions in the driver to get the "DevicePropertyDriverKeyName" >> with the function "IoGetDeviceProperty". Did you have to do that because SetupDiGetDeviceRegistryProperty with SPDRP_ADDRESS did not work against devices driven by libusb0.sys? From testing the libusb0.sys driver against the libusb 1.0 Windows backend, it looks to me like the SPDRP_ADDRESS is retrievable with the existing libusb0.sys, so I'm not sure I understand why you need a new IOCTL in linusb-win32. As Xiaofan mentioned, you shouldn't have to install a specific driver to gain access to the port information. Regards, /Pete ------------------------------------------------------------------------ ------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Libusb-win32-devel mailing list Lib...@li... https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel |
From: Pete B. <pb...@gm...> - 2010-03-09 13:25:37
|
On 2010.03.09 07:16, Patrik Thalin wrote: > My application talks to the devices with the libusb driver and I need to > know the physical location of the port in my application. I have several > "usb_dev_handle" I need to map those to physical ports or an ID for that > port. OK. I don't think libusb (win32, 1.0) exposes any of the port properties, although there might be plans to do that with libusb 1.1, and we certainly have the port information available in the Windows backend of 1.0, so it could be exposed at little cost if needed. > SetupDiGetDeviceRegistryProperty with SPDRP_ADDRESS does work but I need > to match that to one of the libusb open usb device handers (i have > several identical units). I also get SetupDiGetDeviceInstanceId to get > the Device Instance ID. If you need to work with the libusb device handler, whose main purpose is to abstract the device properties, then you would indeed need to modify libusb to expose some of these properties. > Can I get that without a IOCTL? You certainly can do the match you mentioned above without using an IOCTL, but using the SetupDi and Configuration Manager (CM) functions, like CM_Get_Parent, etc instead. This is what we do in libusb 1.0 Windows backend with set_device_paths(). It's a bit more complex than simply adding an IOCTL, but the big advantage is that it works for all drivers, or even if no driver has been installed for the device yet. In fact, if you used libusb 1.0 on Windows, your problem could easily be solved by adding a new libusb call to return the connection_index member of the windows_device_priv structure, which is associated with any libusb device on Windows, as this is really the USB port number. You could also expose the parent device if needed. Regards, /Pete |