restructured flash write command

This commit is contained in:
Jakob Meier 2022-03-22 11:35:44 +01:00
parent 05b43d4d72
commit 78b3f28188
7 changed files with 680 additions and 646 deletions

View File

@ -13,8 +13,6 @@ enum commonClassIds: uint8_t {
IMTQ_HANDLER, //IMTQ IMTQ_HANDLER, //IMTQ
RW_HANDLER, //RWHA RW_HANDLER, //RWHA
STR_HANDLER, //STRH STR_HANDLER, //STRH
PLOC_MPSOC_HANDLER, //PLMP
MPSOC_CMD, //MPCMD
DWLPWRON_CMD, //DWLPWRON DWLPWRON_CMD, //DWLPWRON
MPSOC_TM, //MPTM MPSOC_TM, //MPTM
PLOC_SUPERVISOR_HANDLER, //PLSV PLOC_SUPERVISOR_HANDLER, //PLSV
@ -33,6 +31,7 @@ enum commonClassIds: uint8_t {
FILE_SYSTEM_HELPER, //FSHLP FILE_SYSTEM_HELPER, //FSHLP
PLOC_MPSOC_HELPER, // PLMPHLP PLOC_MPSOC_HELPER, // PLMPHLP
SA_DEPL_HANDLER, //SADPL SA_DEPL_HANDLER, //SADPL
MPSOC_RETURN_VALUES_IF, //MPSOCRTVIF
COMMON_CLASS_ID_END // [EXPORT] : [END] COMMON_CLASS_ID_END // [EXPORT] : [END]
}; };

View File

@ -0,0 +1,30 @@
#ifndef MPSOC_RETURN_VALUES_IF_H_
#define MPSOC_RETURN_VALUES_IF_H_
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
class MPSoCReturnValuesIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_RETURN_VALUES_IF;
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
//! [EXPORT] : [COMMENT] Received command with invalid length
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4);
//! [EXPORT] : [COMMENT] Filename of file in OBC filesystem is too long
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5);
//! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command
static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6);
//! [EXPORT] : [COMMENT] Filename of MPSoC file is to long (max. 256 bytes)
static const ReturnValue_t MPSOC_FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA7);
//! [EXPORT] : [COMMENT] Command has invalid parameter
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xA8);
};
#endif /* MPSOC_RETURN_VALUES_IF_H_ */

View File

