diff --git a/linux/payload/PlocMpsocSpecialComHelper.cpp b/linux/payload/PlocMpsocSpecialComHelper.cpp index a81f8fd6..0af2c3d5 100644 --- a/linux/payload/PlocMpsocSpecialComHelper.cpp +++ b/linux/payload/PlocMpsocSpecialComHelper.cpp @@ -179,9 +179,12 @@ ReturnValue_t PlocMpsocSpecialComHelper::performFlashWrite() { ReturnValue_t PlocMpsocSpecialComHelper::performFlashRead() { std::error_code e; - std::ofstream ofile(flashReadAndWrite.obcFile, - std::ios::trunc | std::ios::binary | std::ios::app); - if (ofile.bad()) { + if (std::filesystem::exists(flashReadAndWrite.obcFile)) { + // Truncate the file first. + std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::binary | std::ios::trunc); + } + std::ofstream ofile(flashReadAndWrite.obcFile, std::ios::binary | std::ios::app); + if (ofile.bad() or not ofile.is_open()) { return returnvalue::FAILED; } ReturnValue_t result = flashfopen(mpsoc::FileAccessModes::READ); diff --git a/tmtc b/tmtc index dccbf89d..067a0160 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit dccbf89da1e2b441a8fc3edc247550ca5dfbd68b +Subproject commit 067a0160405bcf53659072749eddbb7ad7f1d41c