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".

Thanks,

Chris Wolf

Error before patch:

>>> import ctypes.util
>>> import usb.backend.openusb
>>> libname = ctypes.util.find_library('openusb')
>>> lib =  ctypes.util.CDLL(libname)
>>> usbbe = usb.backend.openusb.get_backend()
2010-07-11 14:58:19,869 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 589, in get_backend
    _setup_prototypes(_lib)
  File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/usb/backend/openusb.py",
 line 155, in _setup_prototypes
    lib.openusb.restype = c_int32
  File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/ctypes/__init__.py",
 line 353, in __getattr__
    func = self.__getitem__(name)
  File 
"/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/ctypes/__init__.py",
 line 358, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x722c10, openusb): symbol not found



------------------------------------------------------------------------------
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

Reply via email to