Skip to content

Commit c050b27

Browse files
committed
queue baSED ATTEMPT
1 parent 808e1a2 commit c050b27

File tree

1 file changed

+4
-52
lines changed

1 file changed

+4
-52
lines changed

src/js/tabs/onboard_logging.js

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ onboard_logging.initialize = function (callback) {
480480
if (GUI.connected_to) {
481481
self.blockSize = self.BLOCK_SIZE;
482482

483-
// Begin by refreshing the occupied size in case it changed while the tab was open
484483
flash_update_summary(function () {
485484
const maxBytes = FC.DATAFLASH.usedSize;
486485

@@ -491,61 +490,14 @@ onboard_logging.initialize = function (callback) {
491490

492491
show_saving_dialog();
493492

494-
// START PATCH: minimal retry for null/missing blocks
495493
const MAX_SIMPLE_RETRIES = 5;
496-
const RETRY_BACKOFF_MS = 30; // 30 ms delay for retries
494+
const RETRY_BACKOFF_MS = 30;
497495
let simpleRetryCount = 0;
498496

499-
const startTime = new Date().getTime(); // Start timestamp
497+
const startTime = new Date().getTime();
500498

501499
function onChunkRead(chunkAddress, chunkDataView, bytesCompressed) {
502-
if (chunkDataView && chunkDataView.byteLength > 0) {
503-
// Reset retry counter after a good block
504-
simpleRetryCount = 0;
505-
506-
// --- ORIGINAL BLOCK WRITE LOGIC ---
507-
const blob = new Blob([chunkDataView]);
508-
FileSystem.writeChunk(openedFile, blob);
509-
510-
nextAddress += chunkDataView.byteLength;
511-
512-
if (typeof bytesCompressed === "number") {
513-
if (totalBytesCompressed == null) totalBytesCompressed = 0;
514-
totalBytesCompressed += bytesCompressed;
515-
}
516-
517-
$(".dataflash-saving progress").attr("value", (nextAddress / maxBytes) * 100);
518-
519-
if (saveCancelled || nextAddress >= maxBytes) {
520-
mark_saving_dialog_done(startTime, nextAddress, totalBytesCompressed);
521-
FileSystem.closeFile(openedFile);
522-
} else {
523-
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
524-
}
525-
// --- END ORIGINAL LOGIC ---
526-
} else if (chunkDataView && chunkDataView.byteLength === 0) {
527-
// Zero-length block → EOF
528-
mark_saving_dialog_done(startTime, nextAddress, totalBytesCompressed);
529-
FileSystem.closeFile(openedFile);
530-
} else {
531-
// Null/missing block
532-
if (simpleRetryCount < MAX_SIMPLE_RETRIES) {
533-
simpleRetryCount++;
534-
if (simpleRetryCount % 2 === 1) {
535-
console.warn(`Null/missing block at ${nextAddress}, retry ${simpleRetryCount}`);
536-
}
537-
setTimeout(() => {
538-
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
539-
}, RETRY_BACKOFF_MS);
540-
} else {
541-
console.error(
542-
`Skipping null block at ${nextAddress} after ${MAX_SIMPLE_RETRIES} retries`,
543-
);
544-
nextAddress += self.blockSize; // Move to next block only after retries exhausted
545-
simpleRetryCount = 0;
546-
mspHelper.dataflashRead(nextAddress, self.blockSize, onChunkRead);
547-
}
548-
}
500+
// ... all recursive logic ...
549501
}
550502

551503
// Fetch the initial block
@@ -556,7 +508,7 @@ onboard_logging.initialize = function (callback) {
556508
});
557509
});
558510
}
559-
}
511+
} // <-- this is the exact end of flash_save_begin
560512

561513
function prepare_file(onComplete) {
562514
const prefix = "BLACKBOX_LOG";

0 commit comments

Comments
 (0)