I'm writing an application which will communicate through a USB hub attached to pc. My query is how can I detect other devices connected to USB hub in my python application. I'm using the pyserial library for communicating through USB.
Asked
Active
Viewed 652 times
-2
-
Take a look on [this](https://stackoverflow.com/q/12090503/10824407) question and don't forget **(!!!)** about [this](https://stackoverflow.com/q/12090503/10824407?noredirect=1#comment82288531_12090503) comment. – Olvin Roght May 04 '21 at 11:37
1 Answers
0
Maybe you could try/use pyUSB for this:
#!/usr/bin/python
import sys
import usb.core
# find USB devices
dev = usb.core.find(find_all=True)
# loop through devices, printing vendor and product ids in decimal and hex
for cfg in dev:
sys.stdout.write('Decimal VendorID=' + str(cfg.idVendor) + ' & ProductID=' + str(cfg.idProduct) + '\n')
sys.stdout.write('Hexadecimal VendorID=' + hex(cfg.idVendor) + ' & ProductID=' + hex(cfg.idProduct) + '\n\n')

John Mommers
- 140
- 7
-
Thnak you for the help, but can you please say what it is actually doing because m very new to it so this vendor id and product id m not getting it. – Priyanka Mishra May 07 '21 at 11:59