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::PS_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;
}

View File

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

View File

@ -136,7 +136,7 @@ static const uint16_t RESERVED_4 = 0x5F4;
/**
* @brief Abstract base class for TC space packet of MPSoC.
*/
class TcBase : public SpacePacketBase, public MPSoCReturnValuesIF {
class TcBase : public ploc::SpTcBase, public MPSoCReturnValuesIF {
public:
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
* sent and received packets.
*/
TcBase(SpBaseParams params, uint16_t apid, uint16_t sequenceCount)
: SpacePacketBase(params, apid, sequenceCount) {
TcBase(ploc::SpTcParams params, uint16_t apid, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid, sequenceCount) {
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.
*/
@ -224,7 +202,7 @@ class TcMemRead : public TcBase {
/**
* @brief Constructor
*/
TcMemRead(SpBaseParams params, uint16_t sequenceCount)
TcMemRead(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MEM_READ, sequenceCount) {
spParams.setPayloadLen(COMMAND_LENGTH);
}
@ -276,7 +254,7 @@ class TcMemWrite : public TcBase {
/**
* @brief Constructor
*/
TcMemWrite(SpBaseParams params, uint16_t sequenceCount)
TcMemWrite(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
protected:
@ -312,10 +290,10 @@ class TcMemWrite : public TcBase {
/**
* @brief Class to help creation of flash fopen command.
*/
class FlashFopen : public SpacePacketBase {
class FlashFopen : public ploc::SpTcBase {
public:
FlashFopen(SpBaseParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
FlashFopen(ploc::SpTcParams params, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid::TC_FLASHFOPEN, sequenceCount) {}
static const char APPEND = 'a';
static const char WRITE = 'w';
@ -323,7 +301,6 @@ class FlashFopen : public SpacePacketBase {
ReturnValue_t createPacket(std::string filename, char accessMode_) {
accessMode = accessMode_;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(payloadStart, filename.c_str(), nameSize);
*(spParams.buf + nameSize) = NULL_TERMINATOR;
@ -342,7 +319,7 @@ class FlashFopen : public SpacePacketBase {
*/
class FlashFclose : public TcBase {
public:
FlashFclose(SpBaseParams params, uint16_t sequenceCount)
FlashFclose(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_FLASHFCLOSE, sequenceCount) {}
ReturnValue_t createPacket(std::string filename) {
@ -357,12 +334,12 @@ class FlashFclose : public TcBase {
/**
* @brief Class to build flash write space packet.
*/
class TcFlashWrite : public SpacePacketBase {
class TcFlashWrite : public ploc::SpTcBase {
public:
TcFlashWrite(SpBaseParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHWRITE, sequenceCount) {}
TcFlashWrite(ploc::SpTcParams params, uint16_t 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;
writeLen = writeLen_;
if (writeLen > MAX_DATA_SIZE) {
@ -392,13 +369,12 @@ class TcFlashWrite : public SpacePacketBase {
/**
* @brief Class to help creation of flash delete command.
*/
class TcFlashDelete : public SpacePacketBase {
class TcFlashDelete : public ploc::SpTcBase {
public:
TcFlashDelete(SpBaseParams params, uint16_t sequenceCount)
: SpacePacketBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
TcFlashDelete(ploc::SpTcParams params, uint16_t sequenceCount)
: ploc::SpTcBase(params, apid::TC_FLASHDELETE, sequenceCount) {}
ReturnValue_t buildPacket(std::string filename) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
size_t nameSize = filename.size();
std::memcpy(payloadStart, filename.c_str(), nameSize);
*(payloadStart + nameSize) = NULL_TERMINATOR;
@ -417,7 +393,7 @@ class TcFlashDelete : public SpacePacketBase {
*/
class TcReplayStop : public TcBase {
public:
TcReplayStop(SpBaseParams params, uint16_t sequenceCount)
TcReplayStop(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_STOP, sequenceCount) {}
};
@ -429,7 +405,7 @@ class TcReplayStart : public TcBase {
/**
* @brief Constructor
*/
TcReplayStart(SpBaseParams params, uint16_t sequenceCount)
TcReplayStart(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_START, sequenceCount) {}
protected:
@ -478,7 +454,7 @@ class TcDownlinkPwrOn : public TcBase {
/**
* @brief Constructor
*/
TcDownlinkPwrOn(SpBaseParams params, uint16_t sequenceCount)
TcDownlinkPwrOn(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_PWR_ON, sequenceCount) {}
protected:
@ -545,7 +521,7 @@ class TcDownlinkPwrOn : public TcBase {
*/
class TcDownlinkPwrOff : public TcBase {
public:
TcDownlinkPwrOff(SpBaseParams params, uint16_t sequenceCount)
TcDownlinkPwrOff(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_DOWNLINK_PWR_OFF, sequenceCount) {}
};
@ -557,7 +533,7 @@ class TcReplayWriteSeq : public TcBase {
/**
* @brief Constructor
*/
TcReplayWriteSeq(SpBaseParams params, uint16_t sequenceCount)
TcReplayWriteSeq(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_REPLAY_WRITE_SEQUENCE, sequenceCount) {}
protected:
@ -624,7 +600,7 @@ class FlashWritePusCmd : public MPSoCReturnValuesIF {
*/
class TcModeReplay : public TcBase {
public:
TcModeReplay(SpBaseParams params, uint16_t sequenceCount)
TcModeReplay(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MODE_REPLAY, sequenceCount) {}
};
@ -633,13 +609,13 @@ class TcModeReplay : public TcBase {
*/
class TcModeIdle : public TcBase {
public:
TcModeIdle(SpBaseParams params, uint16_t sequenceCount)
TcModeIdle(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_MODE_IDLE, sequenceCount) {}
};
class TcCamcmdSend : public TcBase {
public:
TcCamcmdSend(SpBaseParams params, uint16_t sequenceCount)
TcCamcmdSend(ploc::SpTcParams params, uint16_t sequenceCount)
: TcBase(params, apid::TC_CAM_CMD_SEND, sequenceCount) {}
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.
*/
class ApidOnlyPacket : public SpacePacketBase {
class ApidOnlyPacket : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -290,7 +290,7 @@ class ApidOnlyPacket : public SpacePacketBase {
*
* @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.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
* of the MPSoC.
*/
class MPSoCBootSelect : public SpacePacketBase {
class MPSoCBootSelect : public ploc::SpTcBase {
public:
static const uint8_t NVM0 = 0;
static const uint8_t NVM1 = 1;
@ -325,7 +325,7 @@ class MPSoCBootSelect : public SpacePacketBase {
*
* @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.creator.setApid(APID_SEL_MPSOC_BOOT_IMAGE);
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
* supervisor.
*/
class EnableNvms : public SpacePacketBase {
class EnableNvms : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -371,7 +371,7 @@ class EnableNvms : public SpacePacketBase {
* @param bp1 Partition pin 1
* @param bp2 Partition pin 2
*/
EnableNvms(SpBaseParams params) : SpacePacketBase(params) {
EnableNvms(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_ENABLE_NVMS);
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.
*/
class SetTimeRef : public SpacePacketBase {
class SetTimeRef : public ploc::SpTcBase {
public:
SetTimeRef(SpBaseParams params) : SpacePacketBase(params) {
SetTimeRef(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_TIME_REF);
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.
*/
class SetBootTimeout : public SpacePacketBase {
class SetBootTimeout : public ploc::SpTcBase {
public:
/**
* @brief Constructor
*
* @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.creator.setApid(APID_SET_BOOT_TIMEOUT);
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.
*/
class SetRestartTries : public SpacePacketBase {
class SetRestartTries : public ploc::SpTcBase {
public:
/**
* @brief Constructor
*
* @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.creator.setApid(APID_SET_MAX_RESTART_TRIES);
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
* command can be useful for debugging.
*/
class DisablePeriodicHkTransmission : public SpacePacketBase {
class DisablePeriodicHkTransmission : public ploc::SpTcBase {
public:
/**
* @brief Constructor
*/
DisablePeriodicHkTransmission(SpBaseParams params) : SpacePacketBase(params) {
DisablePeriodicHkTransmission(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_DISABLE_HK);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -562,7 +562,7 @@ class DisablePeriodicHkTransmission : public SpacePacketBase {
*
* @details There are 7 different latchup alerts.
*/
class LatchupAlert : public SpacePacketBase {
class LatchupAlert : public ploc::SpTcBase {
public:
/**
* @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,
* 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.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
@ -600,7 +600,7 @@ class LatchupAlert : public SpacePacketBase {
void initPacket(uint8_t latchupId) { payloadStart[0] = latchupId; }
};
class SetAlertlimit : public SpacePacketBase {
class SetAlertlimit : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -609,7 +609,7 @@ class SetAlertlimit : public SpacePacketBase {
* 3 - 3.3V, 4 - NVM_4XO, 5 - MISSION, 6 - SAFECOTS)
* @param dutycycle
*/
SetAlertlimit(SpBaseParams params) : SpacePacketBase(params) {
SetAlertlimit(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ALERT_LIMIT);
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.
*/
class SetAdcEnabledChannels : public SpacePacketBase {
class SetAdcEnabledChannels : public ploc::SpTcBase {
public:
/**
* @brief Constructor
*
* @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.creator.setApid(APID_SET_ADC_ENABLED_CHANNELS);
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
* the moving average filter applied to the ADC readings.
*/
class SetAdcWindowAndStride : public SpacePacketBase {
class SetAdcWindowAndStride : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -691,7 +691,7 @@ class SetAdcWindowAndStride : public SpacePacketBase {
* @param windowSize
* @param stridingStepSize
*/
SetAdcWindowAndStride(SpBaseParams params) : SpacePacketBase(params) {
SetAdcWindowAndStride(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_WINDOW_AND_STRIDE);
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.
*/
class SetAdcThreshold : public SpacePacketBase {
class SetAdcThreshold : public ploc::SpTcBase {
public:
/**
* @brief Constructor
*
* @param threshold
*/
SetAdcThreshold(SpBaseParams params) : SpacePacketBase(params) {
SetAdcThreshold(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_ADC_THRESHOLD);
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.
*/
class RunAutoEmTests : public SpacePacketBase {
class RunAutoEmTests : public ploc::SpTcBase {
public:
/**
* @brief Constructor
*
* @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.creator.setApid(APID_RUN_AUTO_EM_TESTS);
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.
*/
class MramCmd : public SpacePacketBase {
class MramCmd : public ploc::SpTcBase {
public:
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.
*/
MramCmd(SpBaseParams params) : SpacePacketBase(params) {
MramCmd(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
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
* required for ground testing.
*/
class SetGpio : public SpacePacketBase {
class SetGpio : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -865,7 +865,7 @@ class SetGpio : public SpacePacketBase {
* @param pin
* @param val
*/
SetGpio(SpBaseParams params) : SpacePacketBase(params) {
SetGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_SET_GPIO);
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
* to the debug output.
*/
class ReadGpio : public SpacePacketBase {
class ReadGpio : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -909,7 +909,7 @@ class ReadGpio : public SpacePacketBase {
* @param port
* @param pin
*/
ReadGpio(SpBaseParams params) : SpacePacketBase(params) {
ReadGpio(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setDataFieldLen(DATA_FIELD_LENGTH);
spParams.creator.setApid(APID_READ_GPIO);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -947,7 +947,7 @@ class ReadGpio : public SpacePacketBase {
* OP = 0x01: Only the mirror entries will be wiped.
* OP = 0x02: Only the circular entries will be wiped.
*/
class FactoryReset : public SpacePacketBase {
class FactoryReset : public ploc::SpTcBase {
public:
enum class Op { CLEAR_ALL, MIRROR_ENTRIES, CIRCULAR_ENTRIES };
@ -956,7 +956,7 @@ class FactoryReset : public SpacePacketBase {
*
* @param op
*/
FactoryReset(SpBaseParams params) : SpacePacketBase(params) {
FactoryReset(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.creator.setApid(APID_FACTORY_RESET);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
}
@ -991,38 +991,9 @@ class FactoryReset : public SpacePacketBase {
}
};
// class SupvTcSpacePacket : public SpacePacketBase {
// 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 {
class SetShutdownTimeout : public ploc::SpTcBase {
public:
SetShutdownTimeout(SpBaseParams params) : SpacePacketBase(params) {
SetShutdownTimeout(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LEN);
spParams.creator.setApid(APID_SET_SHUTDOWN_TIMEOUT);
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.
*/
class CheckMemory : public SpacePacketBase {
class CheckMemory : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -1061,7 +1032,7 @@ class CheckMemory : public SpacePacketBase {
* @param startAddress Start address of CRC calculation
* @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.creator.setApid(APID_CHECK_MEMORY);
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.
*/
class WriteMemory : public SpacePacketBase {
class WriteMemory : public ploc::SpTcBase {
public:
/**
* @brief Constructor
@ -1109,7 +1080,7 @@ class WriteMemory : public SpacePacketBase {
* @param sequenceCount Sequence count (first update packet expects 1 as sequence count)
* @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.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.
*/
class EraseMemory : public SpacePacketBase {
class EraseMemory : public ploc::SpTcBase {
public:
EraseMemory(SpBaseParams params) : SpacePacketBase(params) {
EraseMemory(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_ERASE_MEMORY);
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
*/
class EnableAutoTm : public SpacePacketBase {
class EnableAutoTm : public ploc::SpTcBase {
public:
EnableAutoTm(SpBaseParams params) : SpacePacketBase(params) {
EnableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_AUTO_TM);
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
*/
class DisableAutoTm : public SpacePacketBase {
class DisableAutoTm : public ploc::SpTcBase {
public:
DisableAutoTm(SpBaseParams params) : SpacePacketBase(params) {
DisableAutoTm(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_AUTO_TM);
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
*/
class RequestLoggingData : public SpacePacketBase {
class RequestLoggingData : public ploc::SpTcBase {
public:
enum class Sa : uint8_t {
REQUEST_COUNTERS = 1,
@ -1267,7 +1238,7 @@ class RequestLoggingData : public SpacePacketBase {
SET_LOGGING_TOPIC = 4
};
RequestLoggingData(SpBaseParams params) : SpacePacketBase(params) {
RequestLoggingData(ploc::SpTcParams params) : ploc::SpTcBase(params) {
spParams.setPayloadLen(PAYLOAD_LENGTH);
spParams.creator.setApid(APID_REQUEST_LOGGING_DATA);
spParams.creator.setSeqCount(DEFAULT_SEQUENCE_COUNT);
@ -1288,47 +1259,9 @@ class RequestLoggingData : public SpacePacketBase {
static const uint8_t TPC_OFFSET = 1;
};
/**
* @brief Class for handling tm replies of the supervisor.
*/
class TmPacket : public SpacePacketReader {
class VerificationReport : public ploc::SpTmReader {
public:
TmPacket() = default;
/**
* @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) {}
VerificationReport(const uint8_t* buf, size_t maxSize) : ploc::SpTmReader(buf, maxSize) {}
/**
* @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:
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 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 result = RETURN_OK;
SpacePacket packet;
std::memcpy(packet.getWholeData(), data, tmCamCmdRpt.rememberSpacePacketSize);
result = verifyPacket(data, tmCamCmdRpt.rememberSpacePacketSize);
if (result == MPSoCReturnValuesIF::CRC_FAILURE) {
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);
std::string camCmdRptMsg(
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
<< 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);
handleDeviceTM(packetReader.getPacketData() + sizeof(uint16_t),
packetReader.getPacketDataLen() - 1, mpsoc::TM_CAM_CMD_RPT);
return result;
}

View File

@ -113,6 +113,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
SourceSequenceCounter sequenceCount = SourceSequenceCounter(ccsds::LIMIT_SEQUENCE_COUNT - 1);
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
@ -151,9 +153,6 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF {
TelemetryBuffer tmBuffer;
SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator);
enum class PowerState { OFF, BOOTING, SHUTDOWN, ON };
PowerState powerState = PowerState::OFF;

View File

@ -10,7 +10,12 @@
#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() {}
@ -138,8 +143,11 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
return FILE_CLOSED_ACCIDENTALLY;
}
(*sequenceCount)++;
mpsoc::TcFlashWrite tc(*sequenceCount);
tc.createPacket(tempData, dataLength);
mpsoc::TcFlashWrite tc(spParams, *sequenceCount);
result = tc.buildPacket(tempData, dataLength);
if (result != RETURN_OK) {
return result;
}
result = handlePacketTransmission(tc);
if (result != RETURN_OK) {
return result;
@ -155,7 +163,7 @@ ReturnValue_t PlocMPSoCHelper::performFlashWrite() {
ReturnValue_t PlocMPSoCHelper::flashfopen() {
ReturnValue_t result = RETURN_OK;
(*sequenceCount)++;
mpsoc::FlashFopen flashFopen(*sequenceCount);
mpsoc::FlashFopen flashFopen(spParams, *sequenceCount);
result = flashFopen.createPacket(flashWrite.mpsocFile, mpsoc::FlashFopen::APPEND);
if (result != RETURN_OK) {
return result;
@ -170,7 +178,7 @@ ReturnValue_t PlocMPSoCHelper::flashfopen() {
ReturnValue_t PlocMPSoCHelper::flashfclose() {
ReturnValue_t result = RETURN_OK;
(*sequenceCount)++;
mpsoc::FlashFclose flashFclose(*sequenceCount);
mpsoc::FlashFclose flashFclose(spParams, *sequenceCount);
result = flashFclose.createPacket(flashWrite.mpsocFile);
if (result != RETURN_OK) {
return result;
@ -182,7 +190,7 @@ ReturnValue_t PlocMPSoCHelper::flashfclose() {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(mpsoc::TcBase& tc) {
ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(ploc::SpTcBase& tc) {
ReturnValue_t result = RETURN_OK;
result = sendCommand(tc);
if (result != RETURN_OK) {
@ -199,9 +207,9 @@ ReturnValue_t PlocMPSoCHelper::handlePacketTransmission(mpsoc::TcBase& tc) {
return RETURN_OK;
}
ReturnValue_t PlocMPSoCHelper::sendCommand(mpsoc::TcBase& tc) {
ReturnValue_t PlocMPSoCHelper::sendCommand(ploc::SpTcBase& tc) {
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) {
sif::warning << "PlocMPSoCHelper::sendCommand: Failed to send command" << std::endl;
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 result = RETURN_OK;
mpsoc::TmPacket tmPacket;
result = handleTmReception(&tmPacket, mpsoc::SIZE_ACK_REPORT);
result = handleTmReception(mpsoc::SIZE_ACK_REPORT);
if (result != RETURN_OK) {
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) {
handleAckApidFailure(apid);
return RETURN_FAILED;
@ -239,12 +251,17 @@ void PlocMPSoCHelper::handleAckApidFailure(uint16_t apid) {
ReturnValue_t PlocMPSoCHelper::handleExe() {
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) {
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) {
handleExeApidFailure(apid);
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;
size_t readBytes = 0;
size_t currentBytes = 0;
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) {
return result;
}
@ -284,18 +301,30 @@ ReturnValue_t PlocMPSoCHelper::handleTmReception(mpsoc::TmPacket* tmPacket, size
triggerEvent(MPSOC_MISSING_EXE, remainingBytes, static_cast<uint32_t>(internalState));
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) {
sif::warning << "PlocMPSoCHelper::handleTmReception: CRC check failed" << std::endl;
triggerEvent(MPSOC_TM_CRC_MISSMATCH, *sequenceCount);
return result;
}
(*sequenceCount)++;
uint16_t recvSeqCnt = tmPacket->getPacketSequenceCount();
uint16_t recvSeqCnt = reader.getSequenceCount();
if (recvSeqCnt != *sequenceCount) {
triggerEvent(MPSOC_HELPER_SEQ_CNT_MISMATCH, *sequenceCount, recvSeqCnt);
*sequenceCount = recvSeqCnt;
}
return result;
return RETURN_OK;
}
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
//! P2: Received sequence count
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);
virtual ~PlocMPSoCHelper();
@ -123,6 +125,10 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF, public H
SdCardManager* sdcMan = nullptr;
#endif
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;
@ -134,20 +140,21 @@ class PlocMPSoCHelper : public SystemObject, public ExecutableObjectIF, public H
// Communication cookie. Must be set by the MPSoC Handler
CookieIF* comCookie = nullptr;
// Sequence count, must be set by Ploc MPSoC Handler
SourceSequenceCounter* sequenceCount;
SourceSequenceCounter* sequenceCount = nullptr;
ReturnValue_t resetHelper();
ReturnValue_t performFlashWrite();
ReturnValue_t flashfopen();
ReturnValue_t flashfclose();
ReturnValue_t handlePacketTransmission(mpsoc::TcBase& tc);
ReturnValue_t sendCommand(mpsoc::TcBase& tc);
ReturnValue_t handlePacketTransmission(ploc::SpTcBase& tc);
ReturnValue_t sendCommand(ploc::SpTcBase& tc);
ReturnValue_t receive(uint8_t* data, size_t* readBytes, size_t requestBytes);
ReturnValue_t handleAck();
ReturnValue_t handleExe();
void handleAckApidFailure(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_ */

View File

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

View File

@ -101,7 +101,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
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
@ -371,7 +371,7 @@ class PlocSupervisorHandler : public DeviceHandlerBase {
uint8_t* memoryId, uint32_t* startAddress);
ReturnValue_t eventSubscription();
void handleExecutionSuccessReport(const uint8_t* data);
ReturnValue_t handleExecutionSuccessReport(const uint8_t* data);
void handleExecutionFailureReport(uint16_t statusCode);
void printAckFailureInfo(uint16_t statusCode, DeviceCommandId_t commandId);

View File

@ -334,7 +334,7 @@ ReturnValue_t PlocSupvHelper::eraseMemory() {
return RETURN_OK;
}
ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacketBase& packet,
ReturnValue_t PlocSupvHelper::handlePacketTransmission(ploc::SpTcBase& packet,
uint32_t timeoutExecutionReport) {
ReturnValue_t result = RETURN_OK;
result = sendCommand(packet);
@ -352,7 +352,7 @@ ReturnValue_t PlocSupvHelper::handlePacketTransmission(SpacePacketBase& packet,
return RETURN_OK;
}
ReturnValue_t PlocSupvHelper::sendCommand(SpacePacketBase& packet) {
ReturnValue_t PlocSupvHelper::sendCommand(ploc::SpTcBase& packet) {
ReturnValue_t result = RETURN_OK;
rememberApid = packet.getApid();
result = uartComIF->sendMessage(comCookie, packet.getFullPacket(), packet.getFullPacketLen());
@ -366,14 +366,20 @@ ReturnValue_t PlocSupvHelper::sendCommand(SpacePacketBase& packet) {
ReturnValue_t PlocSupvHelper::handleAck() {
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) {
triggerEvent(ACK_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleAck: Error in reception of acknowledgment report"
<< std::endl;
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();
if (result != RETURN_OK) {
if (result == SupvReturnValuesIF::RECEIVED_ACK_FAILURE) {
@ -388,14 +394,20 @@ ReturnValue_t PlocSupvHelper::handleAck() {
ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
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) {
triggerEvent(EXE_RECEPTION_FAILURE, result, static_cast<uint32_t>(rememberApid));
sif::warning << "PlocSupvHelper::handleExe: Error in reception of execution report"
<< std::endl;
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();
if (result != RETURN_OK) {
if (result == SupvReturnValuesIF::RECEIVED_EXE_FAILURE) {
@ -408,14 +420,13 @@ ReturnValue_t PlocSupvHelper::handleExe(uint32_t timeout) {
return RETURN_OK;
}
ReturnValue_t PlocSupvHelper::handleTmReception(supv::TmPacket* tmPacket, size_t remainingBytes,
uint32_t timeout) {
ReturnValue_t PlocSupvHelper::handleTmReception(size_t remainingBytes, uint32_t timeout) {
ReturnValue_t result = RETURN_OK;
size_t readBytes = 0;
size_t currentBytes = 0;
Countdown countdown(timeout);
while (!countdown.hasTimedOut()) {
result = receive(tmPacket->getWholeData() + readBytes, &currentBytes, remainingBytes);
result = receive(tmBuf.data() + readBytes, &currentBytes, remainingBytes);
if (result != RETURN_OK) {
return result;
}
@ -430,11 +441,6 @@ ReturnValue_t PlocSupvHelper::handleTmReception(supv::TmPacket* tmPacket, size_t
<< remainingBytes << " bytes" << std::endl;
return RETURN_FAILED;
}
result = tmPacket->checkCrc();
if (result != RETURN_OK) {
sif::warning << "PlocSupvHelper::handleTmReception: CRC check failed" << std::endl;
return result;
}
return result;
}
@ -512,10 +518,14 @@ ReturnValue_t PlocSupvHelper::handleCheckMemoryCommand() {
if (result != RETURN_OK) {
return result;
}
supv::UpdateStatusReport updateStatusReport;
result = handleTmReception(&updateStatusReport,
static_cast<size_t>(updateStatusReport.getNominalSize()),
supv::UpdateStatusReport updateStatusReport(tmBuf.data(), tmBuf.size());
result = handleTmReception(static_cast<size_t>(updateStatusReport.getNominalSize()),
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) {
sif::warning
<< "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);
uint32_t packetsRead = 0;
size_t requestLen = 0;
supv::TmPacket tmPacket;
ploc::SpTmReader tmReader(tmBuf.data(), tmBuf.size());
for (packetsRead = 0; packetsRead < NUM_EVENT_BUFFER_PACKETS; packetsRead++) {
if (terminate) {
triggerEvent(SUPV_EVENT_BUFFER_REQUEST_TERMINATED, packetsRead - 1);
@ -567,22 +577,27 @@ ReturnValue_t PlocSupvHelper::handleEventBufferReception() {
} else {
requestLen = SIZE_EVENT_BUFFER_FULL_PACKET;
}
result = handleTmReception(&tmPacket, requestLen);
result = handleTmReception(requestLen);
if (result != RETURN_OK) {
sif::debug << "PlocSupvHelper::handleEventBufferReception: Failed while trying to read packet"
<< " " << packetsRead + 1 << std::endl;
file.close();
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) {
sif::warning << "PlocSupvHelper::handleEventBufferReception: Did not expect space packet "
<< "with APID 0x" << std::hex << apid << std::endl;
file.close();
return EVENT_BUFFER_REPLY_INVALID_APID;
}
file.write(reinterpret_cast<const char*>(tmPacket.getPacketData()),
tmPacket.getPayloadDataLength());
file.write(reinterpret_cast<const char*>(tmReader.getPacketData()),
tmReader.getPayloadDataLength());
}
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
//! P1: Packet number for which the memory write command fails
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);
virtual ~PlocSupvHelper();
@ -178,7 +179,9 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
#endif
uint8_t commandBuffer[supv::MAX_COMMAND_SIZE];
SpacePacketCreator creator;
SpBaseParams spParams = SpBaseParams(creator);
ploc::SpTcParams spParams = ploc::SpTcParams(creator);
std::array<uint8_t, supv::MAX_COMMAND_SIZE> tmBuf;
bool terminate = false;
@ -198,9 +201,9 @@ class PlocSupvHelper : public SystemObject, public ExecutableObjectIF, public Ha
ReturnValue_t continueUpdate();
ReturnValue_t writeUpdatePackets();
ReturnValue_t performEventBufferRequest();
ReturnValue_t handlePacketTransmission(SpacePacketBase& packet,
ReturnValue_t handlePacketTransmission(ploc::SpTcBase& packet,
uint32_t timeoutExecutionReport = 60000);
ReturnValue_t sendCommand(SpacePacketBase& packet);
ReturnValue_t sendCommand(ploc::SpTcBase& packet);
/**
* @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
* failure report.
*/
ReturnValue_t handleTmReception(supv::TmPacket* tmPacket, size_t remainingBytes,
uint32_t timeout = 70000);
ReturnValue_t handleTmReception(size_t remainingBytes, uint32_t timeout = 70000);
ReturnValue_t selectMemory();
ReturnValue_t prepareUpdate();
ReturnValue_t eraseMemory();

View File

@ -2,13 +2,16 @@
#define MISSION_DEVICES_DEVICEDEFINITIONS_SPBASE_H_
#include <fsfw/tmtcpacket/ccsds/SpacePacketCreator.h>
#include <fsfw/tmtcpacket/ccsds/SpacePacketReader.h>
#include <cstdint>
struct SpBaseParams {
SpBaseParams(SpacePacketCreator& creator) : creator(creator) {}
namespace ploc {
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) {}
void setPayloadLen(size_t payloadLen_) { dataFieldLen = payloadLen_ + 2; }
@ -21,11 +24,11 @@ struct SpBaseParams {
size_t dataFieldLen = 0;
};
class SpacePacketBase {
class SpTcBase {
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.setSeqCount(seqCount);
updateFields();
@ -76,8 +79,41 @@ class SpacePacketBase {
}
protected:
SpBaseParams spParams;
ploc::SpTcParams spParams;
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_ */