From 0ab0519c0178d9e3fb6016c2c98ae466ea8731ec Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 12 Jun 2018 14:35:25 +0200 Subject: [PATCH 1/4] power panic fix: short filenames --- Firmware/Marlin_main.cpp | 6 ++---- Firmware/ultralcd.cpp | 11 ++++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index ab1ce505..a74d3cac 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8631,7 +8631,7 @@ void restore_print_from_eeprom() { for (int i = 0; i < depth; i++) { for (int j = 0; j < 8; j++) { dir_name[j] = eeprom_read_byte((uint8_t*)EEPROM_DIRS + j + 8 * i); - + } dir_name[8] = '\0'; MYSERIAL.println(dir_name); @@ -8640,15 +8640,13 @@ void restore_print_from_eeprom() { for (int i = 0; i < 8; i++) { filename[i] = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i); - + } filename[8] = '\0'; MYSERIAL.print(filename); strcat_P(filename, PSTR(".gco")); sprintf_P(cmd, PSTR("M23 %s"), filename); - for (c = &cmd[4]; *c; c++) - *c = tolower(*c); enquecommand(cmd); uint32_t position = eeprom_read_dword((uint32_t*)(EEPROM_FILE_POSITION)); SERIAL_ECHOPGM("Position read from eeprom:"); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 1a222803..c92e4835 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7131,8 +7131,17 @@ static void menu_action_sdfile(const char* filename, char* longFilename) for (c = &cmd[4]; *c; 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++) { - 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(); From fb6f4c6c8fca05dac3b2a7961d6bb3f3619fe90c Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 12 Jun 2018 15:06:11 +0200 Subject: [PATCH 2/4] break --- Firmware/Marlin_main.cpp | 2 -- Firmware/ultralcd.cpp | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a74d3cac..bae9da80 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8631,7 +8631,6 @@ void restore_print_from_eeprom() { for (int i = 0; i < depth; i++) { for (int j = 0; j < 8; j++) { dir_name[j] = eeprom_read_byte((uint8_t*)EEPROM_DIRS + j + 8 * i); - } dir_name[8] = '\0'; MYSERIAL.println(dir_name); @@ -8640,7 +8639,6 @@ void restore_print_from_eeprom() { for (int i = 0; i < 8; i++) { filename[i] = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i); - } filename[8] = '\0'; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index c92e4835..9a059be3 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7138,6 +7138,7 @@ static void menu_action_sdfile(const char* filename, char* longFilename) 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'); + break; } else { eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, cmd[i + 4]); From 3ca7c82e081e75fdc352cda0d0e8340b96b9e866 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 12 Jun 2018 19:45:59 +0200 Subject: [PATCH 3/4] power panic: restore dir names --- Firmware/Marlin_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index bae9da80..2de07c70 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8634,6 +8634,7 @@ void restore_print_from_eeprom() { } dir_name[8] = '\0'; MYSERIAL.println(dir_name); + strcpy(dir_names[i], dir_name); card.chdir(dir_name); } From 1077895fd4ea65a8eb8db4405417653c30841bce Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 13 Jun 2018 18:22:58 +0200 Subject: [PATCH 4/4] Don't return "Not SD printing" in case that SD card print is paused --- Firmware/Marlin.h | 2 +- Firmware/cardreader.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 6139b945..a839ef9a 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -357,7 +357,7 @@ extern uint8_t print_percent_done_silent; extern uint16_t print_time_remaining_silent; #define PRINT_TIME_REMAINING_INIT 65535 #define PRINT_PERCENT_DONE_INIT 255 -#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == 4) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL)) +#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == 4) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused) extern void calculate_extruder_multipliers(); diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 6371339a..23d84dab 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -523,8 +523,11 @@ void CardReader::getStatus() SERIAL_PROTOCOL(itostr2(time%60)); SERIAL_PROTOCOLPGM("\n"); } + else if (paused) { + SERIAL_PROTOCOLLNPGM("SD print paused"); + } else if (saved_printing) { - SERIAL_PROTOCOLLNPGM("Print saved"); + SERIAL_PROTOCOLLNPGM("Print saved"); } else { SERIAL_PROTOCOLLNPGM("Not SD printing");