WebUSB windows issues

1,318 views
Skip to first unread message

Diogo Casado

unread,
Nov 18, 2017, 4:40:15 PM11/18/17
to WebUSB
Hello,

I just started working with WebUsb api on Chrome.

I'm getting two distinct problems.

1) On device.open() I'm getting "DOMException: The device was disconnected".
2) On device.claimInterface(0) I got "Can't claim interface" twice when open() worked.

After reading most of the documentation available (and several posts), This is what I've done.

1) I copied the sample code available into a local html file.

<html>
<body>
  <button onclick="connect()">Connect</button>
</body>
<script>
function connect() {
  navigator.usb.requestDevice({ filters: [{ classCode: 0x0B }] })
  .then(async device => {
    console.log(device);
    await device.open();
    if (device.configuration == null) {
      await device.selectConfiguration(1);
    }
    await device.claimInterface(0);
    console.log("kudos!");
  })
  .catch(error => { console.log(error); });
}
</script>
</html>

2) I used Zadig tool to replace the original driver with a WinUSB that will work with libusb and Chrome.

So far, it detects my device (CCID class smart card reader) and I'm able to select it although the problems mentioned above happen.

I don't know why, it seemed to work two times both open() and claim(). For several times I was able to open() but it stopped working. The code was always the same.

3) I uninstalled, removed and reinstalled the driver serveral times using all available options (WinUSB, libusb-win32 and libKusb), to no luck.

4) I also dug into the Chormium sources at /src/device/usb/usb_* but wasn't able so far to find the bit o code responsible for this open() exception.

5) I also tested on different Windows pcs (same device though), exact same behavior. The device works just fine with the original driver.

6) I monitored Chrome logs, nothing relevant.

Now, I could have posted on Stack overflow but I imagined this group would be more targeted.

If anyone could shed light on this, I would really appreciate since I'm considering using Chrome's WebUsb hoping it might become a standard and avoid me developing an external connector.

Thanks.

Diogo





Vincent Scheib

unread,
Nov 30, 2017, 7:36:18 PM11/30/17
to Diogo Casado, WebUSB
I don't have answers to these questions, sorry.  Stack Overflow (if you haven't already posted there) is the preferred forum.  

--
You received this message because you are subscribed to the Google Groups "WebUSB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webusb+unsubscribe@chromium.org.
To post to this group, send email to web...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/webusb/3fca23dc-4adc-43f0-ab69-9b497402f132%40chromium.org.

Diogo Casado

unread,
Dec 1, 2017, 7:53:13 AM12/1/17
to Reilly Grant, WebUSB
Thank you for your reply.

I had checked already the device log.

Well, I decided not to rely on WebUSB at this time.

Thanks!

Diogo

On Wed, Nov 29, 2017 at 12:07 AM, Reilly Grant <rei...@google.com> wrote:
Which version of Chrome are you running? 

If you open chrome://device-log there should be an error that starts with "Failed to claim interface: " and has the libusb error message associated with each time you had a DOMException thrown with "Unable to claim interface."

Reply all
Reply to author
Forward
0 new messages