serial icon indicating copy to clipboard operation
serial copied to clipboard

Inconsistent Web USB Communication on Windows Machines

Open sagar-bhedodkar opened this issue 1 year ago • 4 comments

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

sagar-bhedodkar avatar Apr 12 '24 18:04 sagar-bhedodkar

this is my exact code so I can't able to find the issue so can you please provide me the solution. Also I find that there is issue in most of the windows machines of 8gb Ram but on 16gb ram windows machine it working fine but on some 16gb ram windows machines it also losses some in between data.

And I think the web serial communation happens locally. But I have one question the good internet connection is always required for the communication or not. Please provide me the solution.

sagar-bhedodkar avatar Apr 12 '24 18:04 sagar-bhedodkar

@reillyeon I stuck in the issue I implemented the web serial according to the documentation in chrome developer section but I stuck in this issue so please help me in this.

sagar-bhedodkar avatar Apr 12 '24 18:04 sagar-bhedodkar

It is tracked by the chromium bug https://g-issues.chromium.org/issues/333954422 and that was closed.

chengweih001 avatar May 01 '24 17:05 chengweih001

Since crbug.com/333954422 has been closed, we should close this issue too.

alvinjiooo avatar May 22 '24 03:05 alvinjiooo