summaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
authorErnesto Castellotti <mail@ernestocastellotti.it>2023-06-06 20:25:44 +0200
committerGitHub <noreply@github.com>2023-06-06 20:25:44 +0200
commit57eda2e09f1d69a28eeb1397053512e20496379b (patch)
treec1fcbffdb157366e05d5e9a5c5fbc3e07ccf9803 /assets/js
parentrootLantiq: Fix BREAK received on FTDI using Uint8Array directly (#214) (diff)
downloadhack-gpon.github.io-57eda2e09f1d69a28eeb1397053512e20496379b.tar
hack-gpon.github.io-57eda2e09f1d69a28eeb1397053512e20496379b.tar.gz
hack-gpon.github.io-57eda2e09f1d69a28eeb1397053512e20496379b.tar.bz2
hack-gpon.github.io-57eda2e09f1d69a28eeb1397053512e20496379b.tar.lz
hack-gpon.github.io-57eda2e09f1d69a28eeb1397053512e20496379b.tar.xz
hack-gpon.github.io-57eda2e09f1d69a28eeb1397053512e20496379b.tar.zst
hack-gpon.github.io-57eda2e09f1d69a28eeb1397053512e20496379b.zip
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/rootLantiq.js19
-rw-r--r--assets/js/serialUtil.js2
2 files changed, 14 insertions, 7 deletions
diff --git a/assets/js/rootLantiq.js b/assets/js/rootLantiq.js
index e592e63..0bd78fe 100644
--- a/assets/js/rootLantiq.js
+++ b/assets/js/rootLantiq.js
@@ -213,7 +213,7 @@ async function waitEndImageLoad(port, baudRate, outputErrorCallback) {
}
}
- await(1000);
+ await delay(1000);
await closePortLineBreak(port, reader, writer, readableStreamClosed, writerStreamClosed);
return true;
} catch (err) {
@@ -233,16 +233,23 @@ async function flashImageMtd(port, image, baudRate, outputErrorCallback) {
} else {
await writer.write(`sf probe 0 && sf erase ${IMAGE1_ADDR} && sf write ${LOAD_ADDR} ${IMAGE1_ADDR} && setenv committed_image 1 && setenv image1_is_valid 1 && saveenv && reset\n`);
}
+ } catch (err) {
+ outputErrorCallback(`Error: ${err.message}`);
+ return false;
+ } finally {
+ await closePortLineBreak(port, reader, writer, readableStreamClosed, writerStreamClosed);
+ }
- await delay(1000);
-
+ const serial = new SerialReadWrite(port, baudRate);
+ try {
/* Wait to avoid the user from disconnecting the SFP while the image is being flashed */
- await detectUboot(reader);
- await closePortLineBreak(port, reader, writer, readableStreamClosed, writerStreamClosed);
+ await delay(1000);
+ await detectUboot(serial);
return true;
} catch (err) {
outputErrorCallback(`Error: ${err.message}`);
- await closePortLineBreak(port, reader, writer, readableStreamClosed, writerStreamClosed);
return false;
+ } finally {
+ await serial.closePort();
}
}
diff --git a/assets/js/serialUtil.js b/assets/js/serialUtil.js
index 1d58e29..ebef166 100644
--- a/assets/js/serialUtil.js
+++ b/assets/js/serialUtil.js
@@ -103,7 +103,7 @@ class SerialReadWrite {
writer = this.port.writable.getWriter();
}
- writer.write(textEncoder.encode(str));
+ writer.write(this.textEncoder.encode(str));
} finally {
if (writer) {
writer.releaseLock();