Browse Source

Use a separate serial line buffer

Scott Lahteine 8 years ago
parent
commit
8fe7420310
6 changed files with 119 additions and 105 deletions
  1. 2
    2
      Marlin/Marlin.h
  2. 99
    86
      Marlin/Marlin_main.cpp
  3. 10
    5
      Marlin/cardreader.cpp
  4. 1
    0
      Marlin/cardreader.h
  5. 1
    1
      Marlin/stepper.cpp
  6. 6
    11
      Marlin/ultralcd.cpp

+ 2
- 2
Marlin/Marlin.h View File

223
 inline bool IsRunning() { return  Running; }
223
 inline bool IsRunning() { return  Running; }
224
 inline bool IsStopped() { return !Running; }
224
 inline bool IsStopped() { return !Running; }
225
 
225
 
226
-bool enqueuecommand(const char* cmd); //put a single ASCII command at the end of the current buffer or return false when it is full
227
-void enqueuecommands_P(const char* cmd); //put one or many ASCII commands at the end of the current buffer, read from flash
226
+bool enqueue_and_echo_command(const char* cmd, bool say_ok=false); //put a single ASCII command at the end of the current buffer or return false when it is full
227
+void enqueue_and_echo_commands_P(const char* cmd); //put one or many ASCII commands at the end of the current buffer, read from flash
228
 
228
 
229
 void prepare_arc_move(char isclockwise);
229
 void prepare_arc_move(char isclockwise);
230
 void clamp_to_software_endstops(float target[3]);
230
 void clamp_to_software_endstops(float target[3]);

+ 99
- 86
Marlin/Marlin_main.cpp View File

276
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
276
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
277
 
277
 
278
 static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
278
 static bool relative_mode = false;  //Determines Absolute or Relative Coordinates
279
-static char serial_char;
280
 static int serial_count = 0;
279
 static int serial_count = 0;
281
-static boolean comment_mode = false;
282
 static char* seen_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
280
 static char* seen_pointer; ///< A pointer to find chars in the command string (X, Y, Z, E, etc.)
283
 const char* queued_commands_P = NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
281
 const char* queued_commands_P = NULL; /* pointer to the current line in the active sequence of commands, or NULL when none */
284
 const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
282
 const int sensitive_pins[] = SENSITIVE_PINS; ///< Sensitive pin list for M42
409
   static bool filrunoutEnqueued = false;
407
   static bool filrunoutEnqueued = false;
410
 #endif
408
 #endif
411
 
409
 
412
-#if ENABLED(SDSUPPORT)
413
-  static bool fromsd[BUFSIZE];
414
-#endif
410
+static bool send_ok[BUFSIZE];
415
 
411
 
416
 #if HAS_SERVOS
412
 #if HAS_SERVOS
417
   Servo servo[NUM_SERVOS];
413
   Servo servo[NUM_SERVOS];
483
   char c;
479
   char c;
484
   while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
480
   while ((c = cmd[i]) && c != '\n') i++; // find the end of this gcode command
485
   cmd[i] = '\0';
481
   cmd[i] = '\0';
