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