-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ return connected
+ }
-
-
+ }
+
+ async function serial_close() {
+ window.location.reload()
+ }
+
+ let writerInit = false
+ let writer = null
+ let writableStreamClosed = null
+ async function serial_write(text) {
+ if (!port || !connected) {
+ connected = false
+ return
+ }
+ if (!writerInit) {
+ const textEncoder = new TextEncoderStream()
+ writableStreamClosed = textEncoder.readable.pipeTo(port.writable)
+ writer = textEncoder.writable.getWriter()
+ writerInit = true
+ }
+ if (writer) await writer.write(text)
+ }
+
+
+