diff options
author | Ernesto Castellotti <mail@ernestocastellotti.it> | 2023-01-11 19:36:30 +0100 |
---|---|---|
committer | Simone <26844016+simonebortolin@users.noreply.github.com> | 2023-01-12 00:02:02 +0100 |
commit | d0bf83f17a40bc140828c58b6d5f8d583bd847ad (patch) | |
tree | 0212d2e5d4d79e00d8325e6d95a8268c63e541b8 /assets/js | |
parent | closePortLineBreak prevent undefined errors (diff) | |
download | hack-gpon.github.io-d0bf83f17a40bc140828c58b6d5f8d583bd847ad.tar hack-gpon.github.io-d0bf83f17a40bc140828c58b6d5f8d583bd847ad.tar.gz hack-gpon.github.io-d0bf83f17a40bc140828c58b6d5f8d583bd847ad.tar.bz2 hack-gpon.github.io-d0bf83f17a40bc140828c58b6d5f8d583bd847ad.tar.lz hack-gpon.github.io-d0bf83f17a40bc140828c58b6d5f8d583bd847ad.tar.xz hack-gpon.github.io-d0bf83f17a40bc140828c58b6d5f8d583bd847ad.tar.zst hack-gpon.github.io-d0bf83f17a40bc140828c58b6d5f8d583bd847ad.zip |
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/rootLantiq.js | 10 | ||||
-rw-r--r-- | assets/js/serialUtil.js | 10 |
2 files changed, 8 insertions, 12 deletions
diff --git a/assets/js/rootLantiq.js b/assets/js/rootLantiq.js index 480cf6e..ff0f478 100644 --- a/assets/js/rootLantiq.js +++ b/assets/js/rootLantiq.js @@ -64,11 +64,12 @@ async function waitFailbackShell(writer, reader, outputMsgCallback) { } async function lantiqRootUboot(port, sfpModel, outputMsgCallback, outputErrorCallback, baudRate = 115200) { - outputMsgCallback(`Please disconnect the ${sfpModel} from the SFP adapter if it is currently plugged in!`); - - const { reader, writer, readableStreamClosed, writerStreamClosed } = await openPortLineBreak(port, baudRate, outputErrorCallback); + let reader,writer, readableStreamClosed, writerStreamClosed; try { + outputMsgCallback(`Please disconnect the ${sfpModel} from the SFP adapter if it is currently plugged in!`); + ({ reader, writer, readableStreamClosed, writerStreamClosed } = await openPortLineBreak(port, baudRate)); + await delay(10000); outputMsgCallback(`Now you need to insert the ${sfpModel} into the SFP adapter, if the procedure does not go ahead, check the connections and then remove and reconnect the ${sfpModel} again`); @@ -107,9 +108,10 @@ async function lantiqRootUboot(port, sfpModel, outputMsgCallback, outputErrorCal } async function unlockHuaweiShell(port, outputMsgCallback, outputErrorCallback, baudRate = 115200) { - const { reader, writer, readableStreamClosed, writerStreamClosed } = await openPortLineBreak(port, baudRate, outputErrorCallback); + let reader,writer, readableStreamClosed, writerStreamClosed; try { + ({ reader, writer, readableStreamClosed, writerStreamClosed } = await openPortLineBreak(port, baudRate)); outputMsgCallback("Root in progress: Rebooting..."); writer.write('reset\n'); await delay(1000); diff --git a/assets/js/serialUtil.js b/assets/js/serialUtil.js index c4d6d84..6e9d155 100644 --- a/assets/js/serialUtil.js +++ b/assets/js/serialUtil.js @@ -2,14 +2,8 @@ function delay(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } -async function openPortLineBreak(port, baudRate, outputErrorCallback) { - try { - await port.open({ baudRate: baudRate }); - } catch (err) { - outputErrorCallback(`Error: ${err.message}`); - return; - } - +async function openPortLineBreak(port, baudRate) { + await port.open({ baudRate: baudRate }); const textDecoder = new TextDecoderStream(); const readableStreamClosed = port.readable.pipeTo(textDecoder.writable); const reader = await textDecoder.readable.pipeThrough(new TransformStream(new LineBreakTransformer())).getReader(); |