소스 검색

Merge pull request #8197 from thinkyhead/bf2_asterisk_not_special

Allow asterisks in G-Code commands
Scott Lahteine 6 년 전
부모
커밋
32a9db3e93
No account linked to committer's email address
1개의 변경된 파일9개의 추가작업 그리고 16개의 파일을 삭제
  1. 9
    16
      Marlin/src/gcode/queue.cpp

+ 9
- 16
Marlin/src/gcode/queue.cpp 파일 보기

@@ -230,18 +230,17 @@ inline void get_serial_commands() {
230 230
      */
231 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 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 245
       if (npos) {
247 246
 
@@ -259,15 +258,14 @@ inline void get_serial_commands() {
259 258
           return;
260 259
         }
261 260
 
261
+        char *apos = strrchr(command, '*');
262 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 265
           if (strtol(apos + 1, NULL, 10) != checksum) {
267 266
             gcode_line_error(PSTR(MSG_ERR_CHECKSUM_MISMATCH));
268 267
             return;
269 268
           }
270
-          // if no errors, continue parsing
271 269
         }
272 270
         else {
273 271
           gcode_line_error(PSTR(MSG_ERR_NO_CHECKSUM));
@@ -275,11 +273,6 @@ inline void get_serial_commands() {
275 273
         }
276 274
 
277 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 278
       // Movement commands alert when stopped

Loading…
취소
저장