diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 8397286d79..be0e4fe7b5 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -8779,9 +8779,18 @@ inline void gcode_M117() { lcd_setstatus(parser.string_arg); } * E1 Have the host 'echo:' the text */ inline void gcode_M118() { - if (parser.seenval('E') && parser.value_bool()) SERIAL_ECHO_START(); - if (parser.seenval('A') && parser.value_bool()) SERIAL_ECHOPGM("// "); - SERIAL_ECHOLN(parser.string_arg); + bool hasE = false, hasA = false; + char *p = parser.string_arg; + for (uint8_t i = 2; i--;) + if ((p[0] == 'A' || p[0] == 'E') && p[1] == '1') { + if (p[0] == 'A') hasA = true; + if (p[0] == 'E') hasE = true; + p += 2; + while (*p == ' ') ++p; + } + if (hasE) SERIAL_ECHO_START(); + if (hasA) SERIAL_ECHOPGM("// "); + SERIAL_ECHOLN(p); } /** diff --git a/Marlin/parser.cpp b/Marlin/parser.cpp index 9abaf1e09f..178583cad0 100644 --- a/Marlin/parser.cpp +++ b/Marlin/parser.cpp @@ -152,7 +152,7 @@ void GCodeParser::parse(char *p) { #endif // Only use string_arg for these M codes - if (letter == 'M') switch (codenum) { case 23: case 28: case 30: case 117: case 928: string_arg = p; return; default: break; } + if (letter == 'M') switch (codenum) { case 23: case 28: case 30: case 117: case 118: case 928: string_arg = p; return; default: break; } #if ENABLED(DEBUG_GCODE_PARSER) const bool debug = codenum == 800;