Mercurial > lcfOS
diff python/lsusb.py @ 130:654093a9a1e3
Added icons, improved device explorer
author | Windel Bouwman |
---|---|
date | Sat, 19 Jan 2013 18:16:04 +0100 |
parents | 056face59ee7 |
children |
line wrap: on
line diff
--- a/python/lsusb.py Fri Jan 18 12:52:11 2013 +0100 +++ b/python/lsusb.py Sat Jan 19 18:16:04 2013 +0100 @@ -2,6 +2,29 @@ from usb import UsbContext +# try to read usb.ids: +vids = {} +pids = {} +try: + with open('usb.ids', 'r', errors='ignore') as f: + vid = 0 + for l in f: + if l.startswith('#') or not l.strip(): + continue + if l.startswith('\t\t'): + print('iface:', l) + elif l.startswith('\t'): + print('product', l) + pid = int(l[1:5], 16) + print('product', hex(pid), l) + else: + print('vendor', l) + vid = int(l[0:4], 16) + print('vendor', hex(vid), l) + +except IOError as e: + print("Error loading usb id's: {0}".format(e)) + context = UsbContext() for d in context.DeviceList: print(d)