On 12/10/2013 5:33 AM, Wander Lairson Costa wrote: > 2013/12/9 Christopher Fowler <christop...@chronofish.com>: >> Hello, >> >> I have been trying to find an easy to use USB API, and this seems pretty >> straight forward, except for getting the dependencies correct. >> >> I am running Python 2.6 on an Angstrom for the Beaglboard XM: >> >> root@beagleboard:~# uname -a >> Linux beagleboard 2.6.32 #3 PREEMPT Tue Jul 26 10:56:56 CEST 2011 armv7l >> GNU/Linux >> >> I have used OPKG to load the following: >> libusb-0.1-4 - 1:0.1.3-r0.6 - libusb-0 compatibility library using libusb-1 >> libusb-1.0-0 - 1.0.8-r0.6 - library to provide userspace access to USB >> devices >> libusbpp-0.1-4 - 0.1.12-r3.5 - libusb is a library to provide userspace >> access to USB devices. >> python-core - 2.6.6-ml12.2.6 - Python Interpreter and core modules (needed!) >> python-ctypes - 2.6.6-ml12.2.6 - Python C Types Support >> python-setuptools - 0.6c9-ml0.3 - Download, build, install, upgrade, and >> uninstall Python packages >> >> I have used the setup.py command to install pyusb-1.0.0a2 >> >> When I run my script without specifying the backend, I get this error: >> >> File "./pyServo.py", line 18, in <module> >> dev = usb.core.find(idVendor=0x1208, idProduct=0x0815) >> File "/usr/lib/python2.6/site-packages/usb/core.py", line 846, in find >> raise ValueError('No backend available') >> ValueError: No backend available >> > You installed libusb 1.0 and libusb-compat. libusb 1.0.8 has been > quite buggy, you may want to upgrade it.
Here is what is available to me via OPKG: root@beagleboard:~/python# opkg list | grep libusb libusb-0.1-4 - 1:0.1.3-r0.6 - libusb-0 compatibility library using libusb-1 libusb-0.1-bin - 1:0.1.3-r0.6 - libusb-0 compatibility library using libusb-1 libusb-0.1-dbg - 1:0.1.3-r0.6 - libusb-0 compatibility library using libusb-1 libusb-0.1-dev - 1:0.1.3-r0.6 - libusb-0 compatibility library using libusb-1 libusb-0.1-static - 1:0.1.3-r0.6 - libusb-0 compatibility library using libusb-1 libusb-1.0-0 - 1.0.8-r0.6 - library to provide userspace access to USB devices libusb-1.0-dbg - 1.0.8-r0.6 - library to provide userspace access to USB devices libusb-1.0-dev - 1.0.8-r0.6 - library to provide userspace access to USB devices libusb-1.0-static - 1.0.8-r0.6 - library to provide userspace access to USB devices libusb-compat-dbg - 1:0.1.2-r0.4 - libusb-0 compatibility library using libusb-1 libusb1-dbg - 1.0.2-r0.4 - library to provide userspace access to USB devices libusbpp-0.1-4 - 0.1.12-r3.5 - libusb is a library to provide userspace access to USB devices. python-pyusb - 0.4.1-r1.3 - libusb Python Bindings python-pyusb-dbg - 0.4.1-r1.3 - libusb Python Bindings python-pyusb-dev - 0.4.1-r1.3 - libusb Python Bindings > >> When I run my script specifying the backend, I get this error: >> 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 >> >> > It seems there is some problem with your libusb-compat library, as > PyUSB cannot find the usb_find_busses symbol. Maybe this is a ctypes > issue. I have installed the libusb-compat-debug package. > > Try to find the libusb 0.1 shared object and run the command objdump > -T <file> and post the output here. root@beagleboard:~/servo# objdump -T /usr/lib/libusb-0.1.so.4 /usr/lib/libusb-0.1.so.4: file format elf32-littlearm DYNAMIC SYMBOL TABLE: 00000f18 l d .init 00000000 .init 0000abf0 l d .jcr 00000000 .jcr 00000000 DF *UND* 000000c0 GLIBC_2.4 strerror 00000000 DF *UND* 00000030 libusb_clear_halt 00000000 DF *UND* 00000008 libusb_get_device_address 00000000 DF *UND* 00000134 libusb_close 00000000 DF *UND* 00000090 libusb_unref_device 00000000 DF *UND* 000001e0 libusb_open 00000000 DF *UND* 0000008c libusb_claim_interface 00000000 DF *UND* 00000030 libusb_set_configuration 00000000 w D *UND* 00000000 __gmon_start__ 00000000 w D *UND* 00000000 _Jv_RegisterClasses 00000000 DF *UND* 00000050 libusb_free_device_list 00000000 DF *UND* 00000128 libusb_get_device_list 00000000 DF *UND* 00000228 libusb_control_transfer 00000000 DF *UND* 00000088 GLIBC_2.4 memset 00000000 DF *UND* 00000198 libusb_get_config_descriptor 00000000 DF *UND* 00000028 libusb_interrupt_transfer 00000000 DF *UND* 00000164 GLIBC_2.4 free 00000000 DF *UND* 00000008 libusb_get_bus_number 00000000 DF *UND* 0000001c libusb_free_config_descriptor 00000000 DF *UND* 00000040 libusb_set_debug 00000000 DF *UND* 00000028 libusb_ref_device 00000000 DF *UND* 00000144 libusb_init 00000000 DF *UND* 00000030 libusb_reset_device 00000000 DF *UND* 0000014c GLIBC_2.4 memcpy 00000000 DF *UND* 00000084 libusb_set_interface_alt_setting 00000000 DF *UND* 0000003c libusb_detach_kernel_driver 00000000 DF *UND* 00000020 GLIBC_2.4 fprintf 00000000 DF *UND* 00000378 GLIBC_2.4 malloc 00000000 DF *UND* 0000010c GLIBC_2.4 fputc 00000000 DF *UND* 000000cc libusb_get_device_descriptor 00000000 DO *UND* 00000004 GLIBC_2.4 stdout 00000000 DF *UND* 0000003c libusb_kernel_driver_active 00000000 DO *UND* 00000004 GLIBC_2.4 stderr 00000000 DF *UND* 00000028 libusb_bulk_transfer 00000000 DF *UND* 00003f8c GLIBC_2.4 vfprintf 00000000 DF *UND* 00000028 GLIBC_2.4 snprintf 00000000 DF *UND* 00000090 libusb_release_interface 00000000 DF *UND* 0000001c GLIBC_2.4 __errno_location 00000000 w DF *UND* 0000011c GLIBC_2.4 __cxa_finalize 00000000 DF *UND* 00000020 GLIBC_2.4 sprintf 00000000 DF *UND* 00000134 libusb_get_string_descriptor_ascii 0000adc8 g D *ABS* 00000000 Base _bss_end__ 0000adb8 g D *ABS* 00000000 Base __bss_start__ 0000adc8 g D *ABS* 00000000 Base __end__ 00001700 g DF .text 0000006c Base usb_interrupt_write 0000adb8 g D *ABS* 00000000 Base _edata 000014c4 g DF .text 0000006c Base usb_control_msg 000012b8 g DF .text 00000030 Base usb_detach_kernel_driver_np 00002be4 g D *ABS* 00000000 Base __exidx_start 00001fe8 g DF .text 000008d8 Base usb_find_devices 000029a8 g DF .fini 00000000 Base _fini 0000adb8 g D *ABS* 00000000 Base __bss_start 0000adb4 g D .data 00000000 Base __data_start 00001a4c g DF .text 00000044 Base usb_claim_interface 000028c0 g DF .text 0000001c Base usb_strerror 000012e8 g DF .text 00000090 Base usb_get_driver_np 00001458 g DF .text 0000006c Base usb_get_string 00001a90 g DF .text 00000030 Base usb_set_configuration 00001530 g DF .text 00000044 Base usb_get_string_simple 00000f18 g DF .init 00000000 Base _init 00001cc0 g DF .text 00000328 Base usb_find_busses 00001c20 g DF .text 000000a0 Base usb_open 00001290 g DF .text 00000020 Base usb_get_busses 00001844 g DF .text 0000006c Base usb_bulk_write 00001ac0 g DF .text 00000020 Base usb_close 00002914 g DF .text 00000094 Base usb_init 000012b0 g DF .text 00000008 Base usb_device 0000adc8 g D *ABS* 00000000 Base __bss_end__ 000019ac g DF .text 00000060 Base usb_set_altinterface 000018b0 g DF .text 0000006c Base usb_bulk_read 0000adbc g DO .bss 00000004 Base usb_busses 0000adc8 g D *ABS* 00000000 Base _end 00001a0c g DF .text 00000040 Base usb_release_interface 000013ec g DF .text 0000006c Base usb_get_descriptor 0000194c g DF .text 00000030 Base usb_clear_halt 00001378 g DF .text 00000074 Base usb_get_descriptor_by_endpoint 0000176c g DF .text 0000006c Base usb_interrupt_read 00002be4 g D *ABS* 00000000 Base __exidx_end 000028dc g DF .text 00000038 Base usb_set_debug 0000191c g DF .text 00000030 Base usb_reset 0000197c g DF .text 00000030 Base usb_resetep > > Another thing is that you installed libusb 1.0 and it is the preferred > backend for PyUSB under linux. Probably PyUSB is not finding it. root@beagleboard:~/servo# locate libusb /usr/lib/libusb-0.1.so.4 /usr/lib/libusb-0.1.so.4.4.4 /usr/lib/libusb-1.0.so.0 /usr/lib/libusb-1.0.so.0.0.0 /usr/lib/opkg/info/libusb-0.1-4.control /usr/lib/opkg/info/libusb-0.1-4.list /usr/lib/opkg/info/libusb-0.1-4.postinst /usr/lib/opkg/info/libusb-1.0-0.control /usr/lib/opkg/info/libusb-1.0-0.list /usr/lib/opkg/info/libusb-1.0-0.postinst >> Here is the simply script that I am using: >> #!/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(iManufacturer='TOROBOT.com') >> dev = usb.core.find(idVendor=0x1208, idProduct=0x0815, >> backend=libusb.get_backend() ) >> >> >> >> >> What am I doing wrong, and what do I need to do to make this work? >> > As you are forcing the use of libusb0 and it is not working, the > script fails. Also notice you are using an old version of PyUSB, you > might want to upgrade it. > I pulled PyUSB off of sourceforge which defaults to pyusb-1.0.0a2. I upgraded to pyusb-1.0.0b1. Thank you so much for your help. -CF ------------------------------------------------------------------------------ Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk _______________________________________________ pyusb-users mailing list pyusb-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pyusb-users