From 2fb8ca4aaa2b19acc5ee76435c6ca9d8e74698fa Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 24 Mar 2022 12:48:23 +0100 Subject: [PATCH 01/10] plpcdu refactoring --- mission/devices/PayloadPcduHandler.cpp | 92 +++++++++++++++----------- mission/devices/PayloadPcduHandler.h | 9 +-- 2 files changed, 57 insertions(+), 44 deletions(-) diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index 1d5f4b89..c0c9e771 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -22,54 +22,66 @@ PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, sdcMan(sdcMan) {} void PayloadPcduHandler::doStartUp() { - if ((state != States::PCDU_OFF) and (state != States::ON_TRANS_SSR)) { + if ((state != States::PL_PCDU_OFF) and (state != States::ON_TRANS_SSR)) { // Config error sif::error << "PayloadPcduHandler::doStartUp: Invalid state" << std::endl; } - if (state == States::PCDU_OFF) { - // Switch on relays here - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0); - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1); - state = States::ON_TRANS_SSR; - transitionOk = true; - } - if (state == States::ON_TRANS_SSR) { - // If necessary, check whether a certain amount of time has elapsed - if (transitionOk) { - transitionOk = false; - state = States::ON_TRANS_ADC_CLOSE_ZERO; - // We are now in ON mode - startTransition(MODE_NORMAL, 0); - adcCountdown.setTimeout(50); - adcCountdown.resetTimer(); - adcState = AdcStates::BOOT_DELAY; - // The ADC can now be read. If the values are not close to zero, we should not allow - // transition - monMode = MonitoringMode::CLOSE_TO_ZERO; - } - } + // TODO: Handle switching power on here + // TODO: Go to on mode here instead, indicating that the power is on + // We are now in ON mode + setMode(MODE_ON); } -void PayloadPcduHandler::stateMachineToNormal() { +void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { using namespace plpcdu; - if (adcState == AdcStates::BOOT_DELAY) { - if (adcCountdown.hasTimedOut()) { - adcState = AdcStates::SEND_SETUP; - adcCmdExecuted = false; + if(submode == plpcdu::NORMAL_ALL_ON or submode == plpcdu::NORMAL_ADC_ONLY) { + if(state == States::PL_PCDU_OFF) { + // TODO: Config error, emit error printout + setMode(MODE_OFF); } - } - if (adcState == AdcStates::SEND_SETUP) { - if (adcCmdExecuted) { - adcState = AdcStates::NORMAL; - setMode(MODE_NORMAL, NORMAL_ADC_ONLY); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - adcCmdExecuted = false; + if (state == States::POWER_CHANNELS_ON) { + // Switch on relays here + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0); + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1); + state = States::ON_TRANS_SSR; + transitionOk = true; + } + if (state == States::ON_TRANS_SSR) { + // If necessary, check whether a certain amount of time has elapsed + if (transitionOk) { + transitionOk = false; + state = States::ON_TRANS_ADC_CLOSE_ZERO; + + adcCountdown.setTimeout(50); + adcCountdown.resetTimer(); + adcState = AdcStates::BOOT_DELAY; + // If the values are not close to zero, we should not allow transition + monMode = MonitoringMode::CLOSE_TO_ZERO; + } + } + if(state == States::ON_TRANS_ADC_CLOSE_ZERO) { + if (adcState == AdcStates::BOOT_DELAY) { + if (adcCountdown.hasTimedOut()) { + adcState = AdcStates::SEND_SETUP; + adcCmdExecuted = false; + } + } + if (adcState == AdcStates::SEND_SETUP) { + if (adcCmdExecuted) { + adcState = AdcStates::NORMAL; + if(submode == plpcdu::NORMAL_ADC_ONLY) { + setMode(MODE_NORMAL, NORMAL_ADC_ONLY); + } + adcCountdown.setTimeout(100); + adcCountdown.resetTimer(); + adcCmdExecuted = false; + } + } } } if (submode == plpcdu::NORMAL_ALL_ON) { if (state == States::ON_TRANS_ADC_CLOSE_ZERO) { - if (not commandExecuted) { + if (not commandExecuted and adcState == AdcStates::NORMAL) { float waitTime = DFT_SSR_TO_DRO_WAIT_TIME; params.getValue(PARAM_KEY_MAP[SSR_TO_DRO_WAIT_TIME], waitTime); countdown.setTimeout(std::round(waitTime * 1000)); @@ -188,7 +200,7 @@ void PayloadPcduHandler::stateMachineToNormal() { } // ADC values are ok, 5 seconds have elapsed if (transitionOk and countdown.hasTimedOut()) { - state = States::PCDU_ON; + state = States::PL_PCDU_ON; setMode(MODE_NORMAL, plpcdu::NORMAL_ALL_ON); countdown.resetTimer(); commandExecuted = false; @@ -200,7 +212,7 @@ void PayloadPcduHandler::stateMachineToNormal() { void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { if (mode == _MODE_TO_NORMAL) { - stateMachineToNormal(); + stateMachineToNormal(modeFrom, subModeFrom); } } @@ -398,7 +410,7 @@ void PayloadPcduHandler::transitionBackToOff(bool notifyFdir) { gpioIF->pullLow(gpioIds::PLPCDU_ENB_TX); gpioIF->pullLow(gpioIds::PLPCDU_ENB_VBAT0); gpioIF->pullLow(gpioIds::PLPCDU_ENB_VBAT1); - state = States::PCDU_OFF; + state = States::PL_PCDU_OFF; adcState = AdcStates::OFF; setMode(MODE_OFF); if (notifyFdir) { diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index b1c34359..5fa229b9 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -75,7 +75,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { private: enum class States : uint8_t { - PCDU_OFF, + PL_PCDU_OFF, + POWER_CHANNELS_ON, // Solid State Relay, enable battery voltages VBAT0 and VBAT1. This will also switch on // the ADC ON_TRANS_SSR, @@ -92,8 +93,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { // Switch on HPA component and monitor voltages for 5 seconds ON_TRANS_HPA, // All components of the experiment are on - PCDU_ON, - } state = States::PCDU_OFF; + PL_PCDU_ON, + } state = States::PL_PCDU_OFF; enum class AdcMode { EXT_CONV, INT_CONV } adcMode = AdcMode::INT_CONV; @@ -158,7 +159,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { void checkAdcValues(); void handleOutOfBoundsPrintout(); void checkJsonFileInit(); - void stateMachineToNormal(); + void stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom); bool checkVoltage(float val, float lowerBound, float upperBound, Event event); bool checkCurrent(float val, float upperBound, Event event); void handleFailureInjection(std::string output, Event event); From 0937697637c119c40bdca96489f83fbb1c371b51 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Mar 2022 15:49:39 +0100 Subject: [PATCH 02/10] use transition mode --- mission/devices/PayloadPcduHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index dbd1708d..fbbdfc7d 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -29,7 +29,7 @@ void PayloadPcduHandler::doStartUp() { // TODO: Handle switching power on here // TODO: Go to on mode here instead, indicating that the power is on // We are now in ON mode - setMode(MODE_ON); + setMode(_MODE_TO_ON); } void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { From 74fa98d16120b77312ef9a845f1b99f8a39675e9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Mar 2022 15:56:44 +0100 Subject: [PATCH 03/10] add dual lane power switcher for PL PCDU --- bsp_q7s/core/ObjectFactory.cpp | 12 +++++++----- bsp_q7s/core/ObjectFactory.h | 3 ++- mission/devices/PayloadPcduHandler.cpp | 14 ++++++++------ mission/devices/PayloadPcduHandler.h | 6 +++++- mission/system/TcsBoardAssembly.h | 3 +-- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a499363c..05110f4b 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -148,7 +148,7 @@ void ObjectFactory::produce(void* args) { createHeaterComponents(); createSolarArrayDeploymentComponents(); - createPlPcduComponents(gpioComIF, spiComIF); + createPlPcduComponents(gpioComIF, spiComIF, pwrSwitcher); #if OBSW_ADD_SYRLINKS == 1 createSyrlinksComponents(); #endif /* OBSW_ADD_SYRLINKS == 1 */ @@ -1134,7 +1134,8 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { #endif /* BOARD_TE0720 == 0 */ } -void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF) { +void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, + PowerSwitchIF* pwrSwitcher) { using namespace gpio; // Create all GPIO components first GpioCookie* plPcduGpios = new GpioCookie; @@ -1180,9 +1181,10 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* q7s::SPI_DEFAULT_DEV, plpcdu::MAX_ADC_REPLY_SIZE, spi::DEFAULT_MAX_1227_MODE, spi::PL_PCDU_MAX_1227_SPEED); // Create device handler components - auto plPcduHandler = - new PayloadPcduHandler(objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie, gpioComIF, - SdCardManager::instance(), false); + auto plPcduHandler = new PayloadPcduHandler( + objects::PLPCDU_HANDLER, objects::SPI_COM_IF, spiCookie, gpioComIF, SdCardManager::instance(), + pwrSwitcher, pcduSwitches::Switches::PDU2_CH1_PL_PCDU_BATT_0_14V8, + pcduSwitches::Switches::PDU2_CH6_PL_PCDU_BATT_1_14V8, false); spiCookie->setCallbackMode(PayloadPcduHandler::extConvAsTwoCallback, plPcduHandler); static_cast(plPcduHandler); #if OBSW_TEST_PL_PCDU == 1 diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index ff88db8e..412f498c 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -15,7 +15,8 @@ void produce(void* args); void createCommunicationInterfaces(LinuxLibgpioIF** gpioComIF, UartComIF** uartComIF, SpiComIF** spiComIF, I2cComIF** i2cComIF); void createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchIF** pwrSwitcher); -void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF); +void createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, + PowerSwitchIF* pwrSwitcher); void createTmpComponents(); void createRadSensorComponent(LinuxLibgpioIF* gpioComIF); void createSunSensorComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* spiComIF, diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index fbbdfc7d..d781bdda 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -14,12 +14,14 @@ PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF, SdCardMountedIF* sdcMan, - bool periodicPrintout) + PowerSwitchIF* pwrSwitcher, pcduSwitches::Switches switchA, + pcduSwitches::Switches switchB, bool periodicPrintout) : DeviceHandlerBase(objectId, comIF, cookie), adcSet(this), periodicPrintout(periodicPrintout), gpioIF(gpioIF), - sdcMan(sdcMan) {} + sdcMan(sdcMan), + pwrStateMachine(switchA, switchB, pwrSwitcher) {} void PayloadPcduHandler::doStartUp() { if ((state != States::PL_PCDU_OFF) and (state != States::ON_TRANS_SSR)) { @@ -34,8 +36,8 @@ void PayloadPcduHandler::doStartUp() { void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { using namespace plpcdu; - if(submode == plpcdu::NORMAL_ALL_ON or submode == plpcdu::NORMAL_ADC_ONLY) { - if(state == States::PL_PCDU_OFF) { + if (submode == plpcdu::NORMAL_ALL_ON or submode == plpcdu::NORMAL_ADC_ONLY) { + if (state == States::PL_PCDU_OFF) { // TODO: Config error, emit error printout setMode(MODE_OFF); } @@ -59,7 +61,7 @@ void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subMode monMode = MonitoringMode::CLOSE_TO_ZERO; } } - if(state == States::ON_TRANS_ADC_CLOSE_ZERO) { + if (state == States::ON_TRANS_ADC_CLOSE_ZERO) { if (adcState == AdcStates::BOOT_DELAY) { if (adcCountdown.hasTimedOut()) { adcState = AdcStates::SEND_SETUP; @@ -69,7 +71,7 @@ void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subMode if (adcState == AdcStates::SEND_SETUP) { if (adcCmdExecuted) { adcState = AdcStates::NORMAL; - if(submode == plpcdu::NORMAL_ADC_ONLY) { + if (submode == plpcdu::NORMAL_ADC_ONLY) { setMode(MODE_NORMAL, NORMAL_ADC_ONLY); } adcCountdown.setTimeout(100); diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index 5fa229b9..e99c737e 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -4,6 +4,7 @@ #include #include #include +#include #include "events/subsystemIdRanges.h" #include "fsfw/FSFW.h" @@ -60,7 +61,9 @@ class PayloadPcduHandler : public DeviceHandlerBase { static constexpr Event I_HPA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 11, severity::MEDIUM); PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF, - SdCardMountedIF* sdcMan, bool periodicPrintout); + SdCardMountedIF* sdcMan, PowerSwitchIF* pwrSwitcher, + pcduSwitches::Switches switchA, pcduSwitches::Switches switchB, + bool periodicPrintout); void setToGoToNormalModeImmediately(bool enable); void enablePeriodicPrintout(bool enable, uint8_t divider); @@ -133,6 +136,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { PoolEntry processedValues = PoolEntry({0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}); PoolEntry tempC = PoolEntry({0.0}); + DualLanePowerStateMachine pwrStateMachine; void doTransition(Mode_t modeFrom, Submode_t subModeFrom) override; void doStartUp() override; diff --git a/mission/system/TcsBoardAssembly.h b/mission/system/TcsBoardAssembly.h index cda78317..832f335d 100644 --- a/mission/system/TcsBoardAssembly.h +++ b/mission/system/TcsBoardAssembly.h @@ -14,8 +14,7 @@ struct TcsBoardHelper { class TcsBoardAssembly : public AssemblyBase, public ConfirmsFailuresIF { public: static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::TCS_BOARD_ASS; - static constexpr Event CHILDREN_LOST_MODE = - event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + static constexpr Event CHILDREN_LOST_MODE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); TcsBoardAssembly(object_id_t objectId, object_id_t parentId, PowerSwitchIF* pwrSwitcher, power::Switch_t switcher, TcsBoardHelper helper); From f88a063d83c047c4d189ce14ec14dde115cd9dbe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Mar 2022 16:01:44 +0100 Subject: [PATCH 04/10] change to more generic type --- common/config/devices/powerSwitcherList.h | 5 ++++- mission/devices/PayloadPcduHandler.cpp | 4 ++-- mission/devices/PayloadPcduHandler.h | 5 ++--- mission/system/DualLanePowerStateMachine.cpp | 4 ++-- mission/system/DualLanePowerStateMachine.h | 6 +++--- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/common/config/devices/powerSwitcherList.h b/common/config/devices/powerSwitcherList.h index f99e0930..f77a3685 100644 --- a/common/config/devices/powerSwitcherList.h +++ b/common/config/devices/powerSwitcherList.h @@ -3,12 +3,15 @@ #include "OBSWConfig.h" +#include + #include #include namespace pcduSwitches { + /* Switches are uint8_t datatype and go from 0 to 255 */ -enum Switches: uint8_t { +enum Switches: power::Switch_t { PDU1_CH0_TCS_BOARD_3V3, PDU1_CH1_SYRLINKS_12V, PDU1_CH2_STAR_TRACKER_5V, diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index d781bdda..e21c1467 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -14,8 +14,8 @@ PayloadPcduHandler::PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF, SdCardMountedIF* sdcMan, - PowerSwitchIF* pwrSwitcher, pcduSwitches::Switches switchA, - pcduSwitches::Switches switchB, bool periodicPrintout) + PowerSwitchIF* pwrSwitcher, power::Switch_t switchA, + power::Switch_t switchB, bool periodicPrintout) : DeviceHandlerBase(objectId, comIF, cookie), adcSet(this), periodicPrintout(periodicPrintout), diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index e99c737e..7a30e297 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -61,9 +61,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { static constexpr Event I_HPA_OUT_OF_BOUNDS = event::makeEvent(SUBSYSTEM_ID, 11, severity::MEDIUM); PayloadPcduHandler(object_id_t objectId, object_id_t comIF, CookieIF* cookie, GpioIF* gpioIF, - SdCardMountedIF* sdcMan, PowerSwitchIF* pwrSwitcher, - pcduSwitches::Switches switchA, pcduSwitches::Switches switchB, - bool periodicPrintout); + SdCardMountedIF* sdcMan, PowerSwitchIF* pwrSwitcher, power::Switch_t switchCh0, + power::Switch_t switchCh1, bool periodicPrintout); void setToGoToNormalModeImmediately(bool enable); void enablePeriodicPrintout(bool enable, uint8_t divider); diff --git a/mission/system/DualLanePowerStateMachine.cpp b/mission/system/DualLanePowerStateMachine.cpp index 666e1d1e..5669ef7d 100644 --- a/mission/system/DualLanePowerStateMachine.cpp +++ b/mission/system/DualLanePowerStateMachine.cpp @@ -3,8 +3,8 @@ #include #include -DualLanePowerStateMachine::DualLanePowerStateMachine(pcduSwitches::Switches switchA, - pcduSwitches::Switches switchB, +DualLanePowerStateMachine::DualLanePowerStateMachine(power::Switch_t switchA, + power::Switch_t switchB, PowerSwitchIF* pwrSwitcher, dur_millis_t checkTimeout) : PowerStateMachineBase(pwrSwitcher, checkTimeout), SWITCH_A(switchA), SWITCH_B(switchB) {} diff --git a/mission/system/DualLanePowerStateMachine.h b/mission/system/DualLanePowerStateMachine.h index e22e7ae4..d2160c64 100644 --- a/mission/system/DualLanePowerStateMachine.h +++ b/mission/system/DualLanePowerStateMachine.h @@ -12,12 +12,12 @@ class PowerSwitchIF; class DualLanePowerStateMachine : public PowerStateMachineBase { public: - DualLanePowerStateMachine(pcduSwitches::Switches switchA, pcduSwitches::Switches switchB, + DualLanePowerStateMachine(power::Switch_t switchA, power::Switch_t switchB, PowerSwitchIF* pwrSwitcher, dur_millis_t checkTimeout = 5000); power::OpCodes fsm() override; - const pcduSwitches::Switches SWITCH_A; - const pcduSwitches::Switches SWITCH_B; + const power::Switch_t SWITCH_A; + const power::Switch_t SWITCH_B; private: }; From 6e25cf912f261ce79304b4693e591ec3efb31d2d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Mar 2022 10:34:03 +0200 Subject: [PATCH 05/10] tmtc update --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index 43a534db..bca8d5d0 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 43a534db9cf8ee14e6c1296dac8b3e2c3c94b240 +Subproject commit bca8d5d05d25812b4e112ac0544b24915ec01971 From 66029cb47aebfb18ea2a19b8949e3afa3359fe94 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Mar 2022 12:23:56 +0200 Subject: [PATCH 06/10] implemented switch handling --- fsfw | 2 +- mission/devices/PayloadPcduHandler.cpp | 51 ++++++++++++++++++++------ mission/devices/PayloadPcduHandler.h | 8 +++- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/fsfw b/fsfw index e6130263..6ea1eabb 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit e6130263ef144c5b1f6eafef734a0150a92d6cda +Subproject commit 6ea1eabb2dd3688f2c7db484cd141f15c9f4fe49 diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index e21c1467..b6c8a6a6 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -28,17 +28,39 @@ void PayloadPcduHandler::doStartUp() { // Config error sif::error << "PayloadPcduHandler::doStartUp: Invalid state" << std::endl; } - // TODO: Handle switching power on here - // TODO: Go to on mode here instead, indicating that the power is on - // We are now in ON mode - setMode(_MODE_TO_ON); + if (pwrStateMachine.getState() == power::States::IDLE) { + pwrStateMachine.start(MODE_ON, pwrSubmode); + } + auto opCode = pwrStateMachine.fsm(); + if (opCode == power::OpCodes::TO_NOT_OFF_DONE or opCode == power::OpCodes::TIMEOUT_OCCURED) { + pwrStateMachine.reset(); + quickTransitionAlreadyCalled = false; + setMode(_MODE_TO_ON); + } +} + +void PayloadPcduHandler::doShutDown() { + if (not quickTransitionAlreadyCalled) { + quickTransitionBackToOff(false, false); + quickTransitionAlreadyCalled = true; + } + if (pwrStateMachine.getState() == power::States::IDLE) { + pwrStateMachine.start(MODE_OFF, 0); + } + auto opCode = pwrStateMachine.fsm(); + if (opCode == power::OpCodes::TO_OFF_DONE or opCode == power::OpCodes::TIMEOUT_OCCURED) { + pwrStateMachine.reset(); + // No need to set mode _MODE_POWER_DOWN, power switching was already handled + setMode(MODE_OFF); + } } void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { using namespace plpcdu; if (submode == plpcdu::NORMAL_ALL_ON or submode == plpcdu::NORMAL_ADC_ONLY) { if (state == States::PL_PCDU_OFF) { - // TODO: Config error, emit error printout + sif::error << "PayloadPcduHandler::stateMachineToNormal: Unexpected state PL_PCDU_OFF" + << "detected" << std::endl; setMode(MODE_OFF); } if (state == States::POWER_CHANNELS_ON) { @@ -215,11 +237,11 @@ void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subMode void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { if (mode == _MODE_TO_NORMAL) { stateMachineToNormal(modeFrom, subModeFrom); + return; } + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); } -void PayloadPcduHandler::doShutDown() { transitionBackToOff(false); } - ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { switch (adcState) { case (AdcStates::SEND_SETUP): { @@ -402,7 +424,7 @@ void PayloadPcduHandler::enablePeriodicPrintout(bool enable, uint8_t divider) { opDivider.setDivider(divider); } -void PayloadPcduHandler::transitionBackToOff(bool notifyFdir) { +void PayloadPcduHandler::quickTransitionBackToOff(bool startTransitionToOff, bool notifyFdir) { States currentState = state; gpioIF->pullLow(gpioIds::PLPCDU_ENB_HPA); gpioIF->pullLow(gpioIds::PLPCDU_ENB_MPA); @@ -414,7 +436,9 @@ void PayloadPcduHandler::transitionBackToOff(bool notifyFdir) { gpioIF->pullLow(gpioIds::PLPCDU_ENB_VBAT1); state = States::PL_PCDU_OFF; adcState = AdcStates::OFF; - setMode(MODE_OFF); + if (startTransitionToOff) { + startTransition(MODE_OFF, 0); + } if (notifyFdir) { triggerEvent(TRANSITION_BACK_TO_OFF, static_cast(currentState)); } @@ -568,7 +592,8 @@ bool PayloadPcduHandler::checkVoltage(float val, float lowerBound, float upperBo serializeFloat(p2, val); triggerEvent(event, tooLarge, p2); transitionOk = false; - transitionBackToOff(true); + quickTransitionBackToOff(true, true); + quickTransitionAlreadyCalled = true; return false; } return true; @@ -580,7 +605,8 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) serializeFloat(p2, val); triggerEvent(event, true, p2); transitionOk = false; - transitionBackToOff(true); + quickTransitionBackToOff(true, true); + quickTransitionAlreadyCalled = true; return false; } return true; @@ -670,7 +696,8 @@ void PayloadPcduHandler::handleFailureInjection(std::string output, Event event) << std::endl; triggerEvent(event, 0, 0); transitionOk = false; - transitionBackToOff(true); + quickTransitionBackToOff(true, true); + quickTransitionAlreadyCalled = true; droToX8InjectionRequested = false; } diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index 7a30e297..62c6f728 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -4,13 +4,14 @@ #include #include #include -#include #include "events/subsystemIdRanges.h" #include "fsfw/FSFW.h" #include "fsfw_hal/common/gpio/GpioIF.h" #include "mission/devices/devicedefinitions/payloadPcduDefinitions.h" #include "mission/memory/SdCardMountedIF.h" +#include "mission/system/DualLanePowerStateMachine.h" +#include "mission/system/definitions.h" #ifdef FSFW_OSAL_LINUX class SpiComIF; @@ -98,6 +99,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { PL_PCDU_ON, } state = States::PL_PCDU_OFF; + duallane::Submodes pwrSubmode = duallane::Submodes::A_SIDE; + enum class AdcMode { EXT_CONV, INT_CONV } adcMode = AdcMode::INT_CONV; enum class MonitoringMode { NONE, CLOSE_TO_ZERO, NEGATIVE } monMode = MonitoringMode::NONE; @@ -130,6 +133,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { GpioIF* gpioIF; SdCardMountedIF* sdcMan; plpcdu::PlPcduParameter params; + bool quickTransitionAlreadyCalled = true; PoolEntry channelValues = PoolEntry({0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}); PoolEntry processedValues = @@ -141,7 +145,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { void doStartUp() override; void doShutDown() override; // Main FDIR function which goes from any PL PCDU state back to all off - void transitionBackToOff(bool notifyFdir); + void quickTransitionBackToOff(bool startTransitionToOff, bool notifyFdir); ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t* id) override; ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t* id) override; void fillCommandAndReplyMap() override; From 6fa975cc74c9478063a56fa255e3b65252d7aef3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Mar 2022 15:29:42 +0200 Subject: [PATCH 07/10] simplified PL PCDU --- fsfw | 2 +- mission/devices/PayloadPcduHandler.cpp | 207 +++++++----------- mission/devices/PayloadPcduHandler.h | 2 +- .../payloadPcduDefinitions.h | 10 + tmtc | 2 +- 5 files changed, 92 insertions(+), 131 deletions(-) diff --git a/fsfw b/fsfw index 6ea1eabb..283a37dc 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 6ea1eabb2dd3688f2c7db484cd141f15c9f4fe49 +Subproject commit 283a37dccc064b71a0e4ca5c483c9a5a5241d355 diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index b6c8a6a6..a3652193 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -35,6 +35,7 @@ void PayloadPcduHandler::doStartUp() { if (opCode == power::OpCodes::TO_NOT_OFF_DONE or opCode == power::OpCodes::TIMEOUT_OCCURED) { pwrStateMachine.reset(); quickTransitionAlreadyCalled = false; + state = States::POWER_CHANNELS_ON; setMode(_MODE_TO_ON); } } @@ -55,13 +56,22 @@ void PayloadPcduHandler::doShutDown() { } } -void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { +void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { + if (mode == _MODE_TO_NORMAL) { + stateMachineToNormal(modeFrom, subModeFrom); + return; + } + DeviceHandlerBase::doTransition(modeFrom, subModeFrom); +} + +ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom) { using namespace plpcdu; - if (submode == plpcdu::NORMAL_ALL_ON or submode == plpcdu::NORMAL_ADC_ONLY) { + if (submode == NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON) { if (state == States::PL_PCDU_OFF) { sif::error << "PayloadPcduHandler::stateMachineToNormal: Unexpected state PL_PCDU_OFF" << "detected" << std::endl; setMode(MODE_OFF); + return HasReturnvaluesIF::RETURN_FAILED; } if (state == States::POWER_CHANNELS_ON) { // Switch on relays here @@ -93,153 +103,73 @@ void PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_t subMode if (adcState == AdcStates::SEND_SETUP) { if (adcCmdExecuted) { adcState = AdcStates::NORMAL; - if (submode == plpcdu::NORMAL_ADC_ONLY) { - setMode(MODE_NORMAL, NORMAL_ADC_ONLY); - } adcCountdown.setTimeout(100); adcCountdown.resetTimer(); adcCmdExecuted = false; + if (submode == plpcdu::NORMAL_ADC_ONLY) { + setMode(MODE_NORMAL, submode); + return HasReturnvaluesIF::RETURN_OK; + } } } } } - if (submode == plpcdu::NORMAL_ALL_ON) { - if (state == States::ON_TRANS_ADC_CLOSE_ZERO) { - if (not commandExecuted and adcState == AdcStates::NORMAL) { - float waitTime = DFT_SSR_TO_DRO_WAIT_TIME; - params.getValue(PARAM_KEY_MAP[SSR_TO_DRO_WAIT_TIME], waitTime); - countdown.setTimeout(std::round(waitTime * 1000)); - countdown.resetTimer(); - commandExecuted = true; - // TODO: For now, skip ADC check - transitionOk = true; - } - // ADC values are ok, 5 seconds have elapsed - if (transitionOk and countdown.hasTimedOut()) { - state = States::ON_TRANS_DRO; - // Now start monitoring for negative voltages instead - monMode = MonitoringMode::NEGATIVE; - commandExecuted = false; - transitionOk = false; - } - } - if (state == States::ON_TRANS_DRO) { - if (not commandExecuted) { - float waitTime = DFT_DRO_TO_X8_WAIT_TIME; - params.getValue(PARAM_KEY_MAP[DRO_TO_X8_WAIT_TIME], waitTime); - countdown.setTimeout(std::round(waitTime * 1000)); - countdown.resetTimer(); + + if (submode == NormalSubmodes::DRO_ON) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU DRO module" << std::endl; + sif::info << "Enabling PL PCDU DRO module" << std::endl; #endif - // Switch on DRO and start monitoring for negative voltages - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - commandExecuted = true; - } - // ADC values are ok, 5 seconds have elapsed - if (transitionOk and countdown.hasTimedOut()) { - state = States::ON_TRANS_X8; - commandExecuted = false; - transitionOk = false; - } - } - if (state == States::ON_TRANS_X8) { - if (not commandExecuted) { - float waitTime = DFT_X8_TO_TX_WAIT_TIME; - params.getValue(PARAM_KEY_MAP[X8_TO_TX_WAIT_TIME], waitTime); - countdown.setTimeout(std::round(waitTime * 1000)); - countdown.resetTimer(); + // Switch on DRO and start monitoring for negative voltages + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO); + adcCountdown.setTimeout(100); + adcCountdown.resetTimer(); + setMode(MODE_NORMAL, submode); + } + + if (submode == NormalSubmodes::X8_ON) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU X8 module" << std::endl; #endif - // Switch on X8 - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8); - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - commandExecuted = true; - } - // ADC values are ok, 5 seconds have elapsed - if (transitionOk and countdown.hasTimedOut()) { - state = States::ON_TRANS_TX; - commandExecuted = false; - transitionOk = false; - } - } - if (state == States::ON_TRANS_TX) { - if (not commandExecuted) { - float waitTime = DFT_TX_TO_MPA_WAIT_TIME; - params.getValue(PARAM_KEY_MAP[TX_TO_MPA_WAIT_TIME], waitTime); - countdown.setTimeout(std::round(waitTime * 1000)); - countdown.resetTimer(); + // Switch on DRO and start monitoring for negative voltages + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO); + adcCountdown.setTimeout(100); + adcCountdown.resetTimer(); + setMode(MODE_NORMAL, submode); + } + + if (submode == NormalSubmodes::TX_ON) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU TX module" << std::endl; #endif - // Switch on TX - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX); - // Wait for 100 ms before checking ADC values - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - commandExecuted = true; - } - // ADC values are ok, 5 seconds have elapsed - if (transitionOk and countdown.hasTimedOut()) { - state = States::ON_TRANS_MPA; - commandExecuted = false; - transitionOk = false; - } - } - if (state == States::ON_TRANS_MPA) { - if (not commandExecuted) { - float waitTime = DFT_MPA_TO_HPA_WAIT_TIME; - params.getValue(PARAM_KEY_MAP[MPA_TO_HPA_WAIT_TIME], waitTime); - countdown.setTimeout(std::round(waitTime * 1000)); - countdown.resetTimer(); + // Switch on DRO and start monitoring for negative voltages + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX); + adcCountdown.setTimeout(100); + adcCountdown.resetTimer(); + setMode(MODE_NORMAL, submode); + } + + if (submode == NormalSubmodes::MPA_ON) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU MPA module" << std::endl; #endif - // Switch on MPA - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA); - // Wait for 100 ms before checking ADC values - adcCountdown.setTimeout(100); - adcCountdown.resetTimer(); - commandExecuted = true; - } - // ADC values are ok, 5 seconds have elapsed - if (transitionOk and countdown.hasTimedOut()) { - state = States::ON_TRANS_HPA; - commandExecuted = false; - transitionOk = false; - } - } - if (state == States::ON_TRANS_HPA) { - if (not commandExecuted) { - // Switch on HPA - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA); + // Switch on DRO and start monitoring for negative voltages + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA); + adcCountdown.setTimeout(100); + adcCountdown.resetTimer(); + setMode(MODE_NORMAL, submode); + } + + if (submode == NormalSubmodes::HPA_ON) { #if OBSW_VERBOSE_LEVEL >= 1 sif::info << "Enabling PL PCDU HPA module" << std::endl; #endif - commandExecuted = true; - } - // ADC values are ok, 5 seconds have elapsed - if (transitionOk and countdown.hasTimedOut()) { - state = States::PL_PCDU_ON; - setMode(MODE_NORMAL, plpcdu::NORMAL_ALL_ON); - countdown.resetTimer(); - commandExecuted = false; - transitionOk = false; - } - } + // Switch on DRO and start monitoring for negative voltages + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA); + adcCountdown.setTimeout(100); + adcCountdown.resetTimer(); + setMode(MODE_NORMAL, submode); } -} - -void PayloadPcduHandler::doTransition(Mode_t modeFrom, Submode_t subModeFrom) { - if (mode == _MODE_TO_NORMAL) { - stateMachineToNormal(modeFrom, subModeFrom); - return; - } - DeviceHandlerBase::doTransition(modeFrom, subModeFrom); + return RETURN_OK; } ReturnValue_t PayloadPcduHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { @@ -613,7 +543,28 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) } ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { - if (mode == MODE_NORMAL and submode <= 1) { + using namespace plpcdu; + if (mode == MODE_NORMAL) { + if (submode == NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON and + this->submode != NormalSubmodes::ALL_OFF) { + return TRANS_NOT_ALLOWED; + } + if ((submode == NormalSubmodes::DRO_ON and + this->submode != NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON)) { + return TRANS_NOT_ALLOWED; + } + if ((submode == NormalSubmodes::X8_ON and this->submode != NormalSubmodes::DRO_ON)) { + return TRANS_NOT_ALLOWED; + } + if ((submode == NormalSubmodes::TX_ON and this->submode != NormalSubmodes::X8_ON)) { + return TRANS_NOT_ALLOWED; + } + if ((submode == NormalSubmodes::MPA_ON and this->submode != NormalSubmodes::MPA_ON)) { + return TRANS_NOT_ALLOWED; + } + if ((submode == NormalSubmodes::HPA_ON and this->submode != NormalSubmodes::MPA_ON)) { + return TRANS_NOT_ALLOWED; + } return HasReturnvaluesIF::RETURN_OK; } return DeviceHandlerBase::isModeCombinationValid(mode, submode); diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index 62c6f728..18311ec8 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -166,7 +166,7 @@ class PayloadPcduHandler : public DeviceHandlerBase { void checkAdcValues(); void handleOutOfBoundsPrintout(); void checkJsonFileInit(); - void stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom); + ReturnValue_t stateMachineToNormal(Mode_t modeFrom, Submode_t subModeFrom); bool checkVoltage(float val, float lowerBound, float upperBound, Event event); bool checkCurrent(float val, float upperBound, Event event); void handleFailureInjection(std::string output, Event event); diff --git a/mission/devices/devicedefinitions/payloadPcduDefinitions.h b/mission/devices/devicedefinitions/payloadPcduDefinitions.h index b6ce949e..89523fad 100644 --- a/mission/devices/devicedefinitions/payloadPcduDefinitions.h +++ b/mission/devices/devicedefinitions/payloadPcduDefinitions.h @@ -94,6 +94,16 @@ static constexpr DeviceCommandId_t READ_WITH_TEMP_EXT = 3; static constexpr Submode_t NORMAL_ADC_ONLY = 0; static constexpr Submode_t NORMAL_ALL_ON = 1; +enum NormalSubmodes { + ALL_OFF = 0, + SOLID_STATE_RELAYS_ADC_ON = 1, + DRO_ON = 2, + X8_ON = 3, + TX_ON = 4, + MPA_ON = 5, + HPA_ON = 6 +}; + // 12 ADC values * 2 + trailing zero static constexpr size_t ADC_REPLY_SIZE = 25; // Conversion byte + 24 * zero diff --git a/tmtc b/tmtc index bca8d5d0..e3743042 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit bca8d5d05d25812b4e112ac0544b24915ec01971 +Subproject commit e37430423e814b9e05f25d63970f2c2b5048cfb1 From f2f350116f4b42ea725c684903a55927ae8e7a82 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Mar 2022 12:09:17 +0200 Subject: [PATCH 08/10] tmtc update --- mission/devices/PayloadPcduHandler.cpp | 3 ++- tmtc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index c9574b83..60bf26a0 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -547,8 +547,9 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { using namespace plpcdu; if (mode == MODE_NORMAL) { + // Also deals with the case where the mode is MODE_ON, submode should be 0 here if (submode == NormalSubmodes::SOLID_STATE_RELAYS_ADC_ON and - this->submode != NormalSubmodes::ALL_OFF) { + (this->mode == MODE_NORMAL and this->submode != NormalSubmodes::ALL_OFF)) { return TRANS_NOT_ALLOWED; } if ((submode == NormalSubmodes::DRO_ON and diff --git a/tmtc b/tmtc index e3743042..b5a9dac8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit e37430423e814b9e05f25d63970f2c2b5048cfb1 +Subproject commit b5a9dac8f6d3733779a67a72b14a20091069a346 From ac0e1aebbae9cd1feebb21c788a310cad4e132bc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Mar 2022 23:01:38 +0200 Subject: [PATCH 09/10] minor bugfix, works now --- mission/devices/PayloadPcduHandler.cpp | 17 +++++++++-------- .../devicedefinitions/payloadPcduDefinitions.h | 3 --- mission/system/PlPcduAssembly.cpp | 1 - mission/system/PlPcduAssembly.h | 4 ---- 4 files changed, 9 insertions(+), 16 deletions(-) delete mode 100644 mission/system/PlPcduAssembly.cpp delete mode 100644 mission/system/PlPcduAssembly.h diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index 60bf26a0..36835051 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -74,6 +74,9 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ return HasReturnvaluesIF::RETURN_FAILED; } if (state == States::POWER_CHANNELS_ON) { +#if OBSW_VERBOSE_LEVEL >= 1 + sif::info << "Switching on SSR VBAT0 & VBAT1 GPIOs" << std::endl; +#endif // Switch on relays here gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0); gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT1); @@ -106,10 +109,8 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ adcCountdown.setTimeout(100); adcCountdown.resetTimer(); adcCmdExecuted = false; - if (submode == plpcdu::NORMAL_ADC_ONLY) { - setMode(MODE_NORMAL, submode); - return HasReturnvaluesIF::RETURN_OK; - } + setMode(MODE_NORMAL, submode); + return HasReturnvaluesIF::RETURN_OK; } } } @@ -128,7 +129,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ if (submode == NormalSubmodes::X8_ON) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU X8 module" << std::endl; + sif::info << "Enabling PL PCDU X8 module" << std::endl; #endif // Switch on DRO and start monitoring for negative voltages gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO); @@ -139,7 +140,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ if (submode == NormalSubmodes::TX_ON) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU TX module" << std::endl; + sif::info << "Enabling PL PCDU TX module" << std::endl; #endif // Switch on DRO and start monitoring for negative voltages gpioIF->pullHigh(gpioIds::PLPCDU_ENB_TX); @@ -150,7 +151,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ if (submode == NormalSubmodes::MPA_ON) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU MPA module" << std::endl; + sif::info << "Enabling PL PCDU MPA module" << std::endl; #endif // Switch on DRO and start monitoring for negative voltages gpioIF->pullHigh(gpioIds::PLPCDU_ENB_MPA); @@ -161,7 +162,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ if (submode == NormalSubmodes::HPA_ON) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Enabling PL PCDU HPA module" << std::endl; + sif::info << "Enabling PL PCDU HPA module" << std::endl; #endif // Switch on DRO and start monitoring for negative voltages gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA); diff --git a/mission/devices/devicedefinitions/payloadPcduDefinitions.h b/mission/devices/devicedefinitions/payloadPcduDefinitions.h index 34a3847a..3013cb82 100644 --- a/mission/devices/devicedefinitions/payloadPcduDefinitions.h +++ b/mission/devices/devicedefinitions/payloadPcduDefinitions.h @@ -91,9 +91,6 @@ static constexpr DeviceCommandId_t SETUP_CMD = 1; static constexpr DeviceCommandId_t READ_TEMP_EXT = 2; static constexpr DeviceCommandId_t READ_WITH_TEMP_EXT = 3; -static constexpr Submode_t NORMAL_ADC_ONLY = 0; -static constexpr Submode_t NORMAL_ALL_ON = 1; - enum NormalSubmodes { ALL_OFF = 0, SOLID_STATE_RELAYS_ADC_ON = 1, diff --git a/mission/system/PlPcduAssembly.cpp b/mission/system/PlPcduAssembly.cpp deleted file mode 100644 index 88403be2..00000000 --- a/mission/system/PlPcduAssembly.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "PlPcduAssembly.h" diff --git a/mission/system/PlPcduAssembly.h b/mission/system/PlPcduAssembly.h deleted file mode 100644 index d74a6693..00000000 --- a/mission/system/PlPcduAssembly.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef MISSION_SYSTEM_PLPCDUASSEMBLY_H_ -#define MISSION_SYSTEM_PLPCDUASSEMBLY_H_ - -#endif /* MISSION_SYSTEM_PLPCDUASSEMBLY_H_ */ From 637941e089caae1abf5515753ab4b862e6bafe49 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 31 Mar 2022 14:40:42 +0200 Subject: [PATCH 10/10] important bugfixes --- linux/fsfwconfig/OBSWConfig.h.in | 6 +++--- mission/devices/PayloadPcduHandler.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 69e6744b..a3ef335c 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -50,7 +50,7 @@ debugging. */ #define OBSW_ADD_RTD_DEVICES 1 #define OBSW_ADD_TMP_DEVICES 0 #define OBSW_ADD_RAD_SENSORS 1 -#define OBSW_ADD_PL_PCDU 0 +#define OBSW_ADD_PL_PCDU 1 #define OBSW_ADD_SYRLINKS 0 #define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0 #define OBSW_STAR_TRACKER_GROUND_CONFIG 1 @@ -88,10 +88,10 @@ debugging. */ #define OBSW_ADD_PL_PCDU 0 #define OBSW_ADD_SYRLINKS 0 #define OBSW_ENABLE_SYRLINKS_TRANSMIT_TIMEOUT 0 -#define OBSW_SYRLINKS_SIMULATED 1 +#define OBSW_SYRLINKS_SIMULATED 1 #define OBSW_STAR_TRACKER_GROUND_CONFIG 1 #define OBSW_ENABLE_PERIODIC_HK 0 -#define OBSW_PRINT_CORE_HK 0 +#define OBSW_PRINT_CORE_HK 0 #define OBSW_INITIALIZE_SWITCHES 0 #endif diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index 36835051..7a1924c1 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -75,7 +75,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ } if (state == States::POWER_CHANNELS_ON) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::info << "Switching on SSR VBAT0 & VBAT1 GPIOs" << std::endl; + sif::info << "Switching on SSR VBAT0 & VBAT1 GPIOs" << std::endl; #endif // Switch on relays here gpioIF->pullHigh(gpioIds::PLPCDU_ENB_VBAT0); @@ -132,7 +132,7 @@ ReturnValue_t PayloadPcduHandler::stateMachineToNormal(Mode_t modeFrom, Submode_ sif::info << "Enabling PL PCDU X8 module" << std::endl; #endif // Switch on DRO and start monitoring for negative voltages - gpioIF->pullHigh(gpioIds::PLPCDU_ENB_DRO); + gpioIF->pullHigh(gpioIds::PLPCDU_ENB_X8); adcCountdown.setTimeout(100); adcCountdown.resetTimer(); setMode(MODE_NORMAL, submode); @@ -563,7 +563,7 @@ ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t if ((submode == NormalSubmodes::TX_ON and this->submode != NormalSubmodes::X8_ON)) { return TRANS_NOT_ALLOWED; } - if ((submode == NormalSubmodes::MPA_ON and this->submode != NormalSubmodes::MPA_ON)) { + if ((submode == NormalSubmodes::MPA_ON and this->submode != NormalSubmodes::TX_ON)) { return TRANS_NOT_ALLOWED; } if ((submode == NormalSubmodes::HPA_ON and this->submode != NormalSubmodes::MPA_ON)) {