python - PyUSB USBError: [Errno None] Unknown error -
i'm trying run set_configuration() method connect usb device receiving following error:
[errno none] unknown error traceback (most recent call last): file "usb_ruf_test.py", line 74, in <module> dev.set_configuration() file "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 819, in set_configuration self._ctx.managed_set_configuration(self, configuration) file "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 129, in managed_set_configuration self.backend.set_configuration(self.handle, cfg.bconfigurationvalue) file "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 786, in set_configuration _check(self.lib.libusb_set_configuration(dev_handle.handle, config_value)) file "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 592, in _check raise usberror(_strerror(ret), ret, _libusb_errno[ret]) usberror: [errno none] unknown error
this code i'm using:
import usb.core import usb.util import time import traceback attempts = 0 dev = usb.core.find(idvendor=0x0ffd, idproduct=0xff00) while dev none: attempts += 1 dev = usb.core.find(idvendor=0x0ffd, idproduct=0xff00) print "(" + str(attempts) + " attempts) waiting 5 seconds before trying again..." time.sleep(5) print "connected " + str(dev) try: dev.set_configuration() cfg = dev.get_active_configuration() intf = cfg[(0,0)] outputendpoint = usb.util.find_descriptor(intf, custom_match = lambda e: usb.util.endpoint_direction(e.bendpointaddress) == usb.util.endpoint_out) message = reading_start_message() print "\nmessage sent:", "\n\n", message, "\n" outputendpoint.write( message ) print "received:\n" good_reads_count = 0 result = dev.read(0x81, 2000, 5000) while len(result) != 0: good_reads_count += 1 print result.tostring() result = dev.read(0x81, 2000, 5000) print "good reads: " + str(good_reads_count) except exception, e: print("there error") print e, traceback.format_exc() print "disconnected"
and device's usb info:
connected device id 0ffd:ff00 on bus 001 address 008 ================= blength : 0x12 (18 bytes) bdescriptortype : 0x1 device bcdusb : 0x200 usb 2.0 bdeviceclass : 0x0 specified @ interface bdevicesubclass : 0x0 bdeviceprotocol : 0x0 bmaxpacketsize0 : 0x40 (64 bytes) idvendor : 0x0ffd idproduct : 0xff00 bcddevice : 0x100 device 1.0 imanufacturer : 0x1 error accessing string iproduct : 0x2 error accessing string iserialnumber : 0x0 bnumconfigurations : 0x1 configuration 1: 500 ma ================================== blength : 0x9 (9 bytes) bdescriptortype : 0x2 configuration wtotallength : 0x20 (32 bytes) bnuminterfaces : 0x1 bconfigurationvalue : 0x1 iconfiguration : 0x0 bmattributes : 0x80 bus powered bmaxpower : 0xfa (500 ma) interface 0: vendor specific =========================== blength : 0x9 (9 bytes) bdescriptortype : 0x4 interface binterfacenumber : 0x0 balternatesetting : 0x0 bnumendpoints : 0x2 binterfaceclass : 0xff vendor specific binterfacesubclass : 0x1 binterfaceprotocol : 0x1 iinterface : 0x0 endpoint 0x81: bulk in =============================== blength : 0x7 (7 bytes) bdescriptortype : 0x5 endpoint bendpointaddress : 0x81 in bmattributes : 0x2 bulk wmaxpacketsize : 0x200 (512 bytes) binterval : 0x0 endpoint 0x2: bulk out =============================== blength : 0x7 (7 bytes) bdescriptortype : 0x5 endpoint bendpointaddress : 0x2 out bmattributes : 0x2 bulk wmaxpacketsize : 0x200 (512 bytes) binterval : 0x0
i'm new pyusb, feel i'm following instructions github page. i'm running code on raspberry pi rasbian os. i'm using python 2.7.3 , running root. device has 1 configuration , 1 interface doing wrong?
Comments
Post a Comment