this should do the job
This commit is contained in:
@ -125,10 +125,7 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
||||
|
||||
switch (actionId) {
|
||||
case mpsoc::TC_FLASH_WRITE_FULL_FILE: {
|
||||
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
|
||||
return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsoc::FlashWritePusCmd flashWritePusCmd;
|
||||
mpsoc::FlashBasePusCmd flashWritePusCmd;
|
||||
result = flashWritePusCmd.extractFields(data, size);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
@ -142,7 +139,19 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
|
||||
return EXECUTION_FINISHED;
|
||||
}
|
||||
case mpsoc::TC_FLASH_READ_FULL_FILE: {
|
||||
// TODO: Finsh this.
|
||||
mpsoc::FlashReadPusCmd flashReadPusCmd;
|
||||
result = flashReadPusCmd.extractFields(data, size);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
result = plocMPSoCHelper->startFlashRead(flashReadPusCmd.getObcFile(),
|
||||
flashReadPusCmd.getMPSoCFile(),
|
||||
flashReadPusCmd.getReadSize());
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
plocMPSoCHelperExecuting = true;
|
||||
return EXECUTION_FINISHED;
|
||||
break;
|
||||
}
|
||||
case (mpsoc::OBSW_RESET_SEQ_COUNT): {
|
||||
|
@ -84,7 +84,7 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
|
||||
}
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
|
||||
ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile);
|
||||
ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile));
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
@ -94,7 +94,7 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string
|
||||
|
||||
ReturnValue_t PlocMPSoCHelper::startFlashRead(std::string obcFile, std::string mpsocFile,
|
||||
size_t readFileSize) {
|
||||
ReturnValue_t result = startFlashReadOrWriteBase(obcFile, mpsocFile);
|
||||
ReturnValue_t result = startFlashReadOrWriteBase(std::move(obcFile), std::move(mpsocFile));
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
@ -437,8 +437,8 @@ ReturnValue_t PlocMPSoCHelper::startFlashReadOrWriteBase(std::string obcFile,
|
||||
return result;
|
||||
}
|
||||
|
||||
flashReadAndWrite.obcFile = obcFile;
|
||||
flashReadAndWrite.mpsocFile = mpsocFile;
|
||||
flashReadAndWrite.obcFile = std::move(obcFile);
|
||||
flashReadAndWrite.mpsocFile = std::move(mpsocFile);
|
||||
return resetHelper();
|
||||
}
|
||||
|
||||
|
@ -736,36 +736,69 @@ class TcReplayWriteSeq : public TcBase {
|
||||
/**
|
||||
* @brief Helps to extract the fields of the flash write command from the PUS packet.
|
||||
*/
|
||||
class FlashWritePusCmd : public MPSoCReturnValuesIF {
|
||||
class FlashBasePusCmd : public MPSoCReturnValuesIF {
|
||||
public:
|
||||
FlashWritePusCmd(){};
|
||||
FlashBasePusCmd() = default;
|
||||
virtual ~FlashBasePusCmd() = default;
|
||||
|
||||
ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
||||
virtual ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) {
|
||||
if (commandDataLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE + MAX_FILENAME_SIZE)) {
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
obcFile = std::string(reinterpret_cast<const char*>(commandData));
|
||||
if (obcFile.size() > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
||||
size_t fileLen = strnlen(reinterpret_cast<const char*>(commandData), commandDataLen);
|
||||
if (fileLen > (config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE)) {
|
||||
return FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsocFile = std::string(
|
||||
reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR));
|
||||
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
|
||||
obcFile = std::string(reinterpret_cast<const char*>(commandData), fileLen);
|
||||
fileLen =
|
||||
strnlen(reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR),
|
||||
commandDataLen - obcFile.size() - 1);
|
||||
if (fileLen > MAX_FILENAME_SIZE) {
|
||||
return MPSOC_FILENAME_TOO_LONG;
|
||||
}
|
||||
mpsocFile = std::string(
|
||||
reinterpret_cast<const char*>(commandData + obcFile.size() + SIZE_NULL_TERMINATOR),
|
||||
fileLen);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
std::string getObcFile() { return obcFile; }
|
||||
const std::string& getObcFile() const { return obcFile; }
|
||||
|
||||
std::string getMPSoCFile() { return mpsocFile; }
|
||||
const std::string& getMPSoCFile() const { return mpsocFile; }
|
||||
|
||||
protected:
|
||||
size_t getParsedSize() const {
|
||||
return getObcFile().size() + getMPSoCFile().size() + 2 * SIZE_NULL_TERMINATOR;
|
||||
}
|
||||
static const size_t SIZE_NULL_TERMINATOR = 1;
|
||||
|
||||
private:
|
||||
static const size_t SIZE_NULL_TERMINATOR = 1;
|
||||
std::string obcFile = "";
|
||||
std::string mpsocFile = "";
|
||||
std::string obcFile;
|
||||
std::string mpsocFile;
|
||||
};
|
||||
|
||||
class FlashReadPusCmd : public FlashBasePusCmd {
|
||||
public:
|
||||
FlashReadPusCmd(){};
|
||||
|
||||
ReturnValue_t extractFields(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = FlashBasePusCmd::extractFields(commandData, commandDataLen);
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
if (commandDataLen < (getParsedSize() + 4)) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
size_t deserDummy = 4;
|
||||
return SerializeAdapter::deSerialize(&readSize, commandData + getParsedSize(), &deserDummy,
|
||||
SerializeIF::Endianness::NETWORK);
|
||||
}
|
||||
|
||||
size_t getReadSize() const { return readSize; }
|
||||
|
||||
private:
|
||||
size_t readSize = 0;
|
||||
};
|
||||
/**
|
||||
* @brief Class to build replay stop space packet.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user