|
@@ -150,12 +150,30 @@ void GCodeParser::parse(char *p) {
|
150
|
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
|
172
|
* Screen for good command letters. G, M, and T are always accepted.
|
154
|
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
|
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
|
177
|
// Skip spaces to get the numeric part
|
160
|
178
|
while (*p == ' ') p++;
|
161
|
179
|
|
|
@@ -177,20 +195,18 @@ void GCodeParser::parse(char *p) {
|
177
|
195
|
// A '?' signifies an unknown command
|
178
|
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
|
211
|
// Allow for decimal point in command
|
196
|
212
|
#if USE_GCODE_SUBCODES
|
|
@@ -213,38 +229,33 @@ void GCodeParser::parse(char *p) {
|
213
|
229
|
}
|
214
|
230
|
#endif
|
215
|
231
|
|
216
|
|
- break;
|
|
232
|
+ } break;
|
217
|
233
|
|
218
|
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
|
251
|
case 'X' ... 'Z': case 'E' ... 'F':
|
225
|
252
|
if (motion_mode_codenum < 0) return;
|
226
|
253
|
command_letter = 'G';
|
227
|
254
|
codenum = motion_mode_codenum;
|
228
|
255
|
TERN_(USE_GCODE_SUBCODES, subcode = motion_mode_subcode);
|
229
|
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
|
259
|
#endif
|
249
|
260
|
|
250
|
261
|
default: return;
|
|
@@ -252,18 +263,12 @@ void GCodeParser::parse(char *p) {
|
252
|
263
|
|
253
|
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
|
268
|
// Only use string_arg for these M codes
|
260
|
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
|
272
|
case 23: case 28: case 30: case 117 ... 118: case 928:
|
268
|
273
|
string_arg = unescape_string(p);
|
269
|
274
|
return;
|