I am trying to use the WebSerial API on Windows after it worked fine on macOS with no problem. The device was plugged into a Macbook and no extra action was required. When I connect the device (USB to Serial adapter) to a Windows machine and access my Angular website using Google Chrome, I get this error:
DOMException: Failed to open serial port.
When I access chrome://device-log/
I see this error:
[USB][ERROR][17:09:20] Failed to read descriptor from node connection: A device attached to the system is not functioning. (0x1F)
Below is the code that I am using, and an error is displayed when code runs line await this.scale.open({ baudRate: 9600 });
.
const VENDOR_ID = 1027;
const PRODUCT_ID = 24577;
...
let button = document.getElementById('request-device');
button.addEventListener('click', async () => {
try {
this.scale = await navigator.serial.requestPort({
filters: [{
usbProductId: PRODUCT_ID,
usbVendorId: VENDOR_ID
}]
});
await this.scale.open({ baudRate: 9600 }); //ERROR HAPPENS HERE
} catch (error) {
console.log(error)
}
});
}
There are two similar questions here on for Ubuntu but no answers or solutions were given. (Question 1 and Question 2)
It was a driver issue.
Most old models USB to Serial adapters are presenting problems on Windows 10. After trying several drivers, I found this one that solved my problem.
It is linked to a Youtube video in a language that I do not understand. However, the steps are easy to follow. After downloading the driver and following the steps, it works just fine.