Przeglądaj źródła

Tweak process_line_done for speed

Scott Lahteine 4 lat temu
rodzic
commit
22b974691e
1 zmienionych plików z 11 dodań i 7 usunięć
  1. 11
    7
      Marlin/src/gcode/queue.cpp

+ 11
- 7
Marlin/src/gcode/queue.cpp Wyświetl plik

254
         SERIAL_ECHO(*p++);
254
         SERIAL_ECHO(*p++);
255
     }
255
     }
256
     SERIAL_ECHOPAIR_P(SP_P_STR, int(BLOCK_BUFFER_SIZE - planner.movesplanned() - 1));
256
     SERIAL_ECHOPAIR_P(SP_P_STR, int(BLOCK_BUFFER_SIZE - planner.movesplanned() - 1));
257
-    SERIAL_ECHOPAIR(" B", BUFSIZE - length);
257
+    SERIAL_ECHOPAIR(" B", int(BUFSIZE - length));
258
   #endif
258
   #endif
259
   SERIAL_EOL();
259
   SERIAL_EOL();
260
 }
260
 }
364
 inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind) {
364
 inline bool process_line_done(uint8_t &sis, char (&buff)[MAX_CMD_SIZE], int &ind) {
365
   sis = PS_NORMAL;
365
   sis = PS_NORMAL;
366
   buff[ind] = 0;
366
   buff[ind] = 0;
367
-  if (!ind) { thermalManager.manage_heater(); return true; }
368
-  ind = 0;
369
-  return false;
367
+  if (ind) { ind = 0; return false; }
368
+  thermalManager.manage_heater();
369
+  return true;
370
 }
370
 }
371
 
371
 
372
 /**
372
 /**
415
 
415
 
416
       if (serial_char == '\n' || serial_char == '\r') {
416
       if (serial_char == '\n' || serial_char == '\r') {
417
 
417
 
418
-        if (process_line_done(serial_input_state[i], serial_line_buffer[i], serial_count[i])) continue;
418
+        // Reset our state, continue if the line was empty
419
+        if (process_line_done(serial_input_state[i], serial_line_buffer[i], serial_count[i]))
420
+          continue;
419
 
421
 
420
         char* command = serial_line_buffer[i];
422
         char* command = serial_line_buffer[i];
421
 
423
 
422
-        while (*command == ' ') command++;                // Skip leading spaces
424
+        while (*command == ' ') command++;                   // Skip leading spaces
423
         char *npos = (*command == 'N') ? command : nullptr;  // Require the N parameter to start the line
425
         char *npos = (*command == 'N') ? command : nullptr;  // Require the N parameter to start the line
424
 
426
 
425
         if (npos) {
427
         if (npos) {
551
         else if (n < 0)
553
         else if (n < 0)
552
           SERIAL_ERROR_MSG(MSG_SD_ERR_READ);
554
           SERIAL_ERROR_MSG(MSG_SD_ERR_READ);
553
 
555
 
554
-        if (process_line_done(sd_input_state, command_buffer[index_w], sd_count)) continue;
556
+        // Terminate the buffer, reset the input state, continue for empty line
557
+        if (process_line_done(sd_input_state, command_buffer[index_w], sd_count))
558
+          continue;
555
 
559
 
556
         _commit_command(false);
560
         _commit_command(false);
557
 
561
 

Ładowanie…
Anuluj
Zapisz