it compiles again

This commit is contained in:
Robin Müller 2022-08-15 18:34:26 +02:00
parent 0c371623c6
commit 7e3517d309
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
14 changed files with 259 additions and 249 deletions

View File

@ -92,7 +92,8 @@ ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &local
localDataPoolMap.emplace(core::TEMPERATURE, new PoolEntry<float>({0})); localDataPoolMap.emplace(core::TEMPERATURE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(core::PS_VOLTAGE, new PoolEntry<float>({0})); localDataPoolMap.emplace(core::PS_VOLTAGE, new PoolEntry<float>({0}));
localDataPoolMap.emplace(core::PL_VOLTAGE, new PoolEntry<float>({0})); localDataPoolMap.emplace(core::PL_VOLTAGE, new PoolEntry<float>({0}));
poolManager.subscribeForPeriodicPacket(hkSet.getSid(), false, 10.0, false); poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(hkSet.getSid(), false, 10.0));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -95,8 +95,8 @@
ResetArgs RESET_ARGS_GNSS; ResetArgs RESET_ARGS_GNSS;
void Factory::setStaticFrameworkObjectIds() { void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_PACKET_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL; PusServiceBase::PACKET_DESTINATION = objects::TM_FUNNEL;
CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
@ -117,8 +117,7 @@ void Factory::setStaticFrameworkObjectIds() {
LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING; LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
} }
void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); } void ObjectFactory::setStatics() { Factory::setStaticFrameworkObjectIds(); }

View File

