javascript - How to claim interface using WebUSB? - Stack Overflow

After obtaining access to an attached device using navigator.usb.requestDevice I'm trying to open

After obtaining access to an attached device using navigator.usb.requestDevice I'm trying to open a connection with an attached device as follows:

device.open()
    .then(() => device.selectConfiguration(1))
    .then(() => device.claimInterface(1))

It seemingly successfully selects the configuration, however the claimInterface step will produce the following error:

DOMException: Unable to claim interface.

I'm running Chrome 55.0.2883.75 beta with the --disable-webusb-security flag as root (without those I didn't get any devices) on Ubuntu 16.10.

How can I get the connection up and running?

Edit:

It seems that the cdc_acm driver already claimed the interface since device I'm trying to attach is a serial device, unloading the driver will allow you to claim the device (however after this it plains about interface 1 not being available, as well as 0 or 2).

After obtaining access to an attached device using navigator.usb.requestDevice I'm trying to open a connection with an attached device as follows:

device.open()
    .then(() => device.selectConfiguration(1))
    .then(() => device.claimInterface(1))

It seemingly successfully selects the configuration, however the claimInterface step will produce the following error:

DOMException: Unable to claim interface.

I'm running Chrome 55.0.2883.75 beta with the --disable-webusb-security flag as root (without those I didn't get any devices) on Ubuntu 16.10.

How can I get the connection up and running?

Edit:

It seems that the cdc_acm driver already claimed the interface since device I'm trying to attach is a serial device, unloading the driver will allow you to claim the device (however after this it plains about interface 1 not being available, as well as 0 or 2).

Share Improve this question edited Dec 7, 2016 at 7:33 Joris Blaak asked Dec 6, 2016 at 13:45 Joris BlaakJoris Blaak 3982 silver badges10 bronze badges 1
  • 1 Since this device has multiple interfaces we should make sure that you're claiming the right one. Please include the output of lsusb -v for your device which will list the full device descriptors. A USB CDC device will indeed be difficult to use with WebUSB because of the existing drivers that are loaded however forcing the driver to unload should release the interface. When you get an error like "Unable to claim interface" Chrome will provide possibly more detail about the error in chrome://device-log. – Reilly Grant Commented May 5, 2017 at 23:54
Add a ment  | 

1 Answer 1

Reset to default 2

Once the configuration is selected, you can find the right interface number in device.configuration.interfaces[0].interfaceNumber:

device.open()
    .then(() => device.selectConfiguration(1))
    .then(() => device.claimInterface(device.configuration.interfaces[0].interfaceNumber))

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744753613a4591747.html

相关推荐

  • javascript - How to claim interface using WebUSB? - Stack Overflow

    After obtaining access to an attached device using navigator.usb.requestDevice I'm trying to open

    11天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信