'How do I read data from usb serial port?
I'm trying to read data from the USB serial port. It is a thermometer scanner. The connection was successful but I don't know how to read the result data. I'm getting the result like the image below. How do I decode the data?
Here is my code.
const reader = port.readable.getReader();
// Listen to data coming from the serial device.
while (true) {
const { value, done } = await reader.read();
if (done) {
// Allow the serial port to be closed later.
reader.releaseLock();
break;
}
// value is a Uint8Array.
console.log(value);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

