summaryrefslogtreecommitdiffstats
path: root/assets
diff options
context:
space:
mode:
authorErnesto Castellotti <mail@ernestocastellotti.it>2023-01-12 00:41:15 +0100
committerSimone <26844016+simonebortolin@users.noreply.github.com>2023-01-12 01:03:22 +0100
commite6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747 (patch)
tree36ef026c388ce9bdddcda6b5bd9948e63efff954 /assets
parentRemove outputErrorCallback from openPortLineBreak (diff)
downloadhack-gpon.github.io-e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747.tar
hack-gpon.github.io-e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747.tar.gz
hack-gpon.github.io-e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747.tar.bz2
hack-gpon.github.io-e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747.tar.lz
hack-gpon.github.io-e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747.tar.xz
hack-gpon.github.io-e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747.tar.zst
hack-gpon.github.io-e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747.zip
Diffstat (limited to 'assets')
-rw-r--r--assets/js/serialUtil.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/assets/js/serialUtil.js b/assets/js/serialUtil.js
index 6e9d155..9624619 100644
--- a/assets/js/serialUtil.js
+++ b/assets/js/serialUtil.js
@@ -2,6 +2,23 @@ function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
+class LineBreakTransformer {
+ constructor() {
+ this.chunks = "";
+ }
+
+ transform(chunk, controller) {
+ this.chunks += chunk;
+ const lines = this.chunks.split("\n");
+ this.chunks = lines.pop();
+ lines.forEach((line) => controller.enqueue(line));
+ }
+
+ flush(controller) {
+ controller.enqueue(this.chunks);
+ }
+}
+
async function openPortLineBreak(port, baudRate) {
await port.open({ baudRate: baudRate });
const textDecoder = new TextDecoderStream();