2011/8/7 chris clark <clac...@gmail.com>: > Before I start wailing "I need help! I need help!", kudos to everyone > involved in PyUSB.
Thank you. > I'm not a hardware guy, I know nothing about USB > protocols and yet I was able to convert someone else's C program and > convert it into Python using PyUSB. The old tool only worked with > libusb-0.1 (it fails to work with libusb-1.0 and the libusb-0.1 compat > lib), my new shiny Python script works with all combinations of libusb > on both 32 and 64 bit Linux machines. I don't know anyting about > OpenUSB so I've not even attempted to test that. > OpenUSB support has not been implemented yet. > I deliberately used PyUSB 1.0 as it was pure python, and thus easier > to deploy. According to the readme it is still alpha (1?), and (from > the readme) "``reset`` method hangs under Windows (libusb 1.0 > backend)". Alpha stage in PyUSB means it is not feature complete yet and its API may suffer changes from one version to another. The reset issue is related to libusb 1.0 windows backend. Libusb guys can give you better explanation on that (or maybe Xiaofan if he is around here). > > I'm hitting something, I'm not sure what it is though when trying to > use reset :-) > > I've been converting http://code.google.com/p/dava33display/ and > everything works fine under Linux :-) If you want more detail on the > device there is some reverse engineering notes (not my me) at > http://kieranlevin.com/index.php?option=com_content&view=article&id=54:reverseengdisplay&catid=35:projects&Itemid=54 > > Under Windows I've had 2 issues: > > 1) I found that under Linux I (sometimes) needed to call > detach_kernel_driver(), under Windows this consistently fails. > Removing this call is my workaround (and it works fine, I might try > catching AttributeError instead as a work around). This seems like a > bug in PyUSB but I'm not sure as I do not know what I'm doing :-( > Traceback at end of mail in case this is remotely helpful. I'm not > clear if it is reasonable for PyUSB to hide this error and to just > carry on or not. > detach_kernel_driver is Linux (actually Unix like) only. The point is that under Linux there is usbfs which allows you to talk to USB devices directly, and a driver attached to the device just disturb the things... Under Windows quite the opposite is true, you do need a driver attached to the device (either WinUSB or libusb-win32 driver), thus detach_kernel_driver does no make sense under Windows, and it is not implemented in libusb-win32. I didn't decide yet which is better, issue a "Not Implemented' exception under Windows or implement a "does nothing" function. > 2) reset() problem (slightly different to known issue in readme for > libusb-1.0, I guess as I'm using libusb-01). The symptom I see is that > the TFT display appears to power off, I get no errors and no hangs. > When I try to re-run my script to send a new image I get time outs (it > isn't like the device isn't there as it opens fine.. but that may be > an artifact about the way libusb drivers work under Windows). Trace > back @eom for the 2nd run when the display is "off". Removing reset() > is the workaround here too and it works fine, I can re-run my script > under Windows and the display updates with the new image. When I ran a > debugger over the reset, the first time I got no problem (until this > point reset consistently "failed" for me), subsequent runs all "fail" > (even if I wait a few secs for each method call) and cause power off > at core.py:565 self._ctx.backend.reset_device(self._ctx.handle). Once > the TFT powers off I need to reboot the machine (kinda painful, any > ideas on how to re-start it or is this device specific?). > Bear in mind that after a reset, you have to do set_configuration again, as the device was just plugged in. If you are doing this, this may be a firmware problem. Do you face any reset problem under Linux? > > I installed the Windows libusb driver from libusb-win32-bin-1.2.4.0, > PyUSB is SVN rev 90. There were some issues with reset but it is supposed to be fixed on this revision. > > I installed the driver using inf-wizard (I used the install now button > generated at the end of the wizard, rather than manually clicking the > newly created .INF file). Interestingly the device shows up twice in > inf-wizard, it shows up as "ASeries Device (Interface 1)" and "ASeries > Device (Interface 1)", I ended up installing both (just one didn't > seem to work). It didn't prompt me to reboot but rebooting appeared to > fix some problems I had writinf to the device. > > I'm looking for any kind of help I can get! :-) I'm really not > familiar with libusb (it took some trial and error to get the drivers > installed, I couldn't find a good Windows readme). > > Is there any value in trying the older PyUSB (with pre-builts, I'm not > setup with a compiler)? I know from my Linux experience I'll need to > recode my script to use the older API. Right now what I have works for > me but if I can help progress PyUSB 1.0 I'd like to help, I just have > no idea what I'm doing. PyUSB development is frozen mostly because I am dedicating all my free time to my master thesis. If someone is interested in keep the development while I am out, just contact me and we can talk. > > Slightly off topic, the PyUSB wiki appears to be down/empty (no errors > blank screen), http://pyusb.wiki.sourceforge.net/ > PyUSB was moved to Trac, you can access it at http://sourceforge.net/apps/trac/pyusb/. > > Thanks for PyUSB and thanks in advance for any assistance You're welcome. > > Chris > > Trace back #1 - missing detach: > > > E:\asusdisplay>E:\apps\PortablePython1.0\python.exe > E:\asusdisplay\asusdisplay.py E:\asusdisplay\testimg.bmp > reading E:\asusdisplay\testimg.bmp > Traceback (most recent call last): > File "E:\asusdisplay\asusdisplay.py", line 328, in <module> > sys.exit(main()) > File "E:\asusdisplay\asusdisplay.py", line 320, in main > display.displayinit() > File "E:\asusdisplay\asusdisplay.py", line 197, in displayinit > dev.detach_kernel_driver(1) > File "E:\apps\PortablePython1.0\lib\site-packages\usb\core.py", line > 695, in detach_kernel_driver > self._ctx.backend.detach_kernel_driver(self._ctx.handle, interface) > File "e:\apps\PortablePython1.0\lib\site-packages\usb\_debug.py", > line 52, in do_trace > return f(*args, **named_args) > File "e:\apps\PortablePython1.0\lib\site-packages\usb\backend\libusb01.py", > line 526, in detach_kernel_driver > _check(_lib.usb_detach_kernel_driver_np(dev_handle, intf)) > File "e:\apps\PortablePython1.0\lib\ctypes\__init__.py", line 325, > in __getattr__ > func = self.__getitem__(name) > File "e:\apps\PortablePython1.0\lib\ctypes\__init__.py", line 330, > in __getitem__ > func = self._FuncPtr((name_or_ordinal, self)) > AttributeError: function 'usb_detach_kernel_driver_np' not found > > > Trace back #2 - device "missing" after reset powers off device > > > E:\asusdisplay>E:\apps\PortablePython1.0\python.exe > E:\asusdisplay\debug_asusdisplay.py E:\asusdisplay\testimg.bmp > reading E:\asusdisplay\testimg.bmp > Traceback (most recent call last): > File "E:\asusdisplay\debug_asusdisplay.py", line 330, in <module> > sys.exit(main()) > File "E:\asusdisplay\debug_asusdisplay.py", line 322, in main > display.displayinit() > File "E:\asusdisplay\debug_asusdisplay.py", line 207, in displayinit > self.write(0x02, data) > File "E:\asusdisplay\debug_asusdisplay.py", line 295, in write > self.dev.write(ep, block, interface=None, timeout=1000) > File "E:\apps\PortablePython1.0\lib\site-packages\usb\core.py", line > 602, in write > self.__get_timeout(timeout) > File "e:\apps\PortablePython1.0\lib\site-packages\usb\_debug.py", > line 52, in do_trace > return f(*args, **named_args) > File "e:\apps\PortablePython1.0\lib\site-packages\usb\backend\libusb01.py", > line 454, in bulk_write > data, timeout) > File "e:\apps\PortablePython1.0\lib\site-packages\usb\backend\libusb01.py", > line 536, in __write > timeout > File "e:\apps\PortablePython1.0\lib\site-packages\usb\backend\libusb01.py", > line 364, in _check > raise USBError(errmsg) > usb.core.USBError: libusb0-dll:err [_usb_reap_async] timeout error > > ------------------------------------------------------------------------------ > BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA > The must-attend event for mobile developers. Connect with experts. > Get tools for creating Super Apps. See the latest technologies. > Sessions, hands-on labs, demos & much more. Register early & save! > http://p.sf.net/sfu/rim-blackberry-1 > _______________________________________________ > pyusb-users mailing list > pyusb-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pyusb-users > -- Best Regards, Wander Lairson Costa ------------------------------------------------------------------------------ BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA The must-attend event for mobile developers. Connect with experts. Get tools for creating Super Apps. See the latest technologies. Sessions, hands-on labs, demos & much more. Register early & save! http://p.sf.net/sfu/rim-blackberry-1 _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users