From 30f4beb5f692cf9b4c2f3bd1de3acc6d1b8476c7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 25 Feb 2022 20:14:59 +0100 Subject: [PATCH] first sucessfull full transition --- bsp_q7s/core/ObjectFactory.cpp | 17 +++++------ mission/devices/PayloadPcduHandler.cpp | 29 +++++++++++++++++++ mission/devices/PayloadPcduHandler.h | 3 ++ .../payloadPcduDefinitions.h | 4 +-- tmtc | 2 +- 5 files changed, 43 insertions(+), 12 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 7bc30481..2000f3d5 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1170,15 +1170,6 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_DRO, consumer, gpio::DIR_OUT, gpio::Levels::LOW); plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_DRO, gpio); - consumer = "PLPCDU_ENB_HPA"; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_HPA, consumer, gpio::DIR_OUT, - gpio::Levels::LOW); - plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_HPA, gpio); - consumer = "PLPCDU_ENB_MPA"; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_MPA, consumer, gpio::DIR_OUT, - gpio::Levels::LOW); - plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_MPA, gpio); - consumer = "PLPCDU_ENB_X8"; gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_X8, consumer, gpio::DIR_OUT, gpio::Levels::LOW); @@ -1187,6 +1178,14 @@ void ObjectFactory::createPlPcduComponents(LinuxLibgpioIF* gpioComIF, SpiComIF* gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_TX, consumer, gpio::DIR_OUT, gpio::Levels::LOW); plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_TX, gpio); + consumer = "PLPCDU_ENB_MPA"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_MPA, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_MPA, gpio); + consumer = "PLPCDU_ENB_HPA"; + gpio = new GpiodRegularByLineName(q7s::gpioNames::PL_PCDU_ENABLE_HPA, consumer, gpio::DIR_OUT, + gpio::Levels::LOW); + plPcduGpios->addGpio(gpioIds::PLPCDU_ENB_HPA, gpio); // Chip select pin is active low consumer = "PLPCDU_ADC_CS"; diff --git a/mission/devices/PayloadPcduHandler.cpp b/mission/devices/PayloadPcduHandler.cpp index bfa95cb2..c5bad0bf 100644 --- a/mission/devices/PayloadPcduHandler.cpp +++ b/mission/devices/PayloadPcduHandler.cpp @@ -37,6 +37,7 @@ void PayloadPcduHandler::doStartUp() { // 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); @@ -92,6 +93,9 @@ void PayloadPcduHandler::stateMachineToNormal() { params.getValue(PlPcduParameter::DRO_TO_X8_WAIT_TIME_K, waitTime); countdown.setTimeout(std::round(waitTime * 1000)); countdown.resetTimer(); +#if OBSW_VERBOSE_LEVEL >= 1 + 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); @@ -111,6 +115,9 @@ void PayloadPcduHandler::stateMachineToNormal() { params.getValue(PlPcduParameter::X8_TO_TX_WAIT_TIME_K, waitTime); countdown.setTimeout(std::round(waitTime * 1000)); countdown.resetTimer(); +#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); @@ -130,6 +137,9 @@ void PayloadPcduHandler::stateMachineToNormal() { params.getValue(PlPcduParameter::TX_TO_MPA_WAIT_TIME_K, waitTime); countdown.setTimeout(std::round(waitTime * 1000)); countdown.resetTimer(); +#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 @@ -150,6 +160,9 @@ void PayloadPcduHandler::stateMachineToNormal() { params.getValue(PlPcduParameter::MPA_TO_HPA_WAIT_TIME_K, waitTime); countdown.setTimeout(std::round(waitTime * 1000)); countdown.resetTimer(); +#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 @@ -168,6 +181,9 @@ void PayloadPcduHandler::stateMachineToNormal() { if (not commandExecuted) { // Switch on HPA gpioIF->pullHigh(gpioIds::PLPCDU_ENB_HPA); +#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 @@ -212,6 +228,9 @@ ReturnValue_t PayloadPcduHandler::buildTransitionDeviceCommand(DeviceCommandId_t *id = plpcdu::SETUP_CMD; return buildCommandFromCommand(*id, nullptr, 0); } + if (mode == _MODE_TO_NORMAL) { + return buildNormalDeviceCommand(id); + } return NOTHING_TO_SEND; } @@ -479,6 +498,7 @@ void PayloadPcduHandler::checkAdcValues() { return; } } + transitionOk = true; } void PayloadPcduHandler::checkJsonFileInit() { @@ -503,6 +523,7 @@ bool PayloadPcduHandler::checkVoltage(float val, float lowerBound, float upperBo uint32_t p2 = 0; serializeFloat(p2, val); triggerEvent(event, tooLarge, p2); + transitionOk = false; transitionBackToOff(); return false; } @@ -514,12 +535,20 @@ bool PayloadPcduHandler::checkCurrent(float val, float upperBound, Event event) uint32_t p2 = 0; serializeFloat(p2, val); triggerEvent(event, true, p2); + transitionOk = false; transitionBackToOff(); return false; } return true; } +ReturnValue_t PayloadPcduHandler::isModeCombinationValid(Mode_t mode, Submode_t submode) { + if (mode == MODE_NORMAL and submode <= 1) { + return HasReturnvaluesIF::RETURN_OK; + } + return DeviceHandlerBase::isModeCombinationValid(mode, submode); +} + ReturnValue_t PayloadPcduHandler::serializeFloat(uint32_t& param, float val) { size_t dummy = 0; return SerializeAdapter::serialize(&val, reinterpret_cast(¶m), &dummy, 4, diff --git a/mission/devices/PayloadPcduHandler.h b/mission/devices/PayloadPcduHandler.h index 24b864df..519cc795 100644 --- a/mission/devices/PayloadPcduHandler.h +++ b/mission/devices/PayloadPcduHandler.h @@ -33,6 +33,7 @@ class SpiCookie; class PayloadPcduHandler : public DeviceHandlerBase { public: static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PL_PCDU_HANDLER; + //! [EXPORT] : [COMMENT] Could not transition properly and went back to ALL OFF static constexpr Event TRANSITION_BACK_TO_OFF = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); //! [EXPORT] : [COMMENT] P1: 0 -> too low, 1 -> too high P2: Float value @@ -139,6 +140,8 @@ class PayloadPcduHandler : public DeviceHandlerBase { uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; + ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override; + void handleExtConvRead(const uint8_t* bufStart); void handlePrintout(); void checkAdcValues(); diff --git a/mission/devices/devicedefinitions/payloadPcduDefinitions.h b/mission/devices/devicedefinitions/payloadPcduDefinitions.h index eeaeda8c..3af0bd46 100644 --- a/mission/devices/devicedefinitions/payloadPcduDefinitions.h +++ b/mission/devices/devicedefinitions/payloadPcduDefinitions.h @@ -83,8 +83,8 @@ static constexpr float SCALE_CURRENT_DRO = MAX122X_SCALE / (GAIN_INA169 * R_SHUN // TODO: Make these configurable parameters using a JSON file // Upper bound of currents in milliamperes [mA] -static constexpr double NEG_V_LOWER_BOUND = -6.0; -static constexpr double NEG_V_UPPER_BOUND = -3.3; +static constexpr double NEG_V_LOWER_BOUND = -6.5; +static constexpr double NEG_V_UPPER_BOUND = -2.7; static constexpr double DRO_U_LOWER_BOUND = 5.0; static constexpr double DRO_U_UPPER_BOUND = 7.0; diff --git a/tmtc b/tmtc index 7e245891..1238df03 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 7e24589184bb7bbd427c66ed55b3c29bbeba927f +Subproject commit 1238df03834b0b9ddbe2a59565de493661f5476e