@ -1,6 +1,8 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#include "OBSWConfig.h"
#include "MPSoCReturnValuesIF.h"
#include <fsfw/tmtcpacket/SpacePacket.h> #include <fsfw/tmtcpacket/SpacePacket.h>
#include <fsfw/globalfunctions/CRC.h> #include <fsfw/globalfunctions/CRC.h>
#include <fsfw/serialize/SerializeAdapter.h> #include <fsfw/serialize/SerializeAdapter.h>
@ -81,19 +83,12 @@ static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 60;
/** /**
* @brief Abstract base class for TC space packet of MPSoC. * @brief Abstract base class for TC space packet of MPSoC.
*/ */
class TcBase : public SpacePacket, public HasReturnvaluesIF { class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
public: public:
// Initial length field of space packet. Will always be updated when packet is created. // Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = 1; static const uint16_t INIT_LENGTH = 1;
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_CMD;
//! [EXPORT] : [COMMENT] Received command with invalid length
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xC0);
//! [EXPORT] : [COMMENT] Command has invalid parameter
static const ReturnValue_t INVALID_PARAMETER = MAKE_RETURN_CODE(0xC1);
/** /**
* @brief Constructor * @brief Constructor
* *
@ -113,13 +108,13 @@ public:
* @return RETURN_OK if packet creation was successful, otherwise error return value * @return RETURN_OK if packet creation was successful, otherwise error return value
*/ */
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) { virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = initPacket(commandData, commandDataLen); result = initPacket(commandData, commandDataLen);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = addCrc(); result = addCrc();
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return result; return result;
@ -133,21 +128,21 @@ protected:
* @param commandDataLen Length of received command data * @param commandDataLen Length of received command data
*/ */
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
/** /**
* @brief Calculates and adds the CRC * @brief Calculates and adds the CRC
*/ */
ReturnValue_t addCrc() { ReturnValue_t addCrc() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t serializedSize = 0; size_t serializedSize = 0;
uint32_t full_size = getFullSize(); uint32_t full_size = getFullSize();
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE); uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
result = SerializeAdapter::serialize<uint16_t>(&crc, result = SerializeAdapter::serialize<uint16_t>(&crc,
this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc), this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl; sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
} }
return result; return result;
@ -157,13 +152,9 @@ protected:
/** /**
* @brief Class for handling tm replies of the PLOC MPSoC. * @brief Class for handling tm replies of the PLOC MPSoC.
*/ */
class TmPacket : public SpacePacket, public HasReturnvaluesIF { class TmPacket : public SpacePacket, public MPSoCReturnValuesIF {
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::MPSOC_CMD;
//! [EXPORT] : [COMMENT] CRC check of received packet failed
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
/** /**
* @brief Constructor creates idle packet and sets length field to maximum allowed size. * @brief Constructor creates idle packet and sets length field to maximum allowed size.
*/ */
@ -177,7 +168,7 @@ public:
if (recalculatedCrc != receivedCrc) { if (recalculatedCrc != receivedCrc) {
return CRC_FAILURE; return CRC_FAILURE;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -202,9 +193,9 @@ public:
protected: protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen); result = lengthCheck(commandDataLen);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE); std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
@ -214,7 +205,7 @@ protected:
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE; const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
result = SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size, result = SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size,
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if(result != RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return result; return result;
@ -233,7 +224,7 @@ private:
if (commandDataLen != COMMAND_LENGTH){ if (commandDataLen != COMMAND_LENGTH){
return INVALID_LENGTH; return INVALID_LENGTH;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -252,9 +243,9 @@ public:
protected: protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen); result = lengthCheck(commandDataLen);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen); std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
@ -276,7 +267,7 @@ private:
sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl; sif::warning << "TcMemWrite: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -295,17 +286,17 @@ public:
static const char READ = 'r'; static const char READ = 'r';
ReturnValue_t createPacket(std::string filename, char accessMode) { ReturnValue_t createPacket(std::string filename, char accessMode) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size(); size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), std::memcpy(this->getPacketData(), filename.c_str(),
nameSize); nameSize);
std::memcpy(this->getPacketData() + nameSize, &accessMode, std::memcpy(this->getPacketData() + nameSize, &accessMode,
sizeof(accessMode)); sizeof(accessMode));
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
result = addCrc(); result = addCrc();
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
return result; return result;
} }
}; };
@ -321,14 +312,14 @@ public:
} }
ReturnValue_t createPacket(std::string filename) { ReturnValue_t createPacket(std::string filename) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size(); size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize); std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
result = addCrc(); result = addCrc();
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
this->setPacketDataLength(nameSize + CRC_SIZE - 1);
return result; return result;
} }
}; };
@ -346,12 +337,16 @@ public:
ReturnValue_t createPacket(uint8_t* writeData, uint32_t writeLen) { ReturnValue_t createPacket(uint8_t* writeData, uint32_t writeLen) {
if (writeLen > MAX_DATA_SIZE) { if (writeLen > MAX_DATA_SIZE) {
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl; sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
return RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
std::memcpy(this->getPacketData(), writeData, writeLen); std::memcpy(this->getPacketData(), &writeLen, sizeof(writeLen));
addCrc(); std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1)); this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
return RETURN_OK; ReturnValue_t result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -366,12 +361,12 @@ public:
} }
ReturnValue_t createPacket(std::string filename) { ReturnValue_t createPacket(std::string filename) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size(); size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize); std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
this->setPacketDataLength(nameSize + CRC_SIZE - 1); this->setPacketDataLength(nameSize + CRC_SIZE - 1);
result = addCrc(); result = addCrc();
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
return result; return result;
@ -389,13 +384,13 @@ public:
} }
ReturnValue_t createPacket() { ReturnValue_t createPacket() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc(); result = addCrc();
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1)); this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -413,13 +408,13 @@ public:
protected: protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen); result = lengthCheck(commandDataLen);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = checkData(*commandData); result = checkData(*commandData);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen); std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
@ -438,7 +433,7 @@ private:
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl; sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t checkData(uint8_t replay) { ReturnValue_t checkData(uint8_t replay) {
@ -446,7 +441,7 @@ private:
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl; sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
return INVALID_PARAMETER; return INVALID_PARAMETER;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -464,17 +459,17 @@ public:
protected: protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen); result = lengthCheck(commandDataLen);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = modeCheck(*commandData); result = modeCheck(*commandData);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
result = laneRateCheck(*(commandData + 1)); result = laneRateCheck(*(commandData + 1));
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen); std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
@ -503,7 +498,7 @@ private:
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl; sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t modeCheck(uint8_t mode) { ReturnValue_t modeCheck(uint8_t mode) {
@ -511,7 +506,7 @@ private:
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl; sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
return INVALID_MODE; return INVALID_MODE;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t laneRateCheck(uint8_t laneRate) { ReturnValue_t laneRateCheck(uint8_t laneRate) {
@ -519,7 +514,7 @@ private:
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl; sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
return INVALID_LANE_RATE; return INVALID_LANE_RATE;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -534,13 +529,13 @@ public:
} }
ReturnValue_t createPacket() { ReturnValue_t createPacket() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc(); result = addCrc();
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1)); this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
@ -558,9 +553,9 @@ public:
protected: protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen); result = lengthCheck(commandDataLen);
if (result != RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen); std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
@ -577,10 +572,42 @@ private:
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen << std::endl; sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }
return RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
}; };
class FlashWritePusCmd : public MPSoCReturnValuesIF {
public:
FlashWritePusCmd(){};
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)) {
return FILENAME_TOO_LONG;
}
mpsocFile = std::string(reinterpret_cast<const char*>(commandData + obcFile.size()));
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
return MPSOC_FILENAME_TOO_LONG;
}
return HasReturnvaluesIF::HasReturnvaluesIF::RETURN_OK;
}
std::string getObcFile() {
return obcFile;
}
std::string getMPSoCFile() {
return mpsocFile;
}
private:
std::string obcFile = "";
std::string mpsocFile = "";
};
} }
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@
#include "fsfw/tmtcservices/SourceSequenceCounter.h" #include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h" #include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "PlocMPSoCHelper.h" #include "PlocMPSoCHelper.h"
#include "linux/devices/devicedefinitions/MPSoCReturnValuesIF.h"
/** /**
* @brief This is the device handler for the MPSoC of the payload computer. * @brief This is the device handler for the MPSoC of the payload computer.
@ -25,23 +26,6 @@
class PlocMPSoCHandler: public DeviceHandlerBase { class PlocMPSoCHandler: public DeviceHandlerBase {
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::PLOC_MPSOC_HANDLER;
//! [EXPORT] : [COMMENT] Space Packet received from PLOC has invalid CRC
static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0);
//! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC
static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1);
//! [EXPORT] : [COMMENT] Received execution failure reply from PLOC
static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2);
//! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC
static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3);
//! [EXPORT] : [COMMENT] Received command with invalid length
static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xA4);
//! [EXPORT] : [COMMENT] Received command with invalid filename
static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xA5);
//! [EXPORT] : [COMMENT] MPSoC helper is currently executing a command
static const ReturnValue_t MPSOC_HELPER_EXECUTING = MAKE_RETURN_CODE(0xA6);
PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie, PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid, CookieIF * comCookie,
PlocMPSoCHelper* plocMPSoCHelper); PlocMPSoCHelper* plocMPSoCHelper);
virtual ~PlocMPSoCHandler(); virtual ~PlocMPSoCHandler();

View File

@ -3,6 +3,7 @@
#include <filesystem> #include <filesystem>
#include <fstream> #include <fstream>
#include "OBSWConfig.h"
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
#include "bsp_q7s/memory/FileSystemHelper.h" #include "bsp_q7s/memory/FileSystemHelper.h"
#endif #endif
@ -65,7 +66,7 @@ void PlocMPSoCHelper::setSequenceCount(SourceSequenceCounter* sequenceCount_) {
sequenceCount = sequenceCount_; sequenceCount = sequenceCount_;
} }
ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string file) { ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string obcFile, std::string mpsocFile) {
#ifdef XIPHOS_Q7S #ifdef XIPHOS_Q7S
ReturnValue_t result = FilesystemHelper::checkPath(file); ReturnValue_t result = FilesystemHelper::checkPath(file);
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -76,7 +77,16 @@ ReturnValue_t PlocMPSoCHelper::startFlashWrite(std::string file) {
return result; return result;
} }
#endif #endif
flashWrite.file = file; #ifdef TE0720_1CFA
if (not std::filesystem::exists(obcFile)) {
sif::warning << "PlocMPSoCHelper::startFlashWrite: File " << obcFile << "does not exist"
<< std::endl;
return RETURN_FAILED;
}
#endif
flashWrite.obcFile = obcFile;
flashWrite.mpsocFile = mpsocFile;
internalState = InternalState::FLASH_WRITE; internalState = InternalState::FLASH_WRITE;
semaphore.release(); semaphore.release();
terminate = false; terminate = false;
@ -92,7 +102,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
return result; return result;
} }
uint8_t tempData[mpsoc::MAX_DATA_SIZE]; uint8_t tempData[mpsoc::MAX_DATA_SIZE];
std::ifstream file(flashWrite.file, std::ifstream::binary); std::ifstream file(flashWrite.obcFile, std::ifstream::binary);
// Set position of next character to end of file input stream // Set position of next character to end of file input stream
file.seekg(0, file.end); file.seekg(0, file.end);
// tellg returns position of character in input stream // tellg returns position of character in input stream
@ -135,7 +145,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
(*sequenceCount)++; (*sequenceCount)++;
mpsoc::FlashFopen flashFopen(*sequenceCount); mpsoc::FlashFopen flashFopen(*sequenceCount);
result = flashFopen.createPacket(flashWrite.file, mpsoc::FlashFopen::APPEND); result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -150,7 +160,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
(*sequenceCount)++; (*sequenceCount)++;
mpsoc::FlashFclose flashFclose(*sequenceCount); mpsoc::FlashFclose flashFclose(*sequenceCount);
result = flashFclose.createPacket(flashWrite.file); result = flashFclose.createPacket(flashWrite.mpsocFile);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }

View File

@ -79,11 +79,12 @@ public:
/** /**
* @brief Starts flash write sequence * @brief Starts flash write sequence
* *
* @param file File with data to write * @param obcFile File where to read from the data
* @param mpsocFile The file of the MPSoC where should be written to
* *
* @return RETURN_OK if successful, otherwise error return value * @return RETURN_OK if successful, otherwise error return value
*/ */
ReturnValue_t startFlashWrite(std::string file); ReturnValue_t startFlashWrite(std::string obcFile, std::string mpsocFile);
/** /**
* @brief Can be used to interrupt a running data transfer. * @brief Can be used to interrupt a running data transfer.
@ -104,7 +105,8 @@ private:
static const int RETRIES = 3; static const int RETRIES = 3;
struct FlashWrite { struct FlashWrite {
std::string file; std::string obcFile;
std::string mpsocFile;
}; };
struct FlashWrite flashWrite; struct FlashWrite flashWrite;