Hi, Thanks again for the help with this...
I tried the suggestion, using the below code snippits: import usb.core import usb.util import usb.backend.libusb01 backend = usb.backend.libusb01.get_backend() devs = usb.core.find(backend=backend, find_all=True, custom_match=findFromList(vendor, product)) It appears to be a similar/same issue in terms of symptoms. Again, the issue seems to be the SECOND read/write operation after I plug a new device in -- the first one works. ~/killerbee/killerbee$ sudo zbid Warning: You are using pyUSB 1.x, support is in alpha. Dev Product String Serial Number 3:4 KILLERB001 A50400A01C25 Found 1 devices. ~/killerbee/killerbee$ sudo zbdump -f 11 -w test.pcap -i 3:4 Warning: You are using pyUSB 1.x, support is in alpha. Warning: You are using pyUSB 1.x, support is in alpha. zbdump: listening on '3:4', link-type DLT_IEEE802_15_4, capture size 127 bytes Traceback (most recent call last): File "/usr/local/bin/zbdump", line 100, in <module> packet = kb.pnext() File "/usr/local/lib/python2.7/dist-packages/killerbee/__init__.py", line 270, in pnext return self.driver.pnext(timeout) File "/usr/local/lib/python2.7/dist-packages/killerbee/dev_rzusbstick.py", line 443, in pnext pdata = self.dev.read(RZ_USB_PACKET_EP, 1, 0, 100) File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 654, in read self.__get_timeout(timeout) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb01.py", line 483, in bulk_read timeout) File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb01.py", line 568, in __read timeout File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb01.py", line 384, in _check raise USBError(errmsg, ret) usb.core.USBError: [Errno None] Connection timed out This timeout error happens on the second USB related call within the zbdump program. Removing and reinserting the device fixes the issue. The same symptom occurs when I import libusb10 and use that explicitly. Do you have other ideas for what this could be? Is a resource not getting properly released? Thanks, Ryan On 12/27/12, Wander Lairson Costa <wander.lair...@gmail.com> wrote: > 2012/12/26 Ryan Speers <rmspe...@gmail.com>: >> Hello, >> >> Thanks -- I think that usb.legacy isn't exactly compatible yet in this >> regard, specifically as the bus.dirname and dev.filename attributes >> aren't >> set. So, I've decided to go ahead and detect what version of pyUSB is >> being >> used (by trying to import usb.core and catching the exception). >> >> But, here is the issue I'm having... when going down the USBVER==1 branch, >> I >> get timeout errors after the first connection attempt. >> My device, an RZUSBSTICK has a hierarchy of: >> Config value: 1 >> Interface number 0, with alternate setting 0 >> Endpoint 132 for responses >> Endpoint 2 for control >> Endpoint 129 for packets >> >> What I do for setup is: >> self.dev.set_configuration(1) >> self.dev.set_interface_altsetting(interface = 0, alternate_setting = 0) >> >> Then, in my write function, you see the following (first comes the pyUSB >> 0.x >> code, then the 1.x code as marked): >> if USBVER == 0: >> try: >> self.handle.bulkWrite(endpoint, data) >> # Returns a tuple, first value is an int as the RZ_RESP_* >> code >> response = self.handle.bulkRead(RZ_USB_RESPONSE_EP, 1)[0] >> except usb.USBError, e: >> if e.args != ('No error',): # >> http://bugs.debian.org/476796 >> raise e >> time.sleep(0.0005) >> if response != RZ_RESP_SUCCESS: >> if response in RESPONSE_MAP: >> raise Exception("Error: %s" % RESPONSE_MAP[response]) >> else: >> raise Exception("Unknown USB write error: 0x%02x" % >> response) >> else: #pyUSB 1.x >> res = self.dev.write(endpoint, data, 0, 100) >> if len(data) != res: >> raise Exception("Issue writing USB data {0} to endpoint >> {1}, >> got a return of {2}.".format(data, endpoint, res)) >> response = self.dev.read(RZ_USB_RESPONSE_EP, 1, 0, 500).pop() >> #TODO reduce timeout? >> if response != RZ_RESP_SUCCESS: >> if response in RESPONSE_MAP: >> raise Exception("Error: %s" % RESPONSE_MAP[response]) >> else: >> raise Exception("Unknown USB write error: 0x%02x" % >> response) >> >> Second set of code: >> if USBVER == 0: >> try: >> pdata = self.handle.bulkRead(RZ_USB_PACKET_EP, timeout) >> except usb.USBError, e: >> if e.args != ('No error',): # >> http://bugs.debian.org/476796 >> if e.args[0] != "Connection timed out": # USB timeout >> issue >> print "Error args:", e.args >> raise e >> else: # pyUSB 1.x >> pdata = self.dev.read(RZ_USB_PACKET_EP, 1, 0, 100) >> #TODO error handling >> >> The 0.x code has some odd code in there to deal with errors I've had in >> the >> past. Here is the exception I get back when the second self.dev.read() is >> called. I get the timeout error if I call the read on this second >> endpoint, >> as shown below, or if I call it on the first endpoint again (by running >> the >> program again). >> >> zbdump: listening on '2:12', link-type DLT_IEEE802_15_4, capture size 127 >> bytes >> Traceback (most recent call last): >> ... >> File >> "/usr/local/lib/python2.7/dist-packages/killerbee/dev_rzusbstick.py", >> line 443, in pnext >> pdata = self.dev.read(RZ_USB_PACKET_EP, 1, 0, 100) >> File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 654, in >> read >> self.__get_timeout(timeout) >> File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb10.py", >> line 541, in bulk_read >> timeout) >> File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb10.py", >> line 641, in __read >> timeout)) >> File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb10.py", >> line 403, in _check >> raise USBError(_str_error[ret], ret, _libusb_errno[ret]) >> usb.core.USBError: [Errno 110] Operation timed out >> >> > > You are using libusb 1.0 when using PyUSB 1.0, and libusb 0.1 when > using PyUSB 0.4. What about forcing libusb0 backend in PyUSB 1.0? > > import usb.core > import usb.backend.libusb0 > > b = usb.backend.libusb0.get() > d = usb.core.find(backend = b, .....) > > -- > Best Regards, > Wander Lairson Costa > > ------------------------------------------------------------------------------ > Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, > MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current > with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft > MVPs and experts. ON SALE this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122712 > _______________________________________________ > pyusb-users mailing list > pyusb-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pyusb-users > -- Ryan Speers This message (including any attachments) contains confidential information intended for a specific individual and purpose, and is protected by law. If you are not the intended recipient, you should delete this message. Any disclosure, copying, or distribution of this message, or the taking of any action based on it, is strictly prohibited. ------------------------------------------------------------------------------ Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and experts. ON SALE this month only -- learn more at: http://p.sf.net/sfu/learnmore_123012 _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users