From 7daff755f2899d4cbe24aa038b1e32d9369692c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Mi=C5=9Bkiewicz?= Date: Thu, 1 Sep 2022 20:48:24 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Report=20M22=20/=20M23=20success?= =?UTF-8?q?=20/=20fail=20(#24706)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/core/language.h | 1 + Marlin/src/sd/cardreader.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index 157bd69185..545f9df641 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -174,6 +174,7 @@ #define STR_SD_VOL_INIT_FAIL "volume.init failed" #define STR_SD_OPENROOT_FAIL "openRoot failed" #define STR_SD_CARD_OK "SD card ok" +#define STR_SD_CARD_RELEASED "SD card released" #define STR_SD_WORKDIR_FAIL "workDir open failed" #define STR_SD_OPEN_FILE_FAIL "open failed, File: " #define STR_SD_FILE_OPENED "File opened: " diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index 3057bf68af..6a55f7efbf 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -547,6 +547,7 @@ void CardReader::release() { #if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) nrFiles = 0; #endif + SERIAL_ECHO_MSG(STR_SD_CARD_RELEASED); } /** @@ -642,7 +643,7 @@ void announceOpen(const uint8_t doing, const char * const path) { // - 2 : Resuming from a sub-procedure // void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) { - if (!isMounted()) return; + if (!isMounted()) return openFailed(path); switch (subcall_type) { case 0: // Starting a new print. "Now fresh file: ..." @@ -684,7 +685,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ SdFile *diveDir; const char * const fname = diveToFile(true, diveDir, path); - if (!fname) return; + if (!fname) return openFailed(path); if (file.open(diveDir, fname, O_READ)) { filesize = file.fileSize(); @@ -720,21 +721,20 @@ void CardReader::openFileWrite(const char * const path) { SdFile *diveDir; const char * const fname = diveToFile(false, diveDir, path); - if (!fname) return; + if (!fname) return openFailed(path); - #if ENABLED(SDCARD_READONLY) - openFailed(fname); - #else + #if DISABLED(SDCARD_READONLY) if (file.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { flag.saving = true; selectFileByName(fname); TERN_(EMERGENCY_PARSER, emergency_parser.disable()); echo_write_to_file(fname); ui.set_status(fname); + return; } - else - openFailed(fname); #endif + + openFailed(fname); } //