Post by Roger Binnshttp://www.linux-usb.org/usb.ids
I need to be able to lookup vendor, product and interface information.
Note also that about 2/3 of the way down it has definitions for
device classes which would be nice to parse as well.
I have a parser done that will handle the file and create objects like
so...
A master vendor list object that contains all of the vendor objects.
Each vendor object contains a list of associated device objects, and
information about itself.
Each device object contains a list of associated interface objects,
and information about itself.
Each interface object simply contains information about itself.
I have a similar set of relationships for USBClass/Subclass/Protocol
information.
I have accessors set up to work in the following fashion....
import usb_ids as usbids
myUSBids = usbids.usb_ids("resources/usb.ids")
# PRINT OUT THE WHOLE TREE AS A TEST CASE
print_vendor_info(myUSBids)
print_class_info(myUSBids)
# Test lookup for various bits of USB Vendor/Device/Interface
information
vlist = myUSBids.getVendorList()
print vlist.getVendorInfo("05ac")
print vlist.getVendorInfo("05ac", "0206")
print vlist.getVendorInfo("05ac", "0206", "1")
# Test lookup for various bits of USB Class/Subclass/Protocol
information
clist = myUSBids.getUSBClassList()
print clist.getClassInfo("08")
print clist.getClassInfo("08", "04")
print clist.getClassInfo("08", "04", "00")
OUTPUT: (except the whole tree, I've not included that here)
Apple Computer, Inc.
('Apple Computer, Inc.', 'Apple Extended Keyboard [Mitsumi]')
('Apple Computer, Inc.', 'Apple Extended Keyboard [Mitsumi]', 'Unknown
Interface')
Mass Storage
('Mass Storage', 'Floppy (UFI)')
('Mass Storage', 'Floppy (UFI)', 'Control/Bulk/Interrupt')
Is that about right?
One small bit of (perhaps faulty) logic that may cause a problem... I
am making the assumption that any time you hit a comment or blank line
you are no longer processing a given vendor or class entry, so it will
stop looking for devices/interfaces/subclasses/protocols. This was
necessary because (although none are defined in the file at present) an
interface entry probably looks exactly like a protocol entry, and I
didn't want to start adding things to the wrong parent object.
Am I correct in assuming (there's that word!) that following:
vendor ID's are ALWAYS 4-char hex
device ID's are ALWAYS 4-char hex
iface ID's are ALWAYS 2-char hex
Class/Subclass/protocol ID's are ALWAYS 2-char hex
If so, then this should work. I am not doing anything to handle various
line endings, though, so that may be a problem. If it is, I'll rework
things. I'm working with the file as downloaded so it most likely has
UNIX type endings.
-. ----. -.-- - -.--
Steve Palm - ***@n9yty.com
-. ----. -.-- - -.--