诊断chrome.usb.claimInterface()错误 [英] Diagnosing chrome.usb.claimInterface() error

查看:164
本文介绍了诊断chrome.usb.claimInterface()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Chrome应用程序中的chrome.usb API与USB设备(智能卡读卡器)进行交互.我可以打开设备并提取配置.但是,当我调用claimInterface()开始交换数据时,出现了一条错误消息:错误声明接口".并且没有其他诊断程序.

I'm using chrome.usb API from a Chrome app to interact with a USB device, a smart card reader. I can open the device and pull the configuration. Yet when I call claimInterface() to start exchanging data, I get an error with message: "Error claiming interface." and no other diagnostics.

请问任何指针如何处理?例如,可以通过某种方式启用API的诊断日志记录吗?

Any pointers how to deal with that, please? Can I somehow enable diagnostic logging from the API, for example?

推荐答案

在此线程中讨论了类似的问题:

in this thread is discussed a similar problem: Error message 'Interface not claimed' from libusb

此处是副本

libusb-1.0也有同样的问题;我最初有这个顺序:

Just had the same problem with libusb-1.0; I originally had this sequence:

libusb_init
libusb_open_device_with_vid_pid
libusb_reset_device
libusb_get_device
libusb_reset_device
libusb_set_configuration
libusb_claim_interface
libusb_set_interface_alt_setting 
libusb_get_device_descriptor
libusb_get_bus_number 
libusb_get_device_address
libusb_get_string_descriptor_ascii
if(libusb_kernel_driver_active.. ) 
  if(libusb_detach_kernel_driver.. ) 
libusb_bulk_transfer
...

...并且为此,在执行第一个libusb_bulk_transfer时生成了未声明接口"(但没有后续的,上面没有显示),我通过进入gdb来确认了这一点. (顺便说一句,该错误消息来自/linux/drivers/usb/core/devio.c)

... and for it, the "interface not claimed" was generated when the first libusb_bulk_transfer executed (but not subsequent ones, not shown above), which I confirmed by stepping in gdb. (btw, that error message comes from /linux/drivers/usb/core/devio.c)

此页面: USB隐藏问题·Yubico/yubikey-personalization Wiki·GitHub 指的是libusb-0.1的修复程序,该修复程序调用了相应的"detach_driver"函数;所以我也开始在代码中移动"detach_driver"部分-最终,该序列似乎摆脱了"interface not Claim"消息:

This page: USB Hid Issue · Yubico/yubikey-personalization Wiki · GitHub refers to a fix for libusb-0.1 which called the corresponding "detach_driver" function; so I started moving the "detach_driver" part around in my code too - and finally this sequence seems to get rid of the "interface not claimed" message:

libusb_init
libusb_open_device_with_vid_pid
if(libusb_kernel_driver_active.. ) 
  if(libusb_detach_kernel_driver.. ) 
libusb_reset_device
libusb_get_device
libusb_set_configuration
libusb_claim_interface
libusb_set_interface_alt_setting 
libusb_get_device_descriptor
libusb_get_bus_number
libusb_get_device_address
libusb_get_string_descriptor_ascii
libusb_bulk_transfer
...

很明显,如果首先分离驱动程序,然后声明接口,则不会生成任何错误.但这也是您在OP中所拥有的-因此,我认为,OP的诀窍是先进行分离,然后设置配置,然后在该声明接口之后...

Apparently, if the driver is first detached, and then interface is claimed - then no errors are generated. But that is also what you have in OP there - so I think, the trick for OP would be to have detach, then set configuration, and after that claim interface...

这篇关于诊断chrome.usb.claimInterface()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