power panic fix: short filenames

This commit is contained in:
PavelSindler 2018-06-12 14:35:25 +02:00
parent 73b0c65bda
commit 0ab0519c01
2 changed files with 12 additions and 5 deletions

View File

@ -8647,8 +8647,6 @@ void restore_print_from_eeprom() {
MYSERIAL.print(filename); MYSERIAL.print(filename);
strcat_P(filename, PSTR(".gco")); strcat_P(filename, PSTR(".gco"));
sprintf_P(cmd, PSTR("M23 %s"), filename); sprintf_P(cmd, PSTR("M23 %s"), filename);
for (c = &cmd[4]; *c; c++)
*c = tolower(*c);
enquecommand(cmd); enquecommand(cmd);
uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION)); uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION));
SERIAL_ECHOPGM("Position read from eeprom:"); SERIAL_ECHOPGM("Position read from eeprom:");

View File

@ -7131,8 +7131,17 @@ static void menu_action_sdfile(const char* filename, char* longFilename)
for (c = &cmd[4]; *c; c++) for (c = &cmd[4]; *c; c++)
*c = tolower(*c); *c = tolower(*c);
const char end[5] = ".gco";
//we are storing just first 8 characters of 8.3 filename assuming that extension is always ".gco"
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, filename[i]); if (strcmp((cmd + i + 4), end) == 0) {
//filename is shorter then 8.3, store '\0' character on position where ".gco" string was found to terminate stored string properly
eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, '\0');
}
else {
eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, cmd[i + 4]);
}
} }
uint8_t depth = (uint8_t)card.getWorkDirDepth(); uint8_t depth = (uint8_t)card.getWorkDirDepth();