@@ -489,49 +489,57 @@ onboard_logging.initialize = function (callback) {
489489
490490 show_saving_dialog ( ) ;
491491
492- function onChunkRead ( chunkAddress , chunkDataView , bytesCompressed ) {
493- if ( chunkDataView !== null ) {
494- // Did we receive any data?
495- if ( chunkDataView . byteLength > 0 ) {
496- nextAddress += chunkDataView . byteLength ;
497- if ( isNaN ( bytesCompressed ) || isNaN ( totalBytesCompressed ) ) {
498- totalBytesCompressed = null ;
499- } else {
500- totalBytesCompressed += bytesCompressed ;
501- }
502-
503- $ ( ".dataflash-saving progress" ) . attr ( "value" , ( nextAddress / maxBytes ) * 100 ) ;
504-
505- const blob = new Blob ( [ chunkDataView ] ) ;
506- FileSystem . writeChunck ( openedFile , blob ) . then ( ( ) => {
507- if ( saveCancelled || nextAddress >= maxBytes ) {
508- if ( saveCancelled ) {
509- dismiss_saving_dialog ( ) ;
510- } else {
511- mark_saving_dialog_done ( startTime , nextAddress , totalBytesCompressed ) ;
512- }
513- FileSystem . closeFile ( openedFile ) ;
514- } else {
515- if ( ! self . writeError ) {
516- mspHelper . dataflashRead ( nextAddress , self . blockSize , onChunkRead ) ;
517- } else {
518- dismiss_saving_dialog ( ) ;
519- FileSystem . closeFile ( openedFile ) ;
520- }
521- }
522- } ) ;
523- } else {
524- // A zero-byte block indicates end-of-file, so we're done
525- mark_saving_dialog_done ( startTime , nextAddress , totalBytesCompressed ) ;
526- FileSystem . closeFile ( openedFile ) ;
527- }
528- } else {
529- // There was an error with the received block (address didn't match the one we asked for), retry
530- mspHelper . dataflashRead ( nextAddress , self . blockSize , onChunkRead ) ;
531- }
492+ function onChunkRead ( chunkAddress , chunkDataView , bytesCompressed ) {
493+ if ( chunkDataView !== null ) {
494+ // Did we receive any data?
495+ if ( chunkDataView . byteLength > 0 ) {
496+ nextAddress += chunkDataView . byteLength ;
497+ if ( isNaN ( bytesCompressed ) || isNaN ( totalBytesCompressed ) ) {
498+ totalBytesCompressed = null ;
499+ } else {
500+ totalBytesCompressed += bytesCompressed ;
501+ }
502+
503+ $ ( ".dataflash-saving progress" ) . attr ( "value" , ( nextAddress / maxBytes ) * 100 ) ;
504+
505+ const blob = new Blob ( [ chunkDataView ] ) ;
506+ FileSystem . writeChunk ( openedFile , blob ) . then ( ( ) => {
507+ if ( saveCancelled || nextAddress >= maxBytes ) {
508+ if ( saveCancelled ) {
509+ dismiss_saving_dialog ( ) ;
510+ } else {
511+ mark_saving_dialog_done ( startTime , nextAddress , totalBytesCompressed ) ;
512+ }
513+ FileSystem . closeFile ( openedFile ) ;
514+ } else {
515+ if ( ! self . writeError ) {
516+ mspHelper . dataflashRead ( nextAddress , self . blockSize , onChunkRead ) ;
517+ } else {
518+ dismiss_saving_dialog ( ) ;
519+ FileSystem . closeFile ( openedFile ) ;
532520 }
521+ }
522+ } ) ;
523+ } else {
524+ // A zero-byte block indicates end-of-file, so we're done
525+ mark_saving_dialog_done ( startTime , nextAddress , totalBytesCompressed ) ;
526+ FileSystem . closeFile ( openedFile ) ;
527+ }
528+ } else {
529+ // There was an error with the received block (address didn't match the one we asked for), skip it
530+ console . warn ( `Skipping block at address ${ nextAddress } due to CRC or mismatch` ) ;
531+ nextAddress += self . blockSize ;
532+
533+ if ( nextAddress >= maxBytes ) {
534+ mark_saving_dialog_done ( startTime , nextAddress , totalBytesCompressed ) ;
535+ FileSystem . closeFile ( openedFile ) ;
536+ } else {
537+ mspHelper . dataflashRead ( nextAddress , self . blockSize , onChunkRead ) ;
538+ }
539+ }
540+ }
533541
534- const startTime = new Date ( ) . getTime ( ) ;
542+ const startTime = new Date ( ) . getTime ( ) ;
535543 // Fetch the initial block
536544 FileSystem . openFile ( fileWriter ) . then ( ( file ) => {
537545 openedFile = file ;
0 commit comments