-
- import usb.core
- import usb.util
- import sys
-
- # find our device
- dev = usb.core.find(idVendor=0x0403, idProduct=0x6001)
-
- # was it found?
- if dev is None:
- raise ValueError('Device not found')
- else:
- print 'Device was found'
-
- print '----------------\n' + \
- 'Configuration of the device:'
- for cfg in dev:
- sys.stdout.write('bConfigurationValue: ' + str(cfg.bConfigurationValue) + '\n')
- for intf in cfg:
- sys.stdout.write('\tbInterfaceNumber: ' + str(intf.bInterfaceNumber) + '\n' + \
- '\tbAlternateSetting: ' + str(intf.bAlternateSetting) + '\n' + \
- '\tbLength: ' + str(intf.bLength) + '\n')
- for ep in intf:
- sys.stdout.write('\t\tbEndpointAddress: ' + \
- str(ep.bEndpointAddress) + \
- '\n')
-
-
-
-
-
- #dev.set_configuration(1)
-
- #dev.set_configuration()
-
- #cfg = util.find_descriptor(dev, bConfiguration=1)
- #cfg.set()
- #dev.set_configuration(cfg)
-
-
-
- print '----------------\n' + \
- 'start reading test'
-
- epAddress = 129
- nrByteRead = 9
- ifNumber = 0
- timeout = 100
-
- ret = dev.read(epAddress, nrByteRead, ifNumber, timeout)
- sret = ''.join([chr(x) for x in ret])
- print '-'+sret+'-'
-
- print 'end reading test'
-