Discussion:
[pyusb-users] USB topology
Nicolas Pinault
2016-05-12 14:40:47 UTC
Permalink
Hi,

Is it possible to retrieve USB bus topology with PyUSB ?


Regards,
Nicolas
--
*Nicolas PINAULT
R&D electronics engineer
*** ***@aaton.com <mailto:***@aaton.com>

*AATON-Digital*
38000 Grenoble - France
Tel +33 4 7642 9550

http://www.aaton.com
http://www.transvideo.eu
French Technologies for Film and Digital Cinematography

Follow us on Twitter
@Aaton_Digital
@Transvideo_HD

Like us on Facebook
https://www.facebook.com/AatonDigital
Wander Lairson Costa
2016-05-12 15:15:37 UTC
Permalink
Post by Nicolas Pinault
Hi,
Is it possible to retrieve USB bus topology with PyUSB ?
Yes, you will need to use the Device object "port_number" and "bus" properties.
Post by Nicolas Pinault
Regards,
Nicolas
--
Nicolas PINAULT
R&D electronics engineer
AATON-Digital
38000 Grenoble - France
Tel +33 4 7642 9550
http://www.aaton.com
http://www.transvideo.eu
French Technologies for Film and Digital Cinematography
Follow us on Twitter
@Aaton_Digital
@Transvideo_HD
Like us on Facebook
https://www.facebook.com/AatonDigital
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
pyusb-users mailing list
https://lists.sourceforge.net/lists/listinfo/pyusb-users
--
Best Regards,
Wander Lairson Costa
Nicolas Pinault
2016-05-13 13:03:13 UTC
Permalink
Post by Wander Lairson Costa
Post by Nicolas Pinault
Hi,
Is it possible to retrieve USB bus topology with PyUSB ?
Yes, you will need to use the Device object "port_number" and "bus" properties.
While it is enough for my application, I don't see how to reconstruct
the USB tree with just "port_number".
Post by Wander Lairson Costa
Post by Nicolas Pinault
Regards,
Nicolas
--
Nicolas PINAULT
R&D electronics engineer
AATON-Digital
38000 Grenoble - France
Tel +33 4 7642 9550
http://www.aaton.com
http://www.transvideo.eu
French Technologies for Film and Digital Cinematography
Follow us on Twitter
@Aaton_Digital
@Transvideo_HD
Like us on Facebook
https://www.facebook.com/AatonDigital
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
pyusb-users mailing list
https://lists.sourceforge.net/lists/listinfo/pyusb-users
--
*Nicolas PINAULT
R&D electronics engineer
*** ***@aaton.com <mailto:***@aaton.com>

*AATON-Digital*
38000 Grenoble - France
Tel +33 4 7642 9550

http://www.aaton.com
http://www.transvideo.eu
French Technologies for Film and Digital Cinematography

Follow us on Twitter
@Aaton_Digital
@Transvideo_HD

Like us on Facebook
https://www.facebook.com/AatonDigital
Jeffrey Nichols
2016-05-13 13:10:03 UTC
Permalink
Post by Nicolas Pinault
Post by Wander Lairson Costa
Post by Nicolas Pinault
Hi,
Is it possible to retrieve USB bus topology with PyUSB ?
Yes, you will need to use the Device object "port_number" and "bus" properties.
While it is enough for my application, I don't see how to reconstruct
the USB tree with just "port_number".
There's also "port_numbers", assuming you're using a somewhat recent
libusb-1.0 version as your backend. Combine that with the bus attribute,
and you can get a representation of the physical attachment point of the
device.

Jeff
Nicolas Pinault
2016-05-13 14:39:24 UTC
Permalink
Post by Jeffrey Nichols
Post by Nicolas Pinault
Post by Wander Lairson Costa
Post by Nicolas Pinault
Hi,
Is it possible to retrieve USB bus topology with PyUSB ?
Yes, you will need to use the Device object "port_number" and "bus" properties.
While it is enough for my application, I don't see how to reconstruct
the USB tree with just "port_number".
There's also "port_numbers", assuming you're using a somewhat recent
libusb-1.0 version as your backend. Combine that with the bus
attribute, and you can get a representation of the physical attachment
point of the device.
I already tried to use "port_numbers" but this field was always blank.
After updating libusb-1.0, this field is not blank anymore.