486
-  if (enqueuecommand(cmd)) {      // buffer was not full (else we will retry later)
482
+  if (enqueue_and_echo_command(cmd)) {      // buffer was not full (else we will retry later)
487
     if (c)
483
     if (c)
488
       queued_commands_P += i + 1; // move to next command
484
       queued_commands_P += i + 1; // move to next command
489
     else
485
     else
497
  * Aborts the current queue, if any.
493
  * Aborts the current queue, if any.
498
  * Note: drain_queued_commands_P() must be called repeatedly to drain the commands afterwards
494
  * Note: drain_queued_commands_P() must be called repeatedly to drain the commands afterwards
499
  */
495
  */
500
-void enqueuecommands_P(const char* pgcode) {
496
+void enqueue_and_echo_commands_P(const char* pgcode) {
501
   queued_commands_P = pgcode;
497
   queued_commands_P = pgcode;
502
   drain_queued_commands_P(); // first command executed asap (when possible)
498
   drain_queued_commands_P(); // first command executed asap (when possible)
503
 }
499
 }
504
 
500
 
505
 /**
501
 /**
506
- * Copy a command directly into the main command buffer, from RAM.
507
- *
508
- * This is done in a non-safe way and needs a rework someday.
509
- * Returns false if it doesn't add any command
502
+ * Once a new command is in the ring buffer, call this to commit it
510
  */
503
  */
511
-bool enqueuecommand(const char* cmd) {
512
-  if (*cmd == ';' || commands_in_queue >= BUFSIZE) return false;
513
-
514
-  // This is dangerous if a mixing of serial and this happens
515
-  char* command = command_queue[cmd_queue_index_w];
516
-  strcpy(command, cmd);
517
-  SERIAL_ECHO_START;
518
-  SERIAL_ECHOPGM(MSG_Enqueueing);
519
-  SERIAL_ECHO(command);
520
-  SERIAL_ECHOLNPGM("\"");
504
+inline void _commit_command(bool say_ok) {
505
+  send_ok[cmd_queue_index_w] = say_ok;
521
   cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
506
   cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
522
   commands_in_queue++;
507
   commands_in_queue++;
508
+}
509
+
510
+/**
511
+ * Copy a command directly into the main command buffer, from RAM.
512
+ * Returns true if successfully adds the command
513
+ */
514
+inline bool _enqueuecommand(const char* cmd, bool say_ok=false) {
515
+  if (*cmd == ';' || commands_in_queue >= BUFSIZE) return false;
516
+  strcpy(command_queue[cmd_queue_index_w], cmd);
517
+  _commit_command(say_ok);
523
   return true;
518
   return true;
524
 }
519
 }
525
 
520
 
521
+/**
522
+ * Enqueue with Serial Echo
523
+ */
524
+bool enqueue_and_echo_command(const char* cmd, bool say_ok/*=false*/) {
525
+  if (_enqueuecommand(cmd, say_ok)) {
526
+    SERIAL_ECHO_START;
527
+    SERIAL_ECHOPGM(MSG_Enqueueing);
528
+    SERIAL_ECHO(cmd);
529
+    SERIAL_ECHOLNPGM("\"");
530
+    return true;
531
+  }
532
+  return false;
533
+}
534
+
526
 void setup_killpin() {
535
 void setup_killpin() {
527
   #if HAS_KILL
536
   #if HAS_KILL
528
     SET_INPUT(KILL_PIN);
537
     SET_INPUT(KILL_PIN);
679
   SERIAL_ECHOPGM(MSG_PLANNER_BUFFER_BYTES);
688
   SERIAL_ECHOPGM(MSG_PLANNER_BUFFER_BYTES);
680
   SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
689
   SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
681
 
690
 
682
-  #if ENABLED(SDSUPPORT)
683
-    for (int8_t i = 0; i < BUFSIZE; i++) fromsd[i] = false;
684
-  #endif
691
+  // Send "ok" after commands by default
692
+  for (int8_t i = 0; i < BUFSIZE; i++) send_ok[i] = true;
685
 
693
 
686
   // loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
694
   // loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
687
   Config_RetrieveSettings();
695
   Config_RetrieveSettings();
740
  *  - Call LCD update
748
  *  - Call LCD update
741
  */
749
  */
742
 void loop() {
750
 void loop() {
743
-  if (commands_in_queue < BUFSIZE - 1) get_command();
751
+  if (commands_in_queue < BUFSIZE) get_command();
744
 
752
 
745
   #if ENABLED(SDSUPPORT)
753
   #if ENABLED(SDSUPPORT)
746
     card.checkautostart(false);
754
     card.checkautostart(false);
800
  */
808
  */
801
 void get_command() {
809
 void get_command() {
802
 
810
 
811
+  static char serial_line_buffer[MAX_CMD_SIZE];
812
+  static boolean serial_comment_mode = false;
813
+
803
   if (drain_queued_commands_P()) return; // priority is given to non-serial commands
814
   if (drain_queued_commands_P()) return; // priority is given to non-serial commands
804
 
815
 
805
-  #if ENABLED(NO_TIMEOUTS)
816
+  #if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
806
     static millis_t last_command_time = 0;
817
     static millis_t last_command_time = 0;
807
     millis_t ms = millis();
818
     millis_t ms = millis();
808
 
819
 
817
   //
828
   //
818
   while (commands_in_queue < BUFSIZE && MYSERIAL.available() > 0) {
829
   while (commands_in_queue < BUFSIZE && MYSERIAL.available() > 0) {
819
 
830
 
820
-    #if ENABLED(NO_TIMEOUTS)
821
-      last_command_time = ms;
822
-    #endif
823
-
824
-    serial_char = MYSERIAL.read();
831
+    char serial_char = MYSERIAL.read();
825
 
832
 
826
     //
833
     //
827
-    // If the character ends the line, or the line is full...
834
+    // If the character ends the line
828
     //
835
     //
829
-    if (serial_char == '\n' || serial_char == '\r' || serial_count >= MAX_CMD_SIZE - 1) {
836
+    if (serial_char == '\n' || serial_char == '\r') {
830
 
837
 
831
-      // end of line == end of comment
832
-      comment_mode = false;
838
+      serial_comment_mode = false; // end of line == end of comment
833
 
839
 
834
       if (!serial_count) return; // empty lines just exit
840
       if (!serial_count) return; // empty lines just exit
835
 
841
 
836
-      char* command = command_queue[cmd_queue_index_w];
837
-      command[serial_count] = 0; // terminate string
842
+      serial_line_buffer[serial_count] = 0; // terminate string
843
+      serial_count = 0; //reset buffer
838
 
844
 
839
-      // this item in the queue is not from sd
840
-      #if ENABLED(SDSUPPORT)
841
-        fromsd[cmd_queue_index_w] = false;
842
-      #endif
845
+      char* command = serial_line_buffer;
843
 
846
 
844
       while (*command == ' ') command++; // skip any leading spaces
847
       while (*command == ' ') command++; // skip any leading spaces
845
       char* npos = (*command == 'N') ? command : NULL; // Require the N parameter to start the line
848
       char* npos = (*command == 'N') ? command : NULL; // Require the N parameter to start the line
904
       // If command was e-stop process now
907
       // If command was e-stop process now
905
       if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
908
       if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
906
 
909
 
907
-      cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
908
-      commands_in_queue += 1;
910
+      #if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
911
+        last_command_time = ms;
912
+      #endif
909
 
913
 
910
-      serial_count = 0; //clear buffer
914
+      // Add the command to the queue
915
+      _enqueuecommand(serial_line_buffer, true);
916
+    }
917
+    else if (serial_count >= MAX_CMD_SIZE - 1) {
918
+      // Keep fetching, but ignore normal characters beyond the max length
919
+      // The command will be injected when EOL is reached
911
     }
920
     }
912
     else if (serial_char == '\\') {  // Handle escapes
921
     else if (serial_char == '\\') {  // Handle escapes
913
-      if (MYSERIAL.available() > 0 && commands_in_queue < BUFSIZE) {
922
+      if (MYSERIAL.available() > 0) {
914
         // if we have one more character, copy it over
923
         // if we have one more character, copy it over
915
         serial_char = MYSERIAL.read();
924
         serial_char = MYSERIAL.read();
916
-        command_queue[cmd_queue_index_w][serial_count++] = serial_char;
925
+        serial_line_buffer[serial_count++] = serial_char;
917
       }
926
       }
918
       // otherwise do nothing
927
       // otherwise do nothing
919
     }
928
     }
920
-    else { // its not a newline, carriage return or escape char
921
-      if (serial_char == ';') comment_mode = true;
922
-      if (!comment_mode) command_queue[cmd_queue_index_w][serial_count++] = serial_char;
929
+    else { // it's not a newline, carriage return or escape char
930
+      if (serial_char == ';') serial_comment_mode = true;
931
+      if (!serial_comment_mode) serial_line_buffer[serial_count++] = serial_char;
923
     }
932
     }
924
-  }
933
+
934
+  } // queue has space, serial has data
925
 
935
 
926
   #if ENABLED(SDSUPPORT)
936
   #if ENABLED(SDSUPPORT)
927
 
937
 
928
-    if (!card.sdprinting || serial_count) return;
938
+    static bool stop_buffering = false,
939
+                sd_comment_mode = false;
940
+
941
+    if (!card.sdprinting) return;
929
 
942
 
930
     // '#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
943
     // '#' stops reading from SD to the buffer prematurely, so procedural macro calls are possible
931
-    // if it occurs, stop_buffering is triggered and the buffer is ran dry.
944
+    // if it occurs, stop_buffering is triggered and the buffer is run dry.
932
     // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
945
     // this character _can_ occur in serial com, due to checksums. however, no checksums are used in SD printing
933
 
946
 
934
-    static bool stop_buffering = false;
935
     if (commands_in_queue == 0) stop_buffering = false;
947
     if (commands_in_queue == 0) stop_buffering = false;
936
 
948
 
937
-    while (!card.eof() && commands_in_queue < BUFSIZE && !stop_buffering) {
949
+    uint16_t sd_count = 0;
950
+    bool card_eof = card.eof();
951
+    while (commands_in_queue < BUFSIZE && !card_eof && !stop_buffering) {
938
       int16_t n = card.get();
952
       int16_t n = card.get();
939
-      serial_char = (char)n;
940
-      if (serial_char == '\n' || serial_char == '\r' ||
941
-          ((serial_char == '#' || serial_char == ':') && !comment_mode) ||
942
-          serial_count >= (MAX_CMD_SIZE - 1) || n == -1
953
+      char sd_char = (char)n;
954
+      card_eof = card.eof();
955
+      if (card_eof || n == -1
956
+          || sd_char == '\n' || sd_char == '\r'
957
+          || ((sd_char == '#' || sd_char == ':') && !sd_comment_mode)
943
       ) {
958
       ) {
944
-        if (card.eof()) {
959
+        if (card_eof) {
945
           SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
960
           SERIAL_PROTOCOLLNPGM(MSG_FILE_PRINTED);
946
           print_job_stop_ms = millis();
961
           print_job_stop_ms = millis();
947
           char time[30];
962
           char time[30];
954
           card.printingHasFinished();
969
           card.printingHasFinished();
955
           card.checkautostart(true);
970
           card.checkautostart(true);
956
         }
971
         }
957
-        if (serial_char == '#') stop_buffering = true;
972
+        if (sd_char == '#') stop_buffering = true;
958
 
973
 
959
-        if (!serial_count) {
960
-          comment_mode = false; //for new command
961
-          return; //if empty line
962
-        }
963
-        command_queue[cmd_queue_index_w][serial_count] = 0; //terminate string
964
-        // if (!comment_mode) {
965
-        fromsd[cmd_queue_index_w] = true;
966
-        commands_in_queue += 1;
967
-        cmd_queue_index_w = (cmd_queue_index_w + 1) % BUFSIZE;
968
-        // }
969
-        comment_mode = false; //for new command
970
-        serial_count = 0; //clear buffer
974
+        sd_comment_mode = false; //for new command
975
+
976
+        if (!sd_count) continue; //skip empty lines
977
+
978
+        command_queue[cmd_queue_index_w][sd_count] = '\0'; //terminate string
979
+        sd_count = 0; //clear buffer
980
+
981
+        _commit_command(false);
982
+      }
983
+      else if (sd_count >= MAX_CMD_SIZE - 1) {
984
+        // Keep fetching, but ignore normal characters beyond the max length
985
+        // The command will be injected when EOL is reached
971
       }
986
       }
972
       else {
987
       else {
973
-        if (serial_char == ';') comment_mode = true;
974
-        if (!comment_mode) command_queue[cmd_queue_index_w][serial_count++] = serial_char;
988
+        if (sd_char == ';') sd_comment_mode = true;
989
+        if (!sd_comment_mode) command_queue[cmd_queue_index_w][sd_count++] = sd_char;
975
       }
990
       }
976
     }
991
     }
977
 
992
 
2654
       case MeshStart:
2669
       case MeshStart:
2655
         mbl.reset();
2670
         mbl.reset();
2656
         probe_point = 0;
2671
         probe_point = 0;
2657
-        enqueuecommands_P(PSTR("G28\nG29 S2"));
2672
+        enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
2658
         break;
2673
         break;
2659
 
2674
 
2660
       case MeshNext:
2675
       case MeshNext:
2693
           SERIAL_PROTOCOLLNPGM("Mesh probing done.");
2708
           SERIAL_PROTOCOLLNPGM("Mesh probing done.");
2694
           probe_point = -1;
2709
           probe_point = -1;
2695
           mbl.active = 1;
2710
           mbl.active = 1;
2696
-          enqueuecommands_P(PSTR("G28"));
2711
+          enqueue_and_echo_commands_P(PSTR("G28"));
2697
         }
2712
         }
2698
         break;
2713
         break;
2699
 
2714
 
3215
           SERIAL_ECHOLNPGM(Z_PROBE_END_SCRIPT);
3230
           SERIAL_ECHOLNPGM(Z_PROBE_END_SCRIPT);
3216
         }
3231
         }
3217
       #endif
3232
       #endif
3218
-      enqueuecommands_P(PSTR(Z_PROBE_END_SCRIPT));
3233
+      enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
3219
       st_synchronize();
3234
       st_synchronize();
3220
     #endif
3235
     #endif
3221
 
3236
 
3374
   }
3389
   }
3375
 
3390
 
3376
   /**
3391
   /**
3377
-   * M23: Select a file
3392
+   * M23: Open a file
3378
    */
3393
    */
3379
   inline void gcode_M23() {
3394
   inline void gcode_M23() {
3380
     card.openFile(current_command_args, true);
3395
     card.openFile(current_command_args, true);
5244
         SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
5259
         SERIAL_ERRORLNPGM(MSG_ERR_M428_TOO_FAR);
5245
         LCD_ALERTMESSAGEPGM("Err: Too far!");
5260
         LCD_ALERTMESSAGEPGM("Err: Too far!");
5246
         #if HAS_BUZZER
5261
         #if HAS_BUZZER
5247
-          enqueuecommands_P(PSTR("M300 S40 P200"));
5262
+          enqueue_and_echo_commands_P(PSTR("M300 S40 P200"));
5248
         #endif
5263
         #endif
5249
         err = true;
5264
         err = true;
5250
         break;
5265
         break;
5258
     sync_plan_position();
5273
     sync_plan_position();
5259
     LCD_ALERTMESSAGEPGM("Offset applied.");
5274
     LCD_ALERTMESSAGEPGM("Offset applied.");
5260
     #if HAS_BUZZER
5275
     #if HAS_BUZZER
5261
-      enqueuecommands_P(PSTR("M300 S659 P200\nM300 S698 P200"));
5276
+      enqueue_and_echo_commands_P(PSTR("M300 S659 P200\nM300 S698 P200"));
5262
     #endif
5277
     #endif
5263
   }
5278
   }
5264
 }
5279
 }
