diff options
Diffstat (limited to '')
-rw-r--r-- | assets/js/rootLantiq.js | 19 |
1 files changed, 13 insertions, 6 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(); } } |