112
|
1 #!/usr/bin/python
|
|
2
|
|
3 from usb import UsbContext
|
|
4
|
130
|
5 # try to read usb.ids:
|
|
6 vids = {}
|
|
7 pids = {}
|
|
8 try:
|
|
9 with open('usb.ids', 'r', errors='ignore') as f:
|
|
10 vid = 0
|
|
11 for l in f:
|
|
12 if l.startswith('#') or not l.strip():
|
|
13 continue
|
|
14 if l.startswith('\t\t'):
|
|
15 print('iface:', l)
|
|
16 elif l.startswith('\t'):
|
|
17 print('product', l)
|
|
18 pid = int(l[1:5], 16)
|
|
19 print('product', hex(pid), l)
|
|
20 else:
|
|
21 print('vendor', l)
|
|
22 vid = int(l[0:4], 16)
|
|
23 print('vendor', hex(vid), l)
|
|
24
|
|
25 except IOError as e:
|
|
26 print("Error loading usb id's: {0}".format(e))
|
|
27
|
112
|
28 context = UsbContext()
|
|
29 for d in context.DeviceList:
|
|
30 print(d)
|
|
31
|