From c9e16642c5956b8e2384157502834441c2da95ac Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 13:32:13 +0100 Subject: [PATCH 1/4] refactor power code --- CHANGELOG.md | 7 +++++ bsp_q7s/core/CoreController.cpp | 22 +++++++++----- bsp_q7s/core/ObjectFactory.cpp | 12 ++++---- bsp_q7s/obsw.cpp | 2 ++ mission/devices/PcduHandler.cpp | 4 +++ mission/devices/PcduHandler.h | 7 ++++- .../{PDU1Handler.cpp => Pdu1Handler.cpp} | 29 +++++++++---------- .../devices/{PDU1Handler.h => Pdu1Handler.h} | 6 ++-- .../{PDU2Handler.cpp => Pdu2Handler.cpp} | 29 +++++++++---------- .../devices/{PDU2Handler.h => Pdu2Handler.h} | 6 ++-- 10 files changed, 73 insertions(+), 51 deletions(-) rename mission/devices/{PDU1Handler.cpp => Pdu1Handler.cpp} (87%) rename mission/devices/{PDU1Handler.h => Pdu1Handler.h} (93%) rename mission/devices/{PDU2Handler.cpp => Pdu2Handler.cpp} (88%) rename mission/devices/{PDU2Handler.h => Pdu2Handler.h} (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md index be95f310..92c4cc77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,13 @@ will consitute of a breaking change warranting a new major release: - Limitation of RW speeds was done before converting them to the correct unit scale. - The Syrlinks task now has a proper name instead of `MAIN_SPI`. +## Changed + +- Initialize switch states to a special `SWITCH_STATE_UNKNOWN` (2) variable. Return + `returnvalue::FAILED` in switch state getter. +- Wait 1 second before commanding SAFE mode. This ensures or at least increases the chance that + the switch states were initialized. + # [v1.37.0] 2023-03-11 eive-tmtc: v2.18.1 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 702264ab..085d27de 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -32,8 +32,13 @@ xsc::Chip CoreController::CURRENT_CHIP = xsc::Chip::NO_CHIP; xsc::Copy CoreController::CURRENT_COPY = xsc::Copy::NO_COPY; CoreController::CoreController(object_id_t objectId) - : ExtendedControllerBase(objectId, 5), cmdExecutor(4096), cmdReplyBuf(4096, true), cmdRepliesSizes(128), - opDivider5(5), opDivider10(10), hkSet(this) { + : ExtendedControllerBase(objectId, 5), + cmdExecutor(4096), + cmdReplyBuf(4096, true), + cmdRepliesSizes(128), + opDivider5(5), + opDivider10(10), + hkSet(this) { cmdExecutor.setRingBuffer(&cmdReplyBuf, &cmdRepliesSizes); try { sdcMan = SdCardManager::instance(); @@ -102,14 +107,14 @@ void CoreController::performControlOperation() { sdStateMachine(); performMountedSdCardOperations(); readHkData(); - if(shellCmdIsExecuting) { + if (shellCmdIsExecuting) { bool replyReceived = false; // TODO: We could read the data in the ring buffer and send it as an action data reply. - if(cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) { + if (cmdExecutor.check(replyReceived) == CommandExecutor::EXECUTION_FINISHED) { actionHelper.finish(true, successRecipient, EXECUTE_SHELL_CMD); shellCmdIsExecuting = false; cmdReplyBuf.clear(); - while(not cmdRepliesSizes.empty()) { + while (not cmdRepliesSizes.empty()) { cmdRepliesSizes.pop(); } successRecipient = MessageQueueIF::NO_QUEUE; @@ -316,14 +321,15 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ // Warning: This function will never return, because it reboots the system return actionReboot(data, size); } - case(EXECUTE_SHELL_CMD): { + case (EXECUTE_SHELL_CMD): { std::string cmd = std::string(cmd, size); - if(cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or shellCmdIsExecuting) { + if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING or + shellCmdIsExecuting) { return HasActionsIF::IS_BUSY; } cmdExecutor.load(cmd, false, false); ReturnValue_t result = cmdExecutor.execute(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } shellCmdIsExecuting = true; diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 3092e69d..057c7e47 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -74,6 +74,8 @@ #include #include #include +#include +#include #include #include #include @@ -102,8 +104,6 @@ #include "mission/devices/HeaterHandler.h" #include "mission/devices/Max31865PT1000Handler.h" #include "mission/devices/P60DockHandler.h" -#include "mission/devices/PDU1Handler.h" -#include "mission/devices/PDU2Handler.h" #include "mission/devices/PayloadPcduHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" @@ -193,12 +193,12 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie, p60Fdir); auto pdu1Fdir = new GomspacePowerFdir(objects::PDU1_HANDLER); - PDU1Handler* pdu1handler = - new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie, pdu1Fdir); + Pdu1Handler* pdu1handler = + new Pdu1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie, pdu1Fdir); auto pdu2Fdir = new GomspacePowerFdir(objects::PDU2_HANDLER); - PDU2Handler* pdu2handler = - new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie, pdu2Fdir); + Pdu2Handler* pdu2handler = + new Pdu2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie, pdu2Fdir); auto acuFdir = new GomspacePowerFdir(objects::ACU_HANDLER); ACUHandler* acuhandler = diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index e264283f..e16d30bb 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -66,6 +66,8 @@ int obsw::obsw(int argc, char* argv[]) { // Command the EIVE system to safe mode #if OBSW_COMMAND_SAFE_MODE_AT_STARTUP == 1 + // This ensures that the PCDU switches were updated. + TaskFactory::delayTask(1000); commandEiveSystemToSafe(); #else announceAllModes(); diff --git a/mission/devices/PcduHandler.cpp b/mission/devices/PcduHandler.cpp index f5873fcf..17e2f88f 100644 --- a/mission/devices/PcduHandler.cpp +++ b/mission/devices/PcduHandler.cpp @@ -19,6 +19,7 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) commandQueue = QueueFactory::instance()->createMessageQueue( cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); pwrLock = MutexFactory::instance()->createMutex(); + std::memset(switchStates, SWITCH_STATE_UNKNOWN, sizeof(switchStates)); } PCDUHandler::~PCDUHandler() {} @@ -407,6 +408,9 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { MutexGuard mg(pwrLock, LOCK_TYPE, LOCK_TIMEOUT, LOCK_CTX); currentState = switchStates[switchNr]; } + if (currentState == SWITCH_STATE_UNKNOWN) { + return returnvalue::FAILED; + } if (currentState == 1) { return PowerSwitchIF::SWITCH_ON; } else { diff --git a/mission/devices/PcduHandler.h b/mission/devices/PcduHandler.h index 45bbd392..dbd9b5e3 100644 --- a/mission/devices/PcduHandler.h +++ b/mission/devices/PcduHandler.h @@ -35,7 +35,11 @@ class PCDUHandler : public PowerSwitchIF, virtual ReturnValue_t sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) override; virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override; - virtual ReturnValue_t getSwitchState(uint8_t switchNr) const override; + /** + * @param switchNr + * @return returnvalue::FAILED if the switch state has not been updated yet. + */ + ReturnValue_t getSwitchState(uint8_t switchNr) const override; virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; virtual uint32_t getSwitchDelayMs(void) const override; virtual object_id_t getObjectId() const override; @@ -84,6 +88,7 @@ class PCDUHandler : public PowerSwitchIF, /** The timeStamp of the current pdu1HkTableDataset */ CCSDSTime::CDS_short timeStampPdu1HkDataset; + uint8_t SWITCH_STATE_UNKNOWN = 2; uint8_t switchStates[pcdu::NUMBER_OF_SWITCHES]; /** * Pointer to the IPCStore. diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/Pdu1Handler.cpp similarity index 87% rename from mission/devices/PDU1Handler.cpp rename to mission/devices/Pdu1Handler.cpp index 9a44da5e..25f14c76 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/Pdu1Handler.cpp @@ -1,11 +1,10 @@ -#include "PDU1Handler.h" - #include +#include #include #include "devices/powerSwitcherList.h" -PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, +Pdu1Handler::Pdu1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, FailureIsolationBase *customFdir) : GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir), coreHk(this), @@ -13,23 +12,23 @@ PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC initPduConfigTable(); } -PDU1Handler::~PDU1Handler() {} +Pdu1Handler::~Pdu1Handler() {} -ReturnValue_t PDU1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t Pdu1Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { *id = GOMSPACE::REQUEST_HK_TABLE; return buildCommandFromCommand(*id, NULL, 0); } -void PDU1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu1Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); } -void PDU1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { +void Pdu1Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { this->channelSwitchHook = hook; this->hookArgs = args; } -ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, +ReturnValue_t Pdu1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { using namespace PDU1; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU1; @@ -79,15 +78,15 @@ ReturnValue_t PDU1Handler::setParamCallback(SetParamMessageUnpacker &unpacker, return returnvalue::OK; } -void PDU1Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu1Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { handleDeviceTm(packet, PDU::CONFIG_TABLE_SIZE, id); } -void PDU1Handler::parseHkTableReply(const uint8_t *packet) { +void Pdu1Handler::parseHkTableReply(const uint8_t *packet) { GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet); } -ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, +ReturnValue_t Pdu1Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU1); poolManager.subscribeForDiagPeriodicPacket( @@ -97,7 +96,7 @@ ReturnValue_t PDU1Handler::initializeLocalDataPool(localpool::DataPool &localDat return returnvalue::OK; } -LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase *Pdu1Handler::getDataSetHandle(sid_t sid) { if (sid == coreHk.getSid()) { return &coreHk; } else if (sid == auxHk.getSid()) { @@ -106,7 +105,7 @@ LocalPoolDataSetBase *PDU1Handler::getDataSetHandle(sid_t sid) { return nullptr; } -ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { +ReturnValue_t Pdu1Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = returnvalue::OK; switch (cmd) { case (GOMSPACE::PRINT_SWITCH_V_I): { @@ -137,7 +136,7 @@ ReturnValue_t PDU1Handler::printStatus(DeviceCommandId_t cmd) { return result; } -void PDU1Handler::printHkTableSwitchVI() { +void Pdu1Handler::printHkTableSwitchVI() { using namespace PDU1; sif::info << "PDU1 Info: " << std::endl; sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right @@ -163,7 +162,7 @@ void PDU1Handler::printHkTableSwitchVI() { printerHelper("Syrlinks", Channels::SYRLINKS); } -void PDU1Handler::printHkTableLatchups() { +void Pdu1Handler::printHkTableLatchups() { using namespace PDU1; sif::info << "PDU1 Latchup Information" << std::endl; auto printerHelper = [&](std::string channelStr, Channels idx) { diff --git a/mission/devices/PDU1Handler.h b/mission/devices/Pdu1Handler.h similarity index 93% rename from mission/devices/PDU1Handler.h rename to mission/devices/Pdu1Handler.h index 262283a6..b81f647e 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/Pdu1Handler.h @@ -19,11 +19,11 @@ * ACS 3.3V for Side A group, channel 7 * Unoccupied, 5V, channel 8 */ -class PDU1Handler : public GomspaceDeviceHandler { +class Pdu1Handler : public GomspaceDeviceHandler { public: - PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + Pdu1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, FailureIsolationBase* customFdir); - virtual ~PDU1Handler(); + virtual ~Pdu1Handler(); virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/Pdu2Handler.cpp similarity index 88% rename from mission/devices/PDU2Handler.cpp rename to mission/devices/Pdu2Handler.cpp index 4db6999f..363c5f51 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/Pdu2Handler.cpp @@ -1,11 +1,10 @@ -#include "PDU2Handler.h" - #include +#include #include #include "devices/powerSwitcherList.h" -PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, +Pdu2Handler::Pdu2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, FailureIsolationBase *customFdir) : GomspaceDeviceHandler(objectId, comIF, comCookie, cfg, customFdir), coreHk(this), @@ -13,27 +12,27 @@ PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comC initPduConfigTable(); } -PDU2Handler::~PDU2Handler() {} +Pdu2Handler::~Pdu2Handler() {} -ReturnValue_t PDU2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { +ReturnValue_t Pdu2Handler::buildNormalDeviceCommand(DeviceCommandId_t *id) { *id = GOMSPACE::REQUEST_HK_TABLE; return buildCommandFromCommand(*id, NULL, 0); } -void PDU2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu2Handler::letChildHandleHkReply(DeviceCommandId_t id, const uint8_t *packet) { parseHkTableReply(packet); } -void PDU2Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { +void Pdu2Handler::letChildHandleConfigReply(DeviceCommandId_t id, const uint8_t *packet) { handleDeviceTm(packet, PDU::CONFIG_TABLE_SIZE, id); } -void PDU2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { +void Pdu2Handler::assignChannelHookFunction(GOMSPACE::ChannelSwitchHook hook, void *args) { this->channelSwitchHook = hook; this->hookArgs = args; } -LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase *Pdu2Handler::getDataSetHandle(sid_t sid) { if (sid == coreHk.getSid()) { return &coreHk; } else if (sid == auxHk.getSid()) { @@ -42,11 +41,11 @@ LocalPoolDataSetBase *PDU2Handler::getDataSetHandle(sid_t sid) { return nullptr; } -void PDU2Handler::parseHkTableReply(const uint8_t *packet) { +void Pdu2Handler::parseHkTableReply(const uint8_t *packet) { GomspaceDeviceHandler::parsePduHkTable(coreHk, auxHk, packet); } -ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, +ReturnValue_t Pdu2Handler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { initializePduPool(localDataPoolMap, poolManager, pcdu::INIT_SWITCHES_PDU2); poolManager.subscribeForDiagPeriodicPacket( @@ -56,7 +55,7 @@ ReturnValue_t PDU2Handler::initializeLocalDataPool(localpool::DataPool &localDat return returnvalue::OK; } -ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { +ReturnValue_t Pdu2Handler::printStatus(DeviceCommandId_t cmd) { ReturnValue_t result = returnvalue::OK; switch (cmd) { case (GOMSPACE::PRINT_SWITCH_V_I): { @@ -87,7 +86,7 @@ ReturnValue_t PDU2Handler::printStatus(DeviceCommandId_t cmd) { return result; } -void PDU2Handler::printHkTableSwitchVI() { +void Pdu2Handler::printHkTableSwitchVI() { using namespace PDU2; sif::info << "PDU2 Info:" << std::endl; sif::info << "Boot Cause: " << auxHk.bootcause << " | Boot Count: " << std::setw(4) << std::right @@ -111,7 +110,7 @@ void PDU2Handler::printHkTableSwitchVI() { printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA); } -void PDU2Handler::printHkTableLatchups() { +void Pdu2Handler::printHkTableLatchups() { using namespace PDU2; sif::info << "PDU2 Latchup Information" << std::endl; auto printerHelper = [&](std::string channelStr, Channels idx) { @@ -129,7 +128,7 @@ void PDU2Handler::printHkTableLatchups() { printerHelper("Payload Camera", Channels::PAYLOAD_CAMERA); } -ReturnValue_t PDU2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, +ReturnValue_t Pdu2Handler::setParamCallback(SetParamMessageUnpacker &unpacker, bool afterExecution) { using namespace PDU2; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; diff --git a/mission/devices/PDU2Handler.h b/mission/devices/Pdu2Handler.h similarity index 93% rename from mission/devices/PDU2Handler.h rename to mission/devices/Pdu2Handler.h index 40204502..acb229dc 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/Pdu2Handler.h @@ -19,11 +19,11 @@ * ACS Board (Gyro, MGMs, GPS), 3.3V channel 7 * Payload Camera, 8V, channel 8 */ -class PDU2Handler : public GomspaceDeviceHandler { +class Pdu2Handler : public GomspaceDeviceHandler { public: - PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + Pdu2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, FailureIsolationBase* customFdir); - virtual ~PDU2Handler(); + virtual ~Pdu2Handler(); virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; From 6688499128aab008332dc5a302a9e35321331ea3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 13:56:19 +0100 Subject: [PATCH 2/4] power updates --- CHANGELOG.md | 2 + bsp_q7s/core/ObjectFactory.cpp | 2 +- fsfw | 2 +- mission/devices/CMakeLists.txt | 4 +- mission/devices/PcduHandler.cpp | 50 +++++++++---------- mission/devices/PcduHandler.h | 6 +-- .../system/objects/DualLaneAssemblyBase.cpp | 6 ++- 7 files changed, 39 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92c4cc77..8084922a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ will consitute of a breaking change warranting a new major release: `returnvalue::FAILED` in switch state getter. - Wait 1 second before commanding SAFE mode. This ensures or at least increases the chance that the switch states were initialized. +- Dual Lane Assemblies: The returnvalues of the dual lane power state machine FSM are not ignored + anymore. # [v1.37.0] 2023-03-11 diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 057c7e47..09431ea2 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -203,7 +203,7 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI auto acuFdir = new GomspacePowerFdir(objects::ACU_HANDLER); ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie, acuFdir); - auto pcduHandler = new PCDUHandler(objects::PCDU_HANDLER, 50); + auto pcduHandler = new PcduHandler(objects::PCDU_HANDLER, 50); /** * Setting PCDU devices to mode normal immediately after start up because PCDU is always diff --git a/fsfw b/fsfw index 9a8d775e..0b0a0299 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9a8d775eb1a8788ad844215bf2a42d9f707767c0 +Subproject commit 0b0a0299bc044e67413d8912ceb76a779d76ee4e diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index cb6c066a..68e369a0 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -5,8 +5,8 @@ target_sources( Tmp1075Handler.cpp PcduHandler.cpp P60DockHandler.cpp - PDU1Handler.cpp - PDU2Handler.cpp + Pdu1Handler.cpp + Pdu2Handler.cpp ACUHandler.cpp SyrlinksHandler.cpp Max31865PT1000Handler.cpp diff --git a/mission/devices/PcduHandler.cpp b/mission/devices/PcduHandler.cpp index 17e2f88f..4c2f742c 100644 --- a/mission/devices/PcduHandler.cpp +++ b/mission/devices/PcduHandler.cpp @@ -7,7 +7,7 @@ #include #include -PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) +PcduHandler::PcduHandler(object_id_t setObjectId, size_t cmdQueueSize) : SystemObject(setObjectId), poolManager(this, nullptr), p60CoreHk(objects::P60DOCK_HANDLER), @@ -22,9 +22,9 @@ PCDUHandler::PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize) std::memset(switchStates, SWITCH_STATE_UNKNOWN, sizeof(switchStates)); } -PCDUHandler::~PCDUHandler() {} +PcduHandler::~PcduHandler() {} -ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { +ReturnValue_t PcduHandler::performOperation(uint8_t counter) { if (counter == DeviceHandlerIF::PERFORM_OPERATION) { readCommandQueue(); } @@ -52,7 +52,7 @@ ReturnValue_t PCDUHandler::performOperation(uint8_t counter) { return returnvalue::OK; } -ReturnValue_t PCDUHandler::initialize() { +ReturnValue_t PcduHandler::initialize() { ReturnValue_t result; IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); @@ -100,7 +100,7 @@ ReturnValue_t PCDUHandler::initialize() { return returnvalue::OK; } -void PCDUHandler::initializeSwitchStates() { +void PcduHandler::initializeSwitchStates() { using namespace pcdu; try { for (uint8_t idx = 0; idx < NUMBER_OF_SWITCHES; idx++) { @@ -117,7 +117,7 @@ void PCDUHandler::initializeSwitchStates() { } } -void PCDUHandler::readCommandQueue() { +void PcduHandler::readCommandQueue() { ReturnValue_t result = returnvalue::OK; CommandMessage command; @@ -130,9 +130,9 @@ void PCDUHandler::readCommandQueue() { } } -MessageQueueId_t PCDUHandler::getCommandQueue() const { return commandQueue->getId(); } +MessageQueueId_t PcduHandler::getCommandQueue() const { return commandQueue->getId(); } -void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) { +void PcduHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* clearMessage) { if (sid == sid_t(objects::PDU2_HANDLER, static_cast(P60System::SetIds::CORE))) { updateHkTableDataset(storeId, &pdu2CoreHk, &timeStampPdu2HkDataset); updatePdu2SwitchStates(); @@ -144,7 +144,7 @@ void PCDUHandler::handleChangedDataset(sid_t sid, store_address_t storeId, bool* } } -void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, +void PcduHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSetBase* dataset, CCSDSTime::CDS_short* datasetTimeStamp) { ReturnValue_t result; @@ -170,7 +170,7 @@ void PCDUHandler::updateHkTableDataset(store_address_t storeId, LocalPoolDataSet } } -void PCDUHandler::updatePdu2SwitchStates() { +void PcduHandler::updatePdu2SwitchStates() { using namespace pcdu; using namespace PDU2; GOMSPACE::Pdu pdu = GOMSPACE::Pdu::PDU2; @@ -207,7 +207,7 @@ void PCDUHandler::updatePdu2SwitchStates() { } } -void PCDUHandler::updatePdu1SwitchStates() { +void PcduHandler::updatePdu1SwitchStates() { using namespace pcdu; using namespace PDU1; PoolReadGuard rg0(&switcherSet); @@ -244,9 +244,9 @@ void PCDUHandler::updatePdu1SwitchStates() { } } -LocalDataPoolManager* PCDUHandler::getHkManagerHandle() { return &poolManager; } +LocalDataPoolManager* PcduHandler::getHkManagerHandle() { return &poolManager; } -ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) { +ReturnValue_t PcduHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) { using namespace pcdu; ReturnValue_t result; uint16_t memoryAddress = 0; @@ -396,9 +396,9 @@ ReturnValue_t PCDUHandler::sendSwitchCommand(uint8_t switchNr, ReturnValue_t onO return result; } -ReturnValue_t PCDUHandler::sendFuseOnCommand(uint8_t fuseNr) { return returnvalue::OK; } +ReturnValue_t PcduHandler::sendFuseOnCommand(uint8_t fuseNr) { return returnvalue::OK; } -ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { +ReturnValue_t PcduHandler::getSwitchState(uint8_t switchNr) const { if (switchNr >= pcdu::NUMBER_OF_SWITCHES) { sif::debug << "PCDUHandler::getSwitchState: Invalid switch number" << std::endl; return returnvalue::FAILED; @@ -409,7 +409,7 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { currentState = switchStates[switchNr]; } if (currentState == SWITCH_STATE_UNKNOWN) { - return returnvalue::FAILED; + return PowerSwitchIF::SWITCH_UNKNOWN; } if (currentState == 1) { return PowerSwitchIF::SWITCH_ON; @@ -418,13 +418,13 @@ ReturnValue_t PCDUHandler::getSwitchState(uint8_t switchNr) const { } } -ReturnValue_t PCDUHandler::getFuseState(uint8_t fuseNr) const { return returnvalue::OK; } +ReturnValue_t PcduHandler::getFuseState(uint8_t fuseNr) const { return returnvalue::OK; } -uint32_t PCDUHandler::getSwitchDelayMs(void) const { return 20000; } +uint32_t PcduHandler::getSwitchDelayMs(void) const { return 20000; } -object_id_t PCDUHandler::getObjectId() const { return SystemObject::getObjectId(); } +object_id_t PcduHandler::getObjectId() const { return SystemObject::getObjectId(); } -ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, +ReturnValue_t PcduHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { using namespace pcdu; localDataPoolMap.emplace(PoolIds::PDU1_SWITCHES, &pdu1Switches); @@ -435,7 +435,7 @@ ReturnValue_t PCDUHandler::initializeLocalDataPool(localpool::DataPool& localDat return returnvalue::OK; } -ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { +ReturnValue_t PcduHandler::initializeAfterTaskCreation() { if (executingTask != nullptr) { pstIntervalMs = executingTask->getPeriodMs(); } @@ -446,11 +446,11 @@ ReturnValue_t PCDUHandler::initializeAfterTaskCreation() { return returnvalue::OK; } -uint32_t PCDUHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } +uint32_t PcduHandler::getPeriodicOperationFrequency() const { return pstIntervalMs; } -void PCDUHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } +void PcduHandler::setTaskIF(PeriodicTaskIF* task) { executingTask = task; } -LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { +LocalPoolDataSetBase* PcduHandler::getDataSetHandle(sid_t sid) { if (sid == switcherSet.getSid()) { return &switcherSet; } else { @@ -459,7 +459,7 @@ LocalPoolDataSetBase* PCDUHandler::getDataSetHandle(sid_t sid) { } } -void PCDUHandler::checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, +void PcduHandler::checkAndUpdatePduSwitch(GOMSPACE::Pdu pdu, pcdu::Switches switchIdx, uint8_t setValue) { using namespace pcdu; if (switchStates[switchIdx] != setValue) { diff --git a/mission/devices/PcduHandler.h b/mission/devices/PcduHandler.h index dbd9b5e3..170c27f2 100644 --- a/mission/devices/PcduHandler.h +++ b/mission/devices/PcduHandler.h @@ -20,13 +20,13 @@ * This is necessary because the FSFW manages all power related functionalities via one * power object. This includes for example switching on and off of devices. */ -class PCDUHandler : public PowerSwitchIF, +class PcduHandler : public PowerSwitchIF, public HasLocalDataPoolIF, public SystemObject, public ExecutableObjectIF { public: - PCDUHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); - virtual ~PCDUHandler(); + PcduHandler(object_id_t setObjectId, size_t cmdQueueSize = 20); + virtual ~PcduHandler(); virtual ReturnValue_t initialize() override; virtual ReturnValue_t performOperation(uint8_t counter) override; diff --git a/mission/system/objects/DualLaneAssemblyBase.cpp b/mission/system/objects/DualLaneAssemblyBase.cpp index a55553a0..ca969dbb 100644 --- a/mission/system/objects/DualLaneAssemblyBase.cpp +++ b/mission/system/objects/DualLaneAssemblyBase.cpp @@ -19,7 +19,10 @@ DualLaneAssemblyBase::DualLaneAssemblyBase(object_id_t objectId, PowerSwitchIF* void DualLaneAssemblyBase::performChildOperation() { using namespace duallane; if (pwrStateMachine.active()) { - pwrStateMachineWrapper(); + ReturnValue_t result = pwrStateMachineWrapper(); + if (result != returnvalue::OK) { + handleModeTransitionFailed(result); + } } // Only perform the regular child operation if the power state machine is not active. // It does not make any sense to command device modes while the power switcher is busy @@ -112,6 +115,7 @@ void DualLaneAssemblyBase::handleModeReached() { pwrStateMachine.start(targetMode, targetSubmode); // Now we can switch off the power. After that, the AssemblyBase::handleModeReached function // will be called + // Ignore failures for now. pwrStateMachineWrapper(); } else { finishModeOp(); From 6e049f3ee1a1ca37ca349cae32f0e763f4932b93 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 14 Mar 2023 14:03:27 +0100 Subject: [PATCH 3/4] changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6bbd642..c79e34d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,7 @@ will consitute of a breaking change warranting a new major release: ## Changed - Initialize switch states to a special `SWITCH_STATE_UNKNOWN` (2) variable. Return - `returnvalue::FAILED` in switch state getter. + `PowerSwitchIF::SWITCH_UNKNOWN` in switch state getter if this is the state. - Wait 1 second before commanding SAFE mode. This ensures or at least increases the chance that the switch states were initialized. - Dual Lane Assemblies: The returnvalues of the dual lane power state machine FSM are not ignored From 6da3d6f06a1a9614720361274d3567007475af09 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Mar 2023 17:45:24 +0100 Subject: [PATCH 4/4] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index a9338149..350e5d77 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit a93381494ac8f908a327f4c9bf4622399d5754a3 +Subproject commit 350e5d77b8113cc9e21eb72242fc37536368f541