power panic: pause the print, and wait for M79

"PRUSA uvlo" is the last g-code to be processed after the power panic
recovery. For host prints, we want to finish processing all these
g-codes and put the print in a paused state.

Currently I am using lcd_pause_print() but this may be simplified
later.

A new PrinterState is introduced PowerPanicWaitingForHost to
differentiate this paused state from the typical paused state.
In this new paused state the printer is waiting for the host to boot up
and send M79.

Once M79 is seen a new action is sent "// action:uvlo_recovery_ready"

It is up to the host software to then resume the print correctly. All
the needed information to resume the print is in EEPROM and can
be read by using the D3 g-code.

Change in memory:
Flash: +82 bytes
SRAM: 0 bytes
This commit is contained in:
gudnimg 2023-11-26 15:59:23 +00:00 committed by DRracer
parent 02c5da198d
commit 4d9dc11510
4 changed files with 29 additions and 0 deletions

View File

@ -4112,6 +4112,20 @@ void process_commands()
// M24 - Start SD print
enquecommand_P(MSG_M24);
}
else if (eeprom_read_byte((uint8_t*)EEPROM_UVLO_PRINT_TYPE) == PowerPanic::PRINT_TYPE_USB)
{
// For Host prints we need to start the timer so that the pause has any effect
// this will allow g-codes to be processed while in the paused state
// For SD prints, M24 starts the timer
print_job_timer.start();
// Park the extruder to the side and don't resume the print
// we must assume that the host as not fully booted up at this point
lcd_pause_print();
// Used by M79 to differentiate from a normal pause
SetPrinterState(PrinterState::PowerPanicWaitingForHost);
}
// Print is recovered, clear the recovery flag
eeprom_update_byte((uint8_t*)EEPROM_UVLO, PowerPanic::NO_PENDING_RECOVERY);
@ -5972,6 +5986,18 @@ Sigma_Exit:
SetHostStatusScreenName(str.GetUnquotedString());
}
}
if (GetPrinterState() == PrinterState::PowerPanicWaitingForHost && print_job_timer.isPaused()) {
// The print is in a paused state. The print was recovered following a power panic
// but up to this point the printer has been waiting for the M79 from the host
// Send action to the host, so the host can resume the print. It is up to the host
// to resume the print correctly.
SERIAL_ECHOLNRPGM(MSG_OCTOPRINT_UVLO_RECOVERY_READY);
// Update the state so the action is not repeated again
SetPrinterState(PrinterState::IsHostPrinting);
}
break;
/*!

View File

@ -233,6 +233,7 @@ const char MSG_OCTOPRINT_CANCEL[] PROGMEM_N1 = "// action:cancel"; ////
const char MSG_OCTOPRINT_READY[] PROGMEM_N1 = "// action:ready"; ////
const char MSG_OCTOPRINT_NOT_READY[] PROGMEM_N1 = "// action:not_ready"; ////
const char MSG_OCTOPRINT_START[] PROGMEM_N1 = "// action:start"; ////
const char MSG_OCTOPRINT_UVLO_RECOVERY_READY[] PROGMEM_N1 = "// action:uvlo_recovery_ready"; ////
const char MSG_FANCHECK_HOTEND[] PROGMEM_N1 = "Err:HOTEND FAN ERROR"; ////c=20
const char MSG_FANCHECK_PRINT[] PROGMEM_N1 = "Err:PRINT FAN ERROR"; ////c=20
const char MSG_M112_KILL[] PROGMEM_N1 = "M112 called. Emergency Stop."; ////c=20

View File

@ -237,6 +237,7 @@ extern const char MSG_OCTOPRINT_CANCEL[];
extern const char MSG_OCTOPRINT_READY[];
extern const char MSG_OCTOPRINT_NOT_READY[];
extern const char MSG_OCTOPRINT_START[];
extern const char MSG_OCTOPRINT_UVLO_RECOVERY_READY[];
extern const char MSG_FANCHECK_HOTEND[];
extern const char MSG_FANCHECK_PRINT[];
extern const char MSG_M112_KILL[];

View File

@ -23,6 +23,7 @@ enum class PrinterState : uint8_t
HostPrintingFinished = 4,
IsSDPrinting = 5,
IsHostPrinting = 6,
PowerPanicWaitingForHost = 7,
};
PrinterState GetPrinterState();