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.
This commit is contained in:
Marek Bel 2019-08-23 19:27:58 +02:00
parent 5bb510dd2a
commit 52cb37770b
2 changed files with 6 additions and 2 deletions

View File

@ -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_()

View File

@ -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;