From e6ce89dfcc8b3a2a8016e011f3d7894bc5cf2747 Mon Sep 17 00:00:00 2001 From: Ernesto Castellotti Date: Thu, 12 Jan 2023 00:41:15 +0100 Subject: Moved root procedure to root_lantiq.html to be able to use in other pages Now step 2 can also be removed to use the same process on other non-Huawei SFPs --- assets/js/serialUtil.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'assets/js/serialUtil.js') 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(); -- cgit v1.2.3