Browse Source

Fix repeated power panic restarted print from beginning or jumped at most 65536 B back in file printed from SD card.

As sdpos_atomic was not updated after printer power up and first power panic recovery, it was equal 0. When the first command from SD card was queued its size on SD card was computed as current SD index position minus sdpos_atomic. This was equal to offset from beginning of the file limited to 16 bit storage type. When next power outage occurred earlier then this command was finished and wiped out of queue, this command size (extraordinarily big) was subtracted from sdpos_atomic and saved to EEPROM. This led to up to 65536 B jump back in file printed after next power panic recovery.
Marek Bel 4 years ago
parent
commit
52cb37770b
2 changed files with 6 additions and 2 deletions
  1. 4 2
      Firmware/Marlin_main.cpp
  2. 2 0
      Firmware/cmdqueue.h

+ 4 - 2
Firmware/Marlin_main.cpp

@@ -5343,7 +5343,9 @@ if(eSoundMode!=e_SOUND_MODE_SILENT)
     // ----------------------------------
     case 26: 
       if(card.cardOK && code_seen('S')) {
-        card.setIndex(code_value_long());
+        long index = code_value_long();
+        card.setIndex(index);
+        sdpos_atomic = index;
       }
       break;
 
@@ -9497,7 +9499,7 @@ void serialecho_temperatures() {
 	SERIAL_PROTOCOL_F(degBed(), 1);
 	SERIAL_PROTOCOLLN("");
 }
-extern uint32_t sdpos_atomic;
+
 #ifdef UVLO_SUPPORT
 
 void uvlo_()

+ 2 - 0
Firmware/cmdqueue.h

@@ -45,6 +45,8 @@ extern bool cmdbuffer_front_already_processed;
 // Debugging information will be sent to serial line.
 //#define CMDBUFFER_DEBUG
 
+extern uint32_t sdpos_atomic;
+
 extern int serial_count;
 extern boolean comment_mode;
 extern char *strchr_pointer;