6304
 
6319
 
6305
 void ok_to_send() {
6320
 void ok_to_send() {
6306
   refresh_cmd_timeout();
6321
   refresh_cmd_timeout();
6307
-  #if ENABLED(SDSUPPORT)
6308
-    if (fromsd[cmd_queue_index_r]) return;
6309
-  #endif
6322
+  if (!send_ok[cmd_queue_index_r]) return;
6310
   SERIAL_PROTOCOLPGM(MSG_OK);
6323
   SERIAL_PROTOCOLPGM(MSG_OK);
6311
   #if ENABLED(ADVANCED_OK)
6324
   #if ENABLED(ADVANCED_OK)
6312
     char* p = command_queue[cmd_queue_index_r];
6325
     char* p = command_queue[cmd_queue_index_r];
6997
       filrunout();
7010
       filrunout();
6998
   #endif
7011
   #endif
6999
 
7012
 
7000
-  if (commands_in_queue < BUFSIZE - 1) get_command();
7013
+  if (commands_in_queue < BUFSIZE) get_command();
7001
 
7014
 
7002
   millis_t ms = millis();
7015
   millis_t ms = millis();
7003
 
7016
 
7054
     const int HOME_DEBOUNCE_DELAY = 2500;
7067
     const int HOME_DEBOUNCE_DELAY = 2500;
7055
     if (!READ(HOME_PIN)) {
7068
     if (!READ(HOME_PIN)) {
7056
       if (!homeDebounceCount) {
7069
       if (!homeDebounceCount) {
7057
-        enqueuecommands_P(PSTR("G28"));
7070
+        enqueue_and_echo_commands_P(PSTR("G28"));
7058
         LCD_MESSAGEPGM(MSG_AUTO_HOME);
7071
         LCD_MESSAGEPGM(MSG_AUTO_HOME);
7059
       }
7072
       }
7060
       if (homeDebounceCount < HOME_DEBOUNCE_DELAY)
7073
       if (homeDebounceCount < HOME_DEBOUNCE_DELAY)
7180
   void filrunout() {
7193
   void filrunout() {
7181
     if (!filrunoutEnqueued) {
7194
     if (!filrunoutEnqueued) {
7182
       filrunoutEnqueued = true;
7195
       filrunoutEnqueued = true;
7183
-      enqueuecommands_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
7196
+      enqueue_and_echo_commands_P(PSTR(FILAMENT_RUNOUT_SCRIPT));
7184
       st_synchronize();
7197
       st_synchronize();
7185
     }
7198
     }
7186
   }
7199
   }

+ 10
- 5
Marlin/cardreader.cpp View File

243
   cardOK = false;
243
   cardOK = false;
244
 }
244
 }
245
 
245
 
246
+void CardReader::openAndPrintFile(const char *name) {
247
+  char cmd[4 + (FILENAME_LENGTH + 1) * MAX_DIR_DEPTH + 2]; // Room for "M23 ", names with slashes, a null, and one extra
248
+  sprintf_P(cmd, PSTR("M23 %s"), name);
249
+  for (char *c = &cmd[4]; *c; c++) *c = tolower(*c);
250
+  enqueue_and_echo_command(cmd);
251
+  enqueue_and_echo_commands_P(PSTR("M24"));
252
+}
253
+
246
 void CardReader::startFileprint() {
254
 void CardReader::startFileprint() {
247
   if (cardOK)
255
   if (cardOK)
248
     sdprinting = true;
256
     sdprinting = true;
500
   while (root.readDir(p, NULL) > 0) {
508
   while (root.readDir(p, NULL) > 0) {
501
     for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]);
509
     for (int8_t i = 0; i < (int8_t)strlen((char*)p.name); i++) p.name[i] = tolower(p.name[i]);
502
     if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
510
     if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) {
503
-      char cmd[4 + (FILENAME_LENGTH + 1) * (MAX_DIR_DEPTH) + 2];
504
-      sprintf_P(cmd, PSTR("M23 %s"), autoname);
505
-      enqueuecommand(cmd);
506
-      enqueuecommands_P(PSTR("M24"));
511
+      openAndPrintFile(autoname);
507
       found = true;
512
       found = true;
508
     }
513
     }
509
   }
514
   }
589
     sdprinting = false;
594
     sdprinting = false;
590
     if (SD_FINISHED_STEPPERRELEASE) {
595
     if (SD_FINISHED_STEPPERRELEASE) {
591
       //finishAndDisableSteppers();
596
       //finishAndDisableSteppers();
592
-      enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
597
+      enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
593
     }
598
     }
594
     autotempShutdown();
599
     autotempShutdown();
595
   }
600
   }

+ 1
- 0
Marlin/cardreader.h View File

23
   void removeFile(char* name);
23
   void removeFile(char* name);
24
   void closefile(bool store_location=false);
24
   void closefile(bool store_location=false);
25
   void release();
25
   void release();
26
+  void openAndPrintFile(const char *name);
26
   void startFileprint();
27
   void startFileprint();
27
   void pauseSDPrint();
28
   void pauseSDPrint();
28
   void getStatus();
29
   void getStatus();

+ 1
- 1
Marlin/stepper.cpp View File

617
     current_block = NULL;
617
     current_block = NULL;
618
     plan_discard_current_block();
618
     plan_discard_current_block();
619
     #ifdef SD_FINISHED_RELEASECOMMAND
619
     #ifdef SD_FINISHED_RELEASECOMMAND
620
-      if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueuecommands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
620
+      if ((cleaning_buffer_counter == 1) && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
621
     #endif
621
     #endif
622
     cleaning_buffer_counter--;
622
     cleaning_buffer_counter--;
623
     OCR1A = 200;
623
     OCR1A = 200;

+ 6
- 11
Marlin/ultralcd.cpp View File

479
  */
479
  */
480
 void lcd_set_home_offsets() {
480
 void lcd_set_home_offsets() {
481
   // M428 Command
481
   // M428 Command
482
-  enqueuecommands_P(PSTR("M428"));
482
+  enqueue_and_echo_commands_P(PSTR("M428"));
483
   lcd_return_to_status();
483
   lcd_return_to_status();
484
 }
484
 }
485
 
485
 
1504
     lcd_move_y();
1504
     lcd_move_y();
1505
   }
1505
   }
1506
   static void reprapworld_keypad_move_home() {
1506
   static void reprapworld_keypad_move_home() {
1507
-    enqueuecommands_P((PSTR("G28"))); // move all axis home
1507
+    enqueue_and_echo_commands_P((PSTR("G28"))); // move all axis home
1508
   }
1508
   }
1509
 #endif // REPRAPWORLD_KEYPAD
1509
 #endif // REPRAPWORLD_KEYPAD
1510
 
1510
 
1556
  */
1556
  */
1557
 static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); }
1557
 static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); }
1558
 static void menu_action_submenu(menuFunc_t func) { lcd_save_previous_menu(); lcd_goto_menu(func); }
1558
 static void menu_action_submenu(menuFunc_t func) { lcd_save_previous_menu(); lcd_goto_menu(func); }
1559
-static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); }
1559
+static void menu_action_gcode(const char* pgcode) { enqueue_and_echo_commands_P(pgcode); }
1560
 static void menu_action_function(menuFunc_t func) { (*func)(); }
1560
 static void menu_action_function(menuFunc_t func) { (*func)(); }
1561
 
1561
 
1562
 #if ENABLED(SDSUPPORT)
1562
 #if ENABLED(SDSUPPORT)
1563
 
1563
 
1564
   static void menu_action_sdfile(const char* filename, char* longFilename) {
1564
   static void menu_action_sdfile(const char* filename, char* longFilename) {
1565
-    char cmd[30];
1566
-    char* c;
1567
-    sprintf_P(cmd, PSTR("M23 %s"), filename);
1568
-    for (c = &cmd[4]; *c; c++) *c = tolower(*c);
1569
-    enqueuecommand(cmd);
1570
-    enqueuecommands_P(PSTR("M24"));
1565
+    card.openAndPrintFile(filename);
1571
     lcd_return_to_status();
1566
     lcd_return_to_status();
1572
   }
1567
   }
1573
 
1568
 
2313
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2308
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
2314
           line_to_current(Z_AXIS);
2309
           line_to_current(Z_AXIS);
2315
           mbl.active = 1;
2310
           mbl.active = 1;
2316
-          enqueuecommands_P(PSTR("G28"));
2311
+          enqueue_and_echo_commands_P(PSTR("G28"));
2317
           lcd_return_to_status();
2312
           lcd_return_to_status();
2318
         }
2313
         }
2319
         else {
2314
         else {
2357
   static void lcd_level_bed() {
2352
   static void lcd_level_bed() {
2358
     axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false;
2353
     axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false;
2359
     mbl.reset();
2354
     mbl.reset();
2360
-    enqueuecommands_P(PSTR("G28"));
2355
+    enqueue_and_echo_commands_P(PSTR("G28"));
2361
     lcdDrawUpdate = 2;
2356
     lcdDrawUpdate = 2;
2362
     lcd_goto_menu(_lcd_level_bed_homing);
2357
     lcd_goto_menu(_lcd_level_bed_homing);
2363
   }
2358
   }

Loading…
Cancel
Save