Browse Source

Merge pull request #3044 from thinkyhead/rc_gcode_spaces

Fix GCode handling of spaces between command letter and first digit
Scott Lahteine 9 years ago
parent
commit
d118e3f985
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      Marlin/Marlin_main.cpp

+ 6
- 4
Marlin/Marlin_main.cpp View File

5704
   // Get the command code, which must be G, M, or T
5704
   // Get the command code, which must be G, M, or T
5705
   char command_code = *current_command;
5705
   char command_code = *current_command;
5706
 
5706
 
5707
+  // Skip the letter-code and spaces to get the numeric part
5708
+  current_command_args = current_command + 1;
5709
+  while (*current_command_args == ' ') ++current_command_args;
5710
+
5707
   // The code must have a numeric value
5711
   // The code must have a numeric value
5708
-  bool code_is_good = (current_command[1] >= '0' && current_command[1] <= '9');
5712
+  bool code_is_good = (*current_command_args >= '0' && *current_command_args <= '9');
5709
 
5713
 
5710
   int codenum; // define ahead of goto
5714
   int codenum; // define ahead of goto
5711
 
5715
 
5714
 
5718
 
5715
   // Args pointer optimizes code_seen, especially those taking XYZEF
5719
   // Args pointer optimizes code_seen, especially those taking XYZEF
5716
   // This wastes a little cpu on commands that expect no arguments.
5720
   // This wastes a little cpu on commands that expect no arguments.
5717
-  current_command_args = current_command+2; // skip two chars for command code and first digit
5718
-  while (*current_command_args >= '0' && *current_command_args <= '9') ++current_command_args;
5719
-  while (*current_command_args == ' ') ++current_command_args;
5721
+  while (*current_command_args == ' ' || (*current_command_args >= '0' && *current_command_args <= '9')) ++current_command_args;
5720
 
5722
 
5721
   // Interpret the code int
5723
   // Interpret the code int
5722
   seen_pointer = current_command;
5724
   seen_pointer = current_command;

Loading…
Cancel
Save