From a3f67acd6dfe33f3533da2b2e819a8b5756e2ece Mon Sep 17 00:00:00 2001 From: Robby Candra Date: Sun, 31 Mar 2019 01:14:58 +0700 Subject: [PATCH] Fix Power Loss Recovery file delete (#13522) --- Marlin/src/feature/power_loss_recovery.cpp | 2 ++ Marlin/src/gcode/feature/powerloss/M413.cpp | 2 +- Marlin/src/sd/cardreader.cpp | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/src/feature/power_loss_recovery.cpp b/Marlin/src/feature/power_loss_recovery.cpp index a30dffa458..1154b941ec 100644 --- a/Marlin/src/feature/power_loss_recovery.cpp +++ b/Marlin/src/feature/power_loss_recovery.cpp @@ -222,6 +222,8 @@ void PrintJobRecovery::write() { open(false); file.seekSet(0); const int16_t ret = file.write(&info, sizeof(info)); + close(); + #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) if (ret == -1) SERIAL_ECHOLNPGM("Power-loss file write failed."); #else diff --git a/Marlin/src/gcode/feature/powerloss/M413.cpp b/Marlin/src/gcode/feature/powerloss/M413.cpp index 1a0e3a568c..4b7c253a7d 100644 --- a/Marlin/src/gcode/feature/powerloss/M413.cpp +++ b/Marlin/src/gcode/feature/powerloss/M413.cpp @@ -50,7 +50,7 @@ void GcodeSuite::M413() { if (parser.seen('R') || parser.seen('L')) recovery.load(); if (parser.seen('W')) recovery.save(true); if (parser.seen('P')) recovery.purge(); - if (parser.seen('E')) serialprintPGM(recovery.exists() ? PSTR("BIN Exists\n") : PSTR("No BIN\n")); + if (parser.seen('E')) serialprintPGM(recovery.exists() ? PSTR("PLR Exists\n") : PSTR("No PLR\n")); if (parser.seen('V')) serialprintPGM(recovery.valid() ? PSTR("Valid\n") : PSTR("Invalid\n")); #endif } diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 67b901f96a..f2f544809c 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -1004,7 +1004,7 @@ void CardReader::printingHasFinished() { #if ENABLED(POWER_LOSS_RECOVERY) - constexpr char job_recovery_file_name[4] = "BIN"; + constexpr char job_recovery_file_name[4] = "PLR"; bool CardReader::jobRecoverFileExists() { const bool exists = recovery.file.open(&root, job_recovery_file_name, O_READ); @@ -1026,7 +1026,6 @@ void CardReader::printingHasFinished() { // be zeroed and written instead of deleted. void CardReader::removeJobRecoveryFile() { if (jobRecoverFileExists()) { - //closefile(); removeFile(job_recovery_file_name); #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) SERIAL_ECHOPGM("Power-loss file delete");