From 6a4f06d35d518a33cb48099da499c6f2c7631ef8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 25 Feb 2016 22:50:09 -0800 Subject: [PATCH] Fix GCode handling of spaces between command letter and first digit --- Marlin/Marlin_main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index eb0e8fe3ce..d985b15dbd 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -5704,8 +5704,12 @@ void process_next_command() { // Get the command code, which must be G, M, or T char command_code = *current_command; + // Skip the letter-code and spaces to get the numeric part + current_command_args = current_command + 1; + while (*current_command_args == ' ') ++current_command_args; + // The code must have a numeric value - bool code_is_good = (current_command[1] >= '0' && current_command[1] <= '9'); + bool code_is_good = (*current_command_args >= '0' && *current_command_args <= '9'); int codenum; // define ahead of goto @@ -5714,9 +5718,7 @@ void process_next_command() { // Args pointer optimizes code_seen, especially those taking XYZEF // This wastes a little cpu on commands that expect no arguments. - current_command_args = current_command+2; // skip two chars for command code and first digit - while (*current_command_args >= '0' && *current_command_args <= '9') ++current_command_args; - while (*current_command_args == ' ') ++current_command_args; + while (*current_command_args == ' ' || (*current_command_args >= '0' && *current_command_args <= '9')) ++current_command_args; // Interpret the code int seen_pointer = current_command;