@ -87,7 +87,8 @@ ReturnValue_t GPSHyperionLinuxController::initializeLocalDataPool(
localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_USE, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry<uint8_t>()); localDataPoolMap.emplace(GpsHyperion::SATS_IN_VIEW, new PoolEntry<uint8_t>());
localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>()); localDataPoolMap.emplace(GpsHyperion::FIX_MODE, new PoolEntry<uint8_t>());
poolManager.subscribeForPeriodicPacket(gpsSet.getSid(), false, 30.0, false); poolManager.subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams(gpsSet.getSid(), false, 30.0));
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -136,7 +136,7 @@ static const uint16_t RESERVED_4 = 0x5F4;
/** /**
* @brief Abstract base class for TC space packet of MPSoC. * @brief Abstract base class for TC space packet of MPSoC.
*/ */
class TcBase : public SpacePacketBase, public MPSoCReturnValuesIF { class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
public: public:
virtual ~TcBase() = default; virtual ~TcBase() = default;
@ -149,8 +149,8 @@ class TcBase : public SpacePacketBase, public MPSoCReturnValuesIF {
* @param sequenceCount Sequence count of space packet which will be incremented with each * @param sequenceCount Sequence count of space packet which will be incremented with each
* sent and received packets. * sent and received packets.
*/ */
TcBase(SpBaseParams params, uint16_t apid, uint16_t sequenceCount) TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
: SpacePacketBase(params, apid, sequenceCount) { : ploc::SpTcBase(params, apid, sequenceCount) {
spParams.setDataFieldLen(INIT_LENGTH); spParams.setDataFieldLen(INIT_LENGTH);
} }
@ -194,28 +194,6 @@ class TcBase : public SpacePacketBase, public MPSoCReturnValuesIF {
} }
}; };
/**
* @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. * @brief This class helps to build the memory read command for the PLOC.
*/ */
@ -224,7 +202,7 @@ class TcMemRead : public TcBase {
/** /**
* @brief Constructor * @brief Constructor
*/ */
TcMemRead(SpBaseParams params, uint16_t sequenceCount) TcMemRead(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MEM_READ, sequenceCount) { : TcBase(params, apid::TC_MEM_READ, sequenceCount) {
spParams.setPayloadLen(COMMAND_LENGTH); spParams.setPayloadLen(COMMAND_LENGTH);
} }
@ -276,7 +254,7 @@ class TcMemWrite : public TcBase {
/** /**
* @brief Constructor * @brief Constructor
*/ */
TcMemWrite(SpBaseParams params, uint16_t sequenceCount) TcMemWrite(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {} : TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
protected: protected:
@ -312,10 +290,10 @@ class TcMemWrite : public TcBase {
/** /**
* @brief Class to help creation of flash fopen command. * @brief Class to help creation of flash fopen command.
*/ */
class FlashFopen : public SpacePacketBase { class FlashFopen : public ploc::SpTcBase {
public: public:
FlashFopen(SpBaseParams params, uint16_t sequenceCount) FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHFOPEN, sequenceCount) {} : ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
static const char APPEND = 'a'; static const char APPEND = 'a';
static const char WRITE = 'w'; static const char WRITE = 'w';
@ -323,7 +301,6 @@ class FlashFopen : public SpacePacketBase {
ReturnValue_t createPacket(std::string filename, char accessMode_) { ReturnValue_t createPacket(std::string filename, char accessMode_) {
accessMode = accessMode_; accessMode = accessMode_;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size(); size_t nameSize = filename.size();
std::memcpy(payloadStart, filename.c_str(), nameSize); std::memcpy(payloadStart, filename.c_str(), nameSize);
*(spParams.buf + nameSize) = NULL_TERMINATOR; *(spParams.buf + nameSize) = NULL_TERMINATOR;
@ -342,7 +319,7 @@ class FlashFopen : public SpacePacketBase {
*/ */
class FlashFclose : public TcBase { class FlashFclose : public TcBase {
public: public:
FlashFclose(SpBaseParams params, uint16_t sequenceCount) FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {} : TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) { ReturnValue_t createPacket(std::string filename) {
@ -357,12 +334,12 @@ class FlashFclose : public TcBase {
/** /**
* @brief Class to build flash write space packet. * @brief Class to build flash write space packet.
*/ */
class TcFlashWrite : public SpacePacketBase { class TcFlashWrite : public ploc::SpTcBase {
public: public:
TcFlashWrite(SpBaseParams params, uint16_t sequenceCount) TcFlashWrite(ploc::SpTcParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHWRITE, sequenceCount) {} : ploc::SpTcBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
ReturnValue_t createPacket(const uint8_t* writeData, uint32_t writeLen_) { ReturnValue_t buildPacket(const uint8_t* writeData, uint32_t writeLen_) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
writeLen = writeLen_; writeLen = writeLen_;
if (writeLen > MAX_DATA_SIZE) { if (writeLen > MAX_DATA_SIZE) {
@ -392,13 +369,12 @@ class TcFlashWrite : public SpacePacketBase {
/** /**
* @brief Class to help creation of flash delete command. * @brief Class to help creation of flash delete command.
*/ */
class TcFlashDelete : public SpacePacketBase { class TcFlashDelete : public ploc::SpTcBase {
public: public:
TcFlashDelete(SpBaseParams params, uint16_t sequenceCount) TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHDELETE, sequenceCount) {} : ploc::SpTcBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
ReturnValue_t buildPacket(std::string filename) { ReturnValue_t buildPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size(); size_t nameSize = filename.size();
std::memcpy(payloadStart, filename.c_str(), nameSize); std::memcpy(payloadStart, filename.c_str(), nameSize);
*(payloadStart + nameSize) = NULL_TERMINATOR; *(payloadStart + nameSize) = NULL_TERMINATOR;
@ -417,7 +393,7 @@ class TcFlashDelete : public SpacePacketBase {
*/ */
class TcReplayStop : public TcBase { class TcReplayStop : public TcBase {
public: public:
TcReplayStop(SpBaseParams params, uint16_t sequenceCount) TcReplayStop(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_STOP, sequenceCount) {} : TcBase(params, apid::TC_REPLAY_STOP, sequenceCount) {}
}; };
@ -429,7 +405,7 @@ class TcReplayStart : public TcBase {
/** /**
* @brief Constructor * @brief Constructor
*/ */
TcReplayStart(SpBaseParams params, uint16_t sequenceCount) TcReplayStart(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {} : TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
protected: protected:
@ -478,7 +454,7 @@ class TcDownlinkPwrOn : public TcBase {
/** /**
* @brief Constructor * @brief Constructor
*/ */
TcDownlinkPwrOn(SpBaseParams params, uint16_t sequenceCount) TcDownlinkPwrOn(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {} : TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
protected: protected:
@ -545,7 +521,7 @@ class TcDownlinkPwrOn : public TcBase {
*/ */
class TcDownlinkPwrOff : public TcBase { class TcDownlinkPwrOff : public TcBase {
public: public:
TcDownlinkPwrOff(SpBaseParams params, uint16_t sequenceCount) TcDownlinkPwrOff(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {} : TcBase(params, apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
}; };
@ -557,7 +533,7 @@ class TcReplayWriteSeq : public TcBase {
/** /**
* @brief Constructor * @brief Constructor
*/ */
TcReplayWriteSeq(SpBaseParams params, uint16_t sequenceCount) TcReplayWriteSeq(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {} : TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
protected: protected:
@ -624,7 +600,7 @@ class FlashWritePusCmd : public MPSoCReturnValuesIF {
*/ */
class TcModeReplay : public TcBase { class TcModeReplay : public TcBase {
public: public:
TcModeReplay(SpBaseParams params, uint16_t sequenceCount) TcModeReplay(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MODE_REPLAY, sequenceCount) {} : TcBase(params, apid::TC_MODE_REPLAY, sequenceCount) {}
}; };
@ -633,13 +609,13 @@ class TcModeReplay : public TcBase {
*/ */
class TcModeIdle : public TcBase { class TcModeIdle : public TcBase {
public: public:
TcModeIdle(SpBaseParams params, uint16_t sequenceCount) TcModeIdle(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MODE_IDLE, sequenceCount) {} : TcBase(params, apid::TC_MODE_IDLE, sequenceCount) {}
}; };
class TcCamcmdSend : public TcBase { class TcCamcmdSend : public TcBase {
public: public:
TcCamcmdSend(SpBaseParams params, uint16_t sequenceCount) TcCamcmdSend(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {} : TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
protected: protected:

View File

@ -281,7 +281,7 @@ static const uint32_t UPDATE_STATUS_REPORT = 70000;
/** /**
* @brief This class creates a space packet containing only the header data and the CRC. * @brief This class creates a space packet containing only the header data and the CRC.
*/ */
class ApidOnlyPacket : public SpacePacketBase { class ApidOnlyPacket : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -290,7 +290,7 @@ class ApidOnlyPacket : public SpacePacketBase {
* *
* @note Sequence count of empty packet is always 1. * @note Sequence count of empty packet is always 1.
*/ */
ApidOnlyPacket(SpBaseParams params, uint16_t apid) : SpacePacketBase(params) { ApidOnlyPacket(ploc::SpTcParams params, uint16_t apid) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(LENGTH_EMPTY_TC); spParams.setDataFieldLen(LENGTH_EMPTY_TC);
spParams.creator.setApid(apid); spParams.creator.setApid(apid);
} }
@ -310,7 +310,7 @@ class ApidOnlyPacket : public SpacePacketBase {
* @brief This class can be used to generate the space packet selecting the boot image of * @brief This class can be used to generate the space packet selecting the boot image of
* of the MPSoC. * of the MPSoC.
*/ */
class MPSoCBootSelect : public SpacePacketBase { class MPSoCBootSelect : public ploc::SpTcBase {
public: public:
static const uint8_t NVM0 = 0; static const uint8_t NVM0 = 0;
static const uint8_t NVM1 = 1; static const uint8_t NVM1 = 1;
@ -325,7 +325,7 @@ class MPSoCBootSelect : public SpacePacketBase {
* *
* @note Selection of partitions is currently not supported. * @note Selection of partitions is currently not supported.
*/ */
MPSoCBootSelect(SpBaseParams params) : SpacePacketBase(params) { MPSoCBootSelect(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE); spParams.creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -361,7 +361,7 @@ class MPSoCBootSelect : public SpacePacketBase {
* @brief This class creates the command to enable or disable the NVMs connected to the * @brief This class creates the command to enable or disable the NVMs connected to the
* supervisor. * supervisor.
*/ */
class EnableNvms : public SpacePacketBase { class EnableNvms : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -371,7 +371,7 @@ class EnableNvms : public SpacePacketBase {
* @param bp1 Partition pin 1 * @param bp1 Partition pin 1
* @param bp2 Partition pin 2 * @param bp2 Partition pin 2
*/ */
EnableNvms(SpBaseParams params) : SpacePacketBase(params) { EnableNvms(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_ENABLE_NVMS); spParams.creator.setApid(APID_ENABLE_NVMS);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -399,9 +399,9 @@ class EnableNvms : public SpacePacketBase {
/** /**
* @brief This class generates the space packet to update the time of the PLOC supervisor. * @brief This class generates the space packet to update the time of the PLOC supervisor.
*/ */
class SetTimeRef : public SpacePacketBase { class SetTimeRef : public ploc::SpTcBase {
public: public:
SetTimeRef(SpBaseParams params) : SpacePacketBase(params) { SetTimeRef(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_TIME_REF); spParams.creator.setApid(APID_SET_TIME_REF);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -457,14 +457,14 @@ class SetTimeRef : public SpacePacketBase {
/** /**
* @brief This class can be used to generate the set boot timout command. * @brief This class can be used to generate the set boot timout command.
*/ */
class SetBootTimeout : public SpacePacketBase { class SetBootTimeout : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* *
* @param timeout The boot timeout in milliseconds. * @param timeout The boot timeout in milliseconds.
*/ */
SetBootTimeout(SpBaseParams params) : SpacePacketBase(params) { SetBootTimeout(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_BOOT_TIMEOUT); spParams.creator.setApid(APID_SET_BOOT_TIMEOUT);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -494,14 +494,14 @@ class SetBootTimeout : public SpacePacketBase {
/** /**
* @brief This class can be used to generate the space packet to set the maximum boot tries. * @brief This class can be used to generate the space packet to set the maximum boot tries.
*/ */
class SetRestartTries : public SpacePacketBase { class SetRestartTries : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* *
* @param restartTries Maximum restart tries to set. * @param restartTries Maximum restart tries to set.
*/ */
SetRestartTries(SpBaseParams params) : SpacePacketBase(params) { SetRestartTries(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_MAX_RESTART_TRIES); spParams.creator.setApid(APID_SET_MAX_RESTART_TRIES);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -530,12 +530,12 @@ class SetRestartTries : public SpacePacketBase {
* of housekeeping data. Normally, this will be disabled by default. However, adding this * of housekeeping data. Normally, this will be disabled by default. However, adding this
* command can be useful for debugging. * command can be useful for debugging.
*/ */
class DisablePeriodicHkTransmission : public SpacePacketBase { class DisablePeriodicHkTransmission : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
*/ */
DisablePeriodicHkTransmission(SpBaseParams params) : SpacePacketBase(params) { DisablePeriodicHkTransmission(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_DISABLE_HK); spParams.creator.setApid(APID_DISABLE_HK);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -562,7 +562,7 @@ class DisablePeriodicHkTransmission : public SpacePacketBase {
* *
* @details There are 7 different latchup alerts. * @details There are 7 different latchup alerts.
*/ */
class LatchupAlert : public SpacePacketBase { class LatchupAlert : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -571,7 +571,7 @@ class LatchupAlert : public SpacePacketBase {
* @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC, * @param latchupId Identifies the latchup to enable/disable (0 - 0.85V, 1 - 1.8V, 2 - MISC,
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
*/ */
LatchupAlert(SpBaseParams params) : SpacePacketBase(params) { LatchupAlert(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
} }
@ -600,7 +600,7 @@ class LatchupAlert : public SpacePacketBase {
void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; } void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; }
}; };
class SetAlertlimit : public SpacePacketBase { class SetAlertlimit : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -609,7 +609,7 @@ class SetAlertlimit : public SpacePacketBase {
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS) * 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
* @param dutycycle * @param dutycycle
*/ */
SetAlertlimit(SpBaseParams params) : SpacePacketBase(params) { SetAlertlimit(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ALERT_LIMIT); spParams.creator.setApid(APID_SET_ALERT_LIMIT);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -645,14 +645,14 @@ class SetAlertlimit : public SpacePacketBase {
/** /**
* @brief This class packages the space packet to enable or disable ADC channels. * @brief This class packages the space packet to enable or disable ADC channels.
*/ */
class SetAdcEnabledChannels : public SpacePacketBase { class SetAdcEnabledChannels : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* *
* @param ch Defines channels to be enabled or disabled. * @param ch Defines channels to be enabled or disabled.
*/ */
SetAdcEnabledChannels(SpBaseParams params) : SpacePacketBase(params) { SetAdcEnabledChannels(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_ENABLED_CHANNELS); spParams.creator.setApid(APID_SET_ADC_ENABLED_CHANNELS);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -683,7 +683,7 @@ class SetAdcEnabledChannels : public SpacePacketBase {
* @brief This class packages the space packet to configures the window size and striding step of * @brief This class packages the space packet to configures the window size and striding step of
* the moving average filter applied to the ADC readings. * the moving average filter applied to the ADC readings.
*/ */
class SetAdcWindowAndStride : public SpacePacketBase { class SetAdcWindowAndStride : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -691,7 +691,7 @@ class SetAdcWindowAndStride : public SpacePacketBase {
* @param windowSize * @param windowSize
* @param stridingStepSize * @param stridingStepSize
*/ */
SetAdcWindowAndStride(SpBaseParams params) : SpacePacketBase(params) { SetAdcWindowAndStride(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE); spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -724,14 +724,14 @@ class SetAdcWindowAndStride : public SpacePacketBase {
/** /**
* @brief This class packages the space packet to set the ADC trigger threshold. * @brief This class packages the space packet to set the ADC trigger threshold.
*/ */
class SetAdcThreshold : public SpacePacketBase { class SetAdcThreshold : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* *
* @param threshold * @param threshold
*/ */
SetAdcThreshold(SpBaseParams params) : SpacePacketBase(params) { SetAdcThreshold(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_THRESHOLD); spParams.creator.setApid(APID_SET_ADC_THRESHOLD);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -762,14 +762,14 @@ class SetAdcThreshold : public SpacePacketBase {
/** /**
* @brief This class packages the space packet to run auto EM tests. * @brief This class packages the space packet to run auto EM tests.
*/ */
class RunAutoEmTests : public SpacePacketBase { class RunAutoEmTests : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
* *
* @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3) * @param test 1 - complete EM test, 2 - Short test (only memory readback NVM0,1,3)
*/ */
RunAutoEmTests(SpBaseParams params) : SpacePacketBase(params) { RunAutoEmTests(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_RUN_AUTO_EM_TESTS); spParams.creator.setApid(APID_RUN_AUTO_EM_TESTS);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -798,7 +798,7 @@ class RunAutoEmTests : public SpacePacketBase {
/** /**
* @brief This class packages the space packet to wipe or dump parts of the MRAM. * @brief This class packages the space packet to wipe or dump parts of the MRAM.
*/ */
class MramCmd : public SpacePacketBase { class MramCmd : public ploc::SpTcBase {
public: public:
enum class MramAction { WIPE, DUMP }; enum class MramAction { WIPE, DUMP };
@ -811,7 +811,7 @@ class MramCmd : public SpacePacketBase {
* *
* @note The content at the stop address is excluded from the dump or wipe operation. * @note The content at the stop address is excluded from the dump or wipe operation.
*/ */
MramCmd(SpBaseParams params) : SpacePacketBase(params) { MramCmd(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
} }
@ -856,7 +856,7 @@ class MramCmd : public SpacePacketBase {
* @brief This class packages the space packet change the state of a GPIO. This command is only * @brief This class packages the space packet change the state of a GPIO. This command is only
* required for ground testing. * required for ground testing.
*/ */
class SetGpio : public SpacePacketBase { class SetGpio : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -865,7 +865,7 @@ class SetGpio : public SpacePacketBase {
* @param pin * @param pin
* @param val * @param val
*/ */
SetGpio(SpBaseParams params) : SpacePacketBase(params) { SetGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_GPIO); spParams.creator.setApid(APID_SET_GPIO);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -901,7 +901,7 @@ class SetGpio : public SpacePacketBase {
* @brief This class packages the space packet causing the supervisor print the state of a GPIO * @brief This class packages the space packet causing the supervisor print the state of a GPIO
* to the debug output. * to the debug output.
*/ */
class ReadGpio : public SpacePacketBase { class ReadGpio : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -909,7 +909,7 @@ class ReadGpio : public SpacePacketBase {
* @param port * @param port
* @param pin * @param pin
*/ */
ReadGpio(SpBaseParams params) : SpacePacketBase(params) { ReadGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH); spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_READ_GPIO); spParams.creator.setApid(APID_READ_GPIO);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -947,7 +947,7 @@ class ReadGpio : public SpacePacketBase {
* OP = 0x01: Only the mirror entries will be wiped. * OP = 0x01: Only the mirror entries will be wiped.
* OP = 0x02: Only the circular entries will be wiped. * OP = 0x02: Only the circular entries will be wiped.
*/ */
class FactoryReset : public SpacePacketBase { class FactoryReset : public ploc::SpTcBase {
public: public:
enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES }; enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES };
@ -956,7 +956,7 @@ class FactoryReset : public SpacePacketBase {
* *
* @param op * @param op
*/ */
FactoryReset(SpBaseParams params) : SpacePacketBase(params) { FactoryReset(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.creator.setApid(APID_FACTORY_RESET); spParams.creator.setApid(APID_FACTORY_RESET);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
} }
@ -991,38 +991,9 @@ class FactoryReset : public SpacePacketBase {
} }
}; };
// class SupvTcSpacePacket : public SpacePacketBase { class SetShutdownTimeout : public ploc::SpTcBase {
// public:
// /**
// * @brief Constructor
// *
// * @param payloadDataLen Length of data field without CRC
// */
// SupvTcSpacePacket(SpBaseParams params): SpacePacketBase(params) {
// spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
// }
//
// ReturnValue_t buildPacket(uint16_t payloadDataLenWithoutCrc, uint16_t apid) {
// spParams.setPayloadLen(payloadDataLenWithoutCrc + 2);
// spParams.creator.setApid(apid);
// auto res = checkSizeAndSerializeHeader();
// if(res != result::OK) {
// return res;
// }
// return calcCrc();
// }
//
// private:
// // The sequence count of most of the TC packets for the supervisor is 1.
// static const uint16_t DEFAULT_SEQUENCE_COUNT = 1;
//
// // The size of the payload data (data field without crc size)
// size_t payloadDataLen = 0;
// };
class SetShutdownTimeout : public SpacePacketBase {
public: public:
SetShutdownTimeout(SpBaseParams params) : SpacePacketBase(params) { SetShutdownTimeout(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LEN); spParams.setPayloadLen(PAYLOAD_LEN);
spParams.creator.setApid(APID_SET_SHUTDOWN_TIMEOUT); spParams.creator.setApid(APID_SET_SHUTDOWN_TIMEOUT);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -1052,7 +1023,7 @@ class SetShutdownTimeout : public SpacePacketBase {
/** /**
* @brief Command to request CRC over memory region of the supervisor. * @brief Command to request CRC over memory region of the supervisor.
*/ */
class CheckMemory : public SpacePacketBase { class CheckMemory : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -1061,7 +1032,7 @@ class CheckMemory : public SpacePacketBase {
* @param startAddress Start address of CRC calculation * @param startAddress Start address of CRC calculation
* @param length Length in bytes of memory region * @param length Length in bytes of memory region
*/ */
CheckMemory(SpBaseParams params) : SpacePacketBase(params) { CheckMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH); spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_CHECK_MEMORY); spParams.creator.setApid(APID_CHECK_MEMORY);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -1100,7 +1071,7 @@ class CheckMemory : public SpacePacketBase {
/** /**
* @brief This class packages the space packet transporting a part of an MPSoC update. * @brief This class packages the space packet transporting a part of an MPSoC update.
*/ */
class WriteMemory : public SpacePacketBase { class WriteMemory : public ploc::SpTcBase {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -1109,7 +1080,7 @@ class WriteMemory : public SpacePacketBase {
* @param sequenceCount Sequence count (first update packet expects 1 as sequence count) * @param sequenceCount Sequence count (first update packet expects 1 as sequence count)
* @param updateData Pointer to buffer containing update data * @param updateData Pointer to buffer containing update data
*/ */
WriteMemory(SpBaseParams params) : SpacePacketBase(params) { WriteMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.creator.setApid(APID_WRITE_MEMORY); spParams.creator.setApid(APID_WRITE_MEMORY);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
} }
@ -1164,9 +1135,9 @@ class WriteMemory : public SpacePacketBase {
/** /**
* @brief This class can be used to package the update available or update verify command. * @brief This class can be used to package the update available or update verify command.
*/ */
class EraseMemory : public SpacePacketBase { class EraseMemory : public ploc::SpTcBase {
public: public:
EraseMemory(SpBaseParams params) : SpacePacketBase(params) { EraseMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH); spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_ERASE_MEMORY); spParams.creator.setApid(APID_ERASE_MEMORY);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -1208,9 +1179,9 @@ class EraseMemory : public SpacePacketBase {
/** /**
* @brief This class creates the space packet to enable the auto TM generation * @brief This class creates the space packet to enable the auto TM generation
*/ */
class EnableAutoTm : public SpacePacketBase { class EnableAutoTm : public ploc::SpTcBase {
public: public:
EnableAutoTm(SpBaseParams params) : SpacePacketBase(params) { EnableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH); spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_AUTO_TM); spParams.creator.setApid(APID_AUTO_TM);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -1233,9 +1204,9 @@ class EnableAutoTm : public SpacePacketBase {
/** /**
* @brief This class creates the space packet to disable the auto TM generation * @brief This class creates the space packet to disable the auto TM generation
*/ */
class DisableAutoTm : public SpacePacketBase { class DisableAutoTm : public ploc::SpTcBase {
public: public:
DisableAutoTm(SpBaseParams params) : SpacePacketBase(params) { DisableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH); spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_AUTO_TM); spParams.creator.setApid(APID_AUTO_TM);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -1258,7 +1229,7 @@ class DisableAutoTm : public SpacePacketBase {
/** /**
* @brief This class creates the space packet to request the logging data from the supervisor * @brief This class creates the space packet to request the logging data from the supervisor
*/ */
class RequestLoggingData : public SpacePacketBase { class RequestLoggingData : public ploc::SpTcBase {
public: public:
enum class Sa : uint8_t { enum class Sa : uint8_t {
REQUEST_COUNTERS = 1, REQUEST_COUNTERS = 1,
@ -1267,7 +1238,7 @@ class RequestLoggingData : public SpacePacketBase {
SET_LOGGING_TOPIC = 4 SET_LOGGING_TOPIC = 4
}; };
RequestLoggingData(SpBaseParams params) : SpacePacketBase(params) { RequestLoggingData(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH); spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_REQUEST_LOGGING_DATA); spParams.creator.setApid(APID_REQUEST_LOGGING_DATA);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT); spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -1288,47 +1259,9 @@ class RequestLoggingData : public SpacePacketBase {
static const uint8_t TPC_OFFSET = 1; static const uint8_t TPC_OFFSET = 1;
}; };
/** class VerificationReport : public ploc::SpTmReader {
* @brief Class for handling tm replies of the supervisor.
*/
class TmPacket : public SpacePacketReader {
public: public:
TmPacket() = default; VerificationReport(const uint8_t* buf, size_t maxSize) : ploc::SpTmReader(buf, maxSize) {}
/**
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
*/
TmPacket(const uint8_t* buf, size_t maxSize) : SpacePacketReader(buf, maxSize) {}
ReturnValue_t setData(const uint8_t* buf, size_t maxSize) {
return setReadOnlyData(buf, maxSize);
}
ReturnValue_t check() {
if (isNull()) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return checkSize();
}
/**
* @brief Returns the payload data length (data field length without CRC)
*/
uint16_t getPayloadDataLength() { return getPacketDataLen() - 2; }
ReturnValue_t checkCrc() {
const uint8_t* crcPtr = getFullData() + getFullPacketLen() - CRC_SIZE;
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
uint16_t recalculatedCrc = CRC::crc16ccitt(getFullData(), getFullPacketLen() - CRC_SIZE);
if (recalculatedCrc != receivedCrc) {
return SupvReturnValuesIF::CRC_FAILURE;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
class VerificationReport : public TmPacket {
public:
VerificationReport(const uint8_t* buf, size_t maxSize) : TmPacket(buf, maxSize) {}
/** /**
* @brief Gets the APID of command which caused the transmission of this verification report. * @brief Gets the APID of command which caused the transmission of this verification report.
@ -1870,10 +1803,10 @@ class LoggingReport : public StaticLocalDataSet<LOGGING_RPT_SET_ENTRIES> {
} }
}; };
class UpdateStatusReport : public TmPacket { class UpdateStatusReport : public ploc::SpTmReader {
public: public:
UpdateStatusReport() = default; UpdateStatusReport() = default;
UpdateStatusReport(const uint8_t* buf, size_t maxSize) : TmPacket(buf, maxSize) {} UpdateStatusReport(const uint8_t* buf, size_t maxSize) : ploc::SpTmReader(buf, maxSize) {}
ReturnValue_t parseDataField() { ReturnValue_t parseDataField() {
ReturnValue_t result = lengthCheck(); ReturnValue_t result = lengthCheck();

View File

@ -673,12 +673,11 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) {
ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
SpacePacket packet;
std::memcpy(packet.getWholeData(), data, tmCamCmdRpt.rememberSpacePacketSize);
result = verifyPacket(data, tmCamCmdRpt.rememberSpacePacketSize); result = verifyPacket(data, tmCamCmdRpt.rememberSpacePacketSize);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) { if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl;
} }
SpacePacketReader packetReader(data, tmCamCmdRpt.rememberSpacePacketSize);
const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE + sizeof(uint16_t); const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE + sizeof(uint16_t);
std::string camCmdRptMsg( std::string camCmdRptMsg(
reinterpret_cast<const char*>(dataFieldPtr), reinterpret_cast<const char*>(dataFieldPtr),
@ -689,8 +688,8 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) {
sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex
<< static_cast<unsigned int>(ackValue) << std::endl; << static_cast<unsigned int>(ackValue) << std::endl;
#endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */ #endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */
handleDeviceTM(packet.getPacketData() + sizeof(uint16_t), packet.getPacketDataLength() - 1, handleDeviceTM(packetReader.getPacketData() + sizeof(uint16_t),
mpsoc::TM_CAM_CMD_RPT); packetReader.getPacketDataLen() - 1, mpsoc::TM_CAM_CMD_RPT);
return result; return result;
} }

View File

@ -113,6 +113,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
SourceSequenceCounter sequenceCount = SourceSequenceCounter(ccsds::LIMIT_SEQUENCE_COUNT - 1); SourceSequenceCounter sequenceCount = SourceSequenceCounter(ccsds::LIMIT_SEQUENCE_COUNT - 1);
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE]; uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
SpacePacketCreator creator;
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
/** /**
* This variable is used to store the id of the next reply to receive. This is necessary * This variable is used to store the id of the next reply to receive. This is necessary
@ -151,9 +153,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
TelemetryBuffer tmBuffer; TelemetryBuffer tmBuffer;
SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator);
enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; enum class PowerState { OFF, BOOTING, SHUTDOWN, ON };
PowerState powerState = PowerState::OFF; PowerState powerState = PowerState::OFF;

View File

@ -10,7 +10,12 @@
#include "mission/utility/Timestamp.h" #include "mission/utility/Timestamp.h"
PlocMPSoCHelper::PlocMPSoCHelper(object_id_t objectId) : SystemObject(objectId) {} using namespace ploc;
PlocMPSoCHelper::PlocMPSoCHelper(object_id_t objectId) : SystemObject(objectId) {
spParams.buf = commandBuffer;
spParams.maxSize = sizeof(commandBuffer);
}
PlocMPSoCHelper::~PlocMPSoCHelper() {} PlocMPSoCHelper::~PlocMPSoCHelper() {}
@ -138,8 +143,11 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
return FILE_CLOSED_ACCIDENTALLY; return FILE_CLOSED_ACCIDENTALLY;
} }
(*sequenceCount)++; (*sequenceCount)++;
mpsoc::TcFlashWrite tc(*sequenceCount); mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
tc.createPacket(tempData, dataLength); result = tc.buildPacket(tempData, dataLength);
if (result != RETURN_OK) {
return result;
}
result = handlePacketTransmission(tc); result = handlePacketTransmission(tc);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
@ -155,7 +163,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
ReturnValue_t PlocMPSoCHelper::flashfopen() { ReturnValue_t PlocMPSoCHelper::flashfopen() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
(*sequenceCount)++; (*sequenceCount)++;
mpsoc::FlashFopen flashFopen(*sequenceCount); mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND); result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
@ -170,7 +178,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
ReturnValue_t PlocMPSoCHelper::flashfclose() { ReturnValue_t PlocMPSoCHelper::flashfclose() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
(*sequenceCount)++; (*sequenceCount)++;
mpsoc::FlashFclose flashFclose(*sequenceCount); mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
result = flashFclose.createPacket(flashWrite.mpsocFile); result = flashFclose.createPacket(flashWrite.mpsocFile);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
@ -182,7 +190,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(mpsoc::TcBase& tc) { ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(ploc::SpTcBase& tc) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = sendCommand(tc); result = sendCommand(tc);
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -199,9 +207,9 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(mpsoc::TcBase& tc) {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t PlocMPSoCHelper::sendCommand(mpsoc::TcBase& tc) { ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = uartComIF->sendMessage(comCookie, tc.getWholeData(), tc.getFullSize()); result = uartComIF->sendMessage(comCookie, tc.getFullPacket(), tc.getFullPacketLen());
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl; sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl;
triggerEvent(MPSOC_SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_SENDING_COMMAND_FAILED, result, static_cast<uint32_t>(internalState));
@ -212,12 +220,16 @@ ReturnValue_t PlocMPSoCHelper::sendCommand(mpsoc::TcBase& tc) {
ReturnValue_t PlocMPSoCHelper::handleAck() { ReturnValue_t PlocMPSoCHelper::handleAck() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
mpsoc::TmPacket tmPacket; result = handleTmReception(mpsoc::SIZE_ACK_REPORT);
result = handleTmReception(&tmPacket, mpsoc::SIZE_ACK_REPORT);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
uint16_t apid = tmPacket.getAPID(); SpTmReader tmPacket(tmBuf.data(), tmBuf.size());
result = checkReceivedTm(tmPacket);
if (result != RETURN_OK) {
return result;
}
uint16_t apid = tmPacket.getApid();
if (apid != mpsoc::apid::ACK_SUCCESS) { if (apid != mpsoc::apid::ACK_SUCCESS) {
handleAckApidFailure(apid); handleAckApidFailure(apid);
return RETURN_FAILED; return RETURN_FAILED;
@ -239,12 +251,17 @@ void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) {
ReturnValue_t PlocMPSoCHelper::handleExe() { ReturnValue_t PlocMPSoCHelper::handleExe() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
mpsoc::TmPacket tmPacket;
result = handleTmReception(&tmPacket, mpsoc::SIZE_EXE_REPORT); result = handleTmReception(mpsoc::SIZE_EXE_REPORT);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
uint16_t apid = tmPacket.getAPID(); ploc::SpTmReader tmPacket(tmBuf.data(), tmBuf.size());
result = checkReceivedTm(tmPacket);
if (result != RETURN_OK) {
return result;
}
uint16_t apid = tmPacket.getApid();
if (apid != mpsoc::apid::EXE_SUCCESS) { if (apid != mpsoc::apid::EXE_SUCCESS) {
handleExeApidFailure(apid); handleExeApidFailure(apid);
return RETURN_FAILED; return RETURN_FAILED;
@ -264,12 +281,12 @@ void PlocMPSoCHelper::handleExeApidFailure(uint16_t apid) {
} }
} }
ReturnValue_t PlocMPSoCHelper::handleTmReception(mpsoc::TmPacket* tmPacket, size_t remainingBytes) { ReturnValue_t PlocMPSoCHelper::handleTmReception(size_t remainingBytes) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
size_t readBytes = 0; size_t readBytes = 0;
size_t currentBytes = 0; size_t currentBytes = 0;
for (int retries = 0; retries < RETRIES; retries++) { for (int retries = 0; retries < RETRIES; retries++) {
result = receive(tmPacket->getWholeData() + readBytes, &currentBytes, remainingBytes); result = receive(tmBuf.data() + readBytes, &currentBytes, remainingBytes);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -284,18 +301,30 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(mpsoc::TmPacket* tmPacket, size
triggerEvent(MPSOC_MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState)); triggerEvent(MPSOC_MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState));
return RETURN_FAILED; return RETURN_FAILED;
} }
result = tmPacket->checkCrc(); return result;
}
ReturnValue_t PlocMPSoCHelper::checkReceivedTm(SpTmReader& reader) {
ReturnValue_t result = reader.checkSize();
if (result != RETURN_OK) {
sif::error << "PlocMPSoCHelper::handleTmReception: Size check on received TM failed"
<< std::endl;
triggerEvent(MPSOC_TM_SIZE_ERROR);
return result;
}
reader.checkCrc();
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl; sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl;
triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount);
return result; return result;
} }
(*sequenceCount)++; (*sequenceCount)++;
uint16_t recvSeqCnt = tmPacket->getPacketSequenceCount(); uint16_t recvSeqCnt = reader.getSequenceCount();
if (recvSeqCnt != *sequenceCount) { if (recvSeqCnt != *sequenceCount) {
triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt); triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
*sequenceCount = recvSeqCnt; *sequenceCount = recvSeqCnt;
} }
return result; return RETURN_OK;
} }
ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t requestBytes) { ReturnValue_t PlocMPSoCHelper::receive(uint8_t* data, size_t* readBytes, size_t requestBytes) {

View File

@ -67,6 +67,8 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF, public H
//! P1: Expected sequence count //! P1: Expected sequence count
//! P2: Received sequence count //! P2: Received sequence count
static const Event MPSOC_HELPER_SEQ_CNT_MISMATCH = MAKE_EVENT(11, severity::LOW); static const Event MPSOC_HELPER_SEQ_CNT_MISMATCH = MAKE_EVENT(11, severity::LOW);
static const Event MPSOC_TM_SIZE_ERROR = MAKE_EVENT(12, severity::LOW);
static const Event MPSOC_TM_CRC_MISSMATCH = MAKE_EVENT(13, severity::LOW);
PlocMPSoCHelper(object_id_t objectId); PlocMPSoCHelper(object_id_t objectId);
virtual ~PlocMPSoCHelper(); virtual ~PlocMPSoCHelper();
@ -123,6 +125,10 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF, public H
SdCardManager* sdcMan = nullptr; SdCardManager* sdcMan = nullptr;
#endif #endif
uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE]; uint8_t commandBuffer[mpsoc::MAX_COMMAND_SIZE];
SpacePacketCreator creator;
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
std::array<uint8_t, mpsoc::MAX_REPLY_SIZE> tmBuf;
bool terminate = false; bool terminate = false;
@ -134,20 +140,21 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF, public H
// Communication cookie. Must be set by the MPSoC Handler // Communication cookie. Must be set by the MPSoC Handler
CookieIF* comCookie = nullptr; CookieIF* comCookie = nullptr;
// Sequence count, must be set by Ploc MPSoC Handler // Sequence count, must be set by Ploc MPSoC Handler
SourceSequenceCounter* sequenceCount; SourceSequenceCounter* sequenceCount = nullptr;
ReturnValue_t resetHelper(); ReturnValue_t resetHelper();
ReturnValue_t performFlashWrite(); ReturnValue_t performFlashWrite();
ReturnValue_t flashfopen(); ReturnValue_t flashfopen();
ReturnValue_t flashfclose(); ReturnValue_t flashfclose();
ReturnValue_t handlePacketTransmission(mpsoc::TcBase& tc); ReturnValue_t handlePacketTransmission(ploc::SpTcBase& tc);
ReturnValue_t sendCommand(mpsoc::TcBase& tc); ReturnValue_t sendCommand(ploc::SpTcBase& tc);
ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes); ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes);
ReturnValue_t handleAck(); ReturnValue_t handleAck();
ReturnValue_t handleExe(); ReturnValue_t handleExe();
void handleAckApidFailure(uint16_t apid); void handleAckApidFailure(uint16_t apid);
void handleExeApidFailure(uint16_t apid); void handleExeApidFailure(uint16_t apid);
ReturnValue_t handleTmReception(mpsoc::TmPacket* tmPacket, size_t remainingBytes); ReturnValue_t handleTmReception(size_t remainingBytes);
ReturnValue_t checkReceivedTm(ploc::SpTmReader& reader);
}; };
#endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */ #endif /* BSP_Q7S_DEVICES_PLOCMPSOCHELPER_H_ */

View File

@ -906,8 +906,8 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
using namespace supv; using namespace supv;
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
AcknowledgmentReport ack; AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
ack.addWholeData(data, SIZE_ACK_REPORT); // ack.addWholeData(data, SIZE_ACK_REPORT);
result = ack.checkCrc(); result = ack.checkCrc();
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -960,8 +960,14 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionReport(const uint8_t* data)
using namespace supv; using namespace supv;
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
ExecutionReport exe; ExecutionReport exe(data, SIZE_EXE_REPORT);
exe.addWholeData(data, SIZE_EXE_REPORT); if (exe.isNull()) {
return RETURN_FAILED;
}
result = exe.checkSize();
if (result != RETURN_OK) {
return result;
}
result = exe.checkCrc(); result = exe.checkCrc();
if (result != RETURN_OK) { if (result != RETURN_OK) {
@ -2018,24 +2024,30 @@ ReturnValue_t PlocSupervisorHandler::eventSubscription() {
return result; return result;
} }
void PlocSupervisorHandler::handleExecutionSuccessReport(const uint8_t* data) { ReturnValue_t PlocSupervisorHandler::handleExecutionSuccessReport(const uint8_t* data) {
DeviceCommandId_t commandId = getPendingCommand(); DeviceCommandId_t commandId = getPendingCommand();
switch (commandId) { switch (commandId) {
case supv::READ_GPIO: { case supv::READ_GPIO: {
supv::ExecutionReport exe; supv::ExecutionReport exe(data, supv::SIZE_EXE_REPORT);
exe.addWholeData(data, supv::SIZE_EXE_REPORT); if (exe.isNull()) {
return RETURN_FAILED;
}
ReturnValue_t result = exe.checkSize();
if (result != RETURN_OK) {
return result;
}
uint16_t gpioState = exe.getStatusCode(); uint16_t gpioState = exe.getStatusCode();
#if OBSW_DEBUG_PLOC_SUPERVISOR == 1 #if OBSW_DEBUG_PLOC_SUPERVISOR == 1
sif::info << "PlocSupervisorHandler: Read GPIO TM, State: " << gpioState << std::endl; sif::info << "PlocSupervisorHandler: Read GPIO TM, State: " << gpioState << std::endl;
#endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_DEBUG_PLOC_SUPERVISOR == 1 */
DeviceCommandMap::iterator iter = deviceCommandMap.find(commandId); DeviceCommandMap::iterator iter = deviceCommandMap.find(commandId);
if (iter->second.sendReplyTo == NO_COMMAND_ID) { if (iter->second.sendReplyTo == NO_COMMAND_ID) {
return; return RETURN_OK;
} }
uint8_t data[sizeof(gpioState)]; uint8_t data[sizeof(gpioState)];
size_t size = 0; size_t size = 0;
ReturnValue_t result = SerializeAdapter::serialize(&gpioState, data, &size, sizeof(gpioState), result = SerializeAdapter::serialize(&gpioState, data, &size, sizeof(gpioState),
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::debug << "PlocSupervisorHandler: Failed to deserialize GPIO state" << std::endl; sif::debug << "PlocSupervisorHandler: Failed to deserialize GPIO state" << std::endl;
} }
@ -2054,6 +2066,7 @@ void PlocSupervisorHandler::handleExecutionSuccessReport(const uint8_t* data) {
default: default:
break; break;
} }
return RETURN_OK;
} }
void PlocSupervisorHandler::handleExecutionFailureReport(uint16_t statusCode) { void PlocSupervisorHandler::handleExecutionFailureReport(uint16_t statusCode) {

View File

@ -101,7 +101,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]; uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
SpacePacketCreator creator; SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator); ploc::SpTcParams spParams = ploc::SpTcParams(creator);
/** /**
* This variable is used to store the id of the next reply to receive. This is necessary * This variable is used to store the id of the next reply to receive. This is necessary
@ -371,7 +371,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
uint8_t* memoryId, uint32_t* startAddress); uint8_t* memoryId, uint32_t* startAddress);
ReturnValue_t eventSubscription(); ReturnValue_t eventSubscription();
void handleExecutionSuccessReport(const uint8_t* data); ReturnValue_t handleExecutionSuccessReport(const uint8_t* data);
void handleExecutionFailureReport(uint16_t statusCode); void handleExecutionFailureReport(uint16_t statusCode);
void printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId); void printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId);

View File

@ -334,7 +334,7 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacketBase& packet, ReturnValue_t PlocSupvHelper::handlePacketTransmission(ploc::SpTcBase& packet,
uint32_t timeoutExecutionReport) { uint32_t timeoutExecutionReport) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
result = sendCommand(packet); result = sendCommand(packet);
@ -352,7 +352,7 @@ ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacketBase& packet,
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t PlocSupvHelper::sendCommand(SpacePacketBase& packet) { ReturnValue_t PlocSupvHelper::sendCommand(ploc::SpTcBase& packet) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
rememberApid = packet.getApid(); rememberApid = packet.getApid();
result = uartComIF->sendMessage(comCookie, packet.getFullPacket(), packet.getFullPacketLen()); result = uartComIF->sendMessage(comCookie, packet.getFullPacket(), packet.getFullPacketLen());
@ -366,14 +366,20 @@ ReturnValue_t PlocSupvHelper::sendCommand(SpacePacketBase& packet) {
ReturnValue_t PlocSupvHelper::handleAck() { ReturnValue_t PlocSupvHelper::handleAck() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
supv::AcknowledgmentReport ackReport;
result = handleTmReception(&ackReport, supv::SIZE_ACK_REPORT); result = handleTmReception(supv::SIZE_ACK_REPORT);
if (result != RETURN_OK) { if (result != RETURN_OK) {
triggerEvent(ACK_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid)); triggerEvent(ACK_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleAck: Error in reception of acknowledgment report" sif::warning << "PlocSupvHelper::handleAck: Error in reception of acknowledgment report"
<< std::endl; << std::endl;
return result; return result;
} }
supv::AcknowledgmentReport ackReport(tmBuf.data(), tmBuf.size());
result = ackReport.checkCrc();
if (result != RETURN_OK) {
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
return result;
}
result = ackReport.checkApid(); result = ackReport.checkApid();
if (result != RETURN_OK) { if (result != RETURN_OK) {
if (result == SupvReturnValuesIF::RECEIVED_ACK_FAILURE) { if (result == SupvReturnValuesIF::RECEIVED_ACK_FAILURE) {
@ -388,14 +394,20 @@ ReturnValue_t PlocSupvHelper::handleAck() {
ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) { ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
supv::ExecutionReport exeReport;
result = handleTmReception(&exeReport, supv::SIZE_EXE_REPORT, timeout); result = handleTmReception(supv::SIZE_EXE_REPORT, timeout);
if (result != RETURN_OK) { if (result != RETURN_OK) {
triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid)); triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report" sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report"
<< std::endl; << std::endl;
return result; return result;
} }
supv::ExecutionReport exeReport(tmBuf.data(), tmBuf.size());
result = exeReport.checkCrc();
if (result != RETURN_OK) {
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
return result;
}
result = exeReport.checkApid(); result = exeReport.checkApid();
if (result != RETURN_OK) { if (result != RETURN_OK) {
if (result == SupvReturnValuesIF::RECEIVED_EXE_FAILURE) { if (result == SupvReturnValuesIF::RECEIVED_EXE_FAILURE) {
@ -408,14 +420,13 @@ ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t PlocSupvHelper::handleTmReception(supv::TmPacket* tmPacket, size_t remainingBytes, ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint32_t timeout) {
uint32_t timeout) {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
size_t readBytes = 0; size_t readBytes = 0;
size_t currentBytes = 0; size_t currentBytes = 0;
Countdown countdown(timeout); Countdown countdown(timeout);
while (!countdown.hasTimedOut()) { while (!countdown.hasTimedOut()) {
result = receive(tmPacket->getWholeData() + readBytes, &currentBytes, remainingBytes); result = receive(tmBuf.data() + readBytes, &currentBytes, remainingBytes);
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
@ -430,11 +441,6 @@ ReturnValue_t PlocSupvHelper::handleTmReception(supv::TmPacket* tmPacket, size_t
<< remainingBytes << " bytes" << std::endl; << remainingBytes << " bytes" << std::endl;
return RETURN_FAILED; return RETURN_FAILED;
} }
result = tmPacket->checkCrc();
if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::handleTmReception: CRC check failed" << std::endl;
return result;
}
return result; return result;
} }
@ -512,10 +518,14 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
if (result != RETURN_OK) { if (result != RETURN_OK) {
return result; return result;
} }
supv::UpdateStatusReport updateStatusReport; supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
result = handleTmReception(&updateStatusReport, result = handleTmReception(static_cast<size_t>(updateStatusReport.getNominalSize()),
static_cast<size_t>(updateStatusReport.getNominalSize()),
supv::recv_timeout::UPDATE_STATUS_REPORT); supv::recv_timeout::UPDATE_STATUS_REPORT);
result = updateStatusReport.checkCrc();
if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::handleTmReception: CRC check failed" << std::endl;
return result;
}
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::warning sif::warning
<< "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report" << "PlocSupvHelper::handleCheckMemoryCommand: Failed to receive update status report"
@ -555,7 +565,7 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
std::ofstream file(filename, std::ios_base::app | std::ios_base::out); std::ofstream file(filename, std::ios_base::app | std::ios_base::out);
uint32_t packetsRead = 0; uint32_t packetsRead = 0;
size_t requestLen = 0; size_t requestLen = 0;
supv::TmPacket tmPacket; ploc::SpTmReader tmReader(tmBuf.data(), tmBuf.size());
for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS; packetsRead++) { for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS; packetsRead++) {
if (terminate) { if (terminate) {
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1); triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1);
@ -567,22 +577,27 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
} else { } else {
requestLen = SIZE_EVENT_BUFFER_FULL_PACKET; requestLen = SIZE_EVENT_BUFFER_FULL_PACKET;
} }
result = handleTmReception(&tmPacket, requestLen); result = handleTmReception(requestLen);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::debug << "PlocSupvHelper::handleEventBufferReception: Failed while trying to read packet" sif::debug << "PlocSupvHelper::handleEventBufferReception: Failed while trying to read packet"
<< " " << packetsRead + 1 << std::endl; << " " << packetsRead + 1 << std::endl;
file.close(); file.close();
return result; return result;
} }
uint16_t apid = tmPacket.getApid(); ReturnValue_t result = tmReader.checkCrc();
if (result != RETURN_OK) {
triggerEvent(SUPV_REPLY_CRC_MISSMATCH, rememberApid);
return result;
}
uint16_t apid = tmReader.getApid();
if (apid != supv::APID_MRAM_DUMP_TM) { if (apid != supv::APID_MRAM_DUMP_TM) {
sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet " sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet "
<< "with APID 0x" << std::hex << apid << std::endl; << "with APID 0x" << std::hex << apid << std::endl;
file.close(); file.close();
return EVENT_BUFFER_REPLY_INVALID_APID; return EVENT_BUFFER_REPLY_INVALID_APID;
} }
file.write(reinterpret_cast<const char*>(tmPacket.getPacketData()), file.write(reinterpret_cast<const char*>(tmReader.getPacketData()),
tmPacket.getPayloadDataLength()); tmReader.getPayloadDataLength());
} }
return result; return result;
} }

View File

@ -86,6 +86,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
//! [EXPORT] : [COMMENT] Update procedure failed when sending packet with number P1 //! [EXPORT] : [COMMENT] Update procedure failed when sending packet with number P1
//! P1: Packet number for which the memory write command fails //! P1: Packet number for which the memory write command fails
static const Event WRITE_MEMORY_FAILED = MAKE_EVENT(19, severity::LOW); static const Event WRITE_MEMORY_FAILED = MAKE_EVENT(19, severity::LOW);
static const Event SUPV_REPLY_CRC_MISSMATCH = MAKE_EVENT(20, severity::LOW);
PlocSupvHelper(object_id_t objectId); PlocSupvHelper(object_id_t objectId);
virtual ~PlocSupvHelper(); virtual ~PlocSupvHelper();
@ -178,7 +179,9 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
#endif #endif
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE]; uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
SpacePacketCreator creator; SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator); ploc::SpTcParams spParams = ploc::SpTcParams(creator);
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf;
bool terminate = false; bool terminate = false;
@ -198,9 +201,9 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
ReturnValue_t continueUpdate(); ReturnValue_t continueUpdate();
ReturnValue_t writeUpdatePackets(); ReturnValue_t writeUpdatePackets();
ReturnValue_t performEventBufferRequest(); ReturnValue_t performEventBufferRequest();
ReturnValue_t handlePacketTransmission(SpacePacketBase& packet, ReturnValue_t handlePacketTransmission(ploc::SpTcBase& packet,
uint32_t timeoutExecutionReport = 60000); uint32_t timeoutExecutionReport = 60000);
ReturnValue_t sendCommand(SpacePacketBase& packet); ReturnValue_t sendCommand(ploc::SpTcBase& packet);
/** /**
* @brief Function which reads form the communication interface * @brief Function which reads form the communication interface
* *
@ -221,8 +224,7 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
* @note It can take up to 70 seconds until the supervisor replies with an acknowledgment * @note It can take up to 70 seconds until the supervisor replies with an acknowledgment
* failure report. * failure report.
*/ */
ReturnValue_t handleTmReception(supv::TmPacket* tmPacket, size_t remainingBytes, ReturnValue_t handleTmReception(size_t remainingBytes, uint32_t timeout = 70000);
uint32_t timeout = 70000);
ReturnValue_t selectMemory(); ReturnValue_t selectMemory();
ReturnValue_t prepareUpdate(); ReturnValue_t prepareUpdate();
ReturnValue_t eraseMemory(); ReturnValue_t eraseMemory();

View File

@ -2,13 +2,16 @@
#define MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_
#include <fsfw/tmtcpacket/ccsds/SpacePacketCreator.h> #include <fsfw/tmtcpacket/ccsds/SpacePacketCreator.h>
#include <fsfw/tmtcpacket/ccsds/SpacePacketReader.h>
#include <cstdint> #include <cstdint>
struct SpBaseParams { namespace ploc {
SpBaseParams(SpacePacketCreator& creator) : creator(creator) {}
SpBaseParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize) struct SpTcParams {
SpTcParams(SpacePacketCreator& creator) : creator(creator) {}
SpTcParams(SpacePacketCreator& creator, uint8_t* buf, size_t maxSize)
: creator(creator), buf(buf), maxSize(maxSize) {} : creator(creator), buf(buf), maxSize(maxSize) {}
void setPayloadLen(size_t payloadLen_) { dataFieldLen = payloadLen_ + 2; } void setPayloadLen(size_t payloadLen_) { dataFieldLen = payloadLen_ + 2; }
@ -21,11 +24,11 @@ struct SpBaseParams {
size_t dataFieldLen = 0; size_t dataFieldLen = 0;
}; };
class SpacePacketBase { class SpTcBase {
public: public:
SpacePacketBase(SpBaseParams params) : spParams(params) { updateFields(); } SpTcBase(SpTcParams params) : spParams(params) { updateFields(); }
SpacePacketBase(SpBaseParams params, uint16_t apid, uint16_t seqCount) : spParams(params) { SpTcBase(SpTcParams params, uint16_t apid, uint16_t seqCount) : spParams(params) {
spParams.creator.setApid(apid); spParams.creator.setApid(apid);
spParams.creator.setSeqCount(seqCount); spParams.creator.setSeqCount(seqCount);
updateFields(); updateFields();
@ -76,8 +79,41 @@ class SpacePacketBase {
} }
protected: protected:
SpBaseParams spParams; ploc::SpTcParams spParams;
uint8_t* payloadStart; uint8_t* payloadStart;
}; };
/**
* @brief Class for handling tm replies of the supervisor.
*/
class SpTmReader : public SpacePacketReader {
public:
SpTmReader() = default;
/**
* @brief Constructor creates idle packet and sets length field to maximum allowed size.
*/
SpTmReader(const uint8_t* buf, size_t maxSize) : SpacePacketReader(buf, maxSize) {}
ReturnValue_t setData(const uint8_t* buf, size_t maxSize) {
return setReadOnlyData(buf, maxSize);
}
/**
* @brief Returns the payload data length (data field length without CRC)
*/
uint16_t getPayloadDataLength() { return getPacketDataLen() - 2; }
ReturnValue_t checkCrc() {
const uint8_t* crcPtr = getFullData() + getFullPacketLen() - CRC_SIZE;
uint16_t receivedCrc = *(crcPtr) << 8 | *(crcPtr + 1);
uint16_t recalculatedCrc = CRC::crc16ccitt(getFullData(), getFullPacketLen() - CRC_SIZE);
if (recalculatedCrc != receivedCrc) {
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
};
} // namespace ploc
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_ */ #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_ */