WIP adapting PlocMpSoCHandler
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit

major PITA, but does compile now, will be back with more patience
This commit is contained in:
Ulrich Mohr 2022-07-27 22:03:41 +02:00
parent c8f4f0b03e
commit 24297a6a97
5 changed files with 1004 additions and 882 deletions

View File

@ -0,0 +1,646 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCCOMMONDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCCOMMONDEFINITIONS_H_
#include <fsfw/action/MinMaxParameter.h>
#include <fsfw/action/TemplateAction.h>
#include <fsfw/introspection/Enum.h>
#include "MPSoCReturnValuesIF.h"
#include "OBSWConfig.h"
#include "eive/definitions.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/tmtcpacket/SpacePacket.h"
namespace mpsoc {
static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14;
static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
static const uint16_t SIZE_TM_CAM_CMD_RPT = 18;
/**
* SpacePacket apids of PLOC telecommands and telemetry.
*/
namespace apid {
static const uint16_t TC_REPLAY_START = 0x110;
static const uint16_t TC_REPLAY_STOP = 0x111;
static const uint16_t TC_REPLAY_WRITE_SEQUENCE = 0x112;
static const uint16_t TC_DOWNLINK_PWR_ON = 0x113;
static const uint16_t TC_MEM_WRITE = 0x114;
static const uint16_t TC_MEM_READ = 0x115;
static const uint16_t TC_FLASHWRITE = 0x117;
static const uint16_t TC_FLASHFOPEN = 0x119;
static const uint16_t TC_FLASHFCLOSE = 0x11A;
static const uint16_t TC_FLASHDELETE = 0x11C;
static const uint16_t TC_MODE_REPLAY = 0x11F;
static const uint16_t TC_MODE_IDLE = 0x11E;
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
static const uint16_t TC_CAM_CMD_SEND = 0x12C;
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t ACK_SUCCESS = 0x400;
static const uint16_t ACK_FAILURE = 0x401;
static const uint16_t EXE_SUCCESS = 0x402;
static const uint16_t EXE_FAILURE = 0x403;
static const uint16_t TM_CAM_CMD_RPT = 0x407;
} // namespace apid
/** Offset from first byte in space packet to first byte of data field */
static const uint8_t DATA_FIELD_OFFSET = 6;
static const size_t MEM_READ_RPT_LEN_OFFSET = 10;
static const char NULL_TERMINATOR = '\0';
static const uint8_t MIN_SPACE_PACKET_LENGTH = 7;
static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
/**
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
* 8.
*/
static const uint8_t SIZE_MEM_READ_RPT_FIX = 6;
static const size_t MAX_FILENAME_SIZE = 256;
/**
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
* field. For the length field in the space packet this size will be substracted by one.
*/
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
static const uint16_t LENGTH_TC_MEM_READ = 8;
static const size_t MAX_REPLY_SIZE = SpacePacket::PACKET_MAX_SIZE * 3;
static const size_t MAX_COMMAND_SIZE = SpacePacket::PACKET_MAX_SIZE;
static const size_t MAX_DATA_SIZE = 1016;
/**
* The replay write sequence command has a maximum delay for the execution report which amounts to
* 30 seconds. (80 cycles * 0.5 seconds = 40 seconds).
*/
static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 80;
// Requires approx. 2 seconds for execution. 8 => 4 seconds
static const uint16_t TC_DOWNLINK_PWR_ON_EXECUTION_DELAY = 8;
namespace status_code {
static const uint16_t UNKNOWN_APID = 0x5DD;
static const uint16_t INCORRECT_LENGTH = 0x5DE;
static const uint16_t INCORRECT_CRC = 0x5DF;
static const uint16_t INCORRECT_PKT_SEQ_CNT = 0x5E0;
static const uint16_t TC_NOT_ALLOWED_IN_MODE = 0x5E1;
static const uint16_t TC_EXEUTION_DISABLED = 0x5E2;
static const uint16_t FLASH_MOUNT_FAILED = 0x5E3;
static const uint16_t FLASH_FILE_ALREADY_CLOSED = 0x5E4;
static const uint16_t FLASH_FILE_OPEN_FAILED = 0x5E5;
static const uint16_t FLASH_FILE_ALREDY_OPEN = 0x5E6;
static const uint16_t FLASH_FILE_NOT_OPEN = 0x5E7;
static const uint16_t FLASH_UNMOUNT_FAILED = 0x5E8;
static const uint16_t HEAP_ALLOCATION_FAILED = 0x5E9;
static const uint16_t INVALID_PARAMETER = 0x5EA;
static const uint16_t NOT_INITIALIZED = 0x5EB;
static const uint16_t REBOOT_IMMINENT = 0x5EC;
static const uint16_t CORRUPT_DATA = 0x5ED;
static const uint16_t FLASH_CORRECTABLE_MISMATCH = 0x5EE;
static const uint16_t FLASH_UNCORRECTABLE_MISMATCH = 0x5EF;
static const uint16_t RESERVED_0 = 0x5F0;
static const uint16_t RESERVED_1 = 0x5F1;
static const uint16_t RESERVED_2 = 0x5F2;
static const uint16_t RESERVED_3 = 0x5F3;
static const uint16_t RESERVED_4 = 0x5F4;
} // namespace status_code
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
public:
// Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = 1;
/**
* @brief Constructor
*
* @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets.
*/
TcBase(uint16_t apid, uint16_t sequenceCount)
: SpacePacket(INIT_LENGTH, true, apid, sequenceCount) {}
/**
* @brief Function to initialize the space packet
*
* @param commandData Pointer to command specific data
* @param commandDataLen Length of command data
*
* @return RETURN_OK if packet creation was successful, otherwise error return value
*/
virtual ReturnValue_t createPacket(void *action) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = initPacket(action);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
protected:
/**
* @brief Must be overwritten by the child class to define the command specific parameters
*
* @param commandData Pointer to received command data
* @param commandDataLen Length of received command data
*/
virtual ReturnValue_t initPacket(void *action) {
return HasReturnvaluesIF::RETURN_OK;
}
/**
* @brief Calculates and adds the CRC
*/
ReturnValue_t addCrc() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t serializedSize = 0;
uint32_t full_size = getFullSize();
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
result = SerializeAdapter::serialize<uint16_t>(
&crc, this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
}
return result;
}
};
/**
* @brief Class for handling tm replies of the PLOC MPSoC.
*/
class TmPacket : public SpacePacket, public MPSoCReturnValuesIF {
public:
/**
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
*/
TmPacket() : SpacePacket(PACKET_MAX_SIZE) {}
ReturnValue_t checkCrc() {
uint8_t *crcPtr = this->getPacketData() + this->getPacketDataLength() - 1;
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
uint16_t recalculatedCrc =
CRC::crc16ccitt(this->localData.byteStream, this->getFullSize() - CRC_SIZE);
if (recalculatedCrc != receivedCrc) {
return CRC_FAILURE;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build the memory read command for the PLOC.
*/
class TcMemRead : public TcBase {
public:
/**
* @brief Constructor
*/
TcMemRead(uint16_t sequenceCount) : TcBase(apid::TC_MEM_READ, sequenceCount) {
this->setPacketDataLength(PACKET_LENGTH);
}
uint16_t getMemLen() const { return memLen; }
protected:
ReturnValue_t initPacket(const uint8_t *commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
std::memcpy(this->localData.fields.buffer + MEM_ADDRESS_SIZE, commandData + MEM_ADDRESS_SIZE,
MEM_LEN_SIZE);
size_t size = sizeof(memLen);
const uint8_t *memLenPtr = commandData + MEM_ADDRESS_SIZE;
result =
SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size, SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
private:
static const size_t COMMAND_LENGTH = 6;
static const size_t MEM_ADDRESS_SIZE = 4;
static const size_t MEM_LEN_SIZE = 2;
static const uint16_t PACKET_LENGTH = 7;
uint16_t memLen = 0;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_LENGTH) {
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Class to help creation of flash fopen command.
*/
class FlashFopen : public TcBase {
public:
FlashFopen(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFOPEN, sequenceCount) {}
static const char APPEND = 'a';
static const char WRITE = 'w';
static const char READ = 'r';
ReturnValue_t createPacket(std::string filename, char accessMode_) {
accessMode = accessMode_;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
std::memcpy(this->getPacketData() + nameSize + sizeof(NULL_TERMINATOR), &accessMode,
sizeof(accessMode));
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE -
1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
private:
char accessMode = APPEND;
};
/**
* @brief Class to help creation of flash fclose command.
*/
class FlashFclose : public TcBase {
public:
FlashFclose(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFCLOSE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
};
/**
* @brief Class to build flash write space packet.
*/
class TcFlashWrite : public TcBase {
public:
TcFlashWrite(uint16_t sequenceCount) : TcBase(apid::TC_FLASHWRITE, sequenceCount) {}
ReturnValue_t createPacket(const uint8_t *writeData, uint32_t writeLen_) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
writeLen = writeLen_;
if (writeLen > MAX_DATA_SIZE) {
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
size_t serializedSize = 0;
result =
SerializeAdapter::serialize<uint32_t>(&writeLen, this->getPacketData(), &serializedSize,
sizeof(writeLen), SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return HasReturnvaluesIF::RETURN_OK;
}
private:
uint32_t writeLen = 0;
};
/**
* @brief Class to help creation of flash delete command.
*/
class TcFlashDelete : public TcBase {
public:
TcFlashDelete(uint16_t sequenceCount) : TcBase(apid::TC_FLASHDELETE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
};
/**
* @brief Class to build replay stop space packet.
*/
class TcReplayStop : public TcBase {
public:
TcReplayStop(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_STOP, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build the replay start command.
*/
class TcReplayStart : public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t *commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = checkData(*commandData);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
return result;
}
private:
static const size_t COMMAND_DATA_LENGTH = 1;
static const uint8_t REPEATING = 0;
static const uint8_t ONCE = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_DATA_LENGTH) {
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t checkData(uint8_t replay) {
if (replay != REPEATING && replay != ONCE) {
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
return INVALID_PARAMETER;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build downlink power on command.
*/
class TcDownlinkPwrOn : public TcBase {
public:
/**
* @brief Constructor
*/
TcDownlinkPwrOn(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t *commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = modeCheck(*commandData);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = laneRateCheck(*(commandData + 1));
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
std::memcpy(this->localData.fields.buffer + commandDataLen, &MAX_AMPLITUDE,
sizeof(MAX_AMPLITUDE));
this->setPacketDataLength(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE - 1);
return result;
}
private:
static const uint8_t INTERFACE_ID = CLASS_ID::DWLPWRON_CMD;
//! [EXPORT] : [COMMENT] Received command has invalid JESD mode (valid modes are 0 - 5)
static const ReturnValue_t INVALID_MODE = MAKE_RETURN_CODE(0xE0);
//! [EXPORT] : [COMMENT] Received command has invalid lane rate (valid lane rate are 0 - 9)
static const ReturnValue_t INVALID_LANE_RATE = MAKE_RETURN_CODE(0xE1);
static const size_t COMMAND_DATA_LENGTH = 2;
static const uint8_t MAX_MODE = 5;
static const uint8_t MAX_LANE_RATE = 9;
static const uint16_t MAX_AMPLITUDE = 0;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_DATA_LENGTH) {
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t modeCheck(uint8_t mode) {
if (mode > MAX_MODE) {
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
return INVALID_MODE;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t laneRateCheck(uint8_t laneRate) {
if (laneRate > MAX_LANE_RATE) {
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
return INVALID_LANE_RATE;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Class to build replay stop space packet.
*/
class TcDownlinkPwrOff : public TcBase {
public:
TcDownlinkPwrOff(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build the replay start command.
*/
class TcReplayWriteSeq : public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayWriteSeq(uint16_t sequenceCount)
: TcBase(apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t *commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
*(this->localData.fields.buffer + commandDataLen) = NULL_TERMINATOR;
this->setPacketDataLength(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
return result;
}
private:
static const size_t USE_DECODING_LENGTH = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen > USE_DECODING_LENGTH + MAX_FILENAME_SIZE) {
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen
<< std::endl;
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Helps to extract the fields of the flash write command from the PUS packet.
*/
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() + SIZE_NULL_TERMINATOR));
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
return MPSOC_FILENAME_TOO_LONG;
}
return HasReturnvaluesIF::RETURN_OK;
}
std::string getObcFile() { return obcFile; }
std::string getMPSoCFile() { return mpsocFile; }
private:
static const size_t SIZE_NULL_TERMINATOR = 1;
std::string obcFile = "";
std::string mpsocFile = "";
};
/**
* @brief Class to build replay stop space packet.
*/
class TcModeReplay : public TcBase {
public:
TcModeReplay(uint16_t sequenceCount) : TcBase(apid::TC_MODE_REPLAY, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Class to build mode idle command
*/
class TcModeIdle : public TcBase {
public:
TcModeIdle(uint16_t sequenceCount) : TcBase(apid::TC_MODE_IDLE, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
class TcCamcmdSend : public TcBase {
public:
TcCamcmdSend(uint16_t sequenceCount) : TcBase(apid::TC_CAM_CMD_SEND, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t *commandData, size_t commandDataLen) {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
size_t size = sizeof(dataLen);
SerializeAdapter::serialize(&dataLen, this->getPacketData(), &size, sizeof(dataLen),
SerializeIF::Endianness::BIG);
std::memcpy(this->getPacketData() + sizeof(dataLen), commandData, commandDataLen);
*(this->getPacketData() + sizeof(dataLen) + commandDataLen) = CARRIAGE_RETURN;
uint16_t trueLength = sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN) + CRC_SIZE;
this->setPacketDataLength(trueLength - 1);
return HasReturnvaluesIF::RETURN_OK;
}
private:
static const uint8_t MAX_DATA_LENGTH = 10;
static const uint8_t CARRIAGE_RETURN = 0xD;
};
} // namespace mpsoc
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCCOMMONDEFINITIONS_H_ */

View File

@ -1,271 +1,146 @@
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_
#include <fsfw/action/MinMaxParameter.h>
#include <fsfw/action/TemplateAction.h>
#include <fsfw/introspection/Enum.h>
#include "MPSoCReturnValuesIF.h"
#include "OBSWConfig.h"
#include "PlocMPSoCCommonDefinitions.h"
#include "eive/definitions.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/serialize/SerializeAdapter.h"
#include "fsfw/tmtcpacket/SpacePacket.h"
class PlocMPSoCHandler;
FSFW_ENUM(PlocMpSoCCommands, DeviceCommandId_t,
((NONE, 0, "No Command"))((TC_MEM_WRITE, 1, "Write to Memory"))(
(TC_MEM_READ, 2, "Read from Memory"))((ACK_REPORT, 3, ""))((EXE_REPORT, 5, ""))(
(TM_MEMORY_READ_REPORT, 6, ""))((TC_FLASHWRITE, 9, "Write Flash"))(
(TC_FLASHDELETE, 10, "Delete Flash"))((TC_REPLAY_START, 11, "Start Replay"))(
(TC_REPLAY_STOP, 12, "Stop Replay"))((TC_REPLAY_WRITE_SEQUENCE, 13,
"Write Sequence"))((TC_DOWNLINK_PWR_ON, 14,
"Set Downlink Power On"))(
(TC_DOWNLINK_PWR_OFF, 15, "Set Downlink Power Off"))((TC_MODE_REPLAY, 16,
"Set Replay Mode"))(
(TC_CAM_CMD_SEND, 17, "Set Replay Mode"))((TC_MODE_IDLE, 18, "Set Idle Mode"))(
(TM_CAM_CMD_RPT, 19, ""))((SET_UART_TX_TRISTATE, 20, "Set UART TX to Tristate"))(
(RELEASE_UART_TX, 21, "Release UART TX"))((OBSW_RESET_SEQ_COUNT, 50,
"Reset OBSW Reset Sequence Count")))
class PlocMpSoCMemWriteAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCMemWriteAction, PlocMpSoCCommands> {
public:
PlocMpSoCMemWriteAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_MEM_WRITE){};
Parameter<uint32_t> address = Parameter<uint32_t>::createParameter(this, "Memory Address");
Parameter<uint32_t> memoryData = Parameter<uint32_t>::createParameter(this, "Data to be written");
};
class PlocMpSoCMemReadAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCMemReadAction, PlocMpSoCCommands> {
public:
PlocMpSoCMemReadAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_MEM_READ){};
};
class PlocMpSoCFlashDeleteAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCFlashDeleteAction, PlocMpSoCCommands> {
public:
PlocMpSoCFlashDeleteAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_FLASHDELETE){};
};
class PlocMpSoCReplayStartAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReplayStartAction, PlocMpSoCCommands> {
public:
PlocMpSoCReplayStartAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_START){};
};
class PlocMpSoCReplayStopAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReplayStopAction, PlocMpSoCCommands> {
public:
PlocMpSoCReplayStopAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_STOP){};
};
class PlocMpSoCReplayWriteSequenceAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReplayWriteSequenceAction,
PlocMpSoCCommands> {
public:
PlocMpSoCReplayWriteSequenceAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE){};
};
class PlocMpSoCDownlinkPwrOnAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCDownlinkPwrOnAction, PlocMpSoCCommands> {
public:
PlocMpSoCDownlinkPwrOnAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_DOWNLINK_PWR_ON){};
};
class PlocMpSoCDownlinkPwrOffAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCDownlinkPwrOffAction, PlocMpSoCCommands> {
public:
PlocMpSoCDownlinkPwrOffAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF){};
};
class PlocMpSoCModeReplayAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCModeReplayAction, PlocMpSoCCommands> {
public:
PlocMpSoCModeReplayAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_MODE_REPLAY){};
};
class PlocMpSoCCamCmdSendAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCCamCmdSendAction, PlocMpSoCCommands> {
public:
PlocMpSoCCamCmdSendAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_CAM_CMD_SEND){};
};
class PlocMpSoCModeIdleAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCModeIdleAction, PlocMpSoCCommands> {
public:
PlocMpSoCModeIdleAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_MODE_IDLE){};
};
class PlocMpSoCFlashWriteAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCFlashWriteAction, PlocMpSoCCommands> {
public:
PlocMpSoCFlashWriteAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::TC_FLASHWRITE){};
};
class PlocMpSoCUartTxTristateAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCUartTxTristateAction, PlocMpSoCCommands> {
public:
PlocMpSoCUartTxTristateAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::SET_UART_TX_TRISTATE){};
};
class PlocMpSoCReleaseUartTxAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCReleaseUartTxAction, PlocMpSoCCommands> {
public:
PlocMpSoCReleaseUartTxAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::RELEASE_UART_TX){};
};
class PlocMpSoCObswResetSeqCountAction
: public TemplateAction<PlocMPSoCHandler, PlocMpSoCObswResetSeqCountAction, PlocMpSoCCommands> {
public:
PlocMpSoCObswResetSeqCountAction(PlocMPSoCHandler *owner)
: TemplateAction(owner, PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT){};
};
namespace mpsoc {
static const DeviceCommandId_t NONE = 0;
static const DeviceCommandId_t TC_MEM_WRITE = 1;
static const DeviceCommandId_t TC_MEM_READ = 2;
static const DeviceCommandId_t ACK_REPORT = 3;
static const DeviceCommandId_t EXE_REPORT = 5;
static const DeviceCommandId_t TM_MEMORY_READ_REPORT = 6;
static const DeviceCommandId_t TC_FLASHFOPEN = 7;
static const DeviceCommandId_t TC_FLASHFCLOSE = 8;
static const DeviceCommandId_t TC_FLASHWRITE = 9;
static const DeviceCommandId_t TC_FLASHDELETE = 10;
static const DeviceCommandId_t TC_REPLAY_START = 11;
static const DeviceCommandId_t TC_REPLAY_STOP = 12;
static const DeviceCommandId_t TC_REPLAY_WRITE_SEQUENCE = 13;
static const DeviceCommandId_t TC_DOWNLINK_PWR_ON = 14;
static const DeviceCommandId_t TC_DOWNLINK_PWR_OFF = 15;
static const DeviceCommandId_t TC_MODE_REPLAY = 16;
static const DeviceCommandId_t TC_CAM_CMD_SEND = 17;
static const DeviceCommandId_t TC_MODE_IDLE = 18;
static const DeviceCommandId_t TM_CAM_CMD_RPT = 19;
static const DeviceCommandId_t SET_UART_TX_TRISTATE = 20;
static const DeviceCommandId_t RELEASE_UART_TX = 21;
// Will reset the sequence count of the OBSW
static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50;
static const uint16_t SIZE_ACK_REPORT = 14;
static const uint16_t SIZE_EXE_REPORT = 14;
static const uint16_t SIZE_TM_MEM_READ_REPORT = 18;
static const uint16_t SIZE_TM_CAM_CMD_RPT = 18;
/**
* SpacePacket apids of PLOC telecommands and telemetry.
*/
namespace apid {
static const uint16_t TC_REPLAY_START = 0x110;
static const uint16_t TC_REPLAY_STOP = 0x111;
static const uint16_t TC_REPLAY_WRITE_SEQUENCE = 0x112;
static const uint16_t TC_DOWNLINK_PWR_ON = 0x113;
static const uint16_t TC_MEM_WRITE = 0x114;
static const uint16_t TC_MEM_READ = 0x115;
static const uint16_t TC_FLASHWRITE = 0x117;
static const uint16_t TC_FLASHFOPEN = 0x119;
static const uint16_t TC_FLASHFCLOSE = 0x11A;
static const uint16_t TC_FLASHDELETE = 0x11C;
static const uint16_t TC_MODE_REPLAY = 0x11F;
static const uint16_t TC_MODE_IDLE = 0x11E;
static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124;
static const uint16_t TC_CAM_CMD_SEND = 0x12C;
static const uint16_t TM_MEMORY_READ_REPORT = 0x404;
static const uint16_t ACK_SUCCESS = 0x400;
static const uint16_t ACK_FAILURE = 0x401;
static const uint16_t EXE_SUCCESS = 0x402;
static const uint16_t EXE_FAILURE = 0x403;
static const uint16_t TM_CAM_CMD_RPT = 0x407;
} // namespace apid
/** Offset from first byte in space packet to first byte of data field */
static const uint8_t DATA_FIELD_OFFSET = 6;
static const size_t MEM_READ_RPT_LEN_OFFSET = 10;
static const char NULL_TERMINATOR = '\0';
static const uint8_t MIN_SPACE_PACKET_LENGTH = 7;
static const uint8_t SPACE_PACKET_HEADER_SIZE = 6;
/**
* The size of payload data which will be forwarded to the requesting object. e.g. PUS Service
* 8.
*/
static const uint8_t SIZE_MEM_READ_RPT_FIX = 6;
static const size_t MAX_FILENAME_SIZE = 256;
/**
* PLOC space packet length for fixed size packets. This is the size of the whole packet data
* field. For the length field in the space packet this size will be substracted by one.
*/
static const uint16_t LENGTH_TC_MEM_WRITE = 12;
static const uint16_t LENGTH_TC_MEM_READ = 8;
static const size_t MAX_REPLY_SIZE = SpacePacket::PACKET_MAX_SIZE * 3;
static const size_t MAX_COMMAND_SIZE = SpacePacket::PACKET_MAX_SIZE;
static const size_t MAX_DATA_SIZE = 1016;
/**
* The replay write sequence command has a maximum delay for the execution report which amounts to
* 30 seconds. (80 cycles * 0.5 seconds = 40 seconds).
*/
static const uint16_t TC_WRITE_SEQ_EXECUTION_DELAY = 80;
// Requires approx. 2 seconds for execution. 8 => 4 seconds
static const uint16_t TC_DOWNLINK_PWR_ON_EXECUTION_DELAY = 8;
namespace status_code {
static const uint16_t UNKNOWN_APID = 0x5DD;
static const uint16_t INCORRECT_LENGTH = 0x5DE;
static const uint16_t INCORRECT_CRC = 0x5DF;
static const uint16_t INCORRECT_PKT_SEQ_CNT = 0x5E0;
static const uint16_t TC_NOT_ALLOWED_IN_MODE = 0x5E1;
static const uint16_t TC_EXEUTION_DISABLED = 0x5E2;
static const uint16_t FLASH_MOUNT_FAILED = 0x5E3;
static const uint16_t FLASH_FILE_ALREADY_CLOSED = 0x5E4;
static const uint16_t FLASH_FILE_OPEN_FAILED = 0x5E5;
static const uint16_t FLASH_FILE_ALREDY_OPEN = 0x5E6;
static const uint16_t FLASH_FILE_NOT_OPEN = 0x5E7;
static const uint16_t FLASH_UNMOUNT_FAILED = 0x5E8;
static const uint16_t HEAP_ALLOCATION_FAILED = 0x5E9;
static const uint16_t INVALID_PARAMETER = 0x5EA;
static const uint16_t NOT_INITIALIZED = 0x5EB;
static const uint16_t REBOOT_IMMINENT = 0x5EC;
static const uint16_t CORRUPT_DATA = 0x5ED;
static const uint16_t FLASH_CORRECTABLE_MISMATCH = 0x5EE;
static const uint16_t FLASH_UNCORRECTABLE_MISMATCH = 0x5EF;
static const uint16_t RESERVED_0 = 0x5F0;
static const uint16_t RESERVED_1 = 0x5F1;
static const uint16_t RESERVED_2 = 0x5F2;
static const uint16_t RESERVED_3 = 0x5F3;
static const uint16_t RESERVED_4 = 0x5F4;
} // namespace status_code
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public SpacePacket, public MPSoCReturnValuesIF {
public:
// Initial length field of space packet. Will always be updated when packet is created.
static const uint16_t INIT_LENGTH = 1;
/**
* @brief Constructor
*
* @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets.
*/
TcBase(uint16_t apid, uint16_t sequenceCount)
: SpacePacket(INIT_LENGTH, true, apid, sequenceCount) {}
/**
* @brief Function to initialize the space packet
*
* @param commandData Pointer to command specific data
* @param commandDataLen Length of command data
*
* @return RETURN_OK if packet creation was successful, otherwise error return value
*/
virtual ReturnValue_t createPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = initPacket(commandData, commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
protected:
/**
* @brief Must be overwritten by the child class to define the command specific parameters
*
* @param commandData Pointer to received command data
* @param commandDataLen Length of received command data
*/
virtual ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
return HasReturnvaluesIF::RETURN_OK;
}
/**
* @brief Calculates and adds the CRC
*/
ReturnValue_t addCrc() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t serializedSize = 0;
uint32_t full_size = getFullSize();
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
result = SerializeAdapter::serialize<uint16_t>(
&crc, this->localData.byteStream + full_size - CRC_SIZE, &serializedSize, sizeof(crc),
SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "TcBase::addCrc: Failed to serialize crc field" << std::endl;
}
return result;
}
};
/**
* @brief Class for handling tm replies of the PLOC MPSoC.
*/
class TmPacket : public SpacePacket, public MPSoCReturnValuesIF {
public:
/**
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
*/
TmPacket() : SpacePacket(PACKET_MAX_SIZE) {}
ReturnValue_t checkCrc() {
uint8_t* crcPtr = this->getPacketData() + this->getPacketDataLength() - 1;
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
uint16_t recalculatedCrc =
CRC::crc16ccitt(this->localData.byteStream, this->getFullSize() - CRC_SIZE);
if (recalculatedCrc != receivedCrc) {
return CRC_FAILURE;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build the memory read command for the PLOC.
*/
class TcMemRead : public TcBase {
public:
/**
* @brief Constructor
*/
TcMemRead(uint16_t sequenceCount) : TcBase(apid::TC_MEM_READ, sequenceCount) {
this->setPacketDataLength(PACKET_LENGTH);
}
uint16_t getMemLen() const { return memLen; }
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, MEM_ADDRESS_SIZE);
std::memcpy(this->localData.fields.buffer + MEM_ADDRESS_SIZE, commandData + MEM_ADDRESS_SIZE,
MEM_LEN_SIZE);
size_t size = sizeof(memLen);
const uint8_t* memLenPtr = commandData + MEM_ADDRESS_SIZE;
result =
SerializeAdapter::deSerialize(&memLen, &memLenPtr, &size, SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
private:
static const size_t COMMAND_LENGTH = 6;
static const size_t MEM_ADDRESS_SIZE = 4;
static const size_t MEM_LEN_SIZE = 2;
static const uint16_t PACKET_LENGTH = 7;
uint16_t memLen = 0;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_LENGTH) {
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to generate the space packet to write data to a memory address within
* the PLOC.
@ -278,23 +153,31 @@ class TcMemWrite : public TcBase {
TcMemWrite(uint16_t sequenceCount) : TcBase(apid::TC_MEM_WRITE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t initPacket(void *actionIn) {
auto action = dynamic_cast<PlocMpSoCMemWriteAction *>(actionIn);
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
// faking until framework code is ready
// uint16_t length = action->memoryData.length;
uint16_t dataLength = 1;
result = lengthCheck(dataLength);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
uint16_t memLen =
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
this->setPacketDataLength(memLen * 4 + FIX_LENGTH - 1);
uint8_t *pointer = this->localData.fields.buffer;
size_t size = 0;
size_t maxSize = PACKET_MAX_SIZE;
SerializeAdapter::serialize(&action->address.value, &pointer, &size, maxSize,
SerializeIF::Endianness::BIG);
SerializeAdapter::serialize(&dataLength, &pointer, &size, maxSize,
SerializeIF::Endianness::BIG);
std::memcpy(pointer, &action->memoryData.value, dataLength);
this->setPacketDataLength(dataLength * sizeof(action->memoryData.value) + FIX_LENGTH - 1);
return result;
}
private:
// Min length consists of 4 byte address, 2 byte mem length field, 4 byte data (1 word)
static const size_t MIN_COMMAND_DATA_LENGTH = 10;
static const size_t MEM_ADDRESS_SIZE = 4;
// Min length consists of 4 byte data (1 word)
static const size_t MIN_COMMAND_DATA_LENGTH = 1;
static const size_t FIX_LENGTH = 8;
ReturnValue_t lengthCheck(size_t commandDataLen) {
@ -305,400 +188,5 @@ class TcMemWrite : public TcBase {
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Class to help creation of flash fopen command.
*/
class FlashFopen : public TcBase {
public:
FlashFopen(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFOPEN, sequenceCount) {}
static const char APPEND = 'a';
static const char WRITE = 'w';
static const char READ = 'r';
ReturnValue_t createPacket(std::string filename, char accessMode_) {
accessMode = accessMode_;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
std::memcpy(this->getPacketData() + nameSize + sizeof(NULL_TERMINATOR), &accessMode,
sizeof(accessMode));
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode) + CRC_SIZE -
1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
private:
char accessMode = APPEND;
};
/**
* @brief Class to help creation of flash fclose command.
*/
class FlashFclose : public TcBase {
public:
FlashFclose(uint16_t sequenceCount) : TcBase(apid::TC_FLASHFCLOSE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
};
/**
* @brief Class to build flash write space packet.
*/
class TcFlashWrite : public TcBase {
public:
TcFlashWrite(uint16_t sequenceCount) : TcBase(apid::TC_FLASHWRITE, sequenceCount) {}
ReturnValue_t createPacket(const uint8_t* writeData, uint32_t writeLen_) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
writeLen = writeLen_;
if (writeLen > MAX_DATA_SIZE) {
sif::debug << "FlashWrite::createPacket: Command data too big" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
size_t serializedSize = 0;
result =
SerializeAdapter::serialize<uint32_t>(&writeLen, this->getPacketData(), &serializedSize,
sizeof(writeLen), SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->getPacketData() + sizeof(writeLen), writeData, writeLen);
this->setPacketDataLength(static_cast<uint16_t>(writeLen + CRC_SIZE - 1));
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return HasReturnvaluesIF::RETURN_OK;
}
private:
uint32_t writeLen = 0;
};
/**
* @brief Class to help creation of flash delete command.
*/
class TcFlashDelete : public TcBase {
public:
TcFlashDelete(uint16_t sequenceCount) : TcBase(apid::TC_FLASHDELETE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(this->getPacketData(), filename.c_str(), nameSize);
*(this->getPacketData() + nameSize) = NULL_TERMINATOR;
this->setPacketDataLength(nameSize + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
};
/**
* @brief Class to build replay stop space packet.
*/
class TcReplayStop : public TcBase {
public:
TcReplayStop(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_STOP, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build the replay start command.
*/
class TcReplayStart : public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayStart(uint16_t sequenceCount) : TcBase(apid::TC_REPLAY_START, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = checkData(*commandData);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
this->setPacketDataLength(commandDataLen + CRC_SIZE - 1);
return result;
}
private:
static const size_t COMMAND_DATA_LENGTH = 1;
static const uint8_t REPEATING = 0;
static const uint8_t ONCE = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_DATA_LENGTH) {
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t checkData(uint8_t replay) {
if (replay != REPEATING && replay != ONCE) {
sif::warning << "TcReplayStart::checkData: Invalid replay value" << std::endl;
return INVALID_PARAMETER;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build downlink power on command.
*/
class TcDownlinkPwrOn : public TcBase {
public:
/**
* @brief Constructor
*/
TcDownlinkPwrOn(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = modeCheck(*commandData);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = laneRateCheck(*(commandData + 1));
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
std::memcpy(this->localData.fields.buffer + commandDataLen, &MAX_AMPLITUDE,
sizeof(MAX_AMPLITUDE));
this->setPacketDataLength(commandDataLen + sizeof(MAX_AMPLITUDE) + CRC_SIZE - 1);
return result;
}
private:
static const uint8_t INTERFACE_ID = CLASS_ID::DWLPWRON_CMD;
//! [EXPORT] : [COMMENT] Received command has invalid JESD mode (valid modes are 0 - 5)
static const ReturnValue_t INVALID_MODE = MAKE_RETURN_CODE(0xE0);
//! [EXPORT] : [COMMENT] Received command has invalid lane rate (valid lane rate are 0 - 9)
static const ReturnValue_t INVALID_LANE_RATE = MAKE_RETURN_CODE(0xE1);
static const size_t COMMAND_DATA_LENGTH = 2;
static const uint8_t MAX_MODE = 5;
static const uint8_t MAX_LANE_RATE = 9;
static const uint16_t MAX_AMPLITUDE = 0;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen != COMMAND_DATA_LENGTH) {
sif::warning << "TcDownlinkPwrOn: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t modeCheck(uint8_t mode) {
if (mode > MAX_MODE) {
sif::warning << "TcDwonlinkPwrOn::modeCheck: Invalid JESD mode" << std::endl;
return INVALID_MODE;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t laneRateCheck(uint8_t laneRate) {
if (laneRate > MAX_LANE_RATE) {
sif::warning << "TcReplayStart::laneRateCheck: Invalid lane rate" << std::endl;
return INVALID_LANE_RATE;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Class to build replay stop space packet.
*/
class TcDownlinkPwrOff : public TcBase {
public:
TcDownlinkPwrOff(uint16_t sequenceCount) : TcBase(apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief This class helps to build the replay start command.
*/
class TcReplayWriteSeq : public TcBase {
public:
/**
* @brief Constructor
*/
TcReplayWriteSeq(uint16_t sequenceCount)
: TcBase(apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
std::memcpy(this->localData.fields.buffer, commandData, commandDataLen);
*(this->localData.fields.buffer + commandDataLen) = NULL_TERMINATOR;
this->setPacketDataLength(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE - 1);
return result;
}
private:
static const size_t USE_DECODING_LENGTH = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen > USE_DECODING_LENGTH + MAX_FILENAME_SIZE) {
sif::warning << "TcReplayWriteSeq: Command has invalid length " << commandDataLen
<< std::endl;
return INVALID_LENGTH;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Helps to extract the fields of the flash write command from the PUS packet.
*/
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() + SIZE_NULL_TERMINATOR));
if (mpsocFile.size() > MAX_FILENAME_SIZE) {
return MPSOC_FILENAME_TOO_LONG;
}
return HasReturnvaluesIF::RETURN_OK;
}
std::string getObcFile() { return obcFile; }
std::string getMPSoCFile() { return mpsocFile; }
private:
static const size_t SIZE_NULL_TERMINATOR = 1;
std::string obcFile = "";
std::string mpsocFile = "";
};
/**
* @brief Class to build replay stop space packet.
*/
class TcModeReplay : public TcBase {
public:
TcModeReplay(uint16_t sequenceCount) : TcBase(apid::TC_MODE_REPLAY, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
/**
* @brief Class to build mode idle command
*/
class TcModeIdle : public TcBase {
public:
TcModeIdle(uint16_t sequenceCount) : TcBase(apid::TC_MODE_IDLE, sequenceCount) {}
ReturnValue_t createPacket() {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = addCrc();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
this->setPacketDataLength(static_cast<uint16_t>(CRC_SIZE - 1));
return HasReturnvaluesIF::RETURN_OK;
}
};
class TcCamcmdSend : public TcBase {
public:
TcCamcmdSend(uint16_t sequenceCount) : TcBase(apid::TC_CAM_CMD_SEND, sequenceCount) {}
protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) {
if (commandDataLen > MAX_DATA_LENGTH) {
return INVALID_LENGTH;
}
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
size_t size = sizeof(dataLen);
SerializeAdapter::serialize(&dataLen, this->getPacketData(), &size, sizeof(dataLen),
SerializeIF::Endianness::BIG);
std::memcpy(this->getPacketData() + sizeof(dataLen), commandData, commandDataLen);
*(this->getPacketData() + sizeof(dataLen) + commandDataLen) = CARRIAGE_RETURN;
uint16_t trueLength = sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN) + CRC_SIZE;
this->setPacketDataLength(trueLength - 1);
return HasReturnvaluesIF::RETURN_OK;
}
private:
static const uint8_t MAX_DATA_LENGTH = 10;
static const uint8_t CARRIAGE_RETURN = 0xD;
};
} // namespace mpsoc
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */

View File

@ -5,6 +5,8 @@
#include "fsfw/globalfunctions/CRC.h"
#include "linux/devices/devicedefinitions/PlocSupervisorDefinitions.h"
//TODO this is work in progress in adapting to new actions
PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid,
CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper,
Gpio uartIsolatorSwitch, object_id_t supervisorHandler)
@ -96,16 +98,14 @@ void PlocMPSoCHandler::performOperationHook() {
}
}
ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) {
ReturnValue_t result = RETURN_OK;
switch (actionId) {
case mpsoc::SET_UART_TX_TRISTATE: {
ReturnValue_t PlocMPSoCHandler::executeAction(Action* action) {
switch (PlocMpSoCCommands(action->getId())) {
case PlocMpSoCCommands::SET_UART_TX_TRISTATE: {
uartIsolatorSwitch.pullLow();
return EXECUTION_FINISHED;
break;
}
case mpsoc::RELEASE_UART_TX: {
case PlocMpSoCCommands::RELEASE_UART_TX: {
uartIsolatorSwitch.pullHigh();
return EXECUTION_FINISHED;
break;
@ -118,32 +118,28 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI
return MPSoCReturnValuesIF::MPSOC_HELPER_EXECUTING;
}
switch (actionId) {
case mpsoc::TC_FLASHWRITE: {
if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
}
mpsoc::FlashWritePusCmd flashWritePusCmd;
result = flashWritePusCmd.extractFields(data, size);
if (result != RETURN_OK) {
return result;
}
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
flashWritePusCmd.getMPSoCFile());
if (result != RETURN_OK) {
return result;
}
plocMPSoCHelperExecuting = true;
return EXECUTION_FINISHED;
switch (PlocMpSoCCommands(action->getId())) {
case PlocMpSoCCommands::TC_FLASHWRITE: {
// refer handling to the handleAction() below
return action->handle();
}
case (mpsoc::OBSW_RESET_SEQ_COUNT): {
case (PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT): {
sequenceCount = 0;
return EXECUTION_FINISHED;
}
default:
break;
}
return DeviceHandlerBase::executeAction(actionId, commandedBy, data, size);
ReturnValue_t result = DeviceHandlerBase::executeAction(action);
if (result == RETURN_OK) {
/**
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
*/
uartComIf->flushUartRxBuffer(comCookie);
}
return result;
}
void PlocMPSoCHandler::doStartUp() {
@ -203,90 +199,31 @@ ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
return NOTHING_TO_SEND;
}
ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t result = RETURN_OK;
switch (deviceCommand) {
case (mpsoc::TC_MEM_WRITE): {
result = prepareTcMemWrite(commandData, commandDataLen);
break;
}
case (mpsoc::TC_MEM_READ): {
result = prepareTcMemRead(commandData, commandDataLen);
break;
}
case (mpsoc::TC_FLASHDELETE): {
result = prepareTcFlashDelete(commandData, commandDataLen);
break;
}
case (mpsoc::TC_REPLAY_START): {
result = prepareTcReplayStart(commandData, commandDataLen);
break;
}
case (mpsoc::TC_REPLAY_STOP): {
result = prepareTcReplayStop();
break;
}
case (mpsoc::TC_DOWNLINK_PWR_ON): {
result = prepareTcDownlinkPwrOn(commandData, commandDataLen);
break;
}
case (mpsoc::TC_DOWNLINK_PWR_OFF): {
result = prepareTcDownlinkPwrOff();
break;
}
case (mpsoc::TC_REPLAY_WRITE_SEQUENCE): {
result = prepareTcReplayWriteSequence(commandData, commandDataLen);
break;
}
case (mpsoc::TC_MODE_REPLAY): {
result = prepareTcModeReplay();
break;
}
case (mpsoc::TC_MODE_IDLE): {
result = prepareTcModeIdle();
break;
}
case (mpsoc::TC_CAM_CMD_SEND): {
result = prepareTcCamCmdSend(commandData, commandDataLen);
break;
}
default:
sif::debug << "PlocMPSoCHandler::buildCommandFromCommand: Command not implemented"
<< std::endl;
result = DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
break;
}
if (result == RETURN_OK) {
/**
* Flushing the receive buffer to make sure there are no data left from a faulty reply.
*/
uartComIf->flushUartRxBuffer(comCookie);
}
return result;
}
void PlocMPSoCHandler::fillCommandAndReplyMap() {
this->insertInCommandMap(mpsoc::TC_MEM_WRITE);
this->insertInCommandMap(mpsoc::TC_MEM_READ);
this->insertInCommandMap(mpsoc::TC_FLASHDELETE);
this->insertInCommandMap(mpsoc::TC_REPLAY_START);
this->insertInCommandMap(mpsoc::TC_REPLAY_STOP);
this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_ON);
this->insertInCommandMap(mpsoc::TC_DOWNLINK_PWR_OFF);
this->insertInCommandMap(mpsoc::TC_REPLAY_WRITE_SEQUENCE);
this->insertInCommandMap(mpsoc::TC_MODE_REPLAY);
this->insertInCommandMap(mpsoc::TC_MODE_IDLE);
this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND);
this->insertInCommandMap(mpsoc::RELEASE_UART_TX);
this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE);
this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT);
this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT);
this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, SpacePacket::PACKET_MAX_SIZE);
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MEM_WRITE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MEM_READ));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_FLASHDELETE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_START));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_STOP));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_DOWNLINK_PWR_ON));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF));
this->insertInCommandMap(
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MODE_REPLAY));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_MODE_IDLE));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TC_CAM_CMD_SEND));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::RELEASE_UART_TX));
this->insertInCommandMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::SET_UART_TX_TRISTATE));
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT), 3, nullptr,
mpsoc::SIZE_ACK_REPORT);
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT), 3, nullptr,
mpsoc::SIZE_EXE_REPORT);
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT),
2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT);
this->insertInReplyMap(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT), 2,
nullptr, SpacePacket::PACKET_MAX_SIZE);
}
ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize,
@ -300,28 +237,28 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
switch (apid) {
case (mpsoc::apid::ACK_SUCCESS):
*foundLen = mpsoc::SIZE_ACK_REPORT;
*foundId = mpsoc::ACK_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT);
break;
case (mpsoc::apid::ACK_FAILURE):
*foundLen = mpsoc::SIZE_ACK_REPORT;
*foundId = mpsoc::ACK_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT);
break;
case (mpsoc::apid::TM_MEMORY_READ_REPORT):
*foundLen = tmMemReadReport.rememberRequestedSize;
*foundId = mpsoc::TM_MEMORY_READ_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT);
break;
case (mpsoc::apid::TM_CAM_CMD_RPT):
*foundLen = spacePacket.getFullSize();
tmCamCmdRpt.rememberSpacePacketSize = *foundLen;
*foundId = mpsoc::TM_CAM_CMD_RPT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT);
break;
case (mpsoc::apid::EXE_SUCCESS):
*foundLen = mpsoc::SIZE_EXE_REPORT;
*foundId = mpsoc::EXE_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT);
break;
case (mpsoc::apid::EXE_FAILURE):
*foundLen = mpsoc::SIZE_EXE_REPORT;
*foundId = mpsoc::EXE_REPORT;
*foundId = static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT);
break;
default: {
sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl;
@ -342,20 +279,22 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain
ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
ReturnValue_t result = RETURN_OK;
switch (id) {
case mpsoc::ACK_REPORT: {
PlocMpSoCCommands enumId = PlocMpSoCCommands(id);
switch (enumId) {
case PlocMpSoCCommands::ACK_REPORT: {
result = handleAckReport(packet);
break;
}
case (mpsoc::TM_MEMORY_READ_REPORT): {
case (PlocMpSoCCommands::TM_MEMORY_READ_REPORT): {
result = handleMemoryReadReport(packet);
break;
}
case (mpsoc::TM_CAM_CMD_RPT): {
case (PlocMpSoCCommands::TM_CAM_CMD_RPT): {
result = handleCamCmdRpt(packet);
break;
}
case (mpsoc::EXE_REPORT): {
case (PlocMpSoCCommands::EXE_REPORT): {
result = handleExecutionReport(packet);
break;
}
@ -390,12 +329,11 @@ void PlocMPSoCHandler::handleEvent(EventMessage* eventMessage) {
}
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCMemWriteAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcMemWrite tcMemWrite(sequenceCount);
result = tcMemWrite.createPacket(commandData, commandDataLen);
result = tcMemWrite.createPacket(action);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -403,13 +341,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemWrite(const uint8_t* commandData,
copyToCommandBuffer(&tcMemWrite);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCMemReadAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcMemRead tcMemRead(sequenceCount);
result = tcMemRead.createPacket(commandData, commandDataLen);
//result = tcMemRead.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -418,17 +354,15 @@ ReturnValue_t PlocMPSoCHandler::prepareTcMemRead(const uint8_t* commandData,
tmMemReadReport.rememberRequestedSize = tcMemRead.getMemLen() * 4 + TmMemReadReport::FIX_SIZE;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
size_t commandDataLen) {
if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
return MPSoCReturnValuesIF::NAME_TOO_LONG;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCFlashDeleteAction* action) {
// if (commandDataLen > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
// return MPSoCReturnValuesIF::NAME_TOO_LONG;
// }
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcFlashDelete tcFlashDelete(sequenceCount);
result = tcFlashDelete.createPacket(
std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
//result = tcFlashDelete.createPacket(
// std::string(reinterpret_cast<const char*>(commandData), commandDataLen));
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -436,13 +370,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcFlashDelete(const uint8_t* commandData,
copyToCommandBuffer(&tcFlashDelete);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayStartAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayStart tcReplayStart(sequenceCount);
result = tcReplayStart.createPacket(commandData, commandDataLen);
//result = tcReplayStart.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -450,8 +382,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStart(const uint8_t* commandData,
copyToCommandBuffer(&tcReplayStart);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayStopAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayStop tcReplayStop(sequenceCount);
@ -464,12 +395,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayStop() {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCDownlinkPwrOnAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOn tcDownlinkPwrOn(sequenceCount);
result = tcDownlinkPwrOn.createPacket(commandData, commandDataLen);
//result = tcDownlinkPwrOn.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -477,8 +407,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOn(const uint8_t* commandDat
copyToCommandBuffer(&tcDownlinkPwrOn);
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCDownlinkPwrOffAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcDownlinkPwrOff tcDownlinkPwrOff(sequenceCount);
@ -491,12 +420,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReplayWriteSequenceAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcReplayWriteSeq tcReplayWriteSeq(sequenceCount);
result = tcReplayWriteSeq.createPacket(commandData, commandDataLen);
//result = tcReplayWriteSeq.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
@ -505,7 +433,7 @@ ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* comm
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCModeReplayAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcModeReplay tcModeReplay(sequenceCount);
@ -517,11 +445,11 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeReplay() {
memcpy(commandBuffer, tcModeReplay.getWholeData(), tcModeReplay.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcModeReplay.getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCModeIdleAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcModeIdle tcModeIdle(sequenceCount);
@ -533,22 +461,52 @@ ReturnValue_t PlocMPSoCHandler::prepareTcModeIdle() {
memcpy(commandBuffer, tcModeIdle.getWholeData(), tcModeIdle.getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tcModeIdle.getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData,
size_t commandDataLen) {
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCCamCmdSendAction* action) {
ReturnValue_t result = RETURN_OK;
sequenceCount++;
mpsoc::TcCamcmdSend tcCamCmdSend(sequenceCount);
result = tcCamCmdSend.createPacket(commandData, commandDataLen);
//result = tcCamCmdSend.createPacket(commandData, commandDataLen);
if (result != RETURN_OK) {
sequenceCount--;
return result;
}
copyToCommandBuffer(&tcCamCmdSend);
nextReplyId = mpsoc::TM_CAM_CMD_RPT;
nextReplyId = PlocMpSoCCommands::TM_CAM_CMD_RPT;
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCFlashWriteAction* action) {
ReturnValue_t result;
// if (size > config::MAX_PATH_SIZE + config::MAX_FILENAME_SIZE) {
// return MPSoCReturnValuesIF::FILENAME_TOO_LONG;
// }
mpsoc::FlashWritePusCmd flashWritePusCmd;
//result = flashWritePusCmd.extractFields(data, size);
if (result != RETURN_OK) {
return result;
}
result = plocMPSoCHelper->startFlashWrite(flashWritePusCmd.getObcFile(),
flashWritePusCmd.getMPSoCFile());
if (result != RETURN_OK) {
return result;
}
plocMPSoCHelperExecuting = true;
return EXECUTION_FINISHED;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCUartTxTristateAction* action) {
// not used
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCReleaseUartTxAction* action) {
// not used
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHandler::handleAction(PlocMpSoCObswResetSeqCountAction* action) {
// not used
return RETURN_OK;
}
@ -559,7 +517,7 @@ void PlocMPSoCHandler::copyToCommandBuffer(mpsoc::TcBase* tc) {
memcpy(commandBuffer, tc->getWholeData(), tc->getFullSize());
rawPacket = commandBuffer;
rawPacketLen = tc->getFullSize();
nextReplyId = mpsoc::ACK_REPORT;
nextReplyId = PlocMpSoCCommands::ACK_REPORT;
}
ReturnValue_t PlocMPSoCHandler::verifyPacket(const uint8_t* start, size_t foundLen) {
@ -577,10 +535,10 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
result = verifyPacket(data, mpsoc::SIZE_ACK_REPORT);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocMPSoCHandler::handleAckReport: CRC failure" << std::endl;
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
replyRawReplyIfnotWiretapped(data, mpsoc::SIZE_ACK_REPORT);
triggerEvent(MPSOC_HANDLER_CRC_FAILURE);
sendFailureReport(mpsoc::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
sendFailureReport(PlocMpSoCCommands::ACK_REPORT, MPSoCReturnValuesIF::CRC_FAILURE);
disableAllReplies();
return IGNORE_REPLY_DATA;
}
@ -596,9 +554,9 @@ ReturnValue_t PlocMPSoCHandler::handleAckReport(const uint8_t* data) {
if (commandId != DeviceHandlerIF::NO_COMMAND_ID) {
triggerEvent(ACK_FAILURE, commandId, status);
}
sendFailureReport(mpsoc::ACK_REPORT, status);
sendFailureReport(PlocMpSoCCommands::ACK_REPORT, status);
disableAllReplies();
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
result = IGNORE_REPLY_DATA;
break;
}
@ -622,7 +580,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
result = verifyPacket(data, mpsoc::SIZE_EXE_REPORT);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocMPSoCHandler::handleExecutionReport: CRC failure" << std::endl;
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
return result;
}
@ -644,7 +602,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
sif::debug << "PlocMPSoCHandler::handleExecutionReport: Unknown command id" << std::endl;
}
printStatus(data);
sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
sendFailureReport(PlocMpSoCCommands::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE);
disableExeReportReply();
result = IGNORE_REPLY_DATA;
break;
@ -655,7 +613,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) {
break;
}
}
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
return result;
}
@ -670,8 +628,8 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
*(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1);
/** Send data to commanding queue */
handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4,
mpsoc::TM_MEMORY_READ_REPORT);
nextReplyId = mpsoc::EXE_REPORT;
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
nextReplyId = PlocMpSoCCommands::EXE_REPORT;
return result;
}
@ -694,7 +652,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
<< static_cast<unsigned int>(ackValue) << std::endl;
#endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */
handleDeviceTM(packet.getPacketData() + sizeof(uint16_t), packet.getPacketDataLength() - 1,
mpsoc::TM_CAM_CMD_RPT);
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
return result;
}
@ -705,41 +663,47 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
uint8_t enabledReplies = 0;
switch (command->first) {
case mpsoc::TC_MEM_WRITE:
case mpsoc::TC_FLASHDELETE:
case mpsoc::TC_REPLAY_START:
case mpsoc::TC_REPLAY_STOP:
case mpsoc::TC_DOWNLINK_PWR_ON:
case mpsoc::TC_DOWNLINK_PWR_OFF:
case mpsoc::TC_REPLAY_WRITE_SEQUENCE:
case mpsoc::TC_MODE_REPLAY:
case mpsoc::TC_MODE_IDLE:
PlocMpSoCCommands enumCommand = PlocMpSoCCommands(command->first);
switch (enumCommand) {
case PlocMpSoCCommands::TC_MEM_WRITE:
case PlocMpSoCCommands::TC_FLASHDELETE:
case PlocMpSoCCommands::TC_REPLAY_START:
case PlocMpSoCCommands::TC_REPLAY_STOP:
case PlocMpSoCCommands::TC_DOWNLINK_PWR_ON:
case PlocMpSoCCommands::TC_DOWNLINK_PWR_OFF:
case PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE:
case PlocMpSoCCommands::TC_MODE_REPLAY:
case PlocMpSoCCommands::TC_MODE_IDLE:
enabledReplies = 2;
break;
case mpsoc::TC_MEM_READ: {
case PlocMpSoCCommands::TC_MEM_READ: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
mpsoc::TM_MEMORY_READ_REPORT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true,
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl;
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT)
<< " not in replyMap" << std::endl;
return result;
}
break;
}
case mpsoc::TC_CAM_CMD_SEND: {
case PlocMpSoCCommands::TC_CAM_CMD_SEND: {
enabledReplies = 3;
result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true,
mpsoc::TM_CAM_CMD_RPT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true,
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< mpsoc::TM_CAM_CMD_RPT << " not in replyMap" << std::endl;
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT)
<< " not in replyMap" << std::endl;
return result;
}
break;
}
case mpsoc::OBSW_RESET_SEQ_COUNT:
case PlocMpSoCCommands::OBSW_RESET_SEQ_COUNT:
break;
default:
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Unknown command id" << std::endl;
@ -750,32 +714,36 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
* Every command causes at least one acknowledgment and one execution report. Therefore both
* replies will be enabled here.
*/
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::ACK_REPORT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true, static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::ACK_REPORT
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT)
<< " not in replyMap" << std::endl;
}
result =
DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, mpsoc::EXE_REPORT);
result = DeviceHandlerBase::enableReplyInReplyMap(
command, enabledReplies, true, static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
if (result != RETURN_OK) {
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " << mpsoc::EXE_REPORT
sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id "
<< static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT)
<< " not in replyMap" << std::endl;
}
switch (command->first) {
case mpsoc::TC_REPLAY_WRITE_SEQUENCE: {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
switch (enumCommand) {
case PlocMpSoCCommands::TC_REPLAY_WRITE_SEQUENCE: {
DeviceReplyIter iter =
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
// Overwrite delay cycles because replay write sequence command can required up to
// 30 seconds for execution
iter->second.delayCycles = mpsoc::TC_WRITE_SEQ_EXECUTION_DELAY;
break;
}
case mpsoc::TC_DOWNLINK_PWR_ON: {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
case PlocMpSoCCommands::TC_DOWNLINK_PWR_ON: {
DeviceReplyIter iter =
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
//
iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON;
iter->second.delayCycles = mpsoc::TC_DOWNLINK_PWR_ON_EXECUTION_DELAY;
break;
}
default:
@ -786,24 +754,24 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator
}
void PlocMPSoCHandler::setNextReplyId() {
switch (getPendingCommand()) {
case mpsoc::TC_MEM_READ:
nextReplyId = mpsoc::TM_MEMORY_READ_REPORT;
switch (PlocMpSoCCommands(getPendingCommand())) {
case PlocMpSoCCommands::TC_MEM_READ:
nextReplyId = PlocMpSoCCommands::TM_MEMORY_READ_REPORT;
break;
default:
/* If no telemetry is expected the next reply is always the execution report */
nextReplyId = mpsoc::EXE_REPORT;
nextReplyId = PlocMpSoCCommands::EXE_REPORT;
break;
}
}
size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
size_t replyLen = 0;
if (nextReplyId == mpsoc::NONE) {
if (nextReplyId == PlocMpSoCCommands::NONE) {
return replyLen;
}
DeviceReplyIter iter = deviceReplyMap.find(nextReplyId);
DeviceReplyIter iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(nextReplyId));
if (iter != deviceReplyMap.end()) {
if (iter->second.delayCycles == 0) {
@ -811,11 +779,11 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
return replyLen;
}
switch (nextReplyId) {
case mpsoc::TM_MEMORY_READ_REPORT: {
case PlocMpSoCCommands::TM_MEMORY_READ_REPORT: {
replyLen = tmMemReadReport.rememberRequestedSize;
break;
}
case mpsoc::TM_CAM_CMD_RPT:
case PlocMpSoCCommands::TM_CAM_CMD_RPT:
// Read acknowledgment, camera and execution report in one go because length of camera
// report is not fixed
replyLen = SpacePacket::PACKET_MAX_SIZE;
@ -827,7 +795,8 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) {
}
} else {
sif::debug << "PlocMPSoCHandler::getNextReplyLength: No entry for reply with reply id "
<< std::hex << nextReplyId << " in deviceReplyMap" << std::endl;
<< std::hex << static_cast<DeviceCommandId_t>(nextReplyId) << " in deviceReplyMap"
<< std::endl;
}
return replyLen;
@ -924,31 +893,33 @@ void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize,
}
void PlocMPSoCHandler::disableAllReplies() {
using namespace mpsoc;
DeviceReplyMap::iterator iter;
/* Disable ack reply */
iter = deviceReplyMap.find(ACK_REPORT);
iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::ACK_REPORT));
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();
DeviceCommandId_t commandId = getPendingCommand();
PlocMpSoCCommands enumCommand = PlocMpSoCCommands(commandId);
/* If the command expects a telemetry packet the appropriate tm reply will be disabled here */
switch (commandId) {
case TC_MEM_WRITE:
switch (enumCommand) {
case PlocMpSoCCommands::TC_MEM_WRITE:
break;
case TC_MEM_READ: {
iter = deviceReplyMap.find(TM_MEMORY_READ_REPORT);
case PlocMpSoCCommands::TC_MEM_READ: {
iter = deviceReplyMap.find(
static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_MEMORY_READ_REPORT));
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
info->command = deviceCommandMap.end();
break;
}
case TC_CAM_CMD_SEND: {
iter = deviceReplyMap.find(TM_CAM_CMD_RPT);
case PlocMpSoCCommands::TC_CAM_CMD_SEND: {
iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::TM_CAM_CMD_RPT));
info = &(iter->second);
info->delayCycles = 0;
info->active = false;
@ -964,11 +935,11 @@ void PlocMPSoCHandler::disableAllReplies() {
/* We always need to disable the execution report reply here */
disableExeReportReply();
nextReplyId = mpsoc::NONE;
nextReplyId = PlocMpSoCCommands::NONE;
}
void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(replyId);
void PlocMPSoCHandler::sendFailureReport(PlocMpSoCCommands replyId, ReturnValue_t status) {
DeviceReplyIter iter = deviceReplyMap.find(static_cast<DeviceCommandId_t>(replyId));
if (iter == deviceReplyMap.end()) {
sif::debug << "PlocMPSoCHandler::sendFailureReport: Reply not in reply map" << std::endl;
return;
@ -985,7 +956,8 @@ void PlocMPSoCHandler::sendFailureReport(DeviceCommandId_t replyId, ReturnValue_
}
void PlocMPSoCHandler::disableExeReportReply() {
DeviceReplyIter iter = deviceReplyMap.find(mpsoc::EXE_REPORT);
DeviceReplyIter iter =
deviceReplyMap.find(static_cast<DeviceCommandId_t>(PlocMpSoCCommands::EXE_REPORT));
DeviceReplyInfo* info = &(iter->second);
info->delayCycles = 0;
info->command = deviceCommandMap.end();

View File

@ -48,8 +48,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
object_id_t supervisorHandler);
virtual ~PlocMPSoCHandler();
virtual ReturnValue_t initialize() override;
ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) override;
ReturnValue_t executeAction(Action* action) override;
void performOperationHook() override;
MessageQueueIF* getCommandQueuePtr() override;
void stepSuccessfulReceived(ActionId_t actionId, uint8_t step) override;
@ -58,6 +57,22 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
void completionSuccessfulReceived(ActionId_t actionId) override;
void completionFailedReceived(ActionId_t actionId, ReturnValue_t returnCode) override;
ReturnValue_t handleAction(PlocMpSoCMemWriteAction* action);
ReturnValue_t handleAction(PlocMpSoCMemReadAction* action);
ReturnValue_t handleAction(PlocMpSoCFlashDeleteAction* action);
ReturnValue_t handleAction(PlocMpSoCReplayStartAction* action);
ReturnValue_t handleAction(PlocMpSoCReplayStopAction* action);
ReturnValue_t handleAction(PlocMpSoCReplayWriteSequenceAction* action);
ReturnValue_t handleAction(PlocMpSoCDownlinkPwrOnAction* action);
ReturnValue_t handleAction(PlocMpSoCDownlinkPwrOffAction* action);
ReturnValue_t handleAction(PlocMpSoCModeReplayAction* action);
ReturnValue_t handleAction(PlocMpSoCCamCmdSendAction* action);
ReturnValue_t handleAction(PlocMpSoCModeIdleAction* action);
ReturnValue_t handleAction(PlocMpSoCFlashWriteAction* action);
ReturnValue_t handleAction(PlocMpSoCUartTxTristateAction* action);
ReturnValue_t handleAction(PlocMpSoCReleaseUartTxAction* action);
ReturnValue_t handleAction(PlocMpSoCObswResetSeqCountAction* action);
protected:
void doStartUp() override;
void doShutDown() override;
@ -121,7 +136,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
* because the PLOC sends as reply to each command at least one acknowledgment and execution
* report.
*/
DeviceCommandId_t nextReplyId = mpsoc::NONE;
PlocMpSoCCommands nextReplyId = PlocMpSoCCommands::NONE;
UartComIF* uartComIf = nullptr;
@ -172,6 +187,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen);
ReturnValue_t prepareTcModeIdle();
/**
* @brief Copies space packet into command buffer
*/
@ -248,7 +264,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
* @param replyId The id of the reply which signals a failure.
* @param status A status byte which gives information about the failure type.
*/
void sendFailureReport(DeviceCommandId_t replyId, ReturnValue_t status);
void sendFailureReport(PlocMpSoCCommands replyId, ReturnValue_t status);
/**
* @brief This function disables the execution report reply. Within this function also the

View File

@ -10,7 +10,7 @@
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcservices/SourceSequenceCounter.h"
#include "fsfw_hal/linux/uart/UartComIF.h"
#include "linux/devices/devicedefinitions/PlocMPSoCDefinitions.h"
#include "linux/devices/devicedefinitions/PlocMPSoCCommonDefinitions.h"
#ifdef XIPHOS_Q7S
#include "bsp_q7s/memory/SdCardManager.h"
#endif