On 7/12/10 9:00 AM, Chris Wolf wrote: > Wander, > > Earlier, I mentioned that the openusb backend did not work for me on > MacOS, but I'm pretty sure I found the problem. There seems to be a > typo in backend/openusb.py on line #155, where it configures the return > type for the function "openusb_init" - this line refers to the function > as "openusb" rather then "openusb_init": > > $ diff -u openusb.py.orig openusb.py > --- openusb.py.orig 2010-07-12 08:51:37.000000000 -0400 > +++ openusb.py 2010-07-12 08:51:49.000000000 -0400 > @@ -152,7 +152,7 @@ > def _setup_prototypes(lib): > # int32_t openusb_init(uint32_t flags , openusb_handle_t *handle); > lib.openusb_init.argtypes = [c_uint32, POINTER(_openusb_handle)] > - lib.openusb.restype = c_int32 > + lib.openusb_init.restype = c_int32 > > # void openusb_fini(openusb_handle_t handle ); > lib.openusb_fini.argtypes = [_openusb_handle] > > > After making this fix, my test code was able to successfully use the > openusb backend to iterate over all my USB devices. > > The download code archive this occurs in is named, "pyusb-1.0.0-a0.zip". > Well, actually, I forgot to override the backend in find(), so it used libusb10, sorry. (I still think this patch is legitimate)
There are still problems with the openusb backend: >>> devices = usb.core.find(find_all=True, backend=usbbe) 2010-07-12 09:10:58,295 DEBUG:usb.backend.openusb:_OpenUSB.enumerate_devices() Exception exceptions.AttributeError: "'_BusIterator' object has no attribute 'buslist'" in <bound method _BusIterator.__del__ of <usb.backend.openusb._BusIterator object at 0x12649f0>> ignored Traceback (most recent call last): File "<stdin>", line 1, in ? File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/core.py", line 824, in find return [d for d in device_iter(k, v)] File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/core.py", line 794, in device_iter for dev in backend.enumerate_devices(): File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py", line 420, in enumerate_devices for bus in _BusIterator(): File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py", line 390, in __init__ self.buslist = POINTER(openusb_busid_t)() NameError: global name 'openusb_busid' is not defined So I again patched as: $ diff -u openusb.py.orig /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py --- openusb.py.orig 2010-07-12 08:51:37.000000000 -0400 +++ /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py 2010-07-12 09:10:42.000000000 -0400 @@ -387,7 +387,7 @@ class _BusIterator(object): def __init__(self): - self.buslist = POINTER(openusb_busid)() + self.buslist = POINTER(openusb_busid_t)() num_busids = c_uint32() _check(_lib.openusb_get_busid_list(_ctx.handle, byref(self.buslist), But now I'm getting this error: >>> import usb.backend.openusb >>> usbbe = usb.backend.openusb.get_backend() dlerror: dlopen(/usr/local/lib/openusb_backend/darwin.so, 1): Symbol not found: _usbi_devices Referenced from: /usr/local/lib/openusb_backend/darwin.so Expected in: flat namespace fail to load /usr/local/lib/openusb_backend/darwin.so 2010-07-12 09:28:04,603 ERROR:usb.backend.openusb:Error loading OpenUSB backend Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py", line 590, in get_backend _ctx = _Context() File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py", line 384, in __init__ _check(_lib.openusb_init(0, byref(self.handle))) File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py", line 376, in _check if retval.value != 0: AttributeError: 'int' object has no attribute 'value' Again, I'm happy to just use libusb10 Thanks, Chris Wolf ------------------------------------------------------------------------------ This SF.net email is sponsored by Sprint What will you do first with EVO, the first 4G phone? Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users