From e762cc5fb35eaffe83d33b0ce9b64c104824ea75 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:22:21 +0200 Subject: [PATCH 01/41] changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc320982..acfd8ef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,11 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. +- The dual lane assembly transition failed handler started new transitions towards the current mode + instead of the target mode. This means that if the dual lane assembly never reached the initial + submode (e.g. mode normal and submode dual side), it will transition back to the current mode, + which is `MODE_OFF`. Furthermore, this lead to invalid internal states, so the subsequent + recovery handling becomes stuck in the custom recovery sequence when swichting power back on. # [v2.0.5] 2023-05-11 From 5728d916efb9a91244b4e3121e927f11beb75267 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:23:21 +0200 Subject: [PATCH 02/41] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acfd8ef3..c185fab1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,7 @@ will consitute of a breaking change warranting a new major release: - The dual lane assembly transition failed handler started new transitions towards the current mode instead of the target mode. This means that if the dual lane assembly never reached the initial submode (e.g. mode normal and submode dual side), it will transition back to the current mode, - which is `MODE_OFF`. Furthermore, this lead to invalid internal states, so the subsequent + which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent recovery handling becomes stuck in the custom recovery sequence when swichting power back on. # [v2.0.5] 2023-05-11 From d5a6feb3475d30e4bb5a5485c522101b5ce49731 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 14:28:05 +0200 Subject: [PATCH 03/41] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c185fab1..af09ec1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,8 @@ will consitute of a breaking change warranting a new major release: submode (e.g. mode normal and submode dual side), it will transition back to the current mode, which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent recovery handling becomes stuck in the custom recovery sequence when swichting power back on. +- The dual lane custom recovery handling was adapted to always perform proper power switch handling + irrespective of current or target modes. # [v2.0.5] 2023-05-11 From 07dd84ff1e6867f4ba8ce5effe5003685a5085b8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Apr 2023 15:34:45 +0200 Subject: [PATCH 04/41] changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af09ec1a..7d096ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,9 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. + +# [v2.0.5] to be released + - The dual lane assembly transition failed handler started new transitions towards the current mode instead of the target mode. This means that if the dual lane assembly never reached the initial submode (e.g. mode normal and submode dual side), it will transition back to the current mode, From 9b5fac828b5d5093ef24ecc01e6f5eddc5463ee8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 21:17:06 +0200 Subject: [PATCH 05/41] changelog --- CHANGELOG.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d096ddd..dc320982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,16 +47,6 @@ will consitute of a breaking change warranting a new major release: - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. -# [v2.0.5] to be released - -- The dual lane assembly transition failed handler started new transitions towards the current mode - instead of the target mode. This means that if the dual lane assembly never reached the initial - submode (e.g. mode normal and submode dual side), it will transition back to the current mode, - which miht be `MODE_OFF`. Furthermore, this can lead to invalid internal states, so the subsequent - recovery handling becomes stuck in the custom recovery sequence when swichting power back on. -- The dual lane custom recovery handling was adapted to always perform proper power switch handling - irrespective of current or target modes. - # [v2.0.5] 2023-05-11 - The dual lane assembly transition failed handler started new transitions towards the current mode From f225d9a7c19f4b2bfa267bab7d893cfd988d638f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 2 May 2023 13:42:20 +0200 Subject: [PATCH 06/41] add HK request command --- linux/payload/PlocMpsocHandler.cpp | 47 ++++++++++++++++++++++++++---- linux/payload/PlocMpsocHandler.h | 9 ++---- linux/payload/plocMpscoDefs.h | 14 +++++++++ 3 files changed, 58 insertions(+), 12 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 72f2355f..29656c59 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -247,6 +247,10 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device result = prepareTcReplayWriteSequence(commandData, commandDataLen); break; } + case (mpsoc::TC_GET_HK_REPORT): { + result = prepareTcGetHkReport(); + break; + } case (mpsoc::TC_MODE_REPLAY): { result = prepareTcModeReplay(); break; @@ -304,6 +308,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::TC_MODE_REPLAY); this->insertInCommandMap(mpsoc::TC_MODE_IDLE); this->insertInCommandMap(mpsoc::TC_CAM_CMD_SEND); + this->insertInCommandMap(mpsoc::TC_GET_HK_REPORT); this->insertInCommandMap(mpsoc::RELEASE_UART_TX); this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE); this->insertInCommandMap(mpsoc::TC_CAM_TAKE_PIC); @@ -313,6 +318,7 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT); this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); + this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, nullptr, 0); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); } @@ -346,9 +352,15 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain break; case (mpsoc::apid::TM_CAM_CMD_RPT): *foundLen = spacePacket.getFullPacketLen(); - tmCamCmdRpt.rememberSpacePacketSize = *foundLen; + foundPacketLen = *foundLen; *foundId = mpsoc::TM_CAM_CMD_RPT; break; + case (mpsoc::apid::TM_HK_GET_REPORT): { + *foundLen = spacePacket.getFullPacketLen(); + foundPacketLen = *foundLen; + *foundId = mpsoc::TM_GET_HK_REPORT; + break; + } case (mpsoc::apid::EXE_SUCCESS): *foundLen = mpsoc::SIZE_EXE_REPORT; *foundId = mpsoc::EXE_REPORT; @@ -386,6 +398,10 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const result = handleMemoryReadReport(packet); break; } + case (mpsoc::TM_GET_HK_REPORT): { + result = handleGetHkReport(packet); + break; + } case (mpsoc::TM_CAM_CMD_RPT): { result = handleCamCmdRpt(packet); break; @@ -512,6 +528,17 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { return returnvalue::OK; } +ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { + ReturnValue_t result = returnvalue::OK; + mpsoc::TcGetHkReport tcDownlinkPwrOff(spParams, sequenceCount); + result = tcDownlinkPwrOff.buildPacket(); + if (result != returnvalue::OK) { + return result; + } + finishTcPrep(tcDownlinkPwrOff.getFullPacketLen()); + return returnvalue::OK; +} + ReturnValue_t PlocMPSoCHandler::prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; @@ -724,17 +751,25 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { return result; } +ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { + ReturnValue_t result = verifyPacket(data, foundPacketLen); + if (result != returnvalue::OK) { + return result; + } + SpacePacketReader packetReader(data, foundPacketLen); + return returnvalue::OK; +} + ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { ReturnValue_t result = returnvalue::OK; - result = verifyPacket(data, tmCamCmdRpt.rememberSpacePacketSize); + ReturnValue_t result = verifyPacket(data, foundPacketLen); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; } - SpacePacketReader packetReader(data, tmCamCmdRpt.rememberSpacePacketSize); + SpacePacketReader packetReader(data, foundPacketLen); const uint8_t* dataFieldPtr = data + mpsoc::SPACE_PACKET_HEADER_SIZE + sizeof(uint16_t); - std::string camCmdRptMsg( - reinterpret_cast(dataFieldPtr), - tmCamCmdRpt.rememberSpacePacketSize - mpsoc::SPACE_PACKET_HEADER_SIZE - sizeof(uint16_t) - 3); + std::string camCmdRptMsg(reinterpret_cast(dataFieldPtr), + foundPacketLen - mpsoc::SPACE_PACKET_HEADER_SIZE - sizeof(uint16_t) - 3); #if OBSW_DEBUG_PLOC_MPSOC == 1 uint8_t ackValue = *(packetReader.getFullData() + packetReader.getFullPacketLen() - 2); sif::info << "PlocMPSoCHandler: CamCmdRpt message: " << camCmdRptMsg << std::endl; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index 10e6bd5d..e11f05eb 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -138,17 +138,12 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { TmMemReadReport tmMemReadReport; - struct TmCamCmdRpt { - size_t rememberSpacePacketSize = 0; - }; - - TmCamCmdRpt tmCamCmdRpt; - struct TelemetryBuffer { uint16_t length = 0; uint8_t buffer[mpsoc::SP_MAX_SIZE]; }; + size_t foundPacketLen = 0; TelemetryBuffer tmBuffer; enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; @@ -167,6 +162,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcReplayStop(); ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcDownlinkPwrOff(); + ReturnValue_t prepareTcGetHkReport(); ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcModeIdle(); @@ -213,6 +209,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { */ ReturnValue_t handleMemoryReadReport(const uint8_t* data); + ReturnValue_t handleGetHkReport(const uint8_t* data); ReturnValue_t handleCamCmdRpt(const uint8_t* data); /** diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 975dad32..e6acf4bf 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -37,6 +37,8 @@ static const DeviceCommandId_t TC_CAM_TAKE_PIC = 22; static const DeviceCommandId_t TC_SIMPLEX_SEND_FILE = 23; static const DeviceCommandId_t TC_DOWNLINK_DATA_MODULATE = 24; static const DeviceCommandId_t TC_MODE_SNAPSHOT = 25; +static const DeviceCommandId_t TC_GET_HK_REPORT = 26; +static const DeviceCommandId_t TM_GET_HK_REPORT = 27; // Will reset the sequence count of the OBSW static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; @@ -45,6 +47,7 @@ static const uint16_t SIZE_ACK_REPORT = 14; static const uint16_t SIZE_EXE_REPORT = 14; static const uint16_t SIZE_TM_MEM_READ_REPORT = 18; static const uint16_t SIZE_TM_CAM_CMD_RPT = 18; +static constexpr size_t SIZE_TM_HK_REPORT = 369; /** * SpacePacket apids of PLOC telecommands and telemetry. @@ -65,6 +68,8 @@ static const uint16_t TC_MODE_IDLE = 0x11E; static const uint16_t TC_MODE_REPLAY = 0x11F; static const uint16_t TC_MODE_SNAPSHOT = 0x120; static const uint16_t TC_DOWNLINK_DATA_MODULATE = 0x121; +static constexpr uint16_t TC_HK_GET_REPORT = 0x123; +static constexpr uint16_t TM_HK_GET_REPORT = 0x408; static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124; static const uint16_t TC_CAM_CMD_SEND = 0x12C; static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130; @@ -561,6 +566,15 @@ class TcDownlinkPwrOn : public TcBase { } }; +/** + * @brief Class to build replay stop space packet. + */ +class TcGetHkReport : public TcBase { + public: + TcGetHkReport(ploc::SpTcParams params, uint16_t sequenceCount) + : TcBase(params, apid::TC_HK_GET_REPORT, sequenceCount) {} +}; + /** * @brief Class to build replay stop space packet. */ From 0fd18204bfdfa2ca9de02424c6783c2631608e3b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 2 May 2023 15:04:14 +0200 Subject: [PATCH 07/41] add new set --- linux/payload/PlocMpsocHandler.cpp | 44 +++++++++++- linux/payload/PlocMpsocHandler.h | 40 ++++++++++- linux/payload/plocMpscoDefs.h | 103 +++++++++++++++++++++++++++++ mission/tcs/Tmp1075Definitions.h | 2 +- 4 files changed, 186 insertions(+), 3 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 29656c59..b0c56667 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -11,6 +11,7 @@ PlocMPSoCHandler::PlocMPSoCHandler(object_id_t objectId, object_id_t uartComIFid CookieIF* comCookie, PlocMPSoCHelper* plocMPSoCHelper, Gpio uartIsolatorSwitch, object_id_t supervisorHandler) : DeviceHandlerBase(objectId, uartComIFid, comCookie), + hkReport(this), plocMPSoCHelper(plocMPSoCHelper), uartIsolatorSwitch(uartIsolatorSwitch), supervisorHandler(supervisorHandler), @@ -425,6 +426,41 @@ uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { + localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus); + localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); + localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); + localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_PWR_ON, &peDownlinkPwrOn); + localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_JESD_SYNC_STATUS, &peDownlinkJesdSyncStatus); + localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_DAC_STATUS, &peDownlinkDacStatus); + localDataPoolMap.emplace(mpsoc::poolid::CAM_STATUS, &peCameraStatus); + localDataPoolMap.emplace(mpsoc::poolid::CAM_SDI_STATUS, &peCameraSdiStatus); + localDataPoolMap.emplace(mpsoc::poolid::CAM_FPGA_TEMP, &peCameraFpgaTemp); + localDataPoolMap.emplace(mpsoc::poolid::CAM_SOC_TEMP, &peCameraSocTemp); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_TEMP, &peSysmonTemp); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCINT, &peSysmonVccInt); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCAUX, &peSysmonVccAux); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCBRAM, &peSysmonVccBram); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCPAUX, &peSysmonVccPaux); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCPINT, &peSysmonVccPint); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCCPDRO, &peSysmonVccPdro); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB12V, &peSysmonMb12V); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB3V3, &peSysmonMb3V3); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB1V8, &peSysmonMb1V8); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC12V, &peSysmonVcc12V); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC3V3, &peSysmonVcc3V3); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC3V3VA, &peSysmonVcc3V3VA); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC2V5DDR, &peSysmonVcc2V5DDR); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC1V2DDR, &peSysmonVcc1V2DDR); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC0V9, &peSysmonVcc0V9); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC0V6VTT, &peSysmonVcc0V6VTT); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_SAFE_COTS_CUR, &peSysmonSafeCotsCur); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_NVM4_XO_CUR, &peSysmonNvm4XoCur); + localDataPoolMap.emplace(mpsoc::poolid::SEM_UNCORRECTABLE_ERRS, &peSemUncorrectableErrs); + localDataPoolMap.emplace(mpsoc::poolid::SEM_CORRECTABLE_ERRS, &peSemCorrectableErrs); + localDataPoolMap.emplace(mpsoc::poolid::SEM_STATUS, &peSemStatus); + localDataPoolMap.emplace(mpsoc::poolid::REBOOT_MPSOC_REQUIRED, &peRebootMpsocRequired); + poolManager.subscribeForRegularPeriodicPacket( + subdp::RegularHkPeriodicParams(hkReport.getSid(), false, 10.0)); return returnvalue::OK; } @@ -761,7 +797,6 @@ ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { } ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { - ReturnValue_t result = returnvalue::OK; ReturnValue_t result = verifyPacket(data, foundPacketLen); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PlocMPSoCHandler::handleCamCmdRpt: CRC failure" << std::endl; @@ -1143,6 +1178,13 @@ void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { return; } +LocalPoolDataSetBase* PlocMPSoCHandler::getDataSetHandle(sid_t sid) { + if (sid == hkReport.getSid()) { + return &hkReport; + } + return nullptr; +} + std::string PlocMPSoCHandler::getStatusString(uint16_t status) { switch (status) { case (mpsoc::status_code::UNKNOWN_APID): { diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index e11f05eb..c9850e18 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -77,7 +77,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { uint8_t expectedReplies = 1, bool useAlternateId = false, DeviceCommandId_t alternateReplyID = 0) override; size_t getNextReplyLength(DeviceCommandId_t deviceCommand) override; - virtual ReturnValue_t doSendReadHook() override; + ReturnValue_t doSendReadHook() override; + LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; private: static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PLOC_MPSOC_HANDLER; @@ -105,6 +106,8 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { static const uint16_t PACKET_SEQUENCE_COUNT_MASK = 0x3FFF; static const uint8_t STATUS_OFFSET = 10; + mpsoc::HkReport hkReport; + MessageQueueIF* eventQueue = nullptr; MessageQueueIF* commandActionHelperQueue = nullptr; @@ -114,6 +117,41 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { SpacePacketCreator creator; ploc::SpTcParams spParams = ploc::SpTcParams(creator); + PoolEntry peStatus = PoolEntry(); + PoolEntry peMode = PoolEntry(); + PoolEntry peDownlinkPwrOn = PoolEntry(); + PoolEntry peDownlinkReplyActive = PoolEntry(); + PoolEntry peDownlinkJesdSyncStatus = PoolEntry(); + PoolEntry peDownlinkDacStatus = PoolEntry(); + PoolEntry peCameraStatus = PoolEntry(); + PoolEntry peCameraSdiStatus = PoolEntry(); + PoolEntry peCameraFpgaTemp = PoolEntry(); + PoolEntry peCameraSocTemp = PoolEntry(); + PoolEntry peSysmonTemp = PoolEntry(); + PoolEntry peSysmonVccInt = PoolEntry(); + PoolEntry peSysmonVccAux = PoolEntry(); + PoolEntry peSysmonVccBram = PoolEntry(); + PoolEntry peSysmonVccPaux = PoolEntry(); + PoolEntry peSysmonVccPint = PoolEntry(); + PoolEntry peSysmonVccPdro = PoolEntry(); + PoolEntry peSysmonMb12V = PoolEntry(); + PoolEntry peSysmonMb3V3 = PoolEntry(); + PoolEntry peSysmonMb1V8 = PoolEntry(); + PoolEntry peSysmonVcc12V = PoolEntry(); + PoolEntry peSysmonVcc5V = PoolEntry(); + PoolEntry peSysmonVcc3V3 = PoolEntry(); + PoolEntry peSysmonVcc3V3VA = PoolEntry(); + PoolEntry peSysmonVcc2V5DDR = PoolEntry(); + PoolEntry peSysmonVcc1V2DDR = PoolEntry(); + PoolEntry peSysmonVcc0V9 = PoolEntry(); + PoolEntry peSysmonVcc0V6VTT = PoolEntry(); + PoolEntry peSysmonSafeCotsCur = PoolEntry(); + PoolEntry peSysmonNvm4XoCur = PoolEntry(); + PoolEntry peSemUncorrectableErrs = PoolEntry(); + PoolEntry peSemCorrectableErrs = PoolEntry(); + PoolEntry peSemStatus = PoolEntry(); + PoolEntry peRebootMpsocRequired = PoolEntry(); + /** * This variable is used to store the id of the next reply to receive. This is necessary * because the PLOC sends as reply to each command at least one acknowledgment and execution diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index e6acf4bf..1ef72bf5 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -1,6 +1,7 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ +#include #include #include #include @@ -12,6 +13,47 @@ namespace mpsoc { +static constexpr uint32_t HK_SET_ID = 0; + +namespace poolid { +enum { + STATUS = 0, + MODE = 1, + DOWNLINK_PWR_ON = 2, + DOWNLINK_REPLY_ACTIIVE = 3, + DOWNLINK_JESD_SYNC_STATUS = 4, + DOWNLINK_DAC_STATUS = 5, + CAM_STATUS = 6, + CAM_SDI_STATUS = 7, + CAM_FPGA_TEMP = 8, + CAM_SOC_TEMP = 9, + SYSMON_TEMP = 10, + SYSMON_VCCINT = 11, + SYSMON_VCCAUX = 12, + SYSMON_VCCBRAM = 13, + SYSMON_VCCPAUX = 14, + SYSMON_VCCPINT = 15, + SYSMON_VCCPDRO = 16, + SYSMON_MB12V = 17, + SYSMON_MB3V3 = 18, + SYSMON_MB1V8 = 19, + SYSMON_VCC12V = 20, + SYSMON_VCC5V = 21, + SYSMON_VCC3V3 = 22, + SYSMON_VCC3V3VA = 23, + SYSMON_VCC2V5DDR = 24, + SYSMON_VCC1V2DDR = 25, + SYSMON_VCC0V9 = 26, + SYSMON_VCC0V6VTT = 27, + SYSMON_SAFE_COTS_CUR = 28, + SYSMON_NVM4_XO_CUR = 29, + SEM_UNCORRECTABLE_ERRS = 30, + SEM_CORRECTABLE_ERRS = 31, + SEM_STATUS = 32, + REBOOT_MPSOC_REQUIRED = 33, +}; +} + static const DeviceCommandId_t NONE = 0; static const DeviceCommandId_t TC_MEM_WRITE = 1; static const DeviceCommandId_t TC_MEM_READ = 2; @@ -788,6 +830,67 @@ class TcCamcmdSend : public TcBase { static const uint8_t CARRIAGE_RETURN = 0xD; }; +class HkReport : public StaticLocalDataSet<36> { + public: + HkReport(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HK_SET_ID) {} + + HkReport(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HK_SET_ID)) {} + + lp_var_t status = lp_var_t(sid.objectId, mpsoc::poolid::STATUS, this); + lp_var_t mode = lp_var_t(sid.objectId, mpsoc::poolid::MODE, this); + lp_var_t downlinkPwrOn = + lp_var_t(sid.objectId, mpsoc::poolid::DOWNLINK_PWR_ON, this); + lp_var_t downlinkReplyActive = + lp_var_t(sid.objectId, mpsoc::poolid::DOWNLINK_REPLY_ACTIIVE, this); + lp_var_t downlinkJesdSyncStatus = + lp_var_t(sid.objectId, mpsoc::poolid::DOWNLINK_JESD_SYNC_STATUS, this); + lp_var_t downlinkDacStatus = + lp_var_t(sid.objectId, mpsoc::poolid::DOWNLINK_DAC_STATUS, this); + lp_var_t camStatus = lp_var_t(sid.objectId, mpsoc::poolid::CAM_STATUS, this); + lp_var_t camSdiStatus = + lp_var_t(sid.objectId, mpsoc::poolid::CAM_SDI_STATUS, this); + lp_var_t camFpgaTemp = lp_var_t(sid.objectId, mpsoc::poolid::CAM_FPGA_TEMP, this); + lp_var_t camSocTemp = lp_var_t(sid.objectId, mpsoc::poolid::CAM_SOC_TEMP, this); + lp_var_t sysmonTemp = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_TEMP, this); + lp_var_t sysmonVccInt = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCCINT, this); + lp_var_t sysmonVccAux = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCCAUX, this); + lp_var_t sysmonVccBram = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCCBRAM, this); + lp_var_t sysmonVccPaux = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCCPAUX, this); + lp_var_t sysmonVccPint = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCCPINT, this); + lp_var_t sysmonVccPdro = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCCPDRO, this); + lp_var_t sysmonMb12V = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_MB12V, this); + lp_var_t sysmonMb3V3 = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_MB3V3, this); + lp_var_t sysmonMb1V8 = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_MB1V8, this); + lp_var_t sysmonVcc12V = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC12V, this); + lp_var_t sysmonVcc5V = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC5V, this); + lp_var_t sysmonVcc3V3 = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC3V3, this); + lp_var_t sysmonVcc3V3VA = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC3V3VA, this); + lp_var_t sysmonVcc2V5DDR = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC2V5DDR, this); + lp_var_t sysmonVcc1V2DDR = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC1V2DDR, this); + lp_var_t sysmonVcc0V9 = lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC0V9, this); + lp_var_t sysmonVcc0V6VTT = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_VCC0V6VTT, this); + lp_var_t sysmonSafeCotsCur = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_SAFE_COTS_CUR, this); + lp_var_t sysmonNvm4XoCur = + lp_var_t(sid.objectId, mpsoc::poolid::SYSMON_NVM4_XO_CUR, this); + lp_var_t semUncorrectableErrs = + lp_var_t(sid.objectId, mpsoc::poolid::SEM_UNCORRECTABLE_ERRS, this); + lp_var_t semCorrectableErrs = + lp_var_t(sid.objectId, mpsoc::poolid::SEM_CORRECTABLE_ERRS, this); + lp_var_t semStatus = + lp_var_t(sid.objectId, mpsoc::poolid::SEM_CORRECTABLE_ERRS, this); + lp_var_t rebootMpsocRequired = + lp_var_t(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this); +}; + } // namespace mpsoc #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_PLOCMPSOCDEFINITIONS_H_ */ diff --git a/mission/tcs/Tmp1075Definitions.h b/mission/tcs/Tmp1075Definitions.h index 946ac82e..345146e6 100644 --- a/mission/tcs/Tmp1075Definitions.h +++ b/mission/tcs/Tmp1075Definitions.h @@ -29,7 +29,7 @@ static const uint8_t MAX_REPLY_LENGTH = GET_TEMP_REPLY_SIZE; enum Tmp1075PoolIds : lp_id_t { TEMPERATURE_C_TMP1075 }; -class Tmp1075Dataset : public StaticLocalDataSet { +class Tmp1075Dataset : public StaticLocalDataSet<2> { public: Tmp1075Dataset(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, TMP1075_DATA_SET_ID) {} From d67414e829574bd90d52e6a6d85cea691726a56d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 13:26:47 +0200 Subject: [PATCH 08/41] bugfxi by marius --- linux/payload/PlocMpsocHandler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index b0c56667..b9d97e90 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -428,7 +428,6 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc LocalDataPoolManager& poolManager) { localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus); localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); - localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_PWR_ON, &peDownlinkPwrOn); localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_JESD_SYNC_STATUS, &peDownlinkJesdSyncStatus); localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_DAC_STATUS, &peDownlinkDacStatus); From 66ca156ab30d71ee2e4a80d4fd8891de0218996d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 13:37:20 +0200 Subject: [PATCH 09/41] mpsoc update --- linux/payload/PlocMpsocHandler.cpp | 55 ++++++++++++++++-------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index b9d97e90..c1cb4bde 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -822,6 +822,16 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator uint8_t enabledReplies = 0; + auto enableThreeReplies = [&](DeviceCommandId_t replyId) { + enabledReplies = 3; + result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, replyId); + if (result != returnvalue::OK) { + sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " + << mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; + return result; + } + break; + }; switch (command->first) { case mpsoc::TC_MEM_WRITE: case mpsoc::TC_FLASHDELETE: @@ -838,26 +848,16 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator case mpsoc::TC_MODE_SNAPSHOT: enabledReplies = 2; break; + case mpsoc::TC_GET_HK_REPORT: { + enableThreeReplies(mpsoc::TM_GET_HK_REPORT); + break; + } case mpsoc::TC_MEM_READ: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - mpsoc::TM_MEMORY_READ_REPORT); - if (result != returnvalue::OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " - << mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; - return result; - } + enableThreeReplies(mpsoc::TM_MEMORY_READ_REPORT); break; } case mpsoc::TC_CAM_CMD_SEND: { - enabledReplies = 3; - result = DeviceHandlerBase::enableReplyInReplyMap(command, enabledReplies, true, - mpsoc::TM_CAM_CMD_RPT); - if (result != returnvalue::OK) { - sif::debug << "PlocMPSoCHandler::enableReplyInReplyMap: Reply with id " - << mpsoc::TM_CAM_CMD_RPT << " not in replyMap" << std::endl; - return result; - } + enableThreeReplies(mpsoc::TM_CAM_CMD_RPT); break; } case mpsoc::OBSW_RESET_SEQ_COUNT: @@ -1065,6 +1065,13 @@ void PlocMPSoCHandler::disableAllReplies() { DeviceCommandId_t commandId = getPendingCommand(); + auto disableCommandWithReply = [](DeviceCommandId_t replyId) { + iter = deviceReplyMap.find(replyId); + info = &(iter->second); + info->delayCycles = 0; + info->active = false; + info->command = deviceCommandMap.end(); + }; /* If the command expects a telemetry packet the appropriate tm reply will be disabled here */ switch (commandId) { case TC_MEM_WRITE: @@ -1082,19 +1089,15 @@ void PlocMPSoCHandler::disableAllReplies() { case TC_MODE_SNAPSHOT: break; case TC_MEM_READ: { - iter = deviceReplyMap.find(TM_MEMORY_READ_REPORT); - info = &(iter->second); - info->delayCycles = 0; - info->active = false; - info->command = deviceCommandMap.end(); + disableCommandWithReply(TM_MEMORY_READ_REPORT); + break; + } + case TC_GET_HK_REPORT: { + disableCommandWithReply(TM_GET_HK_REPORT); break; } case TC_CAM_CMD_SEND: { - iter = deviceReplyMap.find(TM_CAM_CMD_RPT); - info = &(iter->second); - info->delayCycles = 0; - info->active = false; - info->command = deviceCommandMap.end(); + disableCommandWithReply(TM_CAM_CMD_RPT); break; } default: { From 4a3af32a655c563846028203273af32300fd91a3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 21:28:46 +0200 Subject: [PATCH 10/41] MPSoC HK packet --- CHANGELOG.md | 1 + linux/payload/PlocMpsocHandler.cpp | 188 ++++++++++++++++++++++++++++- 2 files changed, 184 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc320982..7b0ecbe9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ will consitute of a breaking change warranting a new major release: CMake from selecting wrong cross-compilers if multiple cross-compilers with the same name are used on the same system. - Add ACS board for EM by default now. +- Add support for MPSoC HK packet. ## Added diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index c1cb4bde..e4c91a4a 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -792,6 +792,175 @@ ReturnValue_t PlocMPSoCHandler::handleGetHkReport(const uint8_t* data) { return result; } SpacePacketReader packetReader(data, foundPacketLen); + const uint8_t* dataStart = data + 6; + PoolReadGuard pg(&hkReport); + size_t deserLen = mpsoc::SIZE_TM_HK_REPORT; + SerializeIF::Endianness endianness = SerializeIF::Endianness::NETWORK; + result = SerializeAdapter::deSerialize(&hkReport.status.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.mode.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.downlinkPwrOn.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.downlinkReplyActive.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.downlinkJesdSyncStatus.value, &dataStart, + &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.downlinkDacStatus.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.camStatus.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.camSdiStatus.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.camFpgaTemp.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.sysmonTemp.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVccInt.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVccAux.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVccBram.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVccPaux.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVccPint.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVccPdro.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.sysmonMb12V.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.sysmonMb3V3.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.sysmonMb1V8.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc12V.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.sysmonVcc5V.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc3V3.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc3V3VA.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc2V5DDR.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc1V2DDR.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc0V9.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonVcc0V6VTT.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonSafeCotsCur.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.sysmonNvm4XoCur.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.semUncorrectableErrs.value, &dataStart, + &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + result = SerializeAdapter::deSerialize(&hkReport.semCorrectableErrs.value, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } + result = + SerializeAdapter::deSerialize(&hkReport.semStatus.value, &dataStart, &deserLen, endianness); + if (result != returnvalue::OK) { + return result; + } + // Skip the weird filename + dataStart += 256; + result = SerializeAdapter::deSerialize(&hkReport.rebootMpsocRequired, &dataStart, &deserLen, + endianness); + if (result != returnvalue::OK) { + return result; + } return returnvalue::OK; } @@ -830,7 +999,7 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator << mpsoc::TM_MEMORY_READ_REPORT << " not in replyMap" << std::endl; return result; } - break; + return returnvalue::OK; }; switch (command->first) { case mpsoc::TC_MEM_WRITE: @@ -849,15 +1018,24 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator enabledReplies = 2; break; case mpsoc::TC_GET_HK_REPORT: { - enableThreeReplies(mpsoc::TM_GET_HK_REPORT); + result = enableThreeReplies(mpsoc::TM_GET_HK_REPORT); + if (result != returnvalue::OK) { + return result; + } break; } case mpsoc::TC_MEM_READ: { - enableThreeReplies(mpsoc::TM_MEMORY_READ_REPORT); + result = enableThreeReplies(mpsoc::TM_MEMORY_READ_REPORT); + if (result != returnvalue::OK) { + return result; + } break; } case mpsoc::TC_CAM_CMD_SEND: { - enableThreeReplies(mpsoc::TM_CAM_CMD_RPT); + result = enableThreeReplies(mpsoc::TM_CAM_CMD_RPT); + if (result != returnvalue::OK) { + return result; + } break; } case mpsoc::OBSW_RESET_SEQ_COUNT: @@ -1065,7 +1243,7 @@ void PlocMPSoCHandler::disableAllReplies() { DeviceCommandId_t commandId = getPendingCommand(); - auto disableCommandWithReply = [](DeviceCommandId_t replyId) { + auto disableCommandWithReply = [&](DeviceCommandId_t replyId) { iter = deviceReplyMap.find(replyId); info = &(iter->second); info->delayCycles = 0; From 2e00e10e093d6c5ffbd6d5fcdf6cf53ab75c1ad2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 14:19:15 +0200 Subject: [PATCH 11/41] request HK regularly now --- linux/payload/PlocMpsocHandler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index e4c91a4a..2e708496 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -202,8 +202,10 @@ void PlocMPSoCHandler::doShutDown() { #endif } + ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - return NOTHING_TO_SEND; + *id = mpsoc::TC_GET_HK_REPORT; + return buildCommandFromCommand(*id, nullptr, 0); } ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { From d4fc95ed9f73de645d75d63c8294278a510eac62 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 14:29:02 +0200 Subject: [PATCH 12/41] start adding dir content report --- linux/payload/plocMpscoDefs.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 1ef72bf5..4df6037a 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -81,6 +81,8 @@ static const DeviceCommandId_t TC_DOWNLINK_DATA_MODULATE = 24; static const DeviceCommandId_t TC_MODE_SNAPSHOT = 25; static const DeviceCommandId_t TC_GET_HK_REPORT = 26; static const DeviceCommandId_t TM_GET_HK_REPORT = 27; +static const DeviceCommandId_t TC_FLASH_GET_DIRECTORY_CONTENT = 28; +static const DeviceCommandId_t TM_FLASH_DIRECTORY_CONTENT = 29; // Will reset the sequence count of the OBSW static const DeviceCommandId_t OBSW_RESET_SEQ_COUNT = 50; @@ -105,6 +107,7 @@ static const uint16_t TC_CAM_TAKE_PIC = 0x116; static const uint16_t TC_FLASHWRITE = 0x117; static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFCLOSE = 0x11A; +static constexpr uint16_t TC_FLASH_GET_DIRECTORY_CONTENT = 0x11B; static const uint16_t TC_FLASHDELETE = 0x11C; static const uint16_t TC_MODE_IDLE = 0x11E; static const uint16_t TC_MODE_REPLAY = 0x11F; @@ -120,6 +123,7 @@ static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_FAILURE = 0x401; static const uint16_t EXE_SUCCESS = 0x402; static const uint16_t EXE_FAILURE = 0x403; +static constexpr uint16_t TM_FLASH_DIRECTORY_CONTENT = 0x406; static const uint16_t TM_CAM_CMD_RPT = 0x407; } // namespace apid From 98a858876a58a0d7e04782a4aa6aa2c6d9e7c5fa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 14:31:47 +0200 Subject: [PATCH 13/41] add some more commands --- linux/payload/PlocMpsocHandler.cpp | 1 - linux/payload/plocMpscoDefs.h | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 2e708496..3c605d2d 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -202,7 +202,6 @@ void PlocMPSoCHandler::doShutDown() { #endif } - ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { *id = mpsoc::TC_GET_HK_REPORT; return buildCommandFromCommand(*id, nullptr, 0); diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 4df6037a..c2c5d570 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -109,15 +109,17 @@ static const uint16_t TC_FLASHFOPEN = 0x119; static const uint16_t TC_FLASHFCLOSE = 0x11A; static constexpr uint16_t TC_FLASH_GET_DIRECTORY_CONTENT = 0x11B; static const uint16_t TC_FLASHDELETE = 0x11C; +static constexpr uint16_t TC_FLASH_CREATE_DIR = 0x11D; static const uint16_t TC_MODE_IDLE = 0x11E; static const uint16_t TC_MODE_REPLAY = 0x11F; static const uint16_t TC_MODE_SNAPSHOT = 0x120; static const uint16_t TC_DOWNLINK_DATA_MODULATE = 0x121; static constexpr uint16_t TC_HK_GET_REPORT = 0x123; -static constexpr uint16_t TM_HK_GET_REPORT = 0x408; static const uint16_t TC_DOWNLINK_PWR_OFF = 0x124; static const uint16_t TC_CAM_CMD_SEND = 0x12C; +static constexpr uint16_t TC_FLASH_COPY_FILE = 0x12E; static const uint16_t TC_SIMPLEX_SEND_FILE = 0x130; +static constexpr uint16_t TM_HK_GET_REPORT = 0x408; static const uint16_t TM_MEMORY_READ_REPORT = 0x404; static const uint16_t ACK_SUCCESS = 0x400; static const uint16_t ACK_FAILURE = 0x401; From 0fb07fd3d527461b836a9584b0962005c5f5c96b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 15:24:47 +0200 Subject: [PATCH 14/41] implement dir content report in OBSW --- linux/payload/PlocMpsocHandler.cpp | 83 +++++++++++++++++++++++------- linux/payload/PlocMpsocHandler.h | 3 +- linux/payload/plocMpscoDefs.h | 17 ++++++ 3 files changed, 83 insertions(+), 20 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 3c605d2d..0caebea3 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -253,6 +253,10 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device result = prepareTcGetHkReport(); break; } + case (mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT): { + result = prepareTcGetDirContent(commandData, commandDataLen); + break; + } case (mpsoc::TC_MODE_REPLAY): { result = prepareTcModeReplay(); break; @@ -314,14 +318,16 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInCommandMap(mpsoc::RELEASE_UART_TX); this->insertInCommandMap(mpsoc::SET_UART_TX_TRISTATE); this->insertInCommandMap(mpsoc::TC_CAM_TAKE_PIC); + this->insertInCommandMap(mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT); this->insertInCommandMap(mpsoc::TC_SIMPLEX_SEND_FILE); this->insertInCommandMap(mpsoc::TC_DOWNLINK_DATA_MODULATE); this->insertInCommandMap(mpsoc::TC_MODE_SNAPSHOT); this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT); this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); - this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, nullptr, 0); + this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, nullptr, mpsoc::SIZE_TM_HK_REPORT); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); + this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, 0); } ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, @@ -339,6 +345,11 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain } uint16_t apid = spacePacket.getApid(); + auto handleDedicatedReply = [&](DeviceCommandId_t replyId) { + *foundLen = spacePacket.getFullPacketLen(); + foundPacketLen = *foundLen; + *foundId = replyId; + }; switch (apid) { case (mpsoc::apid::ACK_SUCCESS): *foundLen = mpsoc::SIZE_ACK_REPORT; @@ -353,14 +364,14 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain *foundId = mpsoc::TM_MEMORY_READ_REPORT; break; case (mpsoc::apid::TM_CAM_CMD_RPT): - *foundLen = spacePacket.getFullPacketLen(); - foundPacketLen = *foundLen; - *foundId = mpsoc::TM_CAM_CMD_RPT; + handleDedicatedReply(mpsoc::TM_CAM_CMD_RPT); break; case (mpsoc::apid::TM_HK_GET_REPORT): { - *foundLen = spacePacket.getFullPacketLen(); - foundPacketLen = *foundLen; - *foundId = mpsoc::TM_GET_HK_REPORT; + handleDedicatedReply(mpsoc::TM_GET_HK_REPORT); + break; + } + case (mpsoc::apid::TM_FLASH_DIRECTORY_CONTENT): { + handleDedicatedReply(mpsoc::TM_FLASH_DIRECTORY_CONTENT); break; } case (mpsoc::apid::EXE_SUCCESS): @@ -408,6 +419,18 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const result = handleCamCmdRpt(packet); break; } + case (mpsoc::TM_FLASH_DIRECTORY_CONTENT): { + result = verifyPacket(packet, foundPacketLen); + if (result == MPSoCReturnValuesIF::CRC_FAILURE) { + sif::warning << "PLOC MPSoC: Flash directory content reply invalid CRC" << std::endl; + } + /** Send data to commanding queue */ + handleDeviceTm(packet + mpsoc::DATA_FIELD_OFFSET, + foundPacketLen - mpsoc::DATA_FIELD_OFFSET - mpsoc::CRC_SIZE, + mpsoc::TM_FLASH_DIRECTORY_CONTENT); + nextReplyId = mpsoc::EXE_REPORT; + return result; + } case (mpsoc::EXE_REPORT): { result = handleExecutionReport(packet); break; @@ -421,7 +444,10 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { + PoolReadGuard pg(&hkReport); + hkReport.setValidity(false, true); +} uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } @@ -624,9 +650,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamCmdSend(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcCamTakePic tcCamTakePic(spParams, sequenceCount); - result = tcCamTakePic.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcCamTakePic.buildPacket(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } @@ -636,9 +661,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcCamTakePic(const uint8_t* commandData, ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcSimplexSendFile tcSimplexSendFile(spParams, sequenceCount); - result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcSimplexSendFile.buildPacket(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } @@ -646,11 +670,21 @@ ReturnValue_t PlocMPSoCHandler::prepareTcSimplexSendFile(const uint8_t* commandD return returnvalue::OK; } +ReturnValue_t PlocMPSoCHandler::prepareTcGetDirContent(const uint8_t* commandData, + size_t commandDataLen) { + mpsoc::TcGetDirContent tcGetDirContent(spParams, sequenceCount); + ReturnValue_t result = tcGetDirContent.buildPacket(commandData, commandDataLen); + if (result != returnvalue::OK) { + return result; + } + finishTcPrep(tcGetDirContent.getFullPacketLen()); + return returnvalue::OK; +} + ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* commandData, size_t commandDataLen) { - ReturnValue_t result = returnvalue::OK; mpsoc::TcDownlinkDataModulate tcDownlinkDataModulate(spParams, sequenceCount); - result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); + ReturnValue_t result = tcDownlinkDataModulate.buildPacket(commandData, commandDataLen); if (result != returnvalue::OK) { return result; } @@ -659,9 +693,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkDataModulate(const uint8_t* com } ReturnValue_t PlocMPSoCHandler::prepareTcModeSnapshot() { - ReturnValue_t result = returnvalue::OK; mpsoc::TcModeSnapshot tcModeSnapshot(spParams, sequenceCount); - result = tcModeSnapshot.buildPacket(); + ReturnValue_t result = tcModeSnapshot.buildPacket(); if (result != returnvalue::OK) { return result; } @@ -781,7 +814,7 @@ ReturnValue_t PlocMPSoCHandler::handleMemoryReadReport(const uint8_t* data) { uint16_t memLen = *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET) << 8 | *(data + mpsoc::MEM_READ_RPT_LEN_OFFSET + 1); /** Send data to commanding queue */ - handleDeviceTM(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4, + handleDeviceTm(data + mpsoc::DATA_FIELD_OFFSET, mpsoc::SIZE_MEM_READ_RPT_FIX + memLen * 4, mpsoc::TM_MEMORY_READ_REPORT); nextReplyId = mpsoc::EXE_REPORT; return result; @@ -980,7 +1013,7 @@ ReturnValue_t PlocMPSoCHandler::handleCamCmdRpt(const uint8_t* data) { sif::info << "PlocMPSoCHandler: CamCmdRpt Ack value: 0x" << std::hex << static_cast(ackValue) << std::endl; #endif /* OBSW_DEBUG_PLOC_MPSOC == 1 */ - handleDeviceTM(packetReader.getPacketData() + sizeof(uint16_t), + handleDeviceTm(packetReader.getPacketData() + sizeof(uint16_t), packetReader.getPacketDataLen() - 1, mpsoc::TM_CAM_CMD_RPT); return result; } @@ -1039,6 +1072,13 @@ ReturnValue_t PlocMPSoCHandler::enableReplyInReplyMap(DeviceCommandMap::iterator } break; } + case mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT: { + result = enableThreeReplies(mpsoc::TM_FLASH_DIRECTORY_CONTENT); + if (result != returnvalue::OK) { + return result; + } + break; + } case mpsoc::OBSW_RESET_SEQ_COUNT: break; default: @@ -1105,6 +1145,7 @@ void PlocMPSoCHandler::setNextReplyId() { break; } } + size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t replyLen = 0; @@ -1206,7 +1247,7 @@ void PlocMPSoCHandler::completionFailedReceived(ActionId_t actionId, ReturnValue handleActionCommandFailure(actionId); } -void PlocMPSoCHandler::handleDeviceTM(const uint8_t* data, size_t dataSize, +void PlocMPSoCHandler::handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId) { ReturnValue_t result = returnvalue::OK; @@ -1275,6 +1316,10 @@ void PlocMPSoCHandler::disableAllReplies() { disableCommandWithReply(TM_GET_HK_REPORT); break; } + case TC_FLASH_GET_DIRECTORY_CONTENT: { + disableCommandWithReply(TM_FLASH_DIRECTORY_CONTENT); + break; + } case TC_CAM_CMD_SEND: { disableCommandWithReply(TM_CAM_CMD_RPT); break; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index c9850e18..a6a866ef 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -201,6 +201,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { ReturnValue_t prepareTcDownlinkPwrOn(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcDownlinkPwrOff(); ReturnValue_t prepareTcGetHkReport(); + ReturnValue_t prepareTcGetDirContent(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcReplayWriteSequence(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcCamCmdSend(const uint8_t* commandData, size_t commandDataLen); ReturnValue_t prepareTcModeIdle(); @@ -266,7 +267,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { * @param dataSize Size of telemetry in bytes. * @param replyId Id of the reply. This will be added to the ActionMessage. */ - void handleDeviceTM(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); + void handleDeviceTm(const uint8_t* data, size_t dataSize, DeviceCommandId_t replyId); /** * @brief In case an acknowledgment failure reply has been received this function disables diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index c2c5d570..5d89360c 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -623,6 +623,23 @@ class TcGetHkReport : public TcBase { : TcBase(params, apid::TC_HK_GET_REPORT, sequenceCount) {} }; +class TcGetDirContent : public TcBase { + public: + TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount) + : TcBase(params, apid::TC_FLASH_GET_DIRECTORY_CONTENT, sequenceCount) {} + + ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { + ReturnValue_t result = returnvalue::OK; + spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE); + if (result != returnvalue::OK) { + return result; + } + std::memcpy(payloadStart, commandData, commandDataLen); + *(payloadStart + commandDataLen) = NULL_TERMINATOR; + return result; + } +}; + /** * @brief Class to build replay stop space packet. */ From bacc46a8dce77c6d934022d5391d43984e3d5a55 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 15:30:30 +0200 Subject: [PATCH 15/41] i think that should do the job --- linux/payload/PlocMpsocHandler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 0caebea3..ec2877a6 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1170,6 +1170,10 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { // report is not fixed replyLen = mpsoc::SP_MAX_SIZE; break; + case mpsoc::TM_FLASH_DIRECTORY_CONTENT: + // I think the reply size is not fixed either. + replyLen = mpsoc::SP_MAX_SIZE; + break; default: { replyLen = iter->second.replyLen; break; From dbdcf0b0d683f97b84ca193ddb03c07fecd97372 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 15:31:54 +0200 Subject: [PATCH 16/41] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b0ecbe9..644d7684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ will consitute of a breaking change warranting a new major release: on the same system. - Add ACS board for EM by default now. - Add support for MPSoC HK packet. +- Add support for MPSoC Flash Directory Content Report. ## Added From 92fd1548cbc1ab025ef266ea516cc3b92dfa3829 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 May 2023 16:42:24 +0200 Subject: [PATCH 17/41] dynamically enable/disable MPSoC --- linux/payload/PlocMpsocHandler.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index ec2877a6..96f6c50d 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -160,6 +160,7 @@ void PlocMPSoCHandler::doStartUp() { powerState = PowerState::BOOTING; break; case PowerState::ON: + hkReport.setReportingEnabled(true); setMode(_MODE_TO_ON); uartIsolatorSwitch.pullHigh(); break; @@ -168,11 +169,13 @@ void PlocMPSoCHandler::doStartUp() { } #else powerState = PowerState::ON; + hkReport.setReportingEnabled(true); setMode(_MODE_TO_ON); uartIsolatorSwitch.pullHigh(); #endif /* not MSPOC_JTAG_BOOT == 1 */ #else powerState = PowerState::ON; + hkReport.setReportingEnabled(true); setMode(_MODE_TO_ON); #endif /* XIPHOS_Q7S */ } @@ -188,6 +191,7 @@ void PlocMPSoCHandler::doShutDown() { break; case PowerState::OFF: sequenceCount = 0; + hkReport.setReportingEnabled(false); setMode(_MODE_POWER_DOWN); break; default: @@ -196,6 +200,7 @@ void PlocMPSoCHandler::doShutDown() { #else sequenceCount = 0; uartIsolatorSwitch.pullLow(); + hkReport.setReportingEnabled(false); setMode(_MODE_POWER_DOWN); powerState = PowerState::OFF; #endif From 50d5180076b7076a4664c43b0edfc556bd415467 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 11 May 2023 21:29:15 +0200 Subject: [PATCH 18/41] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 644d7684..0f2f6ed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ will consitute of a breaking change warranting a new major release: - Add ACS board for EM by default now. - Add support for MPSoC HK packet. - Add support for MPSoC Flash Directory Content Report. +- Dynamically enable and disable HK packets for MPSoC on `ON` and `OFF` commands. ## Added From cbf3315e16737a6e8d388146b4c7acfd6426fe33 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 09:32:24 +0200 Subject: [PATCH 19/41] Various fixes and improvements --- bsp_q7s/core/ObjectFactory.cpp | 1 + linux/payload/PlocSupervisorHandler.cpp | 8 ++++++-- linux/payload/PlocSupervisorHandler.h | 9 ++++++++- tmtc | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 12e9177f..8fcace4e 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -644,6 +644,7 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit auto* supvHandler = new PlocSupervisorHandler(objects::PLOC_SUPERVISOR_HANDLER, supervisorCookie, Gpio(gpioIds::ENABLE_SUPV_UART, gpioComIF), power::PDU1_CH6_PLOC_12V, *supvHelper); + supvHandler->setPowerSwitcher(&pwrSwitch); supvHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ static_cast(consumer); diff --git a/linux/payload/PlocSupervisorHandler.cpp b/linux/payload/PlocSupervisorHandler.cpp index 06a4cf07..682b8020 100644 --- a/linux/payload/PlocSupervisorHandler.cpp +++ b/linux/payload/PlocSupervisorHandler.cpp @@ -151,7 +151,7 @@ void PlocSupervisorHandler::doStartUp() { } } } - if (startupState == StartupState::SET_TIME_EXECUTING) { + if (startupState == StartupState::TIME_WAS_SET) { startupState = StartupState::ON; } if (startupState == StartupState::ON) { @@ -176,7 +176,7 @@ ReturnValue_t PlocSupervisorHandler::buildNormalDeviceCommand(DeviceCommandId_t* ReturnValue_t PlocSupervisorHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { if (startupState == StartupState::SET_TIME) { *id = supv::SET_TIME_REF; - startupState = StartupState::SET_TIME_EXECUTING; + startupState = StartupState::WAIT_FOR_TIME_REPLY; return buildCommandFromCommand(*id, nullptr, 0); } return NOTHING_TO_SEND; @@ -1909,6 +1909,10 @@ ReturnValue_t PlocSupervisorHandler::handleExecutionSuccessReport(ExecutionRepor case supv::SET_TIME_REF: { // We could only allow proper bootup when the time was set successfully, but // this makes debugging difficult. + + if (startupState == StartupState::WAIT_FOR_TIME_REPLY) { + startupState = StartupState::TIME_WAS_SET; + } break; } default: diff --git a/linux/payload/PlocSupervisorHandler.h b/linux/payload/PlocSupervisorHandler.h index 78c20205..3e5ac2a0 100644 --- a/linux/payload/PlocSupervisorHandler.h +++ b/linux/payload/PlocSupervisorHandler.h @@ -99,7 +99,14 @@ class PlocSupervisorHandler : public DeviceHandlerBase { static const uint32_t MRAM_DUMP_TIMEOUT = 60000; // 4 s static const uint32_t BOOT_TIMEOUT = 4000; - enum class StartupState : uint8_t { OFF, BOOTING, SET_TIME, SET_TIME_EXECUTING, ON }; + enum class StartupState : uint8_t { + OFF, + BOOTING, + SET_TIME, + WAIT_FOR_TIME_REPLY, + TIME_WAS_SET, + ON + }; static constexpr bool SET_TIME_DURING_BOOT = true; diff --git a/tmtc b/tmtc index 5fbd19bb..f090c3af 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5fbd19bb6cca0790373a809d78f2307adca9d0c8 +Subproject commit f090c3af66d1a0b760344e80053d6e83895e661a From 0156533385abaa85e743d193677b949f8009184a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 09:35:58 +0200 Subject: [PATCH 20/41] changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc320982..fea60176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,10 @@ will consitute of a breaking change warranting a new major release: 16505 type. - Host build is working again. Added reduced live TM helper which schedules the PUS and CFDP funnel. +- PLOC Supervisor handler now has a power switcher assigned to make PLOC power switching work + without an additional PCDU power switch command. +- The PLOC Supervisor handler now waits for the replies to the `SET_TIME` command to verify working + communication. # [v2.0.5] 2023-05-11 From 29eb0e736f7d22fa8d2931f07eb25eb9b0f314e4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 09:40:31 +0200 Subject: [PATCH 21/41] never add CAM switcher dummy --- bsp_q7s/em/emObjectFactory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/em/emObjectFactory.cpp b/bsp_q7s/em/emObjectFactory.cpp index 0311a468..36863b89 100644 --- a/bsp_q7s/em/emObjectFactory.cpp +++ b/bsp_q7s/em/emObjectFactory.cpp @@ -52,12 +52,12 @@ void ObjectFactory::produce(void* args) { // level components. dummy::DummyCfg dummyCfg; dummyCfg.addCoreCtrlCfg = false; + dummyCfg.addCamSwitcherDummy = false; #if OBSW_ADD_SYRLINKS == 1 dummyCfg.addSyrlinksDummies = false; #endif #if OBSW_ADD_PLOC_SUPERVISOR == 1 || OBSW_ADD_PLOC_MPSOC == 1 dummyCfg.addPlocDummies = false; - dummyCfg.addCamSwitcherDummy = false; #endif #if OBSW_ADD_GOMSPACE_PCDU == 1 dummyCfg.addPowerDummies = false; From 1820dae3d465929d6096cc0bcf52c7c377783b47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 11:06:26 +0200 Subject: [PATCH 22/41] horrible --- linux/payload/PlocMpsocHandler.cpp | 30 +++++++++++++++++++++++------- linux/payload/plocMpscoDefs.h | 3 --- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index cd405fa6..61b82f7f 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -209,8 +209,11 @@ void PlocMPSoCHandler::doShutDown() { ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - *id = mpsoc::TC_GET_HK_REPORT; - return buildCommandFromCommand(*id, nullptr, 0); + if(getPendingCommand() == DeviceHandlerIF::NO_COMMAND_ID) { + *id = mpsoc::TC_GET_HK_REPORT; + return buildCommandFromCommand(*id, nullptr, 0); + } + return NOTHING_TO_SEND; } ReturnValue_t PlocMPSoCHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { @@ -256,6 +259,7 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device break; } case (mpsoc::TC_GET_HK_REPORT): { + sif::debug << "getting HK report" << std::endl; result = prepareTcGetHkReport(); break; } @@ -326,13 +330,14 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInReplyMap(mpsoc::ACK_REPORT, 3, nullptr, mpsoc::SIZE_ACK_REPORT); this->insertInReplyMap(mpsoc::EXE_REPORT, 3, nullptr, mpsoc::SIZE_EXE_REPORT); this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); - this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 2, nullptr, 0); + this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 5, nullptr, mpsoc::SIZE_TM_HK_REPORT); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); } ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = returnvalue::OK; + sif::debug << "remaining size: " << remainingSize << std::endl; SpacePacketReader spacePacket; spacePacket.setReadOnlyData(start, remainingSize); @@ -347,6 +352,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain switch (apid) { case (mpsoc::apid::ACK_SUCCESS): + sif::debug << "recv ack success" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -364,12 +370,14 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain *foundId = mpsoc::TM_CAM_CMD_RPT; break; case (mpsoc::apid::TM_HK_GET_REPORT): { + sif::debug << "recv hk report" << std::endl; *foundLen = spacePacket.getFullPacketLen(); foundPacketLen = *foundLen; *foundId = mpsoc::TM_GET_HK_REPORT; break; } case (mpsoc::apid::EXE_SUCCESS): + sif::debug << "recv exe success" << std::endl; *foundLen = mpsoc::SIZE_EXE_REPORT; *foundId = mpsoc::EXE_REPORT; break; @@ -427,7 +435,9 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() {} +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { + hkReport.setValidity(false, true); +} uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } @@ -572,12 +582,12 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { ReturnValue_t result = returnvalue::OK; - mpsoc::TcGetHkReport tcDownlinkPwrOff(spParams, sequenceCount); - result = tcDownlinkPwrOff.buildPacket(); + mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount); + result = tcGetHkReport.buildPacket(); if (result != returnvalue::OK) { return result; } - finishTcPrep(tcDownlinkPwrOff.getFullPacketLen()); + finishTcPrep(tcGetHkReport.getFullPacketLen()); return returnvalue::OK; } @@ -1105,12 +1115,17 @@ void PlocMPSoCHandler::setNextReplyId() { case mpsoc::TC_MEM_READ: nextReplyId = mpsoc::TM_MEMORY_READ_REPORT; break; + case mpsoc::TC_GET_HK_REPORT: { + nextReplyId = mpsoc::TM_GET_HK_REPORT; + break; + } default: /* If no telemetry is expected the next reply is always the execution report */ nextReplyId = mpsoc::EXE_REPORT; break; } } + size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { size_t replyLen = 0; @@ -1136,6 +1151,7 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { replyLen = mpsoc::SP_MAX_SIZE; break; default: { + sif::debug << "reply length " << iter->second.replyLen << std::endl; replyLen = iter->second.replyLen; break; } diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 1ef72bf5..20d70d66 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -608,9 +608,6 @@ class TcDownlinkPwrOn : public TcBase { } }; -/** - * @brief Class to build replay stop space packet. - */ class TcGetHkReport : public TcBase { public: TcGetHkReport(ploc::SpTcParams params, uint16_t sequenceCount) From 42152ab711ce575ac51dac7e1eb55c3163d238f3 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 12 May 2023 11:07:14 +0200 Subject: [PATCH 23/41] fixed gps altitude fdir --- mission/controller/acs/SensorProcessing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/acs/SensorProcessing.cpp b/mission/controller/acs/SensorProcessing.cpp index 4cc15a16..b106baaa 100644 --- a/mission/controller/acs/SensorProcessing.cpp +++ b/mission/controller/acs/SensorProcessing.cpp @@ -573,7 +573,7 @@ void SensorProcessing::processGps(const double gpsLatitude, const double gpsLong // Altitude FDIR if (gpsAltitude > gpsParameters->maximumFdirAltitude || - gpsAltitude < gpsParameters->maximumFdirAltitude) { + gpsAltitude < gpsParameters->minimumFdirAltitude) { altitude = gpsParameters->fdirAltitude; } else { altitude = gpsAltitude; From f71a363385b6b63e615c762bc9494d8f1ebac924 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 12 May 2023 11:08:41 +0200 Subject: [PATCH 24/41] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fea60176..c33e49f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ will consitute of a breaking change warranting a new major release: without an additional PCDU power switch command. - The PLOC Supervisor handler now waits for the replies to the `SET_TIME` command to verify working communication. +- Fixed correction for `GPS Altitude` in case the sensor data is out of the expected bonds. # [v2.0.5] 2023-05-11 From ba060be0d68df262f78120a32defbac6cd605977 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 11:44:39 +0200 Subject: [PATCH 25/41] some more minor improvements --- linux/payload/PlocMpsocHandler.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 61b82f7f..1e904cd0 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -259,7 +259,6 @@ ReturnValue_t PlocMPSoCHandler::buildCommandFromCommand(DeviceCommandId_t device break; } case (mpsoc::TC_GET_HK_REPORT): { - sif::debug << "getting HK report" << std::endl; result = prepareTcGetHkReport(); break; } @@ -581,9 +580,8 @@ ReturnValue_t PlocMPSoCHandler::prepareTcDownlinkPwrOff() { } ReturnValue_t PlocMPSoCHandler::prepareTcGetHkReport() { - ReturnValue_t result = returnvalue::OK; mpsoc::TcGetHkReport tcGetHkReport(spParams, sequenceCount); - result = tcGetHkReport.buildPacket(); + ReturnValue_t result = tcGetHkReport.buildPacket(); if (result != returnvalue::OK) { return result; } From 66c9a5eea3ff86c7a89fbd0316c077c55467f175 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 11:55:33 +0200 Subject: [PATCH 26/41] some more fixes --- linux/payload/plocMpscoDefs.h | 12 +----------- tmtc | 2 +- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 80ebefb1..c42e61df 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -621,15 +621,6 @@ class TcGetHkReport : public TcBase { : TcBase(params, apid::TC_HK_GET_REPORT, sequenceCount) {} }; -/** - * @brief Class to build replay stop space packet. - */ -class TcGetHkReport : public TcBase { - public: - TcGetHkReport(ploc::SpTcParams params, uint16_t sequenceCount) - : TcBase(params, apid::TC_HK_GET_REPORT, sequenceCount) {} -}; - class TcGetDirContent : public TcBase { public: TcGetDirContent(ploc::SpTcParams params, uint16_t sequenceCount) @@ -637,12 +628,11 @@ class TcGetDirContent : public TcBase { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; - spParams.setFullPayloadLen(commandDataLen + sizeof(NULL_TERMINATOR) + CRC_SIZE); + spParams.setFullPayloadLen(commandDataLen + CRC_SIZE); if (result != returnvalue::OK) { return result; } std::memcpy(payloadStart, commandData, commandDataLen); - *(payloadStart + commandDataLen) = NULL_TERMINATOR; return result; } }; diff --git a/tmtc b/tmtc index f090c3af..87e5abe8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f090c3af66d1a0b760344e80053d6e83895e661a +Subproject commit 87e5abe8ebb6a33d36445d43bcb6674b313626f1 From 699fc9a861243cd428d29b4b9c9e47da8f5b2358 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 12:14:37 +0200 Subject: [PATCH 27/41] some HK corrections --- linux/payload/PlocMpsocHandler.cpp | 2 ++ linux/payload/PlocMpsocHandler.h | 2 +- tmtc | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 1e904cd0..9c2aee4a 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -445,6 +445,7 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc localDataPoolMap.emplace(mpsoc::poolid::STATUS, &peStatus); localDataPoolMap.emplace(mpsoc::poolid::MODE, &peMode); localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_PWR_ON, &peDownlinkPwrOn); + localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_REPLY_ACTIIVE, &peDownlinkReplyActive); localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_JESD_SYNC_STATUS, &peDownlinkJesdSyncStatus); localDataPoolMap.emplace(mpsoc::poolid::DOWNLINK_DAC_STATUS, &peDownlinkDacStatus); localDataPoolMap.emplace(mpsoc::poolid::CAM_STATUS, &peCameraStatus); @@ -462,6 +463,7 @@ ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& loc localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB3V3, &peSysmonMb3V3); localDataPoolMap.emplace(mpsoc::poolid::SYSMON_MB1V8, &peSysmonMb1V8); localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC12V, &peSysmonVcc12V); + localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC5V, &peSysmonVcc5V); localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC3V3, &peSysmonVcc3V3); localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC3V3VA, &peSysmonVcc3V3VA); localDataPoolMap.emplace(mpsoc::poolid::SYSMON_VCC2V5DDR, &peSysmonVcc2V5DDR); diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index c9850e18..d814f086 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -117,7 +117,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { SpacePacketCreator creator; ploc::SpTcParams spParams = ploc::SpTcParams(creator); - PoolEntry peStatus = PoolEntry(); + PoolEntry peStatus = PoolEntry(); PoolEntry peMode = PoolEntry(); PoolEntry peDownlinkPwrOn = PoolEntry(); PoolEntry peDownlinkReplyActive = PoolEntry(); diff --git a/tmtc b/tmtc index f090c3af..87e5abe8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f090c3af66d1a0b760344e80053d6e83895e661a +Subproject commit 87e5abe8ebb6a33d36445d43bcb6674b313626f1 From 2b999e7fa7feaae8c1d7fc26254a421da47abfcf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 12:37:25 +0200 Subject: [PATCH 28/41] requires some wait cycles --- linux/payload/PlocMpsocHandler.cpp | 68 +++++++++++++++++------------- linux/payload/PlocMpsocHandler.h | 2 + linux/payload/plocMpscoDefs.h | 3 +- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 9c2aee4a..227180b4 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -152,32 +152,45 @@ ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueI } void PlocMPSoCHandler::doStartUp() { + if (startupState == StartupState::IDLE) { + startupState = StartupState::HW_INIT; + } + if (startupState == StartupState::HW_INIT) { #ifdef XIPHOS_Q7S #if not OBSW_MPSOC_JTAG_BOOT == 1 - switch (powerState) { - case PowerState::OFF: - commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC); - powerState = PowerState::BOOTING; - break; - case PowerState::ON: - hkReport.setReportingEnabled(true); - setMode(_MODE_TO_ON); - uartIsolatorSwitch.pullHigh(); - break; - default: - break; - } + switch (powerState) { + case PowerState::OFF: + commandActionHelper.commandAction(supervisorHandler, supv::START_MPSOC); + powerState = PowerState::BOOTING; + return; + case PowerState::ON: + uartIsolatorSwitch.pullHigh(); + startupState = StartupState::WAIT_CYCLES; + break; + default: + return; + } #else - powerState = PowerState::ON; - hkReport.setReportingEnabled(true); - setMode(_MODE_TO_ON); - uartIsolatorSwitch.pullHigh(); + uartIsolatorSwitch.pullHigh(); + startupState = StartupState::WAIT_CYCLE; #endif /* not MSPOC_JTAG_BOOT == 1 */ #else - powerState = PowerState::ON; - hkReport.setReportingEnabled(true); - setMode(_MODE_TO_ON); + startupState = StartupState::WAIT_CYCLES; + powerState = PowerState::ON; #endif /* XIPHOS_Q7S */ + } + if (startupState == StartupState::WAIT_CYCLES) { + waitCycles++; + if (waitCycles == 2) { + startupState = StartupState::DONE; + waitCycles = 0; + } + } + if (startupState == StartupState::DONE) { + setMode(_MODE_TO_ON); + hkReport.setReportingEnabled(true); + startupState = StartupState::IDLE; + } } void PlocMPSoCHandler::doShutDown() { @@ -205,11 +218,12 @@ void PlocMPSoCHandler::doShutDown() { powerState = PowerState::OFF; #endif #endif + startupState = StartupState::IDLE; } - ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - if(getPendingCommand() == DeviceHandlerIF::NO_COMMAND_ID) { + // testCycles ++; + if (getPendingCommand() == DeviceHandlerIF::NO_COMMAND_ID) { *id = mpsoc::TC_GET_HK_REPORT; return buildCommandFromCommand(*id, nullptr, 0); } @@ -336,7 +350,6 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = returnvalue::OK; - sif::debug << "remaining size: " << remainingSize << std::endl; SpacePacketReader spacePacket; spacePacket.setReadOnlyData(start, remainingSize); @@ -351,7 +364,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain switch (apid) { case (mpsoc::apid::ACK_SUCCESS): - sif::debug << "recv ack success" << std::endl; + sif::debug << "recv ack success" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -369,14 +382,12 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain *foundId = mpsoc::TM_CAM_CMD_RPT; break; case (mpsoc::apid::TM_HK_GET_REPORT): { - sif::debug << "recv hk report" << std::endl; *foundLen = spacePacket.getFullPacketLen(); foundPacketLen = *foundLen; *foundId = mpsoc::TM_GET_HK_REPORT; break; } case (mpsoc::apid::EXE_SUCCESS): - sif::debug << "recv exe success" << std::endl; *foundLen = mpsoc::SIZE_EXE_REPORT; *foundId = mpsoc::EXE_REPORT; break; @@ -434,9 +445,7 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const return result; } -void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { - hkReport.setValidity(false, true); -} +void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { hkReport.setValidity(false, true); } uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } @@ -1151,7 +1160,6 @@ size_t PlocMPSoCHandler::getNextReplyLength(DeviceCommandId_t commandId) { replyLen = mpsoc::SP_MAX_SIZE; break; default: { - sif::debug << "reply length " << iter->second.replyLen << std::endl; replyLen = iter->second.replyLen; break; } diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index d814f086..2b6548ca 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -183,7 +183,9 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { size_t foundPacketLen = 0; TelemetryBuffer tmBuffer; + uint32_t waitCycles = 0; + enum class StartupState { IDLE, HW_INIT, WAIT_CYCLES, DONE } startupState; enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; PowerState powerState = PowerState::OFF; diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index 20d70d66..cd17d911 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -882,8 +882,7 @@ class HkReport : public StaticLocalDataSet<36> { lp_var_t(sid.objectId, mpsoc::poolid::SEM_UNCORRECTABLE_ERRS, this); lp_var_t semCorrectableErrs = lp_var_t(sid.objectId, mpsoc::poolid::SEM_CORRECTABLE_ERRS, this); - lp_var_t semStatus = - lp_var_t(sid.objectId, mpsoc::poolid::SEM_CORRECTABLE_ERRS, this); + lp_var_t semStatus = lp_var_t(sid.objectId, mpsoc::poolid::SEM_STATUS, this); lp_var_t rebootMpsocRequired = lp_var_t(sid.objectId, mpsoc::poolid::REBOOT_MPSOC_REQUIRED, this); }; From 9391949369ea5494e128ee317680b627cdfff832 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 12:39:54 +0200 Subject: [PATCH 29/41] speed up payload components a bit --- bsp_q7s/core/scheduling.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsp_q7s/core/scheduling.cpp b/bsp_q7s/core/scheduling.cpp index f2cd8229..5866ce8c 100644 --- a/bsp_q7s/core/scheduling.cpp +++ b/bsp_q7s/core/scheduling.cpp @@ -366,7 +366,7 @@ void scheduling::initTasks() { #endif /* OBSW_ADD_PLOC_SUPERVISOR */ PeriodicTaskIF* plTask = factory->createPeriodicTask( - "PL_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.8, missedDeadlineFunc, &RR_SCHEDULING); + "PL_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.5, missedDeadlineFunc, &RR_SCHEDULING); plTask->addComponent(objects::CAM_SWITCHER); scheduling::addMpsocSupvHandlers(plTask); scheduling::scheduleScexDev(plTask); From 90d289f56eaa5cb3bdc412d532942d27e4122a62 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 13:23:17 +0200 Subject: [PATCH 30/41] works now --- linux/payload/PlocMpsocHandler.cpp | 19 +++++++++++++------ linux/payload/PlocMpsocHandler.h | 3 ++- tmtc | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 227180b4..ef92c796 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -172,16 +172,18 @@ void PlocMPSoCHandler::doStartUp() { } #else uartIsolatorSwitch.pullHigh(); - startupState = StartupState::WAIT_CYCLE; + startupState = StartupState::WAIT_CYCLES; #endif /* not MSPOC_JTAG_BOOT == 1 */ #else startupState = StartupState::WAIT_CYCLES; powerState = PowerState::ON; #endif /* XIPHOS_Q7S */ } + // Need to wait, MPSoC still not booted properly, requesting HK without these wait cycles does + // not work, no replies.. if (startupState == StartupState::WAIT_CYCLES) { waitCycles++; - if (waitCycles == 2) { + if (waitCycles >= 10) { startupState = StartupState::DONE; waitCycles = 0; } @@ -222,9 +224,9 @@ void PlocMPSoCHandler::doShutDown() { } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - // testCycles ++; - if (getPendingCommand() == DeviceHandlerIF::NO_COMMAND_ID) { + if (not normalCmdPending) { *id = mpsoc::TC_GET_HK_REPORT; + normalCmdPending = true; return buildCommandFromCommand(*id, nullptr, 0); } return NOTHING_TO_SEND; @@ -364,7 +366,6 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain switch (apid) { case (mpsoc::apid::ACK_SUCCESS): - sif::debug << "recv ack success" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -447,7 +448,7 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const void PlocMPSoCHandler::setNormalDatapoolEntriesInvalid() { hkReport.setValidity(false, true); } -uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 5000; } +uint32_t PlocMPSoCHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return 10000; } ReturnValue_t PlocMPSoCHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { @@ -767,9 +768,15 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { switch (apid) { case (mpsoc::apid::EXE_SUCCESS): { + if (normalCmdPending) { + normalCmdPending = false; + } break; } case (mpsoc::apid::EXE_FAILURE): { + if (normalCmdPending) { + normalCmdPending = false; + } // TODO: Interpretation of status field in execution report sif::warning << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" << std::endl; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index 2b6548ca..d201aeaf 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -108,6 +108,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { mpsoc::HkReport hkReport; + bool normalCmdPending = false; MessageQueueIF* eventQueue = nullptr; MessageQueueIF* commandActionHelperQueue = nullptr; @@ -185,7 +186,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { TelemetryBuffer tmBuffer; uint32_t waitCycles = 0; - enum class StartupState { IDLE, HW_INIT, WAIT_CYCLES, DONE } startupState; + enum class StartupState { IDLE, HW_INIT, WAIT_CYCLES, DONE } startupState = StartupState::IDLE; enum class PowerState { OFF, BOOTING, SHUTDOWN, ON }; PowerState powerState = PowerState::OFF; diff --git a/tmtc b/tmtc index 87e5abe8..377e98b5 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 87e5abe8ebb6a33d36445d43bcb6674b313626f1 +Subproject commit 377e98b5c2da12f10cdd12b027548a8075fdcb58 From 9715612e4608c0d49aeb2e81748c15d1cc91c15e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 13:24:14 +0200 Subject: [PATCH 31/41] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f435358..a5944e7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ will consitute of a breaking change warranting a new major release: without an additional PCDU power switch command. - The PLOC Supervisor handler now waits for the replies to the `SET_TIME` command to verify working communication. +- The PLOC MPSoC now waits 10 cycles before going to on. These wait cycles are necessary because + the MPSoC is not ready to process commands without this additional boot time. # [v2.0.5] 2023-05-11 From a3b119fda67b0bd3e29f95330933f470d3c87719 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 13:26:15 +0200 Subject: [PATCH 32/41] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3580df9b..189be00e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ will consitute of a breaking change warranting a new major release: - Add ACS board for EM by default now. - Add support for MPSoC HK packet. - Dynamically enable and disable HK packets for MPSoC on `ON` and `OFF` commands. +- Increase frequency of payload handlers from 0.8 seconds to 0.5 seconds. ## Added From 1f9c9e2407afb26ef3f50725039903e1dc8aac75 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 15:52:47 +0200 Subject: [PATCH 33/41] horrible --- linux/payload/PlocMpsocHandler.cpp | 27 ++++++++++++++++++--------- linux/payload/plocMpscoDefs.h | 4 +++- tmtc | 2 +- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 481c6b09..325e8ed7 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -224,11 +225,11 @@ void PlocMPSoCHandler::doShutDown() { } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - if (not normalCmdPending) { - *id = mpsoc::TC_GET_HK_REPORT; - normalCmdPending = true; - return buildCommandFromCommand(*id, nullptr, 0); - } + // if (not normalCmdPending) { + // *id = mpsoc::TC_GET_HK_REPORT; + // normalCmdPending = true; + // return buildCommandFromCommand(*id, nullptr, 0); + // } return NOTHING_TO_SEND; } @@ -352,13 +353,14 @@ void PlocMPSoCHandler::fillCommandAndReplyMap() { this->insertInReplyMap(mpsoc::TM_MEMORY_READ_REPORT, 2, nullptr, mpsoc::SIZE_TM_MEM_READ_REPORT); this->insertInReplyMap(mpsoc::TM_GET_HK_REPORT, 5, nullptr, mpsoc::SIZE_TM_HK_REPORT); this->insertInReplyMap(mpsoc::TM_CAM_CMD_RPT, 2, nullptr, mpsoc::SP_MAX_SIZE); - this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, 0); + this->insertInReplyMap(mpsoc::TM_FLASH_DIRECTORY_CONTENT, 2, nullptr, mpsoc::SP_MAX_SIZE); } ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remainingSize, DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = returnvalue::OK; + sif::debug << "remainingSize: " << remainingSize << std::endl; SpacePacketReader spacePacket; spacePacket.setReadOnlyData(start, remainingSize); if (spacePacket.isNull()) { @@ -377,6 +379,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain }; switch (apid) { case (mpsoc::apid::ACK_SUCCESS): + sif::debug << "got ack" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -408,7 +411,8 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain *foundId = mpsoc::EXE_REPORT; break; default: { - sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid apid" << std::endl; + sif::debug << "PlocMPSoCHandler::scanForReply: Reply has invalid APID 0x" << std::hex + << std::setfill('0') << std::setw(2) << apid << std::dec << std::endl; *foundLen = remainingSize; return MPSoCReturnValuesIF::INVALID_APID; } @@ -445,6 +449,7 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const break; } case (mpsoc::TM_FLASH_DIRECTORY_CONTENT): { + sif::debug << "received flash dir content packet" << std::endl; result = verifyPacket(packet, foundPacketLen); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PLOC MPSoC: Flash directory content reply invalid CRC" << std::endl; @@ -1171,6 +1176,10 @@ void PlocMPSoCHandler::setNextReplyId() { case mpsoc::TC_MEM_READ: nextReplyId = mpsoc::TM_MEMORY_READ_REPORT; break; + case mpsoc::TC_FLASH_GET_DIRECTORY_CONTENT: { + nextReplyId = mpsoc::TM_FLASH_DIRECTORY_CONTENT; + break; + } case mpsoc::TC_GET_HK_REPORT: { nextReplyId = mpsoc::TM_GET_HK_REPORT; break; @@ -1403,12 +1412,12 @@ void PlocMPSoCHandler::disableExeReportReply() { } void PlocMPSoCHandler::printStatus(const uint8_t* data) { - uint16_t status = *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1); + uint16_t status = (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); sif::info << "Verification report status: " << getStatusString(status) << std::endl; } uint16_t PlocMPSoCHandler::getStatus(const uint8_t* data) { - return *(data + STATUS_OFFSET) << 8 | *(data + STATUS_OFFSET + 1); + return (*(data + STATUS_OFFSET) << 8) | *(data + STATUS_OFFSET + 1); } void PlocMPSoCHandler::handleActionCommandFailure(ActionId_t actionId) { diff --git a/linux/payload/plocMpscoDefs.h b/linux/payload/plocMpscoDefs.h index de123719..c5d53e6f 100644 --- a/linux/payload/plocMpscoDefs.h +++ b/linux/payload/plocMpscoDefs.h @@ -628,11 +628,13 @@ class TcGetDirContent : public TcBase { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; - spParams.setFullPayloadLen(commandDataLen + CRC_SIZE); + // Yeah it needs to be 256.. even if the path is shorter. + spParams.setFullPayloadLen(256 + CRC_SIZE); if (result != returnvalue::OK) { return result; } std::memcpy(payloadStart, commandData, commandDataLen); + payloadStart[255] = '\0'; return result; } }; diff --git a/tmtc b/tmtc index 377e98b5..ef0adef0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 377e98b5c2da12f10cdd12b027548a8075fdcb58 +Subproject commit ef0adef04aebf8aa0d673e14403b484bd1200d9c From 9887359e31592480b9e080e0606d47f045eb5be4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 16:09:08 +0200 Subject: [PATCH 34/41] finally receiving the content report --- linux/payload/PlocMpsocHandler.cpp | 2 -- tmtc | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 325e8ed7..23f27060 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -379,7 +379,6 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain }; switch (apid) { case (mpsoc::apid::ACK_SUCCESS): - sif::debug << "got ack" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -449,7 +448,6 @@ ReturnValue_t PlocMPSoCHandler::interpretDeviceReply(DeviceCommandId_t id, const break; } case (mpsoc::TM_FLASH_DIRECTORY_CONTENT): { - sif::debug << "received flash dir content packet" << std::endl; result = verifyPacket(packet, foundPacketLen); if (result == MPSoCReturnValuesIF::CRC_FAILURE) { sif::warning << "PLOC MPSoC: Flash directory content reply invalid CRC" << std::endl; diff --git a/tmtc b/tmtc index ef0adef0..e05a54b0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ef0adef04aebf8aa0d673e14403b484bd1200d9c +Subproject commit e05a54b076a9b34059bfa5baf783a7f134a91f09 From edda42cb6165f5e5fd2980de5de412058cffb03e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 16:25:59 +0200 Subject: [PATCH 35/41] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index e05a54b0..04bbe057 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit e05a54b076a9b34059bfa5baf783a7f134a91f09 +Subproject commit 04bbe057e7a0ca24b7d0a2d3c620d422ca15f59a From ac73e6d2c3a1e1198c9f2832ac19f688a2f615c7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 16:27:25 +0200 Subject: [PATCH 36/41] bump tmtc again --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 04bbe057..0c1bfc6f 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 04bbe057e7a0ca24b7d0a2d3c620d422ca15f59a +Subproject commit 0c1bfc6fd32e66fe0da13bebc4eeb3030ead13a9 From 3dc096c42b76bf5f47c7b592080972b8fe270d80 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 16:29:15 +0200 Subject: [PATCH 37/41] add back normal command --- linux/payload/PlocMpsocHandler.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 23f27060..8a00e307 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -225,11 +225,11 @@ void PlocMPSoCHandler::doShutDown() { } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - // if (not normalCmdPending) { - // *id = mpsoc::TC_GET_HK_REPORT; - // normalCmdPending = true; - // return buildCommandFromCommand(*id, nullptr, 0); - // } + if (not normalCmdPending) { + *id = mpsoc::TC_GET_HK_REPORT; + normalCmdPending = true; + return buildCommandFromCommand(*id, nullptr, 0); + } return NOTHING_TO_SEND; } From 4887dc9e6b13c2977366526d2e59fb5aa97ba2f6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 16:58:56 +0200 Subject: [PATCH 38/41] somethings still wrong --- linux/payload/PlocMpsocHandler.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 8a00e307..86589d21 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -360,7 +360,6 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain DeviceCommandId_t* foundId, size_t* foundLen) { ReturnValue_t result = returnvalue::OK; - sif::debug << "remainingSize: " << remainingSize << std::endl; SpacePacketReader spacePacket; spacePacket.setReadOnlyData(start, remainingSize); if (spacePacket.isNull()) { @@ -379,6 +378,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain }; switch (apid) { case (mpsoc::apid::ACK_SUCCESS): + sif::debug << "recv ack" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -394,6 +394,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain handleDedicatedReply(mpsoc::TM_CAM_CMD_RPT); break; case (mpsoc::apid::TM_HK_GET_REPORT): { + sif::debug << "recv hk report" << std::endl; handleDedicatedReply(mpsoc::TM_GET_HK_REPORT); break; } @@ -402,6 +403,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain break; } case (mpsoc::apid::EXE_SUCCESS): + sif::debug << "recv exe" << std::endl; *foundLen = mpsoc::SIZE_EXE_REPORT; *foundId = mpsoc::EXE_REPORT; break; @@ -802,17 +804,22 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; + auto cmdDoneHandler = [&]() { + if (normalCmdPending) { + normalCmdPending = false; + } + auto commandIter = deviceCommandMap.find(getPendingCommand()); + if (commandIter != deviceCommandMap.end()) { + commandIter->second.isExecuting = false; + } + disableAllReplies(); + }; switch (apid) { case (mpsoc::apid::EXE_SUCCESS): { - if (normalCmdPending) { - normalCmdPending = false; - } + cmdDoneHandler(); break; } case (mpsoc::apid::EXE_FAILURE): { - if (normalCmdPending) { - normalCmdPending = false; - } // TODO: Interpretation of status field in execution report sif::warning << "PlocMPSoCHandler::handleExecutionReport: Received execution failure report" << std::endl; @@ -825,8 +832,8 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { } printStatus(data); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); - disableExeReportReply(); result = IGNORE_REPLY_DATA; + cmdDoneHandler(); break; } default: { From 714e2d07e530f7a06c10c8a7bf7fade2617e47ef Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 17:13:51 +0200 Subject: [PATCH 39/41] and were at DHB debugging again --- linux/payload/PlocMpsocHandler.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 86589d21..484ce47c 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -225,9 +225,9 @@ void PlocMPSoCHandler::doShutDown() { } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - if (not normalCmdPending) { + if (not commandIsExecuting(mpsoc::TC_GET_HK_REPORT)) { *id = mpsoc::TC_GET_HK_REPORT; - normalCmdPending = true; + // normalCmdPending = true; return buildCommandFromCommand(*id, nullptr, 0); } return NOTHING_TO_SEND; @@ -424,6 +424,7 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain triggerEvent(MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH, sequenceCount, recvSeqCnt); sequenceCount = recvSeqCnt; } + sif::debug << "sequence count: " << sequenceCount.get() << std::endl; // This sequence count ping pong does not make any sense but it is how the MPSoC expects it. sequenceCount++; return result; @@ -804,19 +805,22 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { uint16_t apid = (*(data) << 8 | *(data + 1)) & APID_MASK; - auto cmdDoneHandler = [&]() { + auto cmdDoneHandler = [&](bool success) { if (normalCmdPending) { normalCmdPending = false; } auto commandIter = deviceCommandMap.find(getPendingCommand()); if (commandIter != deviceCommandMap.end()) { commandIter->second.isExecuting = false; + if (commandIter->second.sendReplyTo != MessageQueueIF::NO_QUEUE) { + actionHelper.finish(success, commandIter->second.sendReplyTo, getPendingCommand(), result); + } } disableAllReplies(); }; switch (apid) { case (mpsoc::apid::EXE_SUCCESS): { - cmdDoneHandler(); + cmdDoneHandler(true); break; } case (mpsoc::apid::EXE_FAILURE): { @@ -833,7 +837,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { printStatus(data); sendFailureReport(mpsoc::EXE_REPORT, MPSoCReturnValuesIF::RECEIVED_EXE_FAILURE); result = IGNORE_REPLY_DATA; - cmdDoneHandler(); + cmdDoneHandler(false); break; } default: { From a718d182fcd1fdedde402db0ef42c9b0e133d435 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 17:39:15 +0200 Subject: [PATCH 40/41] done --- linux/payload/PlocMpsocHandler.cpp | 12 +++++------- linux/payload/PlocMpsocHandler.h | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 484ce47c..94fcb978 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -105,6 +105,7 @@ void PlocMPSoCHandler::performOperationHook() { ReturnValue_t PlocMPSoCHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { ReturnValue_t result = returnvalue::OK; + commandIsPending = true; switch (actionId) { case mpsoc::SET_UART_TX_TRISTATE: { uartIsolatorSwitch.pullLow(); @@ -225,9 +226,9 @@ void PlocMPSoCHandler::doShutDown() { } ReturnValue_t PlocMPSoCHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { - if (not commandIsExecuting(mpsoc::TC_GET_HK_REPORT)) { + if (not commandIsPending) { *id = mpsoc::TC_GET_HK_REPORT; - // normalCmdPending = true; + commandIsPending = true; return buildCommandFromCommand(*id, nullptr, 0); } return NOTHING_TO_SEND; @@ -378,7 +379,6 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain }; switch (apid) { case (mpsoc::apid::ACK_SUCCESS): - sif::debug << "recv ack" << std::endl; *foundLen = mpsoc::SIZE_ACK_REPORT; *foundId = mpsoc::ACK_REPORT; break; @@ -394,7 +394,6 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain handleDedicatedReply(mpsoc::TM_CAM_CMD_RPT); break; case (mpsoc::apid::TM_HK_GET_REPORT): { - sif::debug << "recv hk report" << std::endl; handleDedicatedReply(mpsoc::TM_GET_HK_REPORT); break; } @@ -403,7 +402,6 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain break; } case (mpsoc::apid::EXE_SUCCESS): - sif::debug << "recv exe" << std::endl; *foundLen = mpsoc::SIZE_EXE_REPORT; *foundId = mpsoc::EXE_REPORT; break; @@ -419,12 +417,11 @@ ReturnValue_t PlocMPSoCHandler::scanForReply(const uint8_t* start, size_t remain } } - uint16_t recvSeqCnt = (*(start + 2) << 8 | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK; + uint16_t recvSeqCnt = ((*(start + 2) << 8) | *(start + 3)) & PACKET_SEQUENCE_COUNT_MASK; if (recvSeqCnt != sequenceCount) { triggerEvent(MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH, sequenceCount, recvSeqCnt); sequenceCount = recvSeqCnt; } - sif::debug << "sequence count: " << sequenceCount.get() << std::endl; // This sequence count ping pong does not make any sense but it is how the MPSoC expects it. sequenceCount++; return result; @@ -809,6 +806,7 @@ ReturnValue_t PlocMPSoCHandler::handleExecutionReport(const uint8_t* data) { if (normalCmdPending) { normalCmdPending = false; } + commandIsPending = false; auto commandIter = deviceCommandMap.find(getPendingCommand()); if (commandIter != deviceCommandMap.end()) { commandIter->second.isExecuting = false; diff --git a/linux/payload/PlocMpsocHandler.h b/linux/payload/PlocMpsocHandler.h index 654cded4..a6af8156 100644 --- a/linux/payload/PlocMpsocHandler.h +++ b/linux/payload/PlocMpsocHandler.h @@ -169,6 +169,7 @@ class PlocMPSoCHandler : public DeviceHandlerBase, public CommandsActionsIF { // Used to block incoming commands when MPSoC helper class is currently executing a command bool plocMPSoCHelperExecuting = false; + bool commandIsPending = false; struct TmMemReadReport { static const uint8_t FIX_SIZE = 14; From edf792c4fe972364ed71570db312c604b85d9fad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 12 May 2023 17:44:41 +0200 Subject: [PATCH 41/41] 8 wait cycles are also okay --- linux/payload/PlocMpsocHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/payload/PlocMpsocHandler.cpp b/linux/payload/PlocMpsocHandler.cpp index 94fcb978..07f7759d 100644 --- a/linux/payload/PlocMpsocHandler.cpp +++ b/linux/payload/PlocMpsocHandler.cpp @@ -185,7 +185,7 @@ void PlocMPSoCHandler::doStartUp() { // not work, no replies.. if (startupState == StartupState::WAIT_CYCLES) { waitCycles++; - if (waitCycles >= 10) { + if (waitCycles >= 8) { startupState = StartupState::DONE; waitCycles = 0; }