summaryrefslogtreecommitdiffstats
path: root/assets/js
diff options
context:
space:
mode:
Diffstat (limited to '')
-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();