diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 9a7c29094..6b36b64ed 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -138,6 +138,7 @@ * M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating * Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling * IF AUTOTEMP is enabled, S B F. Exit autotemp by any M109 without F + * M110 - Set the current line number * M111 - Set debug flags with S. See flag bits defined in Marlin.h. * M112 - Emergency stop * M114 - Output current position to serial port @@ -791,8 +792,17 @@ void get_command() { char *npos = strchr(command, 'N'); char *apos = strchr(command, '*'); if (npos) { + + boolean M110 = strstr_P(command, PSTR("M110")) != NULL; + + if (M110) { + char *n2pos = strchr(command + 4, 'N'); + if (n2pos) npos = n2pos; + } + gcode_N = strtol(npos + 1, NULL, 10); - if (gcode_N != gcode_LastN + 1 && strstr_P(command, PSTR("M110")) == NULL) { + + if (gcode_N != gcode_LastN + 1 && !M110) { gcode_line_error(PSTR(MSG_ERR_LINE_NO)); return; } @@ -807,7 +817,7 @@ void get_command() { } // if no errors, continue parsing } - else { + else if (npos == command) { gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM)); return; }