Commit last SD line before fileHasFinished
This commit is contained in:
parent
1d431fe8d2
commit
29ec868c4b
@ -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);
|
||||||
|
@ -1063,7 +1063,7 @@ uint16_t CardReader::get_num_Files() {
|
|||||||
//
|
//
|
||||||
// Return from procedure or close out the Print Job
|
// Return from procedure or close out the Print Job
|
||||||
//
|
//
|
||||||
void CardReader::printingHasFinished() {
|
void CardReader::fileHasFinished() {
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
file.close();
|
file.close();
|
||||||
if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
|
if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
|
||||||
|
@ -106,7 +106,7 @@ public:
|
|||||||
|
|
||||||
// Print job
|
// Print job
|
||||||
static void openAndPrintFile(const char *name); // (working directory)
|
static void openAndPrintFile(const char *name); // (working directory)
|
||||||
static void printingHasFinished();
|
static void fileHasFinished();
|
||||||
static void getAbsFilename(char *dst);
|
static void getAbsFilename(char *dst);
|
||||||
static void startFileprint();
|
static void startFileprint();
|
||||||
static void printFilename();
|
static void printFilename();
|
||||||
|
Loading…
Reference in New Issue
Block a user