diff --git a/linux/payload/PlocMpsocHelper.cpp b/linux/payload/PlocMpsocHelper.cpp index 25bfc8d9..3eaa833d 100644 --- a/linux/payload/PlocMpsocHelper.cpp +++ b/linux/payload/PlocMpsocHelper.cpp @@ -84,32 +84,22 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) { } ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) { - ReturnValue_t result = returnvalue::OK; -#ifdef XIPHOS_Q7S - result = FilesystemHelper::checkPath(obcFile); + ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile); if (result != returnvalue::OK) { return result; } - result = FilesystemHelper::fileExists(mpsocFile); - if (result != returnvalue::OK) { - return result; - } -#endif -#ifdef TE0720_1CFA - if (not std::filesystem::exists(obcFile)) { - sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist" - << std::endl; - return returnvalue::FAILED; - } -#endif - - flashReadAndWrite.obcFile = obcFile; - flashReadAndWrite.mpsocFile = mpsocFile; internalState = InternalState::FLASH_WRITE; - result = resetHelper(); + return result; +} + +ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile, + size_t readFileSize) { + ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile); if (result != returnvalue::OK) { return result; } + flashReadAndWrite.totalReadSize = readFileSize; + internalState = InternalState::FLASH_READ; return result; } @@ -424,6 +414,34 @@ ReturnValue_t PlocMPSoCHelper::handleFlashReadReply(std::ofstream& ofile, size_t return returnvalue::OK; } +ReturnValue_t PlocMPSoCHelper::fileCheck(std::string obcFile) { +#ifdef XIPHOS_Q7S + ReturnValue_t result = FilesystemHelper::checkPath(obcFile); + if (result != returnvalue::OK) { + return result; + } +#elif defined(TE0720_1CFA) + if (not std::filesystem::exists(obcFile)) { + sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist" + << std::endl; + return returnvalue::FAILED; + } +#endif + return returnvalue::OK; +} + +ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile, + std::string mpsocFile) { + ReturnValue_t result = fileCheck(obcFile); + if (result != returnvalue::OK) { + return result; + } + + flashReadAndWrite.obcFile = obcFile; + flashReadAndWrite.mpsocFile = mpsocFile; + return resetHelper(); +} + ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) { ReturnValue_t result = reader.checkSize(); if (result != returnvalue::OK) { diff --git a/linux/payload/PlocMpsocHelper.h b/linux/payload/PlocMpsocHelper.h index 24dd50a1..63a40d0c 100644 --- a/linux/payload/PlocMpsocHelper.h +++ b/linux/payload/PlocMpsocHelper.h @@ -6,6 +6,7 @@ #include +#include "OBSWConfig.h" #include "fsfw/devicehandlers/CookieIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/osal/linux/BinarySemaphore.h" @@ -99,6 +100,14 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { * @return returnvalue::OK if successful, otherwise error return value */ ReturnValue_t startFlashWrite(std::string obcFile, std::string mpsocFile); + /** + * + * @param obcFile Full target file name on OBC + * @param mpsocFile The file on the MPSoC which should be copied ot the OBC + * @param readFileSize The size of the file on the MPSoC. + * @return + */ + ReturnValue_t startFlashRead(std::string obcFile, std::string mpsocFile, size_t readFileSize); /** * @brief Can be used to interrupt a running data transfer. @@ -175,6 +184,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF { ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes); ReturnValue_t handleAck(); ReturnValue_t handleExe(); + ReturnValue_t startFlashReadOrWriteBase(std::string obcFile, std::string mpsocFile); + ReturnValue_t fileCheck(std::string obcFile); void handleAckApidFailure(uint16_t apid); void handleExeApidFailure(uint16_t apid); ReturnValue_t handleTmReception(size_t remainingBytes);