Skip to content

Commit ecd64f6

Browse files
committed
chatGpt one retry attempt
1 parent 9a8a201 commit ecd64f6

File tree

1 file changed

+28
-11
lines changed

1 file changed

+28
-11
lines changed

src/js/tabs/onboard_logging.js

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -491,17 +491,23 @@ onboard_logging.initialize = function (callback) {
491491

492492
show_saving_dialog();
493493

494+
// START PATCH: minimal retry for null/missing blocks
495+
const MAX_SIMPLE_RETRIES = 1;
496+
let simpleRetryCount = 0;
497+
494498
function onChunkRead(chunkAddress, chunkDataView, bytesCompressed) {
495499
if (chunkDataView && chunkDataView.byteLength > 0) {
496-
// Always write non-empty data, even if CRC mismatch
500+
// Reset retry counter after a good block
501+
simpleRetryCount = 0;
502+
503+
// --- ORIGINAL BLOCK WRITE LOGIC ---
497504
const blob = new Blob([chunkDataView]);
498505
FileSystem.writeChunck(openedFile, blob);
499506

500507
nextAddress += chunkDataView.byteLength;
501508

502-
// Track total compressed bytes, if provided
503509
if (typeof bytesCompressed === "number") {
504-
if (totalBytesCompressed == null) totalBytesCompressed = 0; // initialize if previously unknown
510+
if (totalBytesCompressed == null) totalBytesCompressed = 0;
505511
totalBytesCompressed += bytesCompressed;
506512
}
507513

@@ -513,23 +519,34 @@ onboard_logging.initialize = function (callback) {
513519
} else {
514520
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
515521
}
522+
// --- END ORIGINAL LOGIC ---
516523
} else if (chunkDataView && chunkDataView.byteLength === 0) {
517524
// Zero-length block → EOF
518525
mark_saving_dialog_done(startTime, nextAddress, totalBytesCompressed);
519526
FileSystem.closeFile(openedFile);
520527
} else {
521-
// Null block → skip ahead (hard error)
522-
console.warn(`Skipping null block at address ${nextAddress}`);
523-
nextAddress += self.blockSize;
524-
525-
if (nextAddress >= maxBytes) {
526-
mark_saving_dialog_done(startTime, nextAddress, totalBytesCompressed);
527-
FileSystem.closeFile(openedFile);
528-
} else {
528+
// Null/missing block
529+
if (simpleRetryCount < MAX_SIMPLE_RETRIES) {
530+
simpleRetryCount++;
531+
console.warn(`Null/missing block at ${nextAddress}, retry ${simpleRetryCount}`);
529532
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
533+
} else {
534+
console.error(
535+
`Skipping null block at ${nextAddress} after ${MAX_SIMPLE_RETRIES} retry`,
536+
);
537+
nextAddress += self.blockSize; // Move to next block
538+
simpleRetryCount = 0; // reset counter for next block
539+
540+
if (nextAddress >= maxBytes) {
541+
mark_saving_dialog_done(startTime, nextAddress, totalBytesCompressed);
542+
FileSystem.closeFile(openedFile);
543+
} else {
544+
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
545+
}
530546
}
531547
}
532548
}
549+
// END PATCH
533550

534551
const startTime = new Date().getTime(); // Start timestamp
535552

0 commit comments

Comments
 (0)