Tigge / openant

ANT and ANT-FS Python Library
MIT License
174 stars 80 forks source link

USBError: [Errno 32] Pipe error #51

Closed hb9eue closed 2 years ago

hb9eue commented 3 years ago

Hi

I don't manage to get openant / antfs-cli to work. Any hint welcome. I also unloaded the usb_serial_simple as suggested by some google finds, no success.

# antfs-cli --debug
Driver available: [<class ant.base.driver.SerialDriver at 0x7f2ba96081a0>, <class ant.base.driver.USB2Driver at 0x7f2ba9608c20>, <class ant.base.driver.USB3Driver at 0x7f2ba9608c90>]
 - Using: ant.base.driver.USB2Driver
USB Find device, vendor 0xfcf, product 0x1008
USB Config values:
 Config 1
  Interface 0, Alt 0
   Endpoint 129
   Endpoint 1
No kernel driver active
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/antfs_cli/program.py", line 355, in main
    g = AntFSCLI(config_dir, args)
  File "build/bdist.linux-x86_64/egg/antfs_cli/program.py", line 132, in __init__
    Application.__init__(self)
  File "/usr/local/lib/python2.7/dist-packages/ant/fs/manager.py", line 104, in __init__
    self._node = Node()
  File "/usr/local/lib/python2.7/dist-packages/ant/easy/node.py", line 56, in __init__
    self.ant = Ant()
  File "/usr/local/lib/python2.7/dist-packages/ant/base/ant.py", line 68, in __init__
    self._driver.open()
  File "/usr/local/lib/python2.7/dist-packages/ant/base/driver.py", line 195, in open
    alternate_setting = usb.control.get_interface(dev, interface_number)
  File "build/bdist.linux-x86_64/egg/usb/control.py", line 244, in get_interface
    data_or_wLength = 1)[0]
  File "build/bdist.linux-x86_64/egg/usb/core.py", line 1043, in ctrl_transfer
    self.__get_timeout(timeout))
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 883, in ctrl_transfer
    timeout))
  File "build/bdist.linux-x86_64/egg/usb/backend/libusb1.py", line 595, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
USBError: [Errno 32] Pipe error

-Benoit-

hp-pepster commented 3 years ago

Hi,

same here, tried it with ubuntu 20.04, kernel 5.4.0-47 and manjaro, kernel 5.7.19-2. Do you need more information from us? When I use your example (e.g. examples/scan.py), the kernel shows this after the execution: usb 1-1.4: reset full-speed USB device number 9 using ehci-pci

The Ant+-Stick from Anself identifies itself as Bus 001 Device 009: ID 0fcf:1008 Dynastream Innovations, Inc. ANTUSB2 Stick. It's directly connected to the USB port without cable or hub.

Thank you for your work and have a nice weekend.

Tigge commented 3 years ago

Hi. I don't have a clue, unfortunately. You could try to upgrade pyusb to the latest version that was released a couple of days ago. There is also some form of logging for pyusb/libusb1 you could try, see if there are any hints there.

angelos-c commented 3 years ago

Hi,

Same issue here, I've tried using multiple versions of pyusb (1.1.0, 1.0.2, 1.0.0, 1.0.0a2, etc) (https://pypi.org/project/pyusb/#history) with no luck. My error is the same as @hp-pepster and @hb9eue but I don' t seem to have the No kernel driver active that he has, just a broken pipe error. Btw, I am on macOS.

@Tigge do you have any resources so I can read more into the pyusb/libusb1 logging you mentioned? Thank you!

===error below===

$ python3 scan.py 
Driver available: [<class 'ant.base.driver.SerialDriver'>, <class 'ant.base.driver.USB2Driver'>, <class 'ant.base.driver.USB3Driver'>]
 - Using: <class 'ant.base.driver.USB2Driver'>
Traceback (most recent call last):
  File "scan.py", line 78, in <module>
    main()
  File "scan.py", line 56, in main
    node = Node()
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ant/easy/node.py", line 56, in __init__
    self.ant = Ant()
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ant/base/ant.py", line 68, in __init__
    self._driver.open()
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ant/base/driver.py", line 195, in open
    alternate_setting = usb.control.get_interface(dev, interface_number)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usb/control.py", line 251, in get_interface
    data_or_wLength = 1)[0]
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usb/core.py", line 1077, in ctrl_transfer
    self.__get_timeout(timeout))
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usb/backend/libusb1.py", line 901, in ctrl_transfer
    timeout))
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/usb/backend/libusb1.py", line 604, in _check
    raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 32] Pipe error
angelos-c commented 3 years ago

I managed to track down a .log file that from my understanding your fork of openant added (@Tigge). Any idea? It seems now that I do indeed have the No kernel driver active error.

example.log

DEBUG:ant.base.driver:USB Find device, vendor 0xfcf, product 0x1008
DEBUG:ant.base.driver:USB Config values:
DEBUG:ant.base.driver: Config 1
DEBUG:ant.base.driver:  Interface 0, Alt 0
DEBUG:ant.base.driver:   Endpoint 129
DEBUG:ant.base.driver:   Endpoint 1
DEBUG:ant.base.driver:No kernel driver active
Tigge commented 3 years ago

The No kernel driver active only means that there are no active Linux kernel modules that are using the interface we want to use. This is usually what you should get in your logs unless you have e.g. cp210x loaded and using the USB device. (btw, this is the original openant, and not a fork: I wrote it).

Tigge commented 3 years ago

You can set the LIBUSB_DEBUG env variable to 3 and it should print out logs to stderr, btw.

theller commented 3 years ago

I have also seen the pipe error, but only with the ANTUSB2 stick (manufactured by CYCPLUS), not with the original Garmin ANTUSB-m stick. AFAIK the usb pipe error in libusb means "LIBUSB_ERROR_PIPE if the control request was not supported"

The problem is the call usb.control.get_interface(dev, interface_number) in ant/base/driver.py line 213. If I comment this out, the example programs work fine with both sticks that I have. Here is the patch: patch.txt

angelos-c commented 3 years ago

I have also seen the pipe error, but only with the ANTUSB2 stick (manufactured by CYCPLUS), not with the original Garmin ANTUSB-m stick. AFAIK the usb pipe error in libusb means "LIBUSB_ERROR_PIPE if the control request was not supported"

The problem is the call usb.control.get_interface(dev, interface_number) in ant/base/driver.py line 213. If I comment this out, the example programs work fine with both sticks that I have. Here is the patch: patch.txt

Nevermind, ignore what I said above... Your solution works !

Thank you @theller !!!

kkarsten62 commented 3 years ago

Thanks a lot to theller.

I can confirm that the patch from theller will work on Ubuntu 18.04 and Ubuntu 20.04 with Anself Ant+ USB-Stick. Stick is recognize by me after plug in:

$ dmesg [ 3217.886549] usb 4-1: new full-speed USB device number 7 using uhci_hcd [ 3218.082568] usb 4-1: New USB device found, idVendor=0fcf, idProduct=1008 [ 3218.082571] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 3218.082573] usb 4-1: Product: ANT USBStick2 [ 3218.082575] usb 4-1: Manufacturer: CYCPLUS [ 3218.082577] usb 4-1: SerialNumber: 123 [ 3218.090597] usb_serial_simple 4-1:1.0: suunto converter detected [ 3218.090685] usb 4-1: suunto converter now attached to ttyUSB0

Original Garmin Ant+ USB-Stick is still working also after patch is installed.