Closed Whitealbum0 closed 1 year ago
Example 7 explains the requirement that all streams need to be closed before close()
is called. In your code the reader created in readFromSerialDevice()
never has releaseLock()
called. You need to call this before readFromSerialDevice()
returns (since otherwise it only gets closed after it is garbage collected) and in disconnectFromSerialDevice()
so that the read is cancelled if it is still waiting for data from the device.
I click on the button, the list drops out, I select the device, but when I click on the close, I get this error:
Uncaught (in promise) TypeError: Failed to execute 'close' on 'SerialPort': Cannot cancel a locked stream at disconnectFromSerialDevice (WebUSBAPI.js:56:16) at HTMLButtonElement.main (WebUSBAPI.js:73:13)
Of course, I'm a mammoth in this, but I'm trying to figure it out.
Here is the link to the script https://github.com/Whitealbum0/main_test_WebUSBAPI/blob/main/WebUSBAPI.js
Can someone tell me? Thanks in advance