|
|
@ -526,42 +526,38 @@ void GCodeQueue::get_serial_commands() {
|
|
|
|
while (length < BUFSIZE && !card_eof) {
|
|
|
|
while (length < BUFSIZE && !card_eof) {
|
|
|
|
const int16_t n = card.get();
|
|
|
|
const int16_t n = card.get();
|
|
|
|
card_eof = card.eof();
|
|
|
|
card_eof = card.eof();
|
|
|
|
|
|
|
|
if (n < 0) { SERIAL_ERROR_MSG(MSG_SD_ERR_READ); continue; }
|
|
|
|
const char sd_char = (char)n;
|
|
|
|
const char sd_char = (char)n;
|
|
|
|
if (card_eof || n < 0 || sd_char == '\n' || sd_char == '\r') {
|
|
|
|
if (sd_char == '\n' || sd_char == '\r' || card_eof) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Reset stream state, terminate the buffer, and commit a non-empty command
|
|
|
|
|
|
|
|
if (!process_line_done(sd_input_state, command_buffer[index_w], sd_count)) {
|
|
|
|
|
|
|
|
_commit_command(false); // The file was not terminated with a newline
|
|
|
|
|
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
|
|
|
|
|
|
|
recovery.cmd_sdpos = card.getIndex(); // Prime for the next _commit_command
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (card_eof) {
|
|
|
|
if (card_eof) {
|
|
|
|
|
|
|
|
|
|
|
|
card.printingHasFinished();
|
|
|
|
card.fileHasFinished(); // Handle end of file reached
|
|
|
|
|
|
|
|
|
|
|
|
if (IS_SD_PRINTING())
|
|
|
|
if (!IS_SD_PRINTING()) { // Was it the main job file?
|
|
|
|
sd_count = 0; // If a sub-file was printing, continue from call point
|
|
|
|
SERIAL_ECHOLNPGM(MSG_FILE_PRINTED); // Tell the host the file is printed.
|
|
|
|
else {
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPGM(MSG_FILE_PRINTED);
|
|
|
|
|
|
|
|
#if ENABLED(PRINTER_EVENT_LEDS)
|
|
|
|
#if ENABLED(PRINTER_EVENT_LEDS)
|
|
|
|
printerEventLEDs.onPrintCompleted();
|
|
|
|
printerEventLEDs.onPrintCompleted(); // Change LED color for Print Completed
|
|
|
|
#if HAS_RESUME_CONTINUE
|
|
|
|
#if HAS_RESUME_CONTINUE
|
|
|
|
enqueue_now_P(PSTR("M0 S"
|
|
|
|
enqueue_now_P(PSTR("M0 S" // Display "Click to Continue..."
|
|
|
|
#if HAS_LCD_MENU
|
|
|
|
#if HAS_LCD_MENU
|
|
|
|
"1800"
|
|
|
|
"1800" // ...for 30 minutes with LCD
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
"60"
|
|
|
|
"60" // ...for 1 minute with no LCD
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
));
|
|
|
|
));
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (n < 0)
|
|
|
|
|
|
|
|
SERIAL_ERROR_MSG(MSG_SD_ERR_READ);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Terminate the buffer, reset the input state, continue for empty line
|
|
|
|
|
|
|
|
if (process_line_done(sd_input_state, command_buffer[index_w], sd_count))
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_commit_command(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
|
|
|
|
|
|
|
recovery.cmd_sdpos = card.getIndex(); // Prime for the next _commit_command
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
process_stream_char(sd_char, sd_input_state, command_buffer[index_w], sd_count);
|
|
|
|
process_stream_char(sd_char, sd_input_state, command_buffer[index_w], sd_count);
|
|
|
|