From 3f91233f6df84d46fd9bdcb0ea38ceeb6d983623 Mon Sep 17 00:00:00 2001 From: jeffstaley Date: Fri, 25 Jan 2019 07:36:52 -0800 Subject: [PATCH 1/3] M29 logic was reversed If in card-saving mode generate errors line errors for anything that's *NOT* "M29 ?" --- Marlin/src/gcode/queue.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index b0389848cf..1dceb2243e 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -630,7 +630,8 @@ inline void get_serial_commands() { gcode_LastN = gcode_N; } #if ENABLED(SDSUPPORT) - else if (card.flag.saving && command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' ')) + // Pronterface "M29" and "M29 " has no line number + else if (card.flag.saving && !(command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' '))) return gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM), i); #endif From a49f0205eae59dc0d0bb1a18d311a5dd4dc4d61e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 4 Feb 2019 07:11:08 -0600 Subject: [PATCH 2/3] Update queue.cpp --- Marlin/src/gcode/queue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 1dceb2243e..092b94c78e 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -631,7 +631,7 @@ inline void get_serial_commands() { } #if ENABLED(SDSUPPORT) // Pronterface "M29" and "M29 " has no line number - else if (card.flag.saving && !(command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' '))) + else if (card.flag.saving && !(command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' ' || || command[3] == '*'))) return gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM), i); #endif @@ -840,7 +840,7 @@ void advance_command_queue() { if (card.flag.saving) { char* command = command_queue[cmd_queue_index_r]; - if (command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' ')) { + if (command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' ' || || command[3] == '*')) { // M29 closes the file card.closefile(); SERIAL_ECHOLNPGM(MSG_FILE_SAVED); From c03bac9ad4d5a32b0c20054ae81998e5a3786af1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 4 Feb 2019 07:17:40 -0600 Subject: [PATCH 3/3] Update queue.cpp --- Marlin/src/gcode/queue.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/queue.cpp b/Marlin/src/gcode/queue.cpp index 092b94c78e..9742bcb161 100644 --- a/Marlin/src/gcode/queue.cpp +++ b/Marlin/src/gcode/queue.cpp @@ -535,6 +535,10 @@ static int read_serial(const uint8_t index) { #endif // FAST_FILE_TRANSFER +FORCE_INLINE bool is_M29(const char * const cmd) { + return cmd[0] == 'M' && cmd[1] == '2' && cmd[2] == '9' && !WITHIN(cmd[3], '0', '9'); +} + /** * Get all commands waiting on the serial port and queue them. * Exit when the buffer is full or when no more characters are @@ -631,7 +635,7 @@ inline void get_serial_commands() { } #if ENABLED(SDSUPPORT) // Pronterface "M29" and "M29 " has no line number - else if (card.flag.saving && !(command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' ' || || command[3] == '*'))) + else if (card.flag.saving && !is_M29(command)) return gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM), i); #endif @@ -840,7 +844,7 @@ void advance_command_queue() { if (card.flag.saving) { char* command = command_queue[cmd_queue_index_r]; - if (command[0] == 'M' && command[1] == '2' && command[2] == '9' && (command[3] == '\0' || command[3] == ' ' || || command[3] == '*')) { + if (is_M29(command)) { // M29 closes the file card.closefile(); SERIAL_ECHOLNPGM(MSG_FILE_SAVED);