简体   繁体   English

Linux Ubuntu上的LIBUSB异步批量传输超时

[英]LIBUSB Asynchronous Bulk Transfer Timeout On Linux Ubuntu

I am using libusb on Ubuntu and am attempting to send 4 bytes of data via an asynchronous bulk transfer. 我在Ubuntu上使用libusb,并尝试通过异步批量传输发送4个字节的数据。 I am able to successfully perform the following steps:1. 我能够成功执行以下步骤:1。

  1. Allocate the transfer via libusb_alloc_transfer . 通过libusb_alloc_transfer分配传输。
  2. Fill the bulk transfer via libusb_fill_bulk_transfer . 通过libusb_fill_bulk_transfer填充批量传输。
  3. Detach the kernel driver via libusb_detach_kernel_driver . 通过libusb_detach_kernel_driver分离内核驱动程序。
  4. Claim the interface via libusb_claim_interface . 通过libusb_claim_interface声明接口。
  5. Submit the transfer via libusb_submit_transfer . 通过libusb_submit_transfer提交传输。
  6. Lastly, reattach the kernel driver via libusb_attach_kernel_driver . 最后,通过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: 启用libusb调试可提供以下消息:

[10.033374] [000026fe] libusb: debug [handle_events] timerfd triggered [10.033374] [000026fe] libusb:调试[handle_events] timerfd已触发
[10.033375] [000026fe] libusb: debug [libusb_cancel_transfer] transfer 0x55555576de80 [10.033375] [000026fe] libusb:调试[libusb_cancel_transfer]传输0x55555576de80
[10.036908] [000026fe] libusb: debug [disarm_timerfd] [10.036908] [000026fe] libusb:调试[disarm_timerfd]
[10.036919] [000026fe] libusb: debug [handle_events] poll() 3 fds with timeout in 0ms [10.036919] [000026fe] libusb:调试[handle_events] poll()3个fds,超时时间为0ms
[10.036921] [000026fe] libusb: debug [handle_events] poll() returned 1 [10.036921] [000026fe] libusb:调试[handle_events] poll()返回1
[10.036924] [000026fe] libusb: debug [reap_for_handle] urb type=3 status=-2 transferred=0 [10.036924] [000026fe] libusb:调试[reap_for_handle] urb类型= 3状态= -2已转移= 0
[10.036926] [000026fe] libusb: debug [handle_bulk_completion] handling completion status -2 of bulk urb 1/1 [10.036926] [000026fe] libusb:调试[handle_bulk_completion]处理大城市1/1的完成状态-2
[10.036927] [000026fe] libusb: debug [handle_bulk_completion] abnormal reap: urb status -2 [10.036927] [000026fe] libusb:调试[handle_bulk_completion]异常收获:urb状态-2
[10.036928] [000026fe] libusb: debug [handle_bulk_completion] abnormal reap: last URB handled, reporting [10.036928] [000026fe] libusb:调试[handle_bulk_completion]异常收获:上一次处理URB,报告
[10.036930] [000026fe] libusb: debug [usbi_handle_transfer_cancellation] detected timeout cancellation [10.036930] [000026fe] libusb:调试[usbi_handle_transfer_cancellation]检测到超时取消
[10.036931] [000026fe] libusb: debug [disarm_timerfd] [10.036931] [000026fe] libusb:调试[disarm_timerfd]
[10.036932] [000026fe] libusb: debug [usbi_handle_transfer_completion] transfer 0x55555576de80 has callback 0x7ffff7bd4c78 [10.036932] [000026fe] libusb:调试[usbi_handle_transfer_completion]传输0x55555576de80具有回调0x7ffff7bd4c78

Questions: 问题:

  1. What does a URB status of -2 mean? URB状态为-2是什么意思?
  2. Based on your knowledge or experience, what could possibly prevent the transfer from actually taking place? 根据您的知识或经验,有什么可能阻止转移的发生?

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. 在libusb邮件列表中的人们的一些帮助下(用于注册https://sourceforge.net/projects/libusb/lists/libusb-devel ),我能够确定问题所在。

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端点发送数据。 In particular, I was examining bit 0 of the endpoint address instead of bit 7. 特别是,我正在检查端点地址的位0而不是位7。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM