Hi,

We have a problem at work where my coworkers are manually (visually) parsing through the output of "usb-devices" to find information (bus, vendor, prodid, manufacturer, serialnumber, etc) and then using that information to fix problematic devices using that information.  I'd like to write a python script to accomplish what my coworkers have been doing by hand, but instead of parsing through the output of "usb-device" (which I could do, but it's tedious), I'd rather get that information from pyusb if it can provide what I'm looking for.  I've been searching google and scouring through the documentation, but I'm confused and I'm stuck.  I tried the code below but it's just displaying numbers instead of text:

import usb.core

# find USB devices
dev = usb.core.find(find_all=True)

for cfg in dev:
    print('Serial Number=' + str(cfg.iSerialNumber))
    print('VendorID=' + hex(cfg.idVendor))
    print('Manufacturer=' + str(cfg.Manufacturer))
    print('Product=' + hex(cfg.iProduct) + "\n")

and it outputs this:

Serial Number=3
VendorID=0x424
Manufacturer=1
Product=2

Serial Number=3
VendorID=0x403
Manufacturer=1
Product=2

...

Obviously that's not what I'm looking for.  I'm really hoping to get more information similar to the output from usb-devices:

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 8
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev=04.04
S:  Manufacturer=Linux 4.4.0-116-generic xhci-hcd
S:  Product=xHCI Host Controller
S:  SerialNumber=0000:00:15.0
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480 MxCh= 7
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=02 MxPS=64 #Cfgs=  1
P:  Vendor=0424 ProdID=2517 Rev=00.00
S:  Manufacturer=cambrionix
S:  Product=U16S
C:  #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=2mA
I:  If#= 0 Alt= 1 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=02 Driver=hub

...


Any help would be much appreciated!

Thanks,

Mike


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to