From 4fdec7a74cb4713212df9e29fa55818bf729bf2d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 6 May 2024 13:19:15 +0200 Subject: [PATCH] impl proper NORMAL mode for MPSoC --- .../fsfwconfig/events/translateEvents.cpp | 7 +++- .../fsfwconfig/objects/translateObjects.cpp | 2 +- bsp_q7s/objectFactory.cpp | 7 ++-- generators/bsp_hosted_events.csv | 1 + generators/bsp_q7s_events.csv | 1 + generators/events/translateEvents.cpp | 7 +++- generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 7 +++- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- linux/payload/FreshMpsocHandler.cpp | 41 +++++++++++++++---- linux/payload/FreshMpsocHandler.h | 9 +++- linux/payload/plocMpsocHelpers.h | 4 ++ tmtc | 2 +- 13 files changed, 69 insertions(+), 23 deletions(-) diff --git a/bsp_hosted/fsfwconfig/events/translateEvents.cpp b/bsp_hosted/fsfwconfig/events/translateEvents.cpp index 8d67f14d..65081593 100644 --- a/bsp_hosted/fsfwconfig/events/translateEvents.cpp +++ b/bsp_hosted/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 324 translations. + * @brief Auto-generated event translation file. Contains 325 translations. * @details - * Generated on: 2024-04-17 11:22:10 + * Generated on: 2024-05-06 13:06:03 */ #include "translateEvents.h" @@ -142,6 +142,7 @@ const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUEN const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON"; const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT"; +const char *CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING = "CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; @@ -606,6 +607,8 @@ const char *translateEvents(Event event) { return SUPV_NOT_ON_STRING; case (11608): return SUPV_REPLY_TIMEOUT_STRING; + case (11609): + return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING; case (11701): return SELF_TEST_I2C_FAILURE_STRING; case (11702): diff --git a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp index c536b709..ef5a91de 100644 --- a/bsp_hosted/fsfwconfig/objects/translateObjects.cpp +++ b/bsp_hosted/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 176 translations. - * Generated on: 2024-04-17 11:22:10 + * Generated on: 2024-05-06 13:06:03 */ #include "translateObjects.h" diff --git a/bsp_q7s/objectFactory.cpp b/bsp_q7s/objectFactory.cpp index f9ae8dc6..e1ef0816 100644 --- a/bsp_q7s/objectFactory.cpp +++ b/bsp_q7s/objectFactory.cpp @@ -65,6 +65,7 @@ #include "linux/payload/PlocMpsocSpecialComHelper.h" #include "linux/payload/SerialConfig.h" #include "mission/config/configfile.h" +#include "mission/power/defs.h" #include "mission/system/acs/AcsBoardFdir.h" #include "mission/system/acs/AcsSubsystem.h" #include "mission/system/acs/RwAssembly.h" @@ -635,9 +636,9 @@ void ObjectFactory::createPayloadComponents(LinuxLibgpioIF* gpioComIF, PowerSwit auto specialComHelper = new PlocMpsocSpecialComHelper(objects::PLOC_MPSOC_HELPER, *mpsocCommunication); DhbConfig dhbConf(objects::PLOC_MPSOC_HANDLER); - auto* mpsocHandler = new FreshMpsocHandler(dhbConf, *mpsocCommunication, *specialComHelper, - Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), - objects::PLOC_SUPERVISOR_HANDLER); + auto* mpsocHandler = new FreshMpsocHandler( + dhbConf, *mpsocCommunication, *specialComHelper, Gpio(gpioIds::ENABLE_MPSOC_UART, gpioComIF), + objects::PLOC_SUPERVISOR_HANDLER, pwrSwitcher, power::PDU2_CH8_PAYLOAD_CAMERA); mpsocHandler->connectModeTreeParent(satsystem::payload::SUBSYSTEM); #endif /* OBSW_ADD_PLOC_MPSOC == 1 */ #if OBSW_ADD_PLOC_SUPERVISOR == 1 diff --git a/generators/bsp_hosted_events.csv b/generators/bsp_hosted_events.csv index 6f5579c0..6a851c62 100644 --- a/generators/bsp_hosted_events.csv +++ b/generators/bsp_hosted_events.csv @@ -136,6 +136,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/plocMpsocHelpers.h 11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/plocMpsocHelpers.h 11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;linux/payload/plocMpsocHelpers.h +11609;0x2d59;CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE;LOW;Camera must be commanded on first.;linux/payload/plocMpsocHelpers.h 11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 6f5579c0..6a851c62 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -136,6 +136,7 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 11606;0x2d56;MPSOC_SHUTDOWN_FAILED;HIGH;Supervisor fails to shutdown MPSoC. Requires to power off the PLOC and thus also to shutdown the supervisor.;linux/payload/plocMpsocHelpers.h 11607;0x2d57;SUPV_NOT_ON;LOW;SUPV not on for boot or shutdown process. P1: 0 for OFF transition, 1 for ON transition.;linux/payload/plocMpsocHelpers.h 11608;0x2d58;SUPV_REPLY_TIMEOUT;LOW;No description;linux/payload/plocMpsocHelpers.h +11609;0x2d59;CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE;LOW;Camera must be commanded on first.;linux/payload/plocMpsocHelpers.h 11701;0x2db5;SELF_TEST_I2C_FAILURE;LOW;Get self test result returns I2C failure P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11702;0x2db6;SELF_TEST_SPI_FAILURE;LOW;Get self test result returns SPI failure. This concerns the MTM connectivity. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h 11703;0x2db7;SELF_TEST_ADC_FAILURE;LOW;Get self test result returns failure in measurement of current and temperature. P1: Indicates on which axis the failure occurred. 0 -> INIT, 1 -> +X, 2 -> -X, 3 -> +Y, 4 -> -Y, 5 -> +Z, 6 -> -Z, 7 -> FINA;mission/acs/ImtqHandler.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index 8d67f14d..65081593 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 324 translations. + * @brief Auto-generated event translation file. Contains 325 translations. * @details - * Generated on: 2024-04-17 11:22:10 + * Generated on: 2024-05-06 13:06:03 */ #include "translateEvents.h" @@ -142,6 +142,7 @@ const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUEN const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON"; const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT"; +const char *CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING = "CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; @@ -606,6 +607,8 @@ const char *translateEvents(Event event) { return SUPV_NOT_ON_STRING; case (11608): return SUPV_REPLY_TIMEOUT_STRING; + case (11609): + return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING; case (11701): return SELF_TEST_I2C_FAILURE_STRING; case (11702): diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 5ef8a2a7..f1fa381c 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 180 translations. - * Generated on: 2024-04-17 11:22:10 + * Generated on: 2024-05-06 13:06:03 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index 8d67f14d..65081593 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 324 translations. + * @brief Auto-generated event translation file. Contains 325 translations. * @details - * Generated on: 2024-04-17 11:22:10 + * Generated on: 2024-05-06 13:06:03 */ #include "translateEvents.h" @@ -142,6 +142,7 @@ const char *MPSOC_HANDLER_SEQUENCE_COUNT_MISMATCH_STRING = "MPSOC_HANDLER_SEQUEN const char *MPSOC_SHUTDOWN_FAILED_STRING = "MPSOC_SHUTDOWN_FAILED"; const char *SUPV_NOT_ON_STRING = "SUPV_NOT_ON"; const char *SUPV_REPLY_TIMEOUT_STRING = "SUPV_REPLY_TIMEOUT"; +const char *CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING = "CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE"; const char *SELF_TEST_I2C_FAILURE_STRING = "SELF_TEST_I2C_FAILURE"; const char *SELF_TEST_SPI_FAILURE_STRING = "SELF_TEST_SPI_FAILURE"; const char *SELF_TEST_ADC_FAILURE_STRING = "SELF_TEST_ADC_FAILURE"; @@ -606,6 +607,8 @@ const char *translateEvents(Event event) { return SUPV_NOT_ON_STRING; case (11608): return SUPV_REPLY_TIMEOUT_STRING; + case (11609): + return CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE_STRING; case (11701): return SELF_TEST_I2C_FAILURE_STRING; case (11702): diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 5ef8a2a7..f1fa381c 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 180 translations. - * Generated on: 2024-04-17 11:22:10 + * Generated on: 2024-05-06 13:06:03 */ #include "translateObjects.h" diff --git a/linux/payload/FreshMpsocHandler.cpp b/linux/payload/FreshMpsocHandler.cpp index 65c273c2..662bd636 100644 --- a/linux/payload/FreshMpsocHandler.cpp +++ b/linux/payload/FreshMpsocHandler.cpp @@ -8,22 +8,29 @@ #include "fsfw/devicehandlers/FreshDeviceHandlerBase.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/ipc/QueueFactory.h" +#include "fsfw/ipc/messageQueueDefinitions.h" +#include "fsfw/power/PowerSwitchIF.h" +#include "fsfw/power/definitions.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serialize/SerializeAdapter.h" #include "linux/payload/MpsocCommunication.h" #include "linux/payload/plocMpsocHelpers.h" #include "linux/payload/plocSupvDefs.h" +#include "mission/power/gsDefs.h" FreshMpsocHandler::FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface, PlocMpsocSpecialComHelper& specialComHelper, - Gpio uartIsolatorSwitch, object_id_t supervisorHandler) + Gpio uartIsolatorSwitch, object_id_t supervisorHandler, + PowerSwitchIF& powerSwitcher, power::Switch_t camSwitchId) : FreshDeviceHandlerBase(cfg), comInterface(comInterface), specialComHelper(specialComHelper), commandActionHelper(this), uartIsolatorSwitch(uartIsolatorSwitch), hkReport(this), - supervisorHandler(supervisorHandler) { + supervisorHandler(supervisorHandler), + powerSwitcher(powerSwitcher), + camSwitchId(camSwitchId) { commandActionHelperQueue = QueueFactory::instance()->createMessageQueue(10); eventQueue = QueueFactory::instance()->createMessageQueue(10); spParams.maxSize = sizeof(commandBuffer); @@ -77,8 +84,13 @@ void FreshMpsocHandler::performDefaultDeviceOperation() { } } + // We checked the action queue beforehand, so action commands should always be performed + // before normal commands. if (mode == MODE_NORMAL and not activeCmdInfo.pending) { - // TODO: Take care of regular periodic commanding here. + ReturnValue_t result = commandTcGetHkReport(); + if (result == returnvalue::OK) { + commandInitHandling(mpsoc::TC_GET_HK_REPORT, MessageQueueIF::NO_QUEUE); + } } if (activeCmdInfo.pending and activeCmdInfo.cmdCountdown.hasTimedOut()) { @@ -224,6 +236,11 @@ ReturnValue_t FreshMpsocHandler::checkModeCommand(Mode_t mode, Submode_t submode return HasModesIF::INVALID_SUBMODE; } } + if (submode == mpsoc::Submode::SNAPSHOT and + powerSwitcher.getSwitchState(camSwitchId) != PowerSwitchIF::SWITCH_ON) { + triggerEvent(mpsoc::CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE); + return HasModesIF::TRANS_NOT_ALLOWED; + } *msToReachTheMode = MPSOC_MODE_CMD_TIMEOUT_MS; return returnvalue::OK; } @@ -583,16 +600,20 @@ ReturnValue_t FreshMpsocHandler::executeRegularCmd(ActionId_t actionId, } if (result == returnvalue::OK) { - activeCmdInfo.start(actionId, commandedBy); - /** - * Flushing the receive buffer to make sure there are no data left from a faulty reply. - */ - comInterface.getComHelper().flushUartRxBuffer(); + commandInitHandling(actionId, commandedBy); } return result; } +void FreshMpsocHandler::commandInitHandling(ActionId_t actionId, MessageQueueId_t commandedBy) { + activeCmdInfo.start(actionId, commandedBy); + /** + * Flushing the receive buffer to make sure there are no data left from a faulty reply. + */ + comInterface.getComHelper().flushUartRxBuffer(); +} + ReturnValue_t FreshMpsocHandler::commandTcMemWrite(const uint8_t* commandData, size_t commandDataLen) { ReturnValue_t result = returnvalue::OK; @@ -1229,7 +1250,9 @@ bool FreshMpsocHandler::handleHwShutdown() { supvTransitionCd.resetTimer(); powerState = PowerState::PENDING_SHUTDOWN; } else { - triggerEvent(mpsoc::SUPV_NOT_ON, 0); + if ((this->mode != MODE_OFF) and (this->mode != MODE_UNDEFINED)) { + triggerEvent(mpsoc::SUPV_NOT_ON, 0); + } powerState = PowerState::DONE; } } diff --git a/linux/payload/FreshMpsocHandler.h b/linux/payload/FreshMpsocHandler.h index 88460764..f62cd051 100644 --- a/linux/payload/FreshMpsocHandler.h +++ b/linux/payload/FreshMpsocHandler.h @@ -1,3 +1,4 @@ +#include "fsfw/action/ActionMessage.h" #include "fsfw/action/CommandsActionsIF.h" #include "fsfw/devicehandlers/DeviceHandlerIF.h" #include "fsfw/devicehandlers/FreshDeviceHandlerBase.h" @@ -5,6 +6,8 @@ #include "fsfw/ipc/messageQueueDefinitions.h" #include "fsfw/modes/ModeMessage.h" #include "fsfw/objectmanager/SystemObjectIF.h" +#include "fsfw/power/PowerSwitchIF.h" +#include "fsfw/power/definitions.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw_hal/linux/gpio/Gpio.h" #include "linux/payload/MpsocCommunication.h" @@ -18,7 +21,8 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI FreshMpsocHandler(DhbConfig cfg, MpsocCommunication& comInterface, PlocMpsocSpecialComHelper& specialComHelper, Gpio uartIsolatorSwitch, - object_id_t supervisorHandler); + object_id_t supervisorHandler, PowerSwitchIF& powerSwitcher, + power::Switch_t camSwitchId); /** * Periodic helper executed function, implemented by child class. @@ -128,6 +132,8 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI TmMemReadReport tmMemReadReport; uint32_t lastReplySequenceCount = 0; uint8_t skipSupvCommandingToOn = false; + PowerSwitchIF& powerSwitcher; + power::Switch_t camSwitchId; // HK manager abstract functions. LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; @@ -202,4 +208,5 @@ class FreshMpsocHandler : public FreshDeviceHandlerBase, public CommandsActionsI void commandSubmodeTransition(); void commonSpecialComInit(); void commonSpecialComStop(); + void commandInitHandling(ActionId_t actionId, MessageQueueId_t commandedBy); }; diff --git a/linux/payload/plocMpsocHelpers.h b/linux/payload/plocMpsocHelpers.h index 60356f56..ce055873 100644 --- a/linux/payload/plocMpsocHelpers.h +++ b/linux/payload/plocMpsocHelpers.h @@ -8,6 +8,7 @@ #include "eive/eventSubsystemIds.h" #include "eive/resultClassIds.h" #include "fsfw/action/HasActionsIF.h" +#include "fsfw/events/Event.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeIF.h" @@ -113,6 +114,9 @@ static const Event MPSOC_SHUTDOWN_FAILED = MAKE_EVENT(6, severity::HIGH); //! ON transition. static constexpr Event SUPV_NOT_ON = event::makeEvent(SUBSYSTEM_ID, 7, severity::LOW); static constexpr Event SUPV_REPLY_TIMEOUT = event::makeEvent(SUBSYSTEM_ID, 8, severity::LOW); +//! [EXPORT] : [COMMENT] Camera must be commanded on first. +static constexpr Event CAM_MUST_BE_ON_FOR_SNAPSHOT_MODE = + event::makeEvent(SUBSYSTEM_ID, 9, severity::LOW); enum ParamId : uint8_t { SKIP_SUPV_ON_COMMANDING = 0x01 }; diff --git a/tmtc b/tmtc index 5e1b12fa..376f94b1 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5e1b12fa527c21131883176cbcb9f8abe4199d91 +Subproject commit 376f94b1673921ef63f7cb11f4852afd9f8fa818