What I don't understand is that bus/port_number numbers are not unique.
On my system :
IdVendor8086 IdProduct=1E26 bus=1 Address=1 port=0
IdVendor8086 IdProduct=1E2D bus=2 Address=1 port=0
* IdVendor0204 IdProduct=6025 bus=1 Address=6 port=1 ports = (1, 6, 1)
IdVendor0424 IdProduct=2513 bus=1 Address=2 port=6 ports = (1, 6)
+ IdVendor046D IdProduct=C061 bus=2 Address=5 port=1 ports = (1, 1)
IdVendor0529 IdProduct=0001 bus=1 Address=4 port=5 ports = (1, 5)
IdVendor2CFF IdProduct=0002 bus=1 Address=5 port=2 ports = (1, 6, 2)
IdVendor413C IdProduct=2107 bus=2 Address=2 port=2 ports = (1, 2)
+ IdVendor8087 IdProduct=0024 bus=2 Address=4 port=1 ports = (1,)
* IdVendor8087 IdProduct=0024 bus=1 Address=3 port=1 ports = (1,)
IdVendor8564 IdProduct=4000 bus=3 Address=20 port=8 ports = (8,)
IdVendor8086 IdProduct=1E31 bus=3 Address=1 port=0

The lines marked with a + or a * contains same bus/port_number numbers.
Only port_numbers field is different.
What does this mean ?

Regards,
Nicolas
Post by Jeffrey Nichols
Jeff
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
pyusb-users mailing list
https://lists.sourceforge.net/lists/listinfo/pyusb-users
--
*Nicolas PINAULT
R&D electronics engineer
*** ***@aaton.com <mailto:***@aaton.com>

*AATON-Digital*
38000 Grenoble - France
Tel +33 4 7642 9550

http://www.aaton.com
http://www.transvideo.eu
French Technologies for Film and Digital Cinematography

Follow us on Twitter
@Aaton_Digital
@Transvideo_HD

Like us on Facebook
https://www.facebook.com/AatonDigital
Nicolas Pinault
2016-05-13 15:35:32 UTC
Permalink
Post by Nicolas Pinault
Post by Jeffrey Nichols
Post by Nicolas Pinault
Post by Wander Lairson Costa
Post by Nicolas Pinault
Hi,
Is it possible to retrieve USB bus topology with PyUSB ?
Yes, you will need to use the Device object "port_number" and "bus" properties.
While it is enough for my application, I don't see how to
reconstruct the USB tree with just "port_number".
There's also "port_numbers", assuming you're using a somewhat recent
libusb-1.0 version as your backend. Combine that with the bus
attribute, and you can get a representation of the physical
attachment point of the device.
I already tried to use "port_numbers" but this field was always blank.
After updating libusb-1.0, this field is not blank anymore.
What I don't understand is that bus/port_number numbers are not unique.
IdVendor8086 IdProduct=1E26 bus=1 Address=1 port=0
IdVendor8086 IdProduct=1E2D bus=2 Address=1 port=0
* IdVendor0204 IdProduct=6025 bus=1 Address=6 port=1 ports = (1, 6, 1)
IdVendor0424 IdProduct=2513 bus=1 Address=2 port=6 ports = (1, 6)
+ IdVendor046D IdProduct=C061 bus=2 Address=5 port=1 ports = (1, 1)
IdVendor0529 IdProduct=0001 bus=1 Address=4 port=5 ports = (1, 5)
IdVendor2CFF IdProduct=0002 bus=1 Address=5 port=2 ports = (1, 6, 2)
IdVendor413C IdProduct=2107 bus=2 Address=2 port=2 ports = (1, 2)
+ IdVendor8087 IdProduct=0024 bus=2 Address=4 port=1 ports = (1,)
* IdVendor8087 IdProduct=0024 bus=1 Address=3 port=1 ports = (1,)
IdVendor8564 IdProduct=4000 bus=3 Address=20 port=8 ports = (8,)
IdVendor8086 IdProduct=1E31 bus=3 Address=1 port=0
The lines marked with a + or a * contains same bus/port_number numbers.
Only port_numbers field is different.
What does this mean ?
After sorting results and analysing further, I understand the whole picture.
port_numbers like (1,) references a hub
port_numbers like (1, 6, 2) indicate the full path to reach the device
(root/hub/device)
port_number references the port number of the last hub the device is
connected on..

