Browse Source

Merge pull request #8197 from thinkyhead/bf2_asterisk_not_special

Allow asterisks in G-Code commands
Scott Lahteine 6 years ago
parent
commit
32a9db3e93
No account linked to committer's email address
1 changed files with 9 additions and 16 deletions
  1. 9
    16
      Marlin/src/gcode/queue.cpp

+ 9
- 16
Marlin/src/gcode/queue.cpp View File

230
      */
230
      */
231
     if (serial_char == '\n' || serial_char == '\r') {
231
     if (serial_char == '\n' || serial_char == '\r') {
232
 
232
 
233
-      serial_comment_mode = false; // end of line == end of comment
233
+      serial_comment_mode = false;                      // end of line == end of comment
234
 
234
 
235
-      if (!serial_count) continue; // skip empty lines
235
+      if (!serial_count) continue;                      // Skip empty lines
236
 
236
 
237
-      serial_line_buffer[serial_count] = 0; // terminate string
238
-      serial_count = 0; //reset buffer
237
+      serial_line_buffer[serial_count] = 0;             // Terminate string
238
+      serial_count = 0;                                 // Reset buffer
239
 
239
 
240
       char* command = serial_line_buffer;
240
       char* command = serial_line_buffer;
241
 
241
 
242
-      while (*command == ' ') command++; // skip any leading spaces
243
-      char *npos = (*command == 'N') ? command : NULL, // Require the N parameter to start the line
244
-           *apos = strchr(command, '*');
242
+      while (*command == ' ') command++;                // Skip leading spaces
243
+      char *npos = (*command == 'N') ? command : NULL;  // Require the N parameter to start the line
245
 
244
 
246
       if (npos) {
245
       if (npos) {
247
 
246
 
259
           return;
258
           return;
260
         }
259
         }
261
 
260
 
261
+        char *apos = strrchr(command, '*');
262
         if (apos) {
262
         if (apos) {
263
-          byte checksum = 0, count = 0;
264
-          while (command[count] != '*') checksum ^= command[count++];
265
-
263
+          uint8_t checksum = 0, count = uint8_t(apos - command);
264
+          while (count) checksum ^= command[--count];
266
           if (strtol(apos + 1, NULL, 10) != checksum) {
265
           if (strtol(apos + 1, NULL, 10) != checksum) {
267
             gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH));
266
             gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH));
268
             return;
267
             return;
269
           }
268
           }
270
-          // if no errors, continue parsing
271
         }
269
         }
272
         else {
270
         else {
273
           gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
271
           gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
275
         }
273
         }
276
 
274
 
277
         gcode_LastN = gcode_N;
275
         gcode_LastN = gcode_N;
278
-        // if no errors, continue parsing
279
-      }
280
-      else if (apos) { // No '*' without 'N'
281
-        gcode_line_error(PSTR(MSG_ERR_NO_LINENUMBER_WITH_CHECKSUM), false);
282
-        return;
283
       }
276
       }
284
 
277
 
285
       // Movement commands alert when stopped
278
       // Movement commands alert when stopped

Loading…
Cancel
Save