Skip to content

Commit 6d1f80f

Browse files
committed
throttle warnings
1 parent 68fe053 commit 6d1f80f

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

src/js/tabs/onboard_logging.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ onboard_logging.initialize = function (callback) {
495495
const MAX_SIMPLE_RETRIES = 5;
496496
let simpleRetryCount = 0;
497497

498+
const startTime = new Date().getTime(); // Start timestamp
499+
498500
function onChunkRead(chunkAddress, chunkDataView, bytesCompressed) {
499501
if (chunkDataView && chunkDataView.byteLength > 0) {
500502
// Reset retry counter after a good block
@@ -528,27 +530,20 @@ onboard_logging.initialize = function (callback) {
528530
// Null/missing block
529531
if (simpleRetryCount < MAX_SIMPLE_RETRIES) {
530532
simpleRetryCount++;
531-
console.warn(`Null/missing block at ${nextAddress}, retry ${simpleRetryCount}`);
533+
if (simpleRetryCount % 2 === 1) {
534+
console.warn(`Null/missing block at ${nextAddress}, retry ${simpleRetryCount}`);
535+
}
532536
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
533537
} else {
534538
console.error(
535-
`Skipping null block at ${nextAddress} after ${MAX_SIMPLE_RETRIES} retry`,
539+
`Skipping null block at ${nextAddress} after ${MAX_SIMPLE_RETRIES} retries`,
536540
);
537-
nextAddress += self.blockSize; // Move to next block
538-
simpleRetryCount = 0; // reset counter for next block
539-
540-
if (saveCancelled || nextAddress >= maxBytes) {
541-
mark_saving_dialog_done(startTime, nextAddress, totalBytesCompressed);
542-
FileSystem.closeFile(openedFile);
543-
} else {
544-
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
545-
}
541+
nextAddress += self.blockSize; // Move to next block only after retries exhausted
542+
simpleRetryCount = 0;
543+
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
546544
}
547545
}
548546
}
549-
// END PATCH
550-
551-
const startTime = new Date().getTime(); // Start timestamp
552547

553548
// Fetch the initial block
554549
FileSystem.openFile(fileWriter).then((file) => {

0 commit comments

Comments
 (0)