1

我试图让 usb.find 命令在我为 Beagleboard 在 Angstrom 上编写的 python 脚本中正常工作。

这是我的代码:

#!/usr/bin/env python

import usb.core 
import usb.util 
import usb.backend.libusb01 as libusb


PYUSB_DEBUG_LEVEL = 'debug'
# find our device
# Bus 002 Device 006: ID 1208:0815
#  idVendor           0x1208
#  idProduct          0x0815
# dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
# iManufacturer           1 TOROBOT.com

dev = usb.core.find(idVendor=0x1208, idProduct=0x0815,
backend=libusb.get_backend() )

我不知道缺少什么,但这是我所知道的。当我不指定后端时,找不到后端。当我指定后端“usb.backend.libusb01”时,我收到以下错误:

root@beagleboard:~/servo# ./pyServo.py
Traceback (most recent call last):
  File "./pyServo.py", line 17, in <module>
    dev = usb.core.find(idVendor=0x1208, idProduct=0x0815, backend=libusb.get_backend() )
  File "/usr/lib/python2.6/site-packages/usb/core.py", line 854, in find
    return _interop._next(device_iter(k, v))
  File "/usr/lib/python2.6/site-packages/usb/_interop.py", line 60, in _next
    return next(iter)
  File "/usr/lib/python2.6/site-packages/usb/core.py", line 821, in device_iter
    for dev in backend.enumerate_devices():
  File "/usr/lib/python2.6/site-packages/usb/backend/libusb01.py", line 390, in enumerate_devices
    _check(_lib.usb_find_busses())
  File "/usr/lib/python2.6/ctypes/__init__.py", line 366, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python2.6/ctypes/__init__.py", line 371, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python: undefined symbol: usb_find_busses

我错过了什么才能正常工作?

谢谢你。

4

1 回答 1

0

Python、pyusb、libusb。我想就是这样。当然还有 libc,ld-linux.so,但默认情况下这些都在您的系统中。

nm -D /path-to/libusb.so,看看usb_find_busses符号是否真的存在。您的 libusb 总是有可能过时或以某种方式特别编译。

检查您是否收到任何日志,例如缺少 libusb.so 应该会产生类似“加载 libusb 0.1 后端时出错”之类的信息

于 2014-04-17T10:23:15.317 回答