Browse Source

Move job recovery filename

pull/1/head
Scott Lahteine 5 years ago
parent
commit
70ce4f5b36
  1. 2
      Marlin/src/feature/power_loss_recovery.h
  2. 12
      Marlin/src/sd/cardreader.cpp

2
Marlin/src/feature/power_loss_recovery.h

@ -103,6 +103,8 @@ typedef struct {
class PrintJobRecovery {
public:
static constexpr char filename[5] = "/PLR";
static SdFile file;
static job_recovery_info_t info;

12
Marlin/src/sd/cardreader.cpp

@ -1042,10 +1042,8 @@ void CardReader::printingHasFinished() {
#if ENABLED(POWER_LOSS_RECOVERY)
constexpr char job_recovery_file_name[5] = "/PLR";
bool CardReader::jobRecoverFileExists() {
const bool exists = recovery.file.open(&root, job_recovery_file_name, O_READ);
const bool exists = recovery.file.open(&root, recovery.filename, O_READ);
if (exists) recovery.file.close();
return exists;
}
@ -1053,10 +1051,10 @@ void CardReader::printingHasFinished() {
void CardReader::openJobRecoveryFile(const bool read) {
if (!isDetected()) return;
if (recovery.file.isOpen()) return;
if (!recovery.file.open(&root, job_recovery_file_name, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC))
SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, job_recovery_file_name, ".");
if (!recovery.file.open(&root, recovery.filename, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC))
SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, recovery.filename, ".");
else if (!read)
SERIAL_ECHOLNPAIR(MSG_SD_WRITE_TO_FILE, job_recovery_file_name);
SERIAL_ECHOLNPAIR(MSG_SD_WRITE_TO_FILE, recovery.filename);
}
// Removing the job recovery file currently requires closing
@ -1065,7 +1063,7 @@ void CardReader::printingHasFinished() {
void CardReader::removeJobRecoveryFile() {
if (jobRecoverFileExists()) {
recovery.init();
removeFile(job_recovery_file_name);
removeFile(recovery.filename);
#if ENABLED(DEBUG_POWER_LOSS_RECOVERY)
SERIAL_ECHOPGM("Power-loss file delete");
serialprintPGM(jobRecoverFileExists() ? PSTR(" failed.\n") : PSTR("d.\n"));

Loading…
Cancel
Save