LIBUSB Asynchronous Bulk Transfer Timeout On Linux Ubuntu

1.5k Views Asked by At

I am using libusb on Ubuntu and am attempting to send 4 bytes of data via an asynchronous bulk transfer. I am able to successfully perform the following steps:1.

  1. Allocate the transfer via libusb_alloc_transfer.
  2. Fill the bulk transfer via libusb_fill_bulk_transfer.
  3. Detach the kernel driver via libusb_detach_kernel_driver.
  4. Claim the interface via libusb_claim_interface.
  5. Submit the transfer via libusb_submit_transfer.
  6. Lastly, reattach the kernel driver via libusb_attach_kernel_driver.

The code will then run until the transfer times out and the callback function is called. Enabling libusb debug provides the following messages:

[10.033374] [000026fe] libusb: debug [handle_events] timerfd triggered
[10.033375] [000026fe] libusb: debug [libusb_cancel_transfer] transfer 0x55555576de80
[10.036908] [000026fe] libusb: debug [disarm_timerfd]
[10.036919] [000026fe] libusb: debug [handle_events] poll() 3 fds with timeout in 0ms
[10.036921] [000026fe] libusb: debug [handle_events] poll() returned 1
[10.036924] [000026fe] libusb: debug [reap_for_handle] urb type=3 status=-2 transferred=0
[10.036926] [000026fe] libusb: debug [handle_bulk_completion] handling completion status -2 of bulk urb 1/1
[10.036927] [000026fe] libusb: debug [handle_bulk_completion] abnormal reap: urb status -2
[10.036928] [000026fe] libusb: debug [handle_bulk_completion] abnormal reap: last URB handled, reporting
[10.036930] [000026fe] libusb: debug [usbi_handle_transfer_cancellation] detected timeout cancellation
[10.036931] [000026fe] libusb: debug [disarm_timerfd]
[10.036932] [000026fe] libusb: debug [usbi_handle_transfer_completion] transfer 0x55555576de80 has callback 0x7ffff7bd4c78

Questions:

  1. What does a URB status of -2 mean?
  2. Based on your knowledge or experience, what could possibly prevent the transfer from actually taking place?
1

There are 1 best solutions below

0
On BEST ANSWER

With some help from the folks on the libusb Mailing list (to sign up https://sourceforge.net/projects/libusb/lists/libusb-devel) I was able to identify the problem.

Based on the questions they asked I was forced to re-examine some of my base assumptions and in particular the endpoint address that I was using to send the data. I was attempting to send data out of an IN endpoint. In particular, I was examining bit 0 of the endpoint address instead of bit 7.