Browse Source

🐛 Fix RR collision with MM (#21902)

Scott Lahteine 4 years ago
parent
commit
a69e2923dd
No account linked to committer's email address
1 changed files with 50 additions and 45 deletions
  1. 50
    45
      Marlin/src/gcode/parser.cpp

+ 50
- 45
Marlin/src/gcode/parser.cpp View File

150
   #endif
150
   #endif
151
 
151
 
152
   /**
152
   /**
153
+   * Screen for good command letters.
154
+   * With Realtime Reporting, commands S000, P000, and R000 are allowed.
155
+   */
156
+  #if ENABLED(REALTIME_REPORTING_COMMANDS)
157
+    switch (letter) {
158
+      case 'P': case 'R' ... 'S': {
159
+        uint8_t digits = 0;
160
+        char *a = p;
161
+        while (*a++ == '0') digits++; // Count up '0' characters
162
+        if (digits == 3) {            // Three '0' digits is a good command
163
+          codenum = 0;
164
+          command_letter = letter;
165
+          return;
166
+        }
167
+      }
168
+    }
169
+  #endif
170
+
171
+  /**
153
    * Screen for good command letters. G, M, and T are always accepted.
172
    * Screen for good command letters. G, M, and T are always accepted.
154
    * With Motion Modes enabled any axis letter can come first.
173
    * With Motion Modes enabled any axis letter can come first.
155
-   * With Realtime Reporting, commands S000, P000, and R000 are allowed.
156
    */
174
    */
157
   switch (letter) {
175
   switch (letter) {
158
-    case 'G': case 'M': case 'T': TERN_(MARLIN_DEV_MODE, case 'D':)
176
+    case 'G': case 'M': case 'T': TERN_(MARLIN_DEV_MODE, case 'D':) {
159
       // Skip spaces to get the numeric part
177
       // Skip spaces to get the numeric part
160
       while (*p == ' ') p++;
178
       while (*p == ' ') p++;
161
 
179
 
177
       // A '?' signifies an unknown command
195
       // A '?' signifies an unknown command
178
       command_letter = letter;
196
       command_letter = letter;
179
 
197
 
180
-      {
181
-        #if ENABLED(SIGNED_CODENUM)
182
-          int sign = 1; // Allow for a negative code like D-1 or T-1
183
-          if (*p == '-') { sign = -1; ++p; }
184
-        #endif
198
+      #if ENABLED(SIGNED_CODENUM)
199
+        int sign = 1; // Allow for a negative code like D-1 or T-1
200
+        if (*p == '-') { sign = -1; ++p; }
201
+      #endif
185
 
202
 
186
-        // Get the code number - integer digits only
187
-        codenum = 0;
203
+      // Get the code number - integer digits only
204
+      codenum = 0;
188
 
205
 
189
-        do { codenum = codenum * 10 + *p++ - '0'; } while (NUMERIC(*p));
206
+      do { codenum = codenum * 10 + *p++ - '0'; } while (NUMERIC(*p));
190
 
207
 
191
-        // Apply the sign, if any
192
-        TERN_(SIGNED_CODENUM, codenum *= sign);
193
-      }
208
+      // Apply the sign, if any
209
+      TERN_(SIGNED_CODENUM, codenum *= sign);
194
 
210
 
195
       // Allow for decimal point in command
211
       // Allow for decimal point in command
196
       #if USE_GCODE_SUBCODES
212
       #if USE_GCODE_SUBCODES
213
         }
229
         }
214
       #endif
230
       #endif
215
 
231
 
216
-      break;
232
+      } break;
217
 
233
 
218
     #if ENABLED(GCODE_MOTION_MODES)
234
     #if ENABLED(GCODE_MOTION_MODES)
219
-      case 'I' ... 'J':
220
-        if (motion_mode_codenum != 5 && \
221
-            TERN1(ARC_SUPPORT, motion_mode_codenum != 2 && motion_mode_codenum != 3)) return;
222
-      case 'Q':
223
-        if (motion_mode_codenum != 5) return;
235
+
236
+      #if EITHER(BEZIER_CURVE_SUPPORT, ARC_SUPPORT)
237
+        case 'I' ... 'J': case 'P':
238
+          if (TERN1(BEZIER_CURVE_SUPPORT, motion_mode_codenum != 5)
239
+            && TERN1(ARC_P_CIRCLES, !WITHIN(motion_mode_codenum, 2, 3))
240
+          ) return;
241
+      #endif
242
+
243
+      #if ENABLED(BEZIER_CURVE_SUPPORT)
244
+        case 'Q': if (motion_mode_codenum != 5) return;
245
+      #endif
246
+
247
+      #if ENABLED(ARC_SUPPORT)
248
+        case 'R': if (!WITHIN(motion_mode_codenum, 2, 3)) return;
249
+      #endif
250
+
224
       case 'X' ... 'Z': case 'E' ... 'F':
251
       case 'X' ... 'Z': case 'E' ... 'F':
225
         if (motion_mode_codenum < 0) return;
252
         if (motion_mode_codenum < 0) return;
226
         command_letter = 'G';
253
         command_letter = 'G';
227
         codenum = motion_mode_codenum;
254
         codenum = motion_mode_codenum;
228
         TERN_(USE_GCODE_SUBCODES, subcode = motion_mode_subcode);
255
         TERN_(USE_GCODE_SUBCODES, subcode = motion_mode_subcode);
229
         p--; // Back up one character to use the current parameter
256
         p--; // Back up one character to use the current parameter
230
-      break;
231
-    #endif
257
+        break;
232
 
258
 
233
-    #if ENABLED(REALTIME_REPORTING_COMMANDS)
234
-      case 'P': case 'R': {
235
-        if (letter == 'R') {
236
-          #if ENABLED(GCODE_MOTION_MODES)
237
-            if (ENABLED(ARC_SUPPORT) && !WITHIN(motion_mode_codenum, 2, 3)) return;
238
-          #endif
239
-        }
240
-        else if (TERN0(GCODE_MOTION_MODES, motion_mode_codenum != 5)) return;
241
-      } // fall-thru
242
-      case 'S': {
243
-        codenum = 0;                  // The only valid codenum is 0
244
-        uint8_t digits = 0;
245
-        while (*p++ == '0') digits++; // Count up '0' characters
246
-        command_letter = (digits == 3) ? letter : '?'; // Three '0' digits is a good command
247
-      } return;                       // No parameters needed, so return now
248
     #endif
259
     #endif
249
 
260
 
250
     default: return;
261
     default: return;
252
 
263
 
253
   // The command parameters (if any) start here, for sure!
264
   // The command parameters (if any) start here, for sure!
254
 
265
 
255
-  #if DISABLED(FASTER_GCODE_PARSER)
256
-    command_args = p; // Scan for parameters in seen()
257
-  #endif
266
+  IF_DISABLED(FASTER_GCODE_PARSER, command_args = p); // Scan for parameters in seen()
258
 
267
 
259
   // Only use string_arg for these M codes
268
   // Only use string_arg for these M codes
260
   if (letter == 'M') switch (codenum) {
269
   if (letter == 'M') switch (codenum) {
261
-    #if ENABLED(GCODE_MACROS)
262
-      case 810 ... 819:
263
-    #endif
264
-    #if ENABLED(EXPECTED_PRINTER_CHECK)
265
-      case 16:
266
-    #endif
270
+    TERN_(GCODE_MACROS, case 810 ... 819:)
271
+    TERN_(EXPECTED_PRINTER_CHECK, case 16:)
267
     case 23: case 28: case 30: case 117 ... 118: case 928:
272
     case 23: case 28: case 30: case 117 ... 118: case 928:
268
       string_arg = unescape_string(p);
273
       string_arg = unescape_string(p);
269
       return;
274
       return;

Loading…
Cancel
Save