Re: add device port number, usb_device
Xiaofan Chen <[email protected]> Mon, 16 Mar 2015 22:13:41 +0800
| Newsgroups | gmane.comp.lib.libusb.devel.windows |
|---|---|
| Message-ID | <CAGjSPUDEas92bXHj0bUqDoZ0b=xnRbkw7XDqkiQ2N5ZdEeiEWg@mail.gmail.com> |
On Mon, Mar 16, 2015 at 5:48 PM, Alexander Stohr <[email protected]> wrote: > refering to this old topic: > https://sourceforge.net/p/libusb-win32/mailman/libusb-win32-devel/thread/[email protected]/ > > the creator of the topic wrote: > >> If I could translate a libusb0 symbolic index path to an interface’s >> DevicePath >> (i.e. SP_DEVICE_INTERFACE_DETAIL.DevicePath, ex. >> \\?\usb#vid_[VID]&pid_[PID]#[serialNumber]#{[GUID]}), >> then I could use the DevicePath to get its SPDRP_ADDRESS property >> (which is the port number). > > a participant responded: > >> BTW, take note the format of DevicePath is not fixed since some USB device >> may not have a serial number. > > in fact the Windows OS demands that the DevicePath is unique. > in case there is no serial number then the OS decides to use the (still > unique but not "moveable") connetor path. > this path is dependent on the topology and can for USB devices include the > hub and port numbers plus a bit more. > > if looking to the dumps from a later on added posting in that thread then > you will see a real world example: > > C:\libusbK-dev-kit>klist > > Loading USB ID's maintained by Stephen J. Gowdy <linux.usb.ids@...>.. > > 1. STMicroelectronics STLink dongle (SGS Thomson Microelectronics) > [Connected] > Service : libusb0 > ClassGUID : {EB781AAF-9C70-4523-A5DF-642A87ECA567} > DeviceID : USB\VID_0483&PID_3748\8&23117AA8&0&1 > DeviceInterfaceGUID : {47C9C148-9738-1A9B-2CB6-86C13FA48892} > SymbolicLink : > \\?\usb#vid_0483&pid_3748#8&23117aa8&0&1#{47c9c148-97 > 38-1a9b-2cb6-86c13fa48892} > DevicePath : \\.\libusb0-0001 > SerialNumber : 8&23117AA8&0&1 > BusNumber : 0 > DeviceAddress : 1 > > as you can see the serial number is not really something a USB device would > typically export > (probably it's device stored and provided string constant is just an empty > property) > but it is rather a concataneted sequence of hub and port numbers. > > conclusion: there is (in theory) always a string that forms a valid (and > hopefully unique) serial number. > the contents of the OS used serial number entry is never empty/missing even > if the low-level physical device layer does not provide one. Take note the above shows that the device has no serial number. Windows constructs a "fake" serial number based on some internal method which is not documented and may not be unique (I do not know). For device without USB serial number, you will be prompted to install driver again if you switch to a different port, since the device path changes. > BTW there are some USB-JTAG debugger devices from a certain > vendor around that all have the same serial. That is violating the USB standard. A USB device should either have no serial number, or have unique serial number. Having identifical serial number is worse than having no serial number. > with this setup at least the Windows OS will only allow to access one of > these devices at a certain time. Not true. Depending the Windows version, that could even cause BSODs if you insert two such device into one Windows machine. Ref: http://blogs.msdn.com/b/oldnewthing/archive/2004/11/10/255047.aspx > it can be guessed that the vendor wanted this unit to be for some > single-target demo use only. (and production might be a bit cheaper...) That is probably true but why not just leave out the serial number all-together so as not to violate the USB standard. > the professional fully featured debuggers for that vendor can be optained > from third parties at a noticeably higher price. > (the sales volum is low compared to the numbers of units on consumer > markets.) > -- Xiaofan ------------------------------------------------------------------------------ Dive into the World of Parallel Programming The Go Parallel Website, sponsored by Intel and developed in partnership with Slashdot Media, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials and more. Take a look and join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ Libusb-win32-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libusb-win32-devel