Linux libusb 接口已经声明
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6365314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
libusb interface already claimed
提问by jairo
I'm writing a device driver for a usb device using libusb. When I attempt to claim the device I get the error code LIBUSB_ERROR_BUSY (-6). According to the documentation that means that the device has already been claimed (link).
我正在使用 libusb 为 USB 设备编写设备驱动程序。当我尝试认领设备时,我收到错误代码 LIBUSB_ERROR_BUSY (-6)。根据文档,这意味着该设备已被认领(链接)。
How do I find out which driver/program has claimed the device and more importantly, how can I, myself, claim the device once it's claimed.
我如何找出哪个驱动程序/程序声明了该设备,更重要的是,我自己如何在声明该设备后声明该设备。
Code snippet:
代码片段:
r = libusb_claim_interface(handle[0], 0);
if (r < 0) {
fprintf(stderr, "libusb_claim_interface error %d\n", r);
goto out_release;
}
printf("claimed interface\n");
Output:
输出:
libusb_claim_interface error -6
回答by Turbo J
Did you call libusb_set_configuration()
before libusb_claim_interface()
?
你libusb_set_configuration()
之前打过电话libusb_claim_interface()
吗?
This must be called even if there is only one configuration in the descriptor.
即使描述符中只有一个配置,也必须调用它。
回答by David Grayson
Do you call libusb_detach_kernel_driver()
before libusb_claim_interface()
? This may be necessary.
你libusb_detach_kernel_driver()
之前打过电话libusb_claim_interface()
吗?这可能是必要的。
回答by linsek
The issue is most likely that interface is claimed by another Linux driver. call libusb_detach_kernel_driver()
and specify the interface number and then you should be able to connect it.
问题很可能是接口被另一个 Linux 驱动程序声明。调用libusb_detach_kernel_driver()
并指定接口号,然后您应该可以连接它。