Skip to content

Inconsistent Web USB Communication on Windows Machines #202

@sagar-bhedodkar

Description

@sagar-bhedodkar

I use the web usb for communication with the usb device having three sensors. It working fine on some of the windows and all mac os machines. But in some windows machine it get lags and sometimes works fine in same machine. I capture the data continuously. So what is the problem in this.
The code which is use is below :

const CMD1 = new Uint8Array([78, 84, 83, 83, 84, 65, 82, 84, 76, 238, 167, 78, 84, 69]);

const CMD2 = new Uint8Array([78, 84, 83, 83, 84, 65, 82, 84, 68, 40, 166, 78, 84, 69]);

var port = null;
port = await navigator.serial.requestPort();
await port.open({
baudRate: 115200
});
var selectedDevice = port.getInfo();
if (selectedDevice.usbProductId != 10 || selectedDevice.usbVendorId != 1240) {
const { writable, readable } = port;
writer = writable.getWriter();
reader = readable.getReader();
await writer.write(CMD1);
await writer.write(CMD2);
while (true) {
startLoopTimer();
const { value, done } = await reader.read();
if (done) break;
console.log('Received data:', value);
}
IMPORTANT : The issue is happening on most Windows machines with 8GB of RAM.

My device details showing in chrome://device-log is:-
SerialEvent[11:05:11] Serial device added: path=COM5 instance_id=USB\VID_04D8&PID_000A\5&2C179895&0&2 vid=04D8 pid=000A

USBUser[11:05:11] USB device added: path=?\usb#vid_04d8&pid_000a#5&2c179895&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed} vendor=1240 "Microchip Technology Inc.", product=10 "Simple CDC Device Demo", serial="", driver="usbser", guid=f02c59af-8c78-431d-888b-6a987c1ed8e8

SerialEvent[11:05:10] Serial device removed: path=COM5

USBUser[11:05:10] USB device removed: path=?\usb#vid_04d8&pid_000a#5&2c179895&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed} guid=3959900e-8309-4393-9be0-8c65dde53689

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions