|
@@ -526,42 +526,38 @@ void GCodeQueue::get_serial_commands() {
|
526
|
526
|
while (length < BUFSIZE && !card_eof) {
|
527
|
527
|
const int16_t n = card.get();
|
528
|
528
|
card_eof = card.eof();
|
|
529
|
+ if (n < 0) { SERIAL_ERROR_MSG(MSG_SD_ERR_READ); continue; }
|
529
|
530
|
const char sd_char = (char)n;
|
530
|
|
- if (card_eof || n < 0 || sd_char == '\n' || sd_char == '\r') {
|
|
531
|
+ if (sd_char == '\n' || sd_char == '\r' || card_eof) {
|
|
532
|
+
|
|
533
|
+ // Reset stream state, terminate the buffer, and commit a non-empty command
|
|
534
|
+ if (!process_line_done(sd_input_state, command_buffer[index_w], sd_count)) {
|
|
535
|
+ _commit_command(false); // The file was not terminated with a newline
|
|
536
|
+ #if ENABLED(POWER_LOSS_RECOVERY)
|
|
537
|
+ recovery.cmd_sdpos = card.getIndex(); // Prime for the next _commit_command
|
|
538
|
+ #endif
|
|
539
|
+ }
|
|
540
|
+
|
531
|
541
|
if (card_eof) {
|
532
|
542
|
|
533
|
|
- card.printingHasFinished();
|
|
543
|
+ card.fileHasFinished(); // Handle end of file reached
|
534
|
544
|
|
535
|
|
- if (IS_SD_PRINTING())
|
536
|
|
- sd_count = 0; // If a sub-file was printing, continue from call point
|
537
|
|
- else {
|
538
|
|
- SERIAL_ECHOLNPGM(MSG_FILE_PRINTED);
|
|
545
|
+ if (!IS_SD_PRINTING()) { // Was it the main job file?
|
|
546
|
+ SERIAL_ECHOLNPGM(MSG_FILE_PRINTED); // Tell the host the file is printed.
|
539
|
547
|
#if ENABLED(PRINTER_EVENT_LEDS)
|
540
|
|
- printerEventLEDs.onPrintCompleted();
|
|
548
|
+ printerEventLEDs.onPrintCompleted(); // Change LED color for Print Completed
|
541
|
549
|
#if HAS_RESUME_CONTINUE
|
542
|
|
- enqueue_now_P(PSTR("M0 S"
|
|
550
|
+ enqueue_now_P(PSTR("M0 S" // Display "Click to Continue..."
|
543
|
551
|
#if HAS_LCD_MENU
|
544
|
|
- "1800"
|
|
552
|
+ "1800" // ...for 30 minutes with LCD
|
545
|
553
|
#else
|
546
|
|
- "60"
|
|
554
|
+ "60" // ...for 1 minute with no LCD
|
547
|
555
|
#endif
|
548
|
556
|
));
|
549
|
557
|
#endif
|
550
|
558
|
#endif
|
551
|
559
|
}
|
552
|
560
|
}
|
553
|
|
- else if (n < 0)
|
554
|
|
- SERIAL_ERROR_MSG(MSG_SD_ERR_READ);
|
555
|
|
-
|
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;
|
559
|
|
-
|
560
|
|
- _commit_command(false);
|
561
|
|
-
|
562
|
|
- #if ENABLED(POWER_LOSS_RECOVERY)
|
563
|
|
- recovery.cmd_sdpos = card.getIndex(); // Prime for the next _commit_command
|
564
|
|
- #endif
|
565
|
561
|
}
|
566
|
562
|
else
|
567
|
563
|
process_stream_char(sd_char, sd_input_state, command_buffer[index_w], sd_count);
|