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.
- Allocate the transfer via
libusb_alloc_transfer
. - Fill the bulk transfer via
libusb_fill_bulk_transfer
. - Detach the kernel driver via
libusb_detach_kernel_driver
. - Claim the interface via
libusb_claim_interface
. - Submit the transfer via
libusb_submit_transfer
. - 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:
- What does a URB status of -2 mean?
- Based on your knowledge or experience, what could possibly prevent the transfer from actually taking place?