Nicolas
Jeffrey Nichols
2016-05-13 15:36:18 UTC
Permalink
Post by Nicolas Pinault
Post by Jeffrey Nichols
Post by Nicolas Pinault
Post by Wander Lairson Costa
Post by Nicolas Pinault
Hi,
Is it possible to retrieve USB bus topology with PyUSB ?
Yes, you will need to use the Device object "port_number" and "bus" properties.
While it is enough for my application, I don't see how to
reconstruct the USB tree with just "port_number".
There's also "port_numbers", assuming you're using a somewhat recent
libusb-1.0 version as your backend. Combine that with the bus
attribute, and you can get a representation of the physical
attachment point of the device.
I already tried to use "port_numbers" but this field was always blank.
After updating libusb-1.0, this field is not blank anymore.
What I don't understand is that bus/port_number numbers are not unique.
IdVendor8086 IdProduct=1E26 bus=1 Address=1 port=0
IdVendor8086 IdProduct=1E2D bus=2 Address=1 port=0
* IdVendor0204 IdProduct=6025 bus=1 Address=6 port=1 ports = (1, 6, 1)
IdVendor0424 IdProduct=2513 bus=1 Address=2 port=6 ports = (1, 6)
+ IdVendor046D IdProduct=C061 bus=2 Address=5 port=1 ports = (1, 1)
IdVendor0529 IdProduct=0001 bus=1 Address=4 port=5 ports = (1, 5)
IdVendor2CFF IdProduct=0002 bus=1 Address=5 port=2 ports = (1, 6, 2)
IdVendor413C IdProduct=2107 bus=2 Address=2 port=2 ports = (1, 2)
+ IdVendor8087 IdProduct=0024 bus=2 Address=4 port=1 ports = (1,)
* IdVendor8087 IdProduct=0024 bus=1 Address=3 port=1 ports = (1,)
IdVendor8564 IdProduct=4000 bus=3 Address=20 port=8 ports = (8,)
IdVendor8086 IdProduct=1E31 bus=3 Address=1 port=0
The lines marked with a + or a * contains same bus/port_number numbers.
Only port_numbers field is different.
What does this mean ?
When the bus is different, they're on totally different USB buses
(presumably this corresponds internally to USB root hubs, I'm not sure
of the technical details). That's always the first level of differentiation.

The port always corresponds to the final number in the ports tuple. It's
the port number on the last hub in the hierarchy. It's not unique enough
to use to distinguish positions in the hierarchy (even when combined
with bus), and not terribly useful in my opinion.

I use the tuple (bus, port_numbers) in my application to determine a
device's physical location, so when I tell a device to reboot into
bootloader mode I can find the new device in the same location (as a
device anywhere else could not be the one I'm looking for).

Jeff
Nicolas Pinault
2016-05-17 06:48:34 UTC
Permalink
Post by Jeffrey Nichols
Post by Nicolas Pinault
I already tried to use "port_numbers" but this field was always blank.
After updating libusb-1.0, this field is not blank anymore.
What I don't understand is that bus/port_number numbers are not unique.
IdVendor8086 IdProduct=1E26 bus=1 Address=1 port=0
IdVendor8086 IdProduct=1E2D bus=2 Address=1 port=0
* IdVendor0204 IdProduct=6025 bus=1 Address=6 port=1 ports = (1, 6, 1)
IdVendor0424 IdProduct=2513 bus=1 Address=2 port=6 ports = (1, 6)
+ IdVendor046D IdProduct=C061 bus=2 Address=5 port=1 ports = (1, 1)
IdVendor0529 IdProduct=0001 bus=1 Address=4 port=5 ports = (1, 5)
IdVendor2CFF IdProduct=0002 bus=1 Address=5 port=2 ports = (1, 6, 2)
IdVendor413C IdProduct=2107 bus=2 Address=2 port=2 ports = (1, 2)
+ IdVendor8087 IdProduct=0024 bus=2 Address=4 port=1 ports = (1,)
* IdVendor8087 IdProduct=0024 bus=1 Address=3 port=1 ports = (1,)
IdVendor8564 IdProduct=4000 bus=3 Address=20 port=8 ports = (8,)
IdVendor8086 IdProduct=1E31 bus=3 Address=1 port=0
The lines marked with a + or a * contains same bus/port_number numbers.
Only port_numbers field is different.
What does this mean ?
When the bus is different, they're on totally different USB buses
(presumably this corresponds internally to USB root hubs, I'm not sure
of the technical details). That's always the first level of
differentiation.
Sure. It's so obvious I didn't mentioned it.
Post by Jeffrey Nichols
The port always corresponds to the final number in the ports tuple.
It's the port number on the last hub in the hierarchy. It's not unique
enough to use to distinguish positions in the hierarchy (even when
combined with bus), and not terribly useful in my opinion.
That's what I discovered. Only port_numbers is useful.
Post by Jeffrey Nichols
I use the tuple (bus, port_numbers) in my application to determine a
device's physical location, so when I tell a device to reboot into
bootloader mode I can find the new device in the same location (as a
device anywhere else could not be the one I'm looking for).
My use case is different but the idea is the same.

Nicolas

Loading...