home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-usb / examples / usbenum.py next >
Encoding:
Python Source  |  2007-09-28  |  1.3 KB  |  41 lines

  1. #!/usr/bin/env python
  2. #
  3. # Enumerate usb devices
  4. #
  5. #Copyright 2005 - 2007 Wander Lairson Costa
  6.  
  7. import usb
  8.  
  9. busses = usb.busses()
  10.  
  11. for bus in busses:
  12.     devices = bus.devices
  13.     for dev in devices:
  14.         print "Device:", dev.filename
  15.         print "  Device class:",dev.deviceClass
  16.         print "  Device sub class:",dev.deviceSubClass
  17.         print "  Device protocol:",dev.deviceProtocol
  18.         print "  Max packet size:",dev.maxPacketSize
  19.         print "  idVendor:",dev.idVendor
  20.         print "  idProduct:",dev.idProduct
  21.         print "  Device Version:",dev.deviceVersion
  22.         for config in dev.configurations:
  23.             print "  Configuration:", config.value
  24.             print "    Total length:", config.totalLength 
  25.             print "    selfPowered:", config.selfPowered
  26.             print "    remoteWakeup:", config.remoteWakeup
  27.             print "    maxPower:", config.maxPower
  28.             for intf in config.interfaces:
  29.                 print "    Interface:",intf[0].interfaceNumber
  30.                 for alt in intf:
  31.                     print "    Alternate Setting:",alt.alternateSetting
  32.                     print "      Interface class:",alt.interfaceClass
  33.                     print "      Interface sub class:",alt.interfaceSubClass
  34.                     print "      Interface protocol:",alt.interfaceProtocol
  35.                     for ep in alt.endpoints:
  36.                         print "      Endpoint:",hex(ep.address)
  37.                         print "        Type:",ep.type
  38.                         print "        Max packet size:",ep.maxPacketSize
  39.                         print "        Interval:",ep.interval
  40.  
  41.