我有3个摄像机,这些摄像机通过使用libusb(Linux debian 4.18.0-2-amd64 #1 SMP Debian 4.18.10-2 (2018-10-07) x86_64 GNU/Linux
)进行通信的自定义驱动程序连接到我的系统(libusb-1.0-0-dev version 2:1.0.22-2
)。我的控制程序指示所有3个摄像机同时拍照(即每个摄像机都在自己的线程中)并将图像(由摄像机压缩的jpeg格式)传输到主机。但是,在某些情况下,驱动程序会崩溃并
libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=12
我设法找出了导致此崩溃的条件,直到3张图像的累积长度超过大约16700000为止。
使用libusb_set_option(context, LIBUSB_OPTION_LOG_LEVEL, LIBUSB_LOG_LEVEL_DEBUG);
,libusb日志的相关部分为:
[169.598301] [00005f3d] libusb: debug [handle_bulk_completion] handling completion status 0 of bulk urb 1/1
[169.598309] [00005f3d] libusb: debug [handle_bulk_completion] last URB in transfer --> complete!
[169.598317] [00005f3d] libusb: debug [disarm_timerfd]
[169.598338] [00005f3d] libusb: debug [usbi_handle_transfer_completion] transfer 0x7f337c0164b0 has callback 0x7f338cb292c0
[169.598341] [00005f3d] libusb: debug [sync_transfer_cb] actual_length=512
[169.598348] [00005f3d] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[169.598350] [00005f3d] libusb: debug [handle_events] poll() 3 fds with timeout in 1000ms
[169.598355] [00006114] libusb: debug [libusb_free_transfer] transfer 0x7f337c0164b0
[169.598613] [00006114] libusb: debug [libusb_alloc_transfer] transfer 0x7f337c013680
[169.598619] [00006114] libusb: debug [libusb_submit_transfer] transfer 0x7f337c013680
[169.598622] [00006114] libusb: debug [add_to_flying_list] arm timerfd for timeout in 5000ms (first in line)
[169.598627] [00006114] libusb: debug [submit_bulk_transfer] need 1 urbs for new transfer with length 5518974
[169.598633] [00006114] libusb: error [submit_bulk_transfer] submiturb failed error -1 errno=12
[169.598635] [00006114] libusb: debug [submit_bulk_transfer] first URB failed, easy peasy
[169.598638] [00006114] libusb: debug [disarm_timerfd]
[169.598640] [00006114] libusb: debug [libusb_free_transfer] transfer 0x7f337c013680
在https://github.com/Benjamin-Dobell/Heimdall/issues/162中,errno=12
似乎表明libusb中的内存分配失败。
导致失败的urbs
的长度为:
individual lengths: 5344144, 5667142, 5325086, 5340560, 5662879, 5372779, 5677123, 5669363, 5330830, 5701546, 4858929, 5650281, 5692766, 5672324, 5244656, 5757461, 4918281, 5337289, 4922414, 5756863, 5019245, 5337501, 5016021, 4922044, 5354934, 4757346, 4918050, 5012320, 5312396, 5254472, 5261837, 5012182, 5215843, 5254860, 5472029, 5631765, 5254979, 5475969, 5580069, 5475967, 5567574, 5254763, 5412320, 5838796, 5518974
sum of 3 lengths: 16336372, 16376218, 16677316, 16210756, 16609746, 16013031, 15698522, 15275566, 15030330, 15579188, 15489862, 16358654, 16311017, 16298304, 16770090
我的问题是,如何处理此故障? 我看到的选项是:
submit_bulk_transfer
中的错误可以修复吗?