How to declare an interface using WebUSB?

After gaining access to the connected device with, navigator.usb.requestDeviceI try to open a connection with the connected device as follows:

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

It seems that it successfully selects the configuration, however the step claimInterfacewill result in the following error:

DOMException: Unable to claim interface.

I am running the beta version of Chrome 55.0.2883.75 with the flag --disable-webusb-securityas root (without these I did not get any devices) on Ubuntu 16.10.

How can I connect and work?

Edit:

It seems that the cdc_acm driver has already announced the interface, since the device I'm trying to connect is a serial device, unloading the driver will allow you to require the device (however after that it complains that interface 1 is not available, as well as 0 or 2).

+4
1

device.configuration.interfaces[0].interfaceNumber:

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

Source: https://habr.com/ru/post/1662976/


All Articles