diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 9d93b8b542..d56169a9b5 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -262,6 +262,13 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { // Handle a known G, M, or T switch (parser.command_letter) { + #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) + case 'S': case 'P': case 'R': switch (parser.codenum) { + case 0: break; + default: parser.unknown_command_warning(); break; + } + break; + #endif case 'G': switch (parser.codenum) { case 0: case 1: G0_G1( // G0: Fast Move, G1: Linear Move diff --git a/Marlin/src/gcode/parser.cpp b/Marlin/src/gcode/parser.cpp index 298f98a696..98d687493d 100644 --- a/Marlin/src/gcode/parser.cpp +++ b/Marlin/src/gcode/parser.cpp @@ -155,10 +155,28 @@ void GCodeParser::parse(char *p) { #endif #endif + // Bail if the letter is not S, P, or R + #if ENABLED(FULL_REPORT_TO_HOST_FEATURE) + switch (letter) { + case 'S': case 'P': case 'R': + // Bail if there's no command code number + if (!NUMERIC(*p)) break; + // Save the command letter at this point + // A '?' signifies an unknown command + command_letter = letter; + // Get the code number - integer digits only + codenum = 0; + do { codenum *= 10, codenum += *p++ - '0'; } while (NUMERIC(*p)); + return; + + default: break; + } + #endif + + // Bail if the letter is not G, M, or T // (or a valid parameter for the current motion mode) - switch (letter) { - + switch (letter) { case 'G': case 'M': case 'T': #if ENABLED(CANCEL_OBJECTS) case 'O': @@ -216,7 +234,7 @@ void GCodeParser::parse(char *p) { #if ENABLED(GCODE_MOTION_MODES) #if ENABLED(ARC_SUPPORT) - case 'I': case 'J': case 'R': + case 'I': case 'J' : case 'R': if (motion_mode_codenum != 2 && motion_mode_codenum != 3) return; #endif case 'P': case 'Q':