libusb-1.0 for mingw feels like was built with cdecl calling
convention. When I load it with WinDLL (stdcall), it fails, but
loading it with CDLL (cdecl), it works fine:


C:\Documents and Settings\wander.costa>python
ActivePython 2.6.1.1 (ActiveState Software Inc.) based on
Python 2.6.1 (r261:67515, Dec  5 2008, 13:58:38) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import CDLL, WinDLL
>>> c = CDLL('libusb-1.0.dll')
>>> c.libusb_init(None)
0
>>> c.libusb_exit(None)
9775361
>>> w = WinDLL('libusb-1.0.dll')
>>> w.libusb_init(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Procedure probably called with too many arguments (4 bytes in excess
)
>>>

Just wondering if cdecl calling convention for mingw is right... If it
is, I must manage libusb10 backend to detect it is loading a mingw lib
and apply cdecl calling convention.

Wander

2010/4/7 Xiaofan Chen <xiaof...@gmail.com>:
> For normal Windows Python 2.5 and 2.6, I have the same results.
>
> C:\cygwin\home\mcuee\mcu\pyusb\pyusb\tests>set PYUSB_DEBUG_LEVEL=debug
>
> C:\cygwin\home\mcuee\mcu\pyusb\pyusb\tests>c:\Python25\python.exe testall.py
> 2010-04-07 11:17:04,351 DEBUG:usb.backend.libusb10:Error loading libusb 1.0 
> back
> end
> Traceback (most recent call last):
>  File "c:\Python25\Lib\site-packages\usb\backend\libusb10.py", line 558, in 
> get
> _backend
>    _init = _Initializer()
>  File "c:\Python25\Lib\site-packages\usb\backend\libusb10.py", line 375, in 
> __i
> nit__
>    _check(_lib.libusb_init(None))
> ValueError: Procedure probably called with too many arguments (4 bytes in 
> excess
> )
> Exception exceptions.ValueError: 'Procedure probably called with too many 
> argume
> nts (4 bytes in excess)' in <bound method _Initializer.__del__ of 
> <usb.backend.l
> ibusb10._Initializer object at 0x022CC170>> ignored
> 2010-04-07 11:17:04,407 DEBUG:usb.backend.openusb:Error loading OpenUSB 
> backend
> Traceback (most recent call last):
>  File "c:\Python25\Lib\site-packages\usb\backend\openusb.py", line 568, in 
> get_
> backend
>    _lib = _load_library()
>  File "c:\Python25\Lib\site-packages\usb\backend\openusb.py", line 148, in 
> _loa
> d_library
>    raise OSError('USB library could not be found')
> OSError: USB library could not be found
> 2010-04-07 11:17:04,437 INFO:usb.core:Using backend "usb.backend.libusb01"
> 2010-04-07 11:17:04,440 WARNING:usb.test:Test hardware not connected
> Traceback (most recent call last):
>  File "testall.py", line 43, in <module>
>    suite.addTest(m.get_suite())
>  File "C:\cygwin\home\mcuee\mcu\pyusb\pyusb\tests\test_integration.py", line 
> 23
> 3, in get_suite
>    idProduct=devinfo.ID_PRODUCT)
>  File "c:\Python25\Lib\site-packages\usb\core.py", line 835, in find
>    return _interop._next(device_iter(k, v))
>  File "c:\Python25\Lib\site-packages\usb\_interop.py", line 61, in _next
>    return iter.next()
>  File "c:\Python25\Lib\site-packages\usb\core.py", line 802, in device_iter
>    for dev in backend.enumerate_devices():
>  File "c:\Python25\Lib\site-packages\usb\backend\libusb10.py", line 397, in 
> enu
> merate_devices
>    return _DevIterator()
>  File "c:\Python25\Lib\site-packages\usb\backend\libusb10.py", line 386, in 
> __i
> nit__
>    byref(self.dev_list))
> WindowsError: exception: access violation reading 0x00000000
> Exception exceptions.ValueError: 'Procedure probably called with too many 
> argume
> nts (8 bytes in excess)' in <bound method _DevIterator.__del__ of 
> <usb.backend.l
> ibusb10._DevIterator object at 0x022CCDB0>> ignored
>
> C:\cygwin\home\mcuee\mcu\pyusb\pyusb\tests>c:\Python26\python.exe testall.py
> 2010-04-07 11:18:03,388 DEBUG:usb.backend.libusb10:Error loading libusb 1.0 
> back
> end
> Traceback (most recent call last):
>  File "c:\Python26\lib\site-packages\usb\backend\libusb10.py", line 558, in 
> get
> _backend
>    _init = _Initializer()
>  File "c:\Python26\lib\site-packages\usb\backend\libusb10.py", line 375, in 
> __i
> nit__
>    _check(_lib.libusb_init(None))
> ValueError: Procedure probably called with too many arguments (4 bytes in 
> excess
> )
> Exception ValueError: 'Procedure probably called with too many arguments (4 
> byte
> s in excess)' in <bound method _Initializer.__del__ of 
> <usb.backend.libusb10._In
> itializer object at 0x0270E7F0>> ignored
> 2010-04-07 11:18:03,424 DEBUG:usb.backend.openusb:Error loading OpenUSB 
> backend
> Traceback (most recent call last):
>  File "c:\Python26\lib\site-packages\usb\backend\openusb.py", line 568, in 
> get_
> backend
>    _lib = _load_library()
>  File "c:\Python26\lib\site-packages\usb\backend\openusb.py", line 148, in 
> _loa
> d_library
>    raise OSError('USB library could not be found')
> OSError: USB library could not be found
> 2010-04-07 11:18:03,451 INFO:usb.core:Using backend "usb.backend.libusb01"
> 2010-04-07 11:18:03,453 WARNING:usb.test:Test hardware not connected
> Traceback (most recent call last):
>  File "testall.py", line 43, in <module>
>    suite.addTest(m.get_suite())
>  File "C:\cygwin\home\mcuee\mcu\pyusb\pyusb\tests\test_integration.py", line 
> 23
> 3, in get_suite
>    idProduct=devinfo.ID_PRODUCT)
>  File "c:\Python26\lib\site-packages\usb\core.py", line 835, in find
>    return _interop._next(device_iter(k, v))
>  File "c:\Python26\lib\site-packages\usb\_interop.py", line 59, in _next
>    return next(iter)
>  File "c:\Python26\lib\site-packages\usb\core.py", line 802, in device_iter
>    for dev in backend.enumerate_devices():
>  File "c:\Python26\lib\site-packages\usb\backend\libusb10.py", line 397, in 
> enu
> merate_devices
>    return _DevIterator()
>  File "c:\Python26\lib\site-packages\usb\backend\libusb10.py", line 386, in 
> __i
> nit__
>    byref(self.dev_list))
> WindowsError: exception: access violation reading 0x00000000
> Exception ValueError: 'Procedure probably called with too many arguments (8 
> byte
> s in excess)' in <bound method _DevIterator.__del__ of 
> <usb.backend.libusb10._De
> vIterator object at 0x02735250>> ignored
>
>
> --
> Xiaofan http://mcuee.blogspot.com
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> pyusb-users mailing list
> pyusb-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pyusb-users
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
pyusb-users mailing list
pyusb-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pyusb-users

Reply via email to