From 05a85ab8a1acbe85ba8917826390fca6d6c77db6 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 11 Apr 2022 16:52:50 +0200 Subject: [PATCH] implemeted ICD changes --- .../PlocSupervisorDefinitions.h | 352 ++++++++++-------- .../devicedefinitions/SupvReturnValuesIF.h | 59 +++ linux/devices/ploc/PlocSupervisorHandler.cpp | 50 ++- 3 files changed, 280 insertions(+), 181 deletions(-) create mode 100644 linux/devices/devicedefinitions/SupvReturnValuesIF.h diff --git a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h index ed5ed19b..8360c61d 100644 --- a/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h +++ b/linux/devices/devicedefinitions/PlocSupervisorDefinitions.h @@ -7,6 +7,7 @@ #include #include #include + #include "linux/devices/devicedefinitions/SupvReturnValuesIF.h" namespace supv { @@ -54,12 +55,13 @@ static const DeviceCommandId_t REQUEST_LOGGING_DATA = 38; static const DeviceCommandId_t FACTORY_RESET_CLEAR_MIRROR = 40; static const DeviceCommandId_t FACTORY_RESET_CLEAR_CIRCULAR = 41; static const DeviceCommandId_t CONSECUTIVE_MRAM_DUMP = 43; -static const DeviceCommandId_t PREPARE_UPDATE = 44; static const DeviceCommandId_t START_MPSOC_QUIET = 45; static const DeviceCommandId_t SET_SHUTDOWN_TIMEOUT = 46; static const DeviceCommandId_t FACTORY_FLASH = 47; static const DeviceCommandId_t PERFORM_UPDATE = 48; static const DeviceCommandId_t TERMINATE_SUPV_HELPER = 49; +static const DeviceCommandId_t ENABLE_AUTO_TM = 50; +static const DeviceCommandId_t DISABLE_AUTO_TM = 51; /** Reply IDs */ static const DeviceCommandId_t ACK_REPORT = 50; @@ -70,8 +72,7 @@ static const DeviceCommandId_t LATCHUP_REPORT = 54; static const uint16_t SIZE_ACK_REPORT = 14; static const uint16_t SIZE_EXE_REPORT = 14; -// static const uint16_t SIZE_HK_REPORT = 52; -static const uint16_t SIZE_HK_REPORT = 56; +static const uint16_t SIZE_HK_REPORT = 52; static const uint16_t SIZE_BOOT_STATUS_REPORT = 24; static const uint16_t SIZE_LATCHUP_STATUS_REPORT = 31; @@ -115,6 +116,7 @@ static const uint16_t APID_WTD_ENABLE = 0xC0; static const uint16_t APID_WTD_CONFIG_TIMEOUT = 0xC1; static const uint16_t APID_SET_TIME_REF = 0xC2; static const uint16_t APID_DISABLE_HK = 0xC3; +static const uint16_t APID_AUTO_TM = 0xC5; static const uint16_t APID_ENABLE_LATCHUP_ALERT = 0xD0; static const uint16_t APID_DISABLE_LATCHUP_ALERT = 0xD1; static const uint16_t APID_AUTO_CALIBRATE_ALERT = 0xD2; @@ -173,7 +175,7 @@ enum PoolIds : lp_id_t { NUM_TMS, TEMP_PS, TEMP_PL, - SOC_STATE, + HK_SOC_STATE, NVM0_1_STATE, NVM3_STATE, MISSION_IO_STATE, @@ -183,8 +185,8 @@ enum PoolIds : lp_id_t { UPTIME, CPULOAD, AVAILABLEHEAP, - BOOT_SIGNAL, - RESET_COUNTER, + BR_SOC_STATE, + POWER_CYCLES, BOOT_AFTER_MS, BOOT_TIMEOUT_MS, ACTIVE_NVM, @@ -209,7 +211,7 @@ enum PoolIds : lp_id_t { LATCHUP_RPT_TIME_MON, LATCHUP_RPT_TIME_YEAR, LATCHUP_RPT_TIME_MSEC, - LATCHUP_RPT_TIME_USEC, + LATCHUP_RPT_IS_SET, }; static const uint8_t HK_SET_ENTRIES = 13; @@ -338,8 +340,8 @@ class SetTimeRef : public SpacePacket { sizeof(time->minute), SerializeIF::Endianness::BIG); uint8_t hour = static_cast(time->hour); serializedSize = 0; - SerializeAdapter::serialize(&hour, &dataFieldPtr, &serializedSize, - sizeof(time->hour), SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&hour, &dataFieldPtr, &serializedSize, sizeof(time->hour), + SerializeIF::Endianness::BIG); uint8_t day = static_cast(time->day); serializedSize = 0; SerializeAdapter::serialize(&day, &dataFieldPtr, &serializedSize, sizeof(time->day), @@ -350,8 +352,8 @@ class SetTimeRef : public SpacePacket { sizeof(time->month), SerializeIF::Endianness::BIG); uint8_t year = static_cast(time->year - 1900); serializedSize = 0; - SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, - sizeof(time->year), SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, sizeof(time->year), + SerializeIF::Endianness::BIG); serializedSize = 0; /* Calculate crc */ uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, @@ -385,8 +387,8 @@ class SetBootTimeout : public SpacePacket { void initPacket() { size_t serializedSize = 0; uint8_t* dataFieldPtr = this->localData.fields.buffer; - SerializeAdapter::serialize(&timeout, &dataFieldPtr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout), + SerializeIF::Endianness::BIG); /* Calculate crc */ uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); @@ -547,8 +549,8 @@ class WatchdogsConfigTimeout : public SpacePacket { SerializeAdapter::serialize(&watchdog, &dataFieldPtr, &serializedSize, sizeof(watchdog), SerializeIF::Endianness::BIG); serializedSize = 0; - SerializeAdapter::serialize(&timeout, &dataFieldPtr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&timeout, &dataFieldPtr, &serializedSize, sizeof(timeout), + SerializeIF::Endianness::BIG); serializedSize = 0; uint16_t crc = CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + DATA_FIELD_LENGTH - 2); @@ -1308,38 +1310,14 @@ class FactoryReset : public SpacePacket { } }; -class SetShutdownTimeout : public SpacePacket { - public: - SetShutdownTimeout(uint32_t timeout) - : SpacePacket(0, true, APID_SET_SHUTDOWN_TIMEOUT, DEFAULT_SEQUENCE_COUNT), timeout(timeout) { - initPacket(); - } - - private: - uint16_t PACKET_LEN = 1; // uint32_t timeout + CRC - 1 - static const uint16_t DEFAULT_SEQUENCE_COUNT = 1; - - uint32_t timeout = 0; - uint8_t crcOffset = 0; - - void initPacket() { - uint8_t* dataFieldPtr = this->localData.fields.buffer; - size_t serializedSize = 0; - SerializeAdapter::serialize(&timeout, dataFieldPtr, &serializedSize, - sizeof(timeout), SerializeIF::Endianness::BIG); - this->setPacketDataLength(PACKET_LEN); - serializedSize = 0; - uint16_t crc = - CRC::crc16ccitt(this->localData.byteStream, sizeof(CCSDSPrimaryHeader) + PACKET_LEN - 1); - uint8_t* crcPos = this->localData.fields.buffer + crcOffset; - SerializeAdapter::serialize(&crc, &crcPos, &serializedSize, sizeof(crc), - SerializeIF::Endianness::BIG); - } -}; - class SupvTcSpacePacket : public SpacePacket { public: - SupvTcSpacePacket(size_t payloadDataLen, uint16_t apid) + /** + * @brief Constructor + * + * @param payloadDataLen Length of data field without CRC + */ + SupvTcSpacePacket(uint16_t payloadDataLen, uint16_t apid) : SpacePacket(payloadDataLen + 1, true, apid, DEFAULT_SEQUENCE_COUNT), payloadDataLen(payloadDataLen) {} @@ -1360,6 +1338,27 @@ class SupvTcSpacePacket : public SpacePacket { size_t payloadDataLen = 0; }; +class SetShutdownTimeout : public SupvTcSpacePacket { + public: + SetShutdownTimeout(uint32_t timeout) + : SupvTcSpacePacket(PACKET_LEN, APID_SET_SHUTDOWN_TIMEOUT), timeout(timeout) { + initPacket(); + makeCrc(); + } + + private: + static const uint16_t PACKET_LEN = 4; // uint32_t timeout + + uint32_t timeout = 0; + + void initPacket() { + uint8_t* dataFieldPtr = this->localData.fields.buffer; + size_t serializedSize = 0; + SerializeAdapter::serialize(&timeout, dataFieldPtr, &serializedSize, sizeof(timeout), + SerializeIF::Endianness::BIG); + } +}; + /** * @brief Command to request CRC over memory region of the supervisor. */ @@ -1392,8 +1391,8 @@ class CheckMemory : public SupvTcSpacePacket { void initPacket() { size_t serializedSize = 0; uint8_t* dataFieldPtr = this->localData.fields.buffer; - SerializeAdapter::serialize(&memoryId, &dataFieldPtr, &serializedSize, sizeof(memoryId), - SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&memoryId, &dataFieldPtr, &serializedSize, + sizeof(memoryId), SerializeIF::Endianness::BIG); serializedSize = 0; SerializeAdapter::serialize(&n, &dataFieldPtr, &serializedSize, sizeof(n), SerializeIF::Endianness::BIG); @@ -1401,8 +1400,8 @@ class CheckMemory : public SupvTcSpacePacket { SerializeAdapter::serialize(&startAddress, &dataFieldPtr, &serializedSize, sizeof(startAddress), SerializeIF::Endianness::BIG); serializedSize = 0; - SerializeAdapter::serialize(&length, &dataFieldPtr, &serializedSize, - sizeof(length), SerializeIF::Endianness::BIG); + SerializeAdapter::serialize(&length, &dataFieldPtr, &serializedSize, sizeof(length), + SerializeIF::Endianness::BIG); } }; @@ -1469,109 +1468,6 @@ class WriteMemory : public SupvTcSpacePacket { } }; -/** - * @brief This dataset stores the boot status report of the supervisor. - */ -class BootStatusReport : public StaticLocalDataSet { - public: - BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {} - - BootStatusReport(object_id_t objectId) - : StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {} - - /** Information about boot status of MPSoC */ - lp_var_t bootSignal = lp_var_t(sid.objectId, PoolIds::BOOT_SIGNAL, this); - lp_var_t resetCounter = lp_var_t(sid.objectId, PoolIds::RESET_COUNTER, this); - /** Time the MPSoC needs for last boot */ - lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); - /** The currently set boot timeout */ - lp_var_t bootTimeoutMs = - lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); - lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); - /** States of the boot partition pins */ - lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); - lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); - lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); - lp_var_t bootState = lp_var_t(sid.objectId, PoolIds::BOOT_STATE, this); - lp_var_t bootCycles = lp_var_t(sid.objectId, PoolIds::BOOT_CYCLES, this); -}; - -/** - * @brief This dataset stores the housekeeping data of the supervisor. - */ -class HkSet : public StaticLocalDataSet { - public: - HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} - - HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} - - lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); - lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); - lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); - lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); - lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, this); - lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); - lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); - lp_var_t socState = lp_var_t(sid.objectId, PoolIds::SOC_STATE, this); - lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); - lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); - lp_var_t missionIoState = - lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, this); - lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); -}; - -/** - * @brief This dataset stores the last requested latchup status report. - */ -class LatchupStatusReport : public StaticLocalDataSet { - public: - LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {} - - LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {} - - lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); - lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); - lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); - lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); - lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); - lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); - lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); - lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); - lp_var_t timeMsec = - lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); - lp_var_t timeSec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); - lp_var_t timeMin = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); - lp_var_t timeHour = - lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); - lp_var_t timeDay = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); - lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); - lp_var_t timeYear = - lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); -}; - -/** - * @brief Class for handling tm replies of the supervisor. - */ -class TmPacket : public SpacePacket { - 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 SupvReturnValuesIF::CRC_FAILURE; - } - return HasReturnvaluesIF::RETURN_OK; - } -}; - /** * @brief This class can be used to package the update available or update verify command. */ @@ -1611,6 +1507,142 @@ class EraseMemory : public SupvTcSpacePacket { } }; +/** + * @brief This class creates the space packet to enable the auto TM generation + */ +class EnableAutoTm : public SupvTcSpacePacket { + public: + EnableAutoTm() : SupvTcSpacePacket(PAYLOAD_LENGTH, APID_AUTO_TM) { + *(this->localData.fields.buffer) = ENABLE; + makeCrc(); + } + + private: + static const uint16_t PAYLOAD_LENGTH = 1; // length without CRC field + static const uint8_t ENABLE = 1; +}; + +/** + * @brief This class creates the space packet to disable the auto TM generation + */ +class DisableAutoTm : public SupvTcSpacePacket { + public: + DisableAutoTm() : SupvTcSpacePacket(PAYLOAD_LENGTH, APID_AUTO_TM) { + *(this->localData.fields.buffer) = DISABLE; + makeCrc(); + } + + private: + static const uint16_t PAYLOAD_LENGTH = 1; // length without CRC field + static const uint8_t DISABLE = 0; +}; + +/** + * @brief Class for handling tm replies of the supervisor. + */ +class TmPacket : public SpacePacket { + 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 SupvReturnValuesIF::CRC_FAILURE; + } + return HasReturnvaluesIF::RETURN_OK; + } +}; + +/** + * @brief This dataset stores the boot status report of the supervisor. + */ +class BootStatusReport : public StaticLocalDataSet { + public: + BootStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, BOOT_REPORT_SET_ID) {} + + BootStatusReport(object_id_t objectId) + : StaticLocalDataSet(sid_t(objectId, BOOT_REPORT_SET_ID)) {} + + /** Information about boot status of MPSoC */ + lp_var_t socState = lp_var_t(sid.objectId, PoolIds::BR_SOC_STATE, this); + lp_var_t powerCycles = lp_var_t(sid.objectId, PoolIds::POWER_CYCLES, this); + /** Time the MPSoC needs for last boot */ + lp_var_t bootAfterMs = lp_var_t(sid.objectId, PoolIds::BOOT_AFTER_MS, this); + /** The currently set boot timeout */ + lp_var_t bootTimeoutMs = + lp_var_t(sid.objectId, PoolIds::BOOT_TIMEOUT_MS, this); + lp_var_t activeNvm = lp_var_t(sid.objectId, PoolIds::ACTIVE_NVM, this); + /** States of the boot partition pins */ + lp_var_t bp0State = lp_var_t(sid.objectId, PoolIds::BP0_STATE, this); + lp_var_t bp1State = lp_var_t(sid.objectId, PoolIds::BP1_STATE, this); + lp_var_t bp2State = lp_var_t(sid.objectId, PoolIds::BP2_STATE, this); + lp_var_t bootState = lp_var_t(sid.objectId, PoolIds::BOOT_STATE, this); + lp_var_t bootCycles = lp_var_t(sid.objectId, PoolIds::BOOT_CYCLES, this); +}; + +/** + * @brief This dataset stores the housekeeping data of the supervisor. + */ +class HkSet : public StaticLocalDataSet { + public: + HkSet(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} + + HkSet(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} + + lp_var_t tempPs = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempPl = lp_var_t(sid.objectId, PoolIds::TEMP_PS, this); + lp_var_t tempSup = lp_var_t(sid.objectId, PoolIds::TEMP_SUP, this); + lp_var_t uptime = lp_var_t(sid.objectId, PoolIds::UPTIME, this); + lp_var_t cpuLoad = lp_var_t(sid.objectId, PoolIds::CPULOAD, this); + lp_var_t availableHeap = lp_var_t(sid.objectId, PoolIds::AVAILABLEHEAP, this); + lp_var_t numTcs = lp_var_t(sid.objectId, PoolIds::NUM_TCS, this); + lp_var_t numTms = lp_var_t(sid.objectId, PoolIds::NUM_TMS, this); + lp_var_t socState = lp_var_t(sid.objectId, PoolIds::HK_SOC_STATE, this); + lp_var_t nvm0_1_state = lp_var_t(sid.objectId, PoolIds::NVM0_1_STATE, this); + lp_var_t nvm3_state = lp_var_t(sid.objectId, PoolIds::NVM3_STATE, this); + lp_var_t missionIoState = + lp_var_t(sid.objectId, PoolIds::MISSION_IO_STATE, this); + lp_var_t fmcState = lp_var_t(sid.objectId, PoolIds::FMC_STATE, this); +}; + +/** + * @brief This dataset stores the last requested latchup status report. + */ +class LatchupStatusReport : public StaticLocalDataSet { + public: + LatchupStatusReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, LATCHUP_RPT_ID) {} + + LatchupStatusReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, LATCHUP_RPT_ID)) {} + + lp_var_t id = lp_var_t(sid.objectId, PoolIds::LATCHUP_ID, this); + lp_var_t cnt0 = lp_var_t(sid.objectId, PoolIds::CNT0, this); + lp_var_t cnt1 = lp_var_t(sid.objectId, PoolIds::CNT1, this); + lp_var_t cnt2 = lp_var_t(sid.objectId, PoolIds::CNT2, this); + lp_var_t cnt3 = lp_var_t(sid.objectId, PoolIds::CNT3, this); + lp_var_t cnt4 = lp_var_t(sid.objectId, PoolIds::CNT4, this); + lp_var_t cnt5 = lp_var_t(sid.objectId, PoolIds::CNT5, this); + lp_var_t cnt6 = lp_var_t(sid.objectId, PoolIds::CNT6, this); + lp_var_t timeMsec = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MSEC, this); + lp_var_t timeSec = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_SEC, this); + lp_var_t timeMin = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MIN, this); + lp_var_t timeHour = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_HOUR, this); + lp_var_t timeDay = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_DAY, this); + lp_var_t timeMon = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_MON, this); + lp_var_t timeYear = + lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_TIME_YEAR, this); + lp_var_t isSet = lp_var_t(sid.objectId, PoolIds::LATCHUP_RPT_IS_SET, this); + + static const uint8_t IS_SET_BIT_POS = 15; +}; + class UpdateStatusReport : public TmPacket { public: UpdateStatusReport() : TmPacket() {} @@ -1639,19 +1671,15 @@ class UpdateStatusReport : public TmPacket { } ReturnValue_t verifycrc(uint16_t goodCrc) const { - if (crc != goodCrc) { - return SupvReturnValuesIF::UPDATE_CRC_FAILURE; - } - return HasReturnvaluesIF::RETURN_OK; + if (crc != goodCrc) { + return SupvReturnValuesIF::UPDATE_CRC_FAILURE; + } + return HasReturnvaluesIF::RETURN_OK; } - uint16_t getCrc() const { - return crc; - } + uint16_t getCrc() const { return crc; } - uint16_t getNominalSize() const { - return FULL_SIZE; - } + uint16_t getNominalSize() const { return FULL_SIZE; } private: // Nominal size of the space packet diff --git a/linux/devices/devicedefinitions/SupvReturnValuesIF.h b/linux/devices/devicedefinitions/SupvReturnValuesIF.h new file mode 100644 index 00000000..39fa4554 --- /dev/null +++ b/linux/devices/devicedefinitions/SupvReturnValuesIF.h @@ -0,0 +1,59 @@ +#ifndef SUPV_RETURN_VALUES_IF_H_ +#define SUPV_RETURN_VALUES_IF_H_ + +#include "fsfw/returnvalues/HasReturnvaluesIF.h" + +class SupvReturnValuesIF { + public: + static const uint8_t INTERFACE_ID = CLASS_ID::SUPV_RETURN_VALUES_IF; + + //! [EXPORT] : [COMMENT] Space Packet received from PLOC supervisor has invalid CRC + static const ReturnValue_t CRC_FAILURE = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Received ACK failure reply from PLOC supervisor + static const ReturnValue_t RECEIVED_ACK_FAILURE = MAKE_RETURN_CODE(0xA1); + //! [EXPORT] : [COMMENT] Received execution failure reply from PLOC supervisor + static const ReturnValue_t RECEIVED_EXE_FAILURE = MAKE_RETURN_CODE(0xA2); + //! [EXPORT] : [COMMENT] Received space packet with invalid APID from PLOC supervisor + static const ReturnValue_t INVALID_APID = MAKE_RETURN_CODE(0xA3); + //! [EXPORT] : [COMMENT] Failed to read current system time + static const ReturnValue_t GET_TIME_FAILURE = MAKE_RETURN_CODE(0xA4); + //! [EXPORT] : [COMMENT] Received command with invalid watchdog parameter. Valid watchdogs are 0 + //! for PS, 1 for PL and 2 for INT + static const ReturnValue_t INVALID_WATCHDOG = MAKE_RETURN_CODE(0xA5); + //! [EXPORT] : [COMMENT] Received watchdog timeout config command with invalid timeout. Valid + //! timeouts must be in the range between 1000 and 360000 ms. + static const ReturnValue_t INVALID_WATCHDOG_TIMEOUT = MAKE_RETURN_CODE(0xA6); + //! [EXPORT] : [COMMENT] Received latchup config command with invalid latchup ID + static const ReturnValue_t INVALID_LATCHUP_ID = MAKE_RETURN_CODE(0xA7); + //! [EXPORT] : [COMMENT] Received set adc sweep period command with invalid sweep period. Must be + //! larger than 21. + static const ReturnValue_t SWEEP_PERIOD_TOO_SMALL = MAKE_RETURN_CODE(0xA8); + //! [EXPORT] : [COMMENT] Receive auto EM test command with invalid test param. Valid params are 1 + //! and 2. + static const ReturnValue_t INVALID_TEST_PARAM = MAKE_RETURN_CODE(0xA9); + //! [EXPORT] : [COMMENT] Returned when scanning for MRAM dump packets failed. + static const ReturnValue_t MRAM_PACKET_PARSING_FAILURE = MAKE_RETURN_CODE(0xAA); + //! [EXPORT] : [COMMENT] Returned when the start and stop addresses of the MRAM dump or MRAM wipe + //! commands are invalid (e.g. start address bigger than stop address) + static const ReturnValue_t INVALID_MRAM_ADDRESSES = MAKE_RETURN_CODE(0xAB); + //! [EXPORT] : [COMMENT] Expect reception of an MRAM dump packet but received space packet with + //! other apid. + static const ReturnValue_t NO_MRAM_PACKET = MAKE_RETURN_CODE(0xAC); + //! [EXPORT] : [COMMENT] Path to PLOC directory on SD card does not exist + static const ReturnValue_t PATH_DOES_NOT_EXIST = MAKE_RETURN_CODE(0xAD); + //! [EXPORT] : [COMMENT] MRAM dump file does not exists. The file should actually already have + //! been created with the reception of the first dump packet. + static const ReturnValue_t MRAM_FILE_NOT_EXISTS = MAKE_RETURN_CODE(0xAE); + //! [EXPORT] : [COMMENT] Received action command has invalid length + static const ReturnValue_t INVALID_LENGTH = MAKE_RETURN_CODE(0xAF); + //! [EXPORT] : [COMMENT] Filename too long + static const ReturnValue_t FILENAME_TOO_LONG = MAKE_RETURN_CODE(0xB0); + //! [EXPORT] : [COMMENT] Received update status report with invalid packet length field + static const ReturnValue_t UPDATE_STATUS_REPORT_INVALID_LENGTH = MAKE_RETURN_CODE(0xB1); + //! [EXPORT] : [COMMENT] Update status report does not contain expected CRC. There might be a bit flip in the update memory region. + static const ReturnValue_t UPDATE_CRC_FAILURE = MAKE_RETURN_CODE(0xB2); + //! [EXPORT] : [COMMENT] Supervisor helper task ist currently executing a command (wait until helper tas has finished or interrupt by sending the terminate command) + static const ReturnValue_t SUPV_HELPER_EXECUTING = MAKE_RETURN_CODE(0xB3); +}; + +#endif /* SUPV_RETURN_VALUES_IF_H_ */ diff --git a/linux/devices/ploc/PlocSupervisorHandler.cpp b/linux/devices/ploc/PlocSupervisorHandler.cpp index 1825a01b..36cc6053 100644 --- a/linux/devices/ploc/PlocSupervisorHandler.cpp +++ b/linux/devices/ploc/PlocSupervisorHandler.cpp @@ -326,11 +326,6 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d result = RETURN_OK; break; } - case (supv::PREPARE_UPDATE): { - prepareEmptyCmd(supv::APID_PREPARE_UPDATE); - result = RETURN_OK; - break; - } case (supv::START_MPSOC_QUIET): { prepareEmptyCmd(supv::APID_START_MPSOC_QUIET); result = RETURN_OK; @@ -346,6 +341,18 @@ ReturnValue_t PlocSupervisorHandler::buildCommandFromCommand(DeviceCommandId_t d result = RETURN_OK; break; } + case (supv::ENABLE_AUTO_TM): { + supv::EnableAutoTm packet; + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } + case (supv::DISABLE_AUTO_TM): { + supv::DisableAutoTm packet; + packetToOutBuffer(packet.getWholeData(), packet.getFullSize()); + result = RETURN_OK; + break; + } default: sif::debug << "PlocSupervisorHandler::buildCommandFromCommand: Command not implemented" << std::endl; @@ -401,10 +408,11 @@ void PlocSupervisorHandler::fillCommandAndReplyMap() { this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_MIRROR); this->insertInCommandMap(supv::FACTORY_RESET_CLEAR_CIRCULAR); this->insertInCommandMap(supv::CAN_LOOPBACK_TEST); - this->insertInCommandMap(supv::PREPARE_UPDATE); this->insertInCommandMap(supv::START_MPSOC_QUIET); this->insertInCommandMap(supv::SET_SHUTDOWN_TIMEOUT); this->insertInCommandMap(supv::FACTORY_FLASH); + this->insertInCommandMap(supv::ENABLE_AUTO_TM); + this->insertInCommandMap(supv::DISABLE_AUTO_TM); this->insertInCommandAndReplyMap(supv::FIRST_MRAM_DUMP, 3); this->insertInCommandAndReplyMap(supv::CONSECUTIVE_MRAM_DUMP, 3); this->insertInReplyMap(supv::ACK_REPORT, 3, nullptr, supv::SIZE_ACK_REPORT); @@ -527,7 +535,7 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(supv::NUM_TMS, new PoolEntry({0})); localDataPoolMap.emplace(supv::TEMP_PS, new PoolEntry({0})); localDataPoolMap.emplace(supv::TEMP_PL, new PoolEntry({0})); - localDataPoolMap.emplace(supv::SOC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::HK_SOC_STATE, new PoolEntry({0})); localDataPoolMap.emplace(supv::NVM0_1_STATE, new PoolEntry({0})); localDataPoolMap.emplace(supv::NVM3_STATE, new PoolEntry({0})); localDataPoolMap.emplace(supv::MISSION_IO_STATE, new PoolEntry({0})); @@ -537,8 +545,8 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(supv::CPULOAD, new PoolEntry({0})); localDataPoolMap.emplace(supv::AVAILABLEHEAP, new PoolEntry({0})); - localDataPoolMap.emplace(supv::BOOT_SIGNAL, new PoolEntry({0})); - localDataPoolMap.emplace(supv::RESET_COUNTER, new PoolEntry({0})); + localDataPoolMap.emplace(supv::BR_SOC_STATE, new PoolEntry({0})); + localDataPoolMap.emplace(supv::POWER_CYCLES, new PoolEntry({0})); localDataPoolMap.emplace(supv::BOOT_AFTER_MS, new PoolEntry({0})); localDataPoolMap.emplace(supv::BOOT_TIMEOUT_MS, new PoolEntry({0})); localDataPoolMap.emplace(supv::ACTIVE_NVM, new PoolEntry({0})); @@ -561,6 +569,7 @@ ReturnValue_t PlocSupervisorHandler::initializeLocalDataPool(localpool::DataPool localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_DAY, new PoolEntry({0})); localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_MON, new PoolEntry({0})); localDataPoolMap.emplace(supv::LATCHUP_RPT_TIME_YEAR, new PoolEntry({0})); + localDataPoolMap.emplace(supv::LATCHUP_RPT_IS_SET, new PoolEntry({0})); return HasReturnvaluesIF::RETURN_OK; } @@ -672,10 +681,11 @@ ReturnValue_t PlocSupervisorHandler::enableReplyInReplyMap(DeviceCommandMap::ite case supv::FACTORY_RESET_CLEAR_CIRCULAR: case supv::REQUEST_LOGGING_DATA: case supv::DISABLE_PERIOIC_HK_TRANSMISSION: - case supv::PREPARE_UPDATE: case supv::START_MPSOC_QUIET: case supv::SET_SHUTDOWN_TIMEOUT: case supv::FACTORY_FLASH: + case supv::ENABLE_AUTO_TM: + case supv::DISABLE_AUTO_TM: enabledReplies = 2; break; default: @@ -893,9 +903,9 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) } uint16_t offset = supv::DATA_FIELD_OFFSET; - bootStatusReport.bootSignal = *(data + offset); + bootStatusReport.socState = *(data + offset); offset += 1; - bootStatusReport.resetCounter = *(data + offset); + bootStatusReport.powerCycles = *(data + offset); offset += 1; bootStatusReport.bootAfterMs = *(data + offset) << 24 | *(data + offset + 1) << 16 | *(data + offset + 2) << 8 | *(data + offset + 3); @@ -918,10 +928,10 @@ ReturnValue_t PlocSupervisorHandler::handleBootStatusReport(const uint8_t* data) nextReplyId = supv::EXE_REPORT; #if OBSW_VERBOSE_LEVEL >= 1 && OBSW_DEBUG_PLOC_SUPERVISOR == 1 - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Boot signal: " - << static_cast(bootStatusReport.bootSignal.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleBootStatusReport: Reset counter: " - << static_cast(bootStatusReport.resetCounter.value) << std::endl; + sif::info << "PlocSupervisorHandler::handleBootStatusReport: SoC State: " + << static_cast(bootStatusReport.socState.value) << std::endl; + sif::info << "PlocSupervisorHandler::handleBootStatusReport: Power Cycles: " + << static_cast(bootStatusReport.powerCycles.value) << std::endl; sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootAfterMs: " << bootStatusReport.bootAfterMs << " ms" << std::endl; sif::info << "PlocSupervisorHandler::handleBootStatusReport: BootTimeoutMs: " << std::dec @@ -971,7 +981,9 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da offset += 2; latchupStatusReport.cnt6 = *(data + offset) << 8 | *(data + offset + 1); offset += 2; - latchupStatusReport.timeMsec = (*(data + offset) << 8 | *(data + offset + 1)) & 0x7FFF; + uint16_t msec = *(data + offset) << 8 | *(data + offset + 1); + latchupStatusReport.isSet = msec >> supv::LatchupStatusReport::IS_SET_BIT_POS; + latchupStatusReport.timeMsec = msec & (~(1 << latchupStatusReport.IS_SET_BIT_POS)); offset += 2; latchupStatusReport.timeSec = *(data + offset); offset += 1; @@ -1018,8 +1030,8 @@ ReturnValue_t PlocSupervisorHandler::handleLatchupStatusReport(const uint8_t* da << static_cast(latchupStatusReport.timeYear.value) << std::endl; sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: Msec: " << static_cast(latchupStatusReport.timeMsec.value) << std::endl; - sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: 0x" << std::hex - << latchupStatusReport.timeMsec << std::dec << std::endl; + sif::info << "PlocSupervisorHandler::handleLatchupStatusReport: isSet: " + << static_cast(latchupStatusReport.isSet.value) << std::endl; #endif return result;