-
• #2
i tried connection.close() but received an error
Uncaught (in promise) TypeError: Failed to execute 'close' on 'SerialPort': Cannot cancel a locked stream
at Object.connection.close (uart.js:272)how to unlockStream?
-
• #3
I'm not sure about
Cannot cancel a locked stream
- I haven't come across that one before :(If you want to use the command-line and not the browser (eg Node.js) then there's https://serialport.io/ - not quite the same API but it's a very similar idea.
But from the Web Browser itself, for security they say that you have to bring up the port chooser at least once (but there's no need for the BT/USB menu).
UART.js is based on Web Serial, so you could use that directly and you'd have a lot more flexibility (and avoid having the menu) - check out https://codelabs.developers.google.com/codelabs/web-serial/#3
-
• #4
Cannot cancel a locked stream
this is the error from the browser... sorry ;)
the page is connected to espruino
on the espruino:const onInit = () => { var step = 0; require("Encoder").connect(A8,A5, (dir) => { step += dir; print(step); if (dir > 0) { //allume la led 20ms digitalPulse(LED1, 1, 20); } else { digitalPulse(LED2, 1, 20); } }); };
i suppose the port is in use and therfor browser can not cancel connection...
thanks for your time.
é. -
• #5
i suppose the port is in use
Could it be open in another browser window? sometimes you can do that with things like Web Bluetooth, and that might cause the error?
Hello,
i'm playing with the uart.js lib to connect an espruino to a webpage.
Is it possible to connect to an espruino by command line (js) without the menu "bt4 or webserial", if i know the name of my espruino?
and can i use connection.close() (line 3) to disconnect the espruino from the page (without closing the webpage)? (to update the code in the webIDE)
i use this example
regards
é.