Browse Source

Fix M118 parameter handling

Fix #10388
Scott Lahteine 7 years ago
parent
commit
4c8751727a
2 changed files with 13 additions and 4 deletions
  1. 12
    3
      Marlin/src/gcode/host/M118.cpp
  2. 1
    1
      Marlin/src/gcode/parser.cpp

+ 12
- 3
Marlin/src/gcode/host/M118.cpp View File

29
  *  E1  Have the host 'echo:' the text
29
  *  E1  Have the host 'echo:' the text
30
  */
30
  */
31
 void GcodeSuite::M118() {
31
 void GcodeSuite::M118() {
32
-  if (parser.seenval('E') && parser.value_bool()) SERIAL_ECHO_START();
33
-  if (parser.seenval('A') && parser.value_bool()) SERIAL_ECHOPGM("// ");
34
-  SERIAL_ECHOLN(parser.string_arg);
32
+  bool hasE = false, hasA = false;
33
+  char *p = parser.string_arg;
34
+  for (uint8_t i = 2; i--;)
35
+    if ((p[0] == 'A' || p[0] == 'E') && p[1] == '1') {
36
+      if (p[0] == 'A') hasA = true;
37
+      if (p[0] == 'E') hasE = true;
38
+      p += 2;
39
+      while (*p == ' ') ++p;
40
+    }
41
+  if (hasE) SERIAL_ECHO_START();
42
+  if (hasA) SERIAL_ECHOPGM("// ");
43
+  SERIAL_ECHOLN(p);
35
 }
44
 }

+ 1
- 1
Marlin/src/gcode/parser.cpp View File

155
   #endif
155
   #endif
156
 
156
 
157
   // Only use string_arg for these M codes
157
   // Only use string_arg for these M codes
158
-  if (letter == 'M') switch (codenum) { case 23: case 28: case 30: case 117: case 928: string_arg = p; return; default: break; }
158
+  if (letter == 'M') switch (codenum) { case 23: case 28: case 30: case 117: case 118: case 928: string_arg = p; return; default: break; }
159
 
159
 
160
   #if ENABLED(DEBUG_GCODE_PARSER)
160
   #if ENABLED(DEBUG_GCODE_PARSER)
161
     const bool debug = codenum == 800;
161
     const bool debug = codenum == 800;

Loading…
Cancel
Save