From a0ad48d169bf54966c4f3908e4e0ea08d888d36c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:24:39 +0100 Subject: [PATCH 01/23] start adding heater info set --- mission/controller/ThermalController.cpp | 1 + mission/controller/ThermalController.h | 1 + .../ThermalControllerDefinitions.h | 25 +++++++++++++++---- tmtc | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index f0356f66..6f7b7193 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -19,6 +19,7 @@ ThermalController::ThermalController(object_id_t objectId) sensorTemperatures(this), susTemperatures(this), deviceTemperatures(this), + heaterInfo(this), max31865Set0(objects::RTD_0_IC3_PLOC_HEATSPREADER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), max31865Set1(objects::RTD_1_IC4_PLOC_MISSIONBOARD, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 5f4569c3..1783e932 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -37,6 +37,7 @@ class ThermalController : public ExtendedControllerBase { thermalControllerDefinitions::SensorTemperatures sensorTemperatures; thermalControllerDefinitions::SusTemperatures susTemperatures; thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; + thermalControllerDefinitions::HeaterInfo heaterInfo; // Temperature Sensors MAX31865::Max31865Set max31865Set0; diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index 9f800bec..89a1d10e 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -3,14 +3,16 @@ #include #include +#include "devices/heaterSwitcherList.h" namespace thermalControllerDefinitions { enum SetIds : uint32_t { - SENSOR_TEMPERATURES, - DEVICE_TEMPERATURES, - SUS_TEMPERATURES, - COMPONENT_TEMPERATURES + SENSOR_TEMPERATURES = 0, + DEVICE_TEMPERATURES = 1, + SUS_TEMPERATURES = 2, + COMPONENT_TEMPERATURES = 3, + HEATER_SET = 4, }; enum PoolIds : lp_id_t { @@ -75,7 +77,10 @@ enum PoolIds : lp_id_t { TEMP_GYRO_3_SIDE_B, TEMP_MGM_0_SIDE_A, TEMP_MGM_2_SIDE_B, - TEMP_ADC_PAYLOAD_PCDU + TEMP_ADC_PAYLOAD_PCDU, + + HEATER_SWITCH_LIST, + HEATER_CURRENT }; static const uint8_t ENTRIES_SENSOR_TEMPERATURE_SET = 25; @@ -201,6 +206,16 @@ class SusTemperatures : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SUS_11_R_LOC_XBYMZB_PT_ZB, this); }; +class HeaterInfo: public StaticLocalDataSet<12> { +public: + HeaterInfo(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, HEATER_SET) {} + HeaterInfo(object_id_t objectId): StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} + + lp_vec_t heaterSwitchState = + lp_vec_t(sid.objectId, PoolIds::HEATER_SWITCH_LIST, this); + lp_var_t heaterCurrent = lp_var_t(sid.objectId, PoolIds::HEATER_CURRENT, this); +}; + } // namespace thermalControllerDefinitions #endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ */ diff --git a/tmtc b/tmtc index 49f27c99..5998aa12 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 49f27c9923cfa13a3bafce46c37dd2631550f4af +Subproject commit 5998aa12a4750584eb474b5d936fa461e9725154 From 485ee2f8e0e32f987c98650c8afa808cc4ff94c7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:35:56 +0100 Subject: [PATCH 02/23] base line heater info set --- mission/controller/ThermalController.cpp | 4 ++++ mission/controller/ThermalController.h | 12 +++++++----- .../ThermalControllerDefinitions.h | 12 +++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 6f7b7193..35391599 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -205,6 +205,8 @@ ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& lo new PoolEntry({0.0})); localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_ADC_PAYLOAD_PCDU, new PoolEntry({0.0})); + localDataPoolMap.emplace(thermalControllerDefinitions::HEATER_SWITCH_LIST, &heaterSwitchStates); + localDataPoolMap.emplace(thermalControllerDefinitions::HEATER_CURRENT, &heaterCurrent); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(sensorTemperatures.getSid(), false, 10.0)); @@ -212,6 +214,8 @@ ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& lo subdp::RegularHkPeriodicParams(susTemperatures.getSid(), false, 10.0)); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(deviceTemperatures.getSid(), false, 10.0)); + poolManager.subscribeForDiagPeriodicPacket( + subdp::DiagnosticsHkPeriodicParams(heaterInfo.getSid(), false, 10.0)); return returnvalue::OK; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 1783e932..df36defd 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -81,11 +81,13 @@ class ThermalController : public ExtendedControllerBase { // Initial delay to make sure all pool variables have been initialized their owners Countdown initialCountdown = Countdown(DELAY); - PoolEntry tmp1075Tcs0 = PoolEntry(10.0); - PoolEntry tmp1075Tcs1 = PoolEntry(10.0); - PoolEntry tmp1075PlPcdu0 = PoolEntry(10.0); - PoolEntry tmp1075PlPcdu1 = PoolEntry(10.0); - PoolEntry tmp1075IfBrd = PoolEntry(10.0); + PoolEntry tmp1075Tcs0 = PoolEntry({10.0}); + PoolEntry tmp1075Tcs1 = PoolEntry({10.0}); + PoolEntry tmp1075PlPcdu0 = PoolEntry({10.0}); + PoolEntry tmp1075PlPcdu1 = PoolEntry({10.0}); + PoolEntry tmp1075IfBrd = PoolEntry({10.0}); + PoolEntry heaterSwitchStates = PoolEntry(heater::NUMBER_OF_SWITCHES); + PoolEntry heaterCurrent = PoolEntry(); static constexpr dur_millis_t MUTEX_TIMEOUT = 50; void copySensors(); diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index 89a1d10e..3dbecb03 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -3,6 +3,7 @@ #include #include + #include "devices/heaterSwitcherList.h" namespace thermalControllerDefinitions { @@ -206,13 +207,14 @@ class SusTemperatures : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SUS_11_R_LOC_XBYMZB_PT_ZB, this); }; -class HeaterInfo: public StaticLocalDataSet<12> { -public: - HeaterInfo(HasLocalDataPoolIF* owner): StaticLocalDataSet(owner, HEATER_SET) {} - HeaterInfo(object_id_t objectId): StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} +class HeaterInfo : public StaticLocalDataSet<12> { + public: + HeaterInfo(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HEATER_SET) {} + HeaterInfo(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} lp_vec_t heaterSwitchState = - lp_vec_t(sid.objectId, PoolIds::HEATER_SWITCH_LIST, this); + lp_vec_t(sid.objectId, PoolIds::HEATER_SWITCH_LIST, + this); lp_var_t heaterCurrent = lp_var_t(sid.objectId, PoolIds::HEATER_CURRENT, this); }; From d0a7d2892e52fabd646eadda33299718913ff128 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:46:20 +0100 Subject: [PATCH 03/23] added reading of current value --- mission/controller/ThermalController.cpp | 12 ++++++++++++ mission/controller/ThermalController.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 35391599..63bbf861 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -104,6 +104,18 @@ void ThermalController::performControlOperation() { copyDevices(); deviceTemperatures.commit(); } + + { + PoolReadGuard pg(&heaterInfo); + if (pg.getReadResult() == returnvalue::OK) { + { + PoolReadGuard pg(¤tVecPdu2); + if (pg.getReadResult() == returnvalue::OK) { + heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; + } + } + } + } } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index df36defd..f661876d 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -8,6 +8,8 @@ #include #include +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" + class ThermalController : public ExtendedControllerBase { public: static const uint16_t INVALID_TEMPERATURE = 999; @@ -38,6 +40,8 @@ class ThermalController : public ExtendedControllerBase { thermalControllerDefinitions::SusTemperatures susTemperatures; thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; thermalControllerDefinitions::HeaterInfo heaterInfo; + lp_vec_t currentVecPdu2 = + lp_vec_t(gp_id_t(objects::PDU2_HANDLER, PDU::pool::PDU_CURRENTS)); // Temperature Sensors MAX31865::Max31865Set max31865Set0; From 430e535fe9777aeba7cf06e9489adfa88ed93198 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 24 Jan 2023 15:48:06 +0100 Subject: [PATCH 04/23] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7742cb5..f4380e82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,16 @@ list yields a list of all related PRs for each release. # [unreleased] +## Changed + - Startracker temperature set and PCDU switcher set are diagnostic now +## Added + +- Added new heater info set for the TCS controller. This set contains the heater switch states + and the current draw. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 + # [v1.20.0] 2023-01-24 ## Added From 3159574cfabd616150b4e3070f2b50635edafae8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 21:41:19 +0100 Subject: [PATCH 05/23] resolve more merge conflicts --- mission/controller/ThermalController.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index b84f07d6..c2fc8cde 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -110,7 +110,6 @@ void ThermalController::performControlOperation() { deviceTemperatures.commit(); } -<<<<<<< HEAD { PoolReadGuard pg(&heaterInfo); if (pg.getReadResult() == returnvalue::OK) { @@ -122,7 +121,7 @@ void ThermalController::performControlOperation() { } } } -======= + ctrlCameraBody(); ctrlAcsBoard(); ctrlMgt(); @@ -147,7 +146,6 @@ void ThermalController::performControlOperation() { ctrlTx(); ctrlMpa(); ctrlScexBoard(); ->>>>>>> origin/develop } ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, From 7f74cca11ff165964fa490fa9467689d666143de Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Feb 2023 11:50:14 +0100 Subject: [PATCH 06/23] add more mode support for heaters --- CHANGELOG.md | 8 +++- mission/controller/ThermalController.cpp | 2 +- mission/controller/ThermalController.h | 7 ++-- mission/devices/HeaterHandler.cpp | 49 ++++++++++++++++++++++++ mission/devices/HeaterHandler.h | 21 ++++++++++ 5 files changed, 81 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06289802..73088716 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,13 +17,17 @@ change warranting a new major release: # [unreleased] -<<<<<<< HEAD ## Added - Added new heater info set for the TCS controller. This set contains the heater switch states and the current draw. PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 -======= +- The HeaterHandler now exposes a mode which reflects whether the heater power + is on or off. It also triggers mode events for its heater children objects + which show whether the specific heaters are on or off. The heater handler + will be part of the TCS tree. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 + # [v1.28.0] 2023-02-17 eive-tmtc: v2.12.7 diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index cdb14fab..71137668 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -22,7 +22,7 @@ ThermalController::ThermalController(object_id_t objectId, HeaterHandler& heater susTemperatures(this), deviceTemperatures(this), heaterInfo(this), - imtqThermalSet(objects::IMTQ_HANDLER), + imtqThermalSet(objects::IMTQ_HANDLER, ThermalStateCfg()), max31865Set0(objects::RTD_0_IC3_PLOC_HEATSPREADER, EiveMax31855::RtdCommands::EXCHANGE_SET_ID), max31865Set1(objects::RTD_1_IC4_PLOC_MISSIONBOARD, diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 542b8913..122ae8f6 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -9,11 +9,12 @@ #include #include -#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" -#include "mission/devices/HeaterHandler.h" -#include "mission/trace.h" #include +#include "mission/devices/HeaterHandler.h" +#include "mission/devices/devicedefinitions/GomspaceDefinitions.h" +#include "mission/trace.h" + /** * NOP Limit: Hard limit for device, usually from datasheet. Device damage is possible lif NOP limit * is exceeded. diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 43f53bf7..06beb0bc 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -8,11 +8,13 @@ #include #include "devices/powerSwitcherList.h" +#include "fsfw/subsystem/helper.h" HeaterHandler::HeaterHandler(object_id_t setObjectId_, GpioIF* gpioInterface_, HeaterHelper helper, PowerSwitchIF* mainLineSwitcher_, power::Switch_t mainLineSwitch_) : SystemObject(setObjectId_), helper(helper), + modeHelper(this), gpioInterface(gpioInterface_), mainLineSwitcher(mainLineSwitcher_), mainLineSwitch(mainLineSwitch_), @@ -46,6 +48,12 @@ ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) { heater.first->performOperation(0); } handleSwitchHandling(); + if (waitForSwitchOff) { + if (mainLineSwitcher->getSwitchState(mainLineSwitch) == SWITCH_OFF) { + waitForSwitchOff = false; + mode = MODE_OFF; + } + } } catch (const std::out_of_range& e) { sif::warning << "HeaterHandler::performOperation: " "Out of range error | " @@ -76,6 +84,10 @@ ReturnValue_t HeaterHandler::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } + result = modeHelper.initialize(); + if (result != returnvalue::OK) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } return returnvalue::OK; } @@ -218,6 +230,9 @@ void HeaterHandler::handleSwitchHandling() { void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { ReturnValue_t result = returnvalue::OK; auto& heater = heaterVec.at(heaterIdx); + if (waitForSwitchOff) { + waitForSwitchOff = false; + } /* Check if command waits for main switch being set on and whether the timeout has expired */ if (heater.waitMainSwitchOn && heater.mainSwitchCountdown.hasTimedOut()) { // TODO - This requires the initiation of an FDIR procedure @@ -235,6 +250,7 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { // Check state of main line switch ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { + mode = HasModesIF::MODE_ON; if (checkSwitchState(heaterIdx) == SwitchState::OFF) { gpioId_t gpioId = heater.gpioId; result = gpioInterface->pullHigh(gpioId); @@ -298,6 +314,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) { // When all switches are off, also main line switch will be turned off if (allSwitchesOff()) { mainLineSwitcher->sendSwitchCommand(mainLineSwitch, PowerSwitchIF::SWITCH_OFF); + waitForSwitchOff = true; } } } else { @@ -329,6 +346,38 @@ ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, SwitchState return returnvalue::FAILED; } +void HeaterHandler::announceMode(bool recursive) { + triggerEvent(MODE_INFO, mode, submode); + for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { + if (heaterVec[idx].switchState == SWITCH_ON) { + EventManagerIF::triggerEvent(helper.heaters[idx].first->getObjectId(), MODE_INFO, MODE_ON, 0); + } else { + EventManagerIF::triggerEvent(helper.heaters[idx].first->getObjectId(), MODE_INFO, MODE_OFF, + 0); + } + } +} + +void HeaterHandler::getMode(Mode_t* mode, Submode_t* submode) { + if (!mode || !submode) { + return; + } + *mode = this->mode; + *submode = this->submode; +} + +const HasHealthIF* HeaterHandler::getOptHealthIF() const { return nullptr; } + +const HasModesIF& HeaterHandler::getModeIF() const { return *this; } + +ReturnValue_t HeaterHandler::connectModeTreeParent(HasModeTreeChildrenIF& parent) { + return modetree::connectModeTreeParent(parent, *this, nullptr, modeHelper); +} + +ModeTreeChildIF& HeaterHandler::getModeTreeChildIF() { return *this; } + +object_id_t HeaterHandler::getObjectId() const { return SystemObject::getObjectId(); } + bool HeaterHandler::allSwitchesOff() { bool allSwitchesOrd = false; MutexGuard mg(heaterMutex); diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index ac4f94f4..ac856d9c 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -40,6 +42,9 @@ struct HeaterHelper { */ class HeaterHandler : public ExecutableObjectIF, public PowerSwitchIF, + public HasModesIF, + public ModeTreeChildIF, + public ModeTreeConnectionIF, public SystemObject, public HasActionsIF { friend class ThermalController; @@ -131,9 +136,11 @@ class HeaterHandler : public ExecutableObjectIF, MutexIF* heaterMutex = nullptr; HeaterHelper helper; + ModeHelper modeHelper; /** Size of command queue */ size_t cmdQueueSize = 20; + bool waitForSwitchOff = true; GpioIF* gpioInterface = nullptr; @@ -152,6 +159,9 @@ class HeaterHandler : public ExecutableObjectIF, StorageManagerIF* ipcStore = nullptr; + Mode_t mode = HasModesIF::MODE_OFF; + Submode_t submode = 0; + void readCommandQueue(); /** @@ -172,6 +182,17 @@ class HeaterHandler : public ExecutableObjectIF, */ void setInitialSwitchStates(); + // HasModesIF implementation + void announceMode(bool recursive) override; + void getMode(Mode_t* mode, Submode_t* submode) override; + + // Mode Tree helper overrides + object_id_t getObjectId() const override; + const HasHealthIF* getOptHealthIF() const override; + const HasModesIF& getModeIF() const override; + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override; + ModeTreeChildIF& getModeTreeChildIF() override; + void handleSwitchOnCommand(heater::Switchers heaterIdx); void handleSwitchOffCommand(heater::Switchers heaterIdx); From 378120416ad99aaf0dc90dd20c387daf5adeb284 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Feb 2023 13:04:40 +0100 Subject: [PATCH 07/23] attach heater handler to TCS subsystem --- mission/core/GenericFactory.cpp | 2 ++ mission/devices/HeaterHandler.h | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index 992c0093..b62c8af3 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -219,6 +220,7 @@ void ObjectFactory::createGenericHeaterComponents(GpioIF& gpioIF, PowerSwitchIF& }}); heaterHandler = new HeaterHandler(objects::HEATER_HANDLER, &gpioIF, helper, &pwrSwitcher, pcdu::Switches::PDU2_CH3_TCS_BOARD_HEATER_IN_8V); + heaterHandler->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); } void ObjectFactory::createThermalController(HeaterHandler& heaterHandler) { diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index ac856d9c..ecb77ad1 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -66,6 +66,8 @@ class HeaterHandler : public ExecutableObjectIF, HeaterHandler(object_id_t setObjectId, GpioIF* gpioInterface_, HeaterHelper helper, PowerSwitchIF* mainLineSwitcherObjectId, power::Switch_t mainLineSwitch); + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override; + virtual ~HeaterHandler(); protected: @@ -190,7 +192,6 @@ class HeaterHandler : public ExecutableObjectIF, object_id_t getObjectId() const override; const HasHealthIF* getOptHealthIF() const override; const HasModesIF& getModeIF() const override; - ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override; ModeTreeChildIF& getModeTreeChildIF() override; void handleSwitchOnCommand(heater::Switchers heaterIdx); From c1598f88082ab9ca0a03b3ae70de58035bca7359 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Feb 2023 13:11:16 +0100 Subject: [PATCH 08/23] add mode helper usage --- mission/devices/HeaterHandler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 06beb0bc..9bb8e6d8 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -52,6 +52,7 @@ ReturnValue_t HeaterHandler::performOperation(uint8_t operationCode) { if (mainLineSwitcher->getSwitchState(mainLineSwitch) == SWITCH_OFF) { waitForSwitchOff = false; mode = MODE_OFF; + modeHelper.modeChanged(mode, submode); } } } catch (const std::out_of_range& e) { @@ -112,6 +113,10 @@ void HeaterHandler::readCommandQueue() { if (result == returnvalue::OK) { continue; } + result = modeHelper.handleModeCommand(&command); + if(result == returnvalue::OK) { + continue; + } } while (result == returnvalue::OK); } @@ -250,7 +255,6 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { // Check state of main line switch ReturnValue_t mainSwitchState = mainLineSwitcher->getSwitchState(mainLineSwitch); if (mainSwitchState == PowerSwitchIF::SWITCH_ON) { - mode = HasModesIF::MODE_ON; if (checkSwitchState(heaterIdx) == SwitchState::OFF) { gpioId_t gpioId = heater.gpioId; result = gpioInterface->pullHigh(gpioId); @@ -265,6 +269,8 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { } else { triggerEvent(SWITCH_ALREADY_ON, heaterIdx); } + mode = HasModesIF::MODE_ON; + modeHelper.modeChanged(mode, submode); // There is no need to send action finish replies if the sender was the // HeaterHandler itself if (heater.replyQueue != commandQueue->getId()) { From e9104b747955f70f0d7043cc9555c1bc2cb4db00 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Feb 2023 16:08:04 +0100 Subject: [PATCH 09/23] update changelog --- CHANGELOG.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35adddc9..1d52487e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,7 +73,6 @@ eive-tmtc: v2.12.6 - Function for the ACS controller to command MTQ and RWs called by all subroutines - RwHandler now handles commanding of RW speeds via RwSpeedActuationSet - Tracing supports which allows checking whether threads are running as usual. ->>>>>>> origin/develop ## Changed @@ -160,16 +159,13 @@ eive-tmtc: v2.12.2 ## Changed - Reworked dummy handling for the TCS controller. -<<<<<<< HEAD PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/325 -======= - Generator scripts now generate files for hosted and for Q7S build. ## Fixed - GPS Controller: Set fix value to 0 when switching off to allow `GPS_FIX_CHANGE` to work when switching the GPS back on. ->>>>>>> origin/develop # [v1.26.2] 2023-02-08 @@ -382,10 +378,6 @@ Syrlinks PR: PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/353 it has a submode for low datarate (1) and high datarate (2) for the ON command. PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/352 -## Added - -- Startracker temperature set and PCDU switcher set are diagnostic now - # [v1.20.0] 2023-01-24 ## Added From b3cdb05214f398fd35577261d7ae6833c41c430b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Feb 2023 16:10:56 +0100 Subject: [PATCH 10/23] changelg update --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d52487e..7c77a8b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -154,7 +154,6 @@ eive-tmtc: v2.12.2 - First version of a TCS controller heater control loop, but the loop is disabled for now. ->>>>>>> origin/develop ## Changed From ec8c5b7a5c922122151733bcb975f93ff4b7cc99 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 17 Feb 2023 16:32:33 +0100 Subject: [PATCH 11/23] fix shadowing warning --- mission/controller/ThermalController.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 71137668..ecc3566e 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -115,13 +115,9 @@ void ThermalController::performControlOperation() { { PoolReadGuard pg(&heaterInfo); - if (pg.getReadResult() == returnvalue::OK) { - { - PoolReadGuard pg(¤tVecPdu2); - if (pg.getReadResult() == returnvalue::OK) { - heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; - } - } + PoolReadGuard pg2(¤tVecPdu2); + if (pg.getReadResult() == returnvalue::OK and pg2.getReadResult() == returnvalue::OK) { + heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; } } From 01fbb2d9fd4f052abf81ec53fd1609a2fb38fb64 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 19 Feb 2023 17:06:08 +0100 Subject: [PATCH 12/23] improvements --- mission/devices/HeaterHandler.cpp | 1 + mission/tmtc/CfdpTmFunnel.cpp | 6 ++++++ mission/tmtc/PusTmFunnel.cpp | 6 ++++++ mission/tmtc/VirtualChannel.cpp | 8 +++++--- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 9600c0db..1af82604 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -95,6 +95,7 @@ void HeaterHandler::readCommandQueue() { break; } else if (result != returnvalue::OK) { sif::warning << "HeaterHandler::readCommandQueue: Message reception error" << std::endl; + break; } result = actionHelper.handleActionMessage(&command); if (result == returnvalue::OK) { diff --git a/mission/tmtc/CfdpTmFunnel.cpp b/mission/tmtc/CfdpTmFunnel.cpp index f19d5360..50a7b24a 100644 --- a/mission/tmtc/CfdpTmFunnel.cpp +++ b/mission/tmtc/CfdpTmFunnel.cpp @@ -12,6 +12,7 @@ const char* CfdpTmFunnel::getName() const { return "CFDP TM Funnel"; } ReturnValue_t CfdpTmFunnel::performOperation(uint8_t) { TmTcMessage currentMessage; + unsigned int count = 0; ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); while (status == returnvalue::OK) { status = handlePacket(currentMessage); @@ -19,6 +20,11 @@ ReturnValue_t CfdpTmFunnel::performOperation(uint8_t) { sif::warning << "CfdpTmFunnel packet handling failed" << std::endl; break; } + count++; + if(count == 500) { + sif::error << "CfdpTmFunnel: Possible message storm detected" << std::endl; + break; + } status = tmQueue->receiveMessage(¤tMessage); } diff --git a/mission/tmtc/PusTmFunnel.cpp b/mission/tmtc/PusTmFunnel.cpp index dda854a6..e239afc9 100644 --- a/mission/tmtc/PusTmFunnel.cpp +++ b/mission/tmtc/PusTmFunnel.cpp @@ -12,6 +12,7 @@ PusTmFunnel::~PusTmFunnel() = default; ReturnValue_t PusTmFunnel::performOperation(uint8_t) { TmTcMessage currentMessage; + unsigned int count = 0; ReturnValue_t status = tmQueue->receiveMessage(¤tMessage); while (status == returnvalue::OK) { status = handlePacket(currentMessage); @@ -19,6 +20,11 @@ ReturnValue_t PusTmFunnel::performOperation(uint8_t) { sif::warning << "TmFunnel packet handling failed" << std::endl; break; } + count++; + if(count == 500) { + sif::error << "PusTmFunnel: Possible message storm detected" << std::endl; + break; + } status = tmQueue->receiveMessage(¤tMessage); } diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index b0f9391d..a33a7dba 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -28,6 +28,7 @@ ReturnValue_t VirtualChannel::performOperation() { ReturnValue_t result = returnvalue::OK; TmTcMessage message; + unsigned int count = 0; while (tmQueue->receiveMessage(&message) == returnvalue::OK) { store_address_t storeId = message.getStorageId(); const uint8_t* data = nullptr; @@ -45,9 +46,10 @@ ReturnValue_t VirtualChannel::performOperation() { } tmStore->deleteData(storeId); - - if (result != returnvalue::OK) { - return result; + count++; + if(count == 500) { + sif::error << "VirtualChannel: Possible message storm detected" << std::endl; + break; } } return result; From 4b6e0addf1ede2d5005605adad89c29022e6c9e0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 19 Feb 2023 17:07:48 +0100 Subject: [PATCH 13/23] changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 891a4d76..0c9a05df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,15 @@ change warranting a new major release: - git post checkout hook which initializes and updates the submodules automatically. +## Fixed + +- Limit number of handled messages for core TM handlers: + - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/391 + - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/390 + - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/389 +- HeaterHandler better handling for faulty message reception + Issue: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/388 + # [v1.28.0] 2023-02-17 eive-tmtc: v2.12.7 From 9a9574369a36142a2458008e420d2339a2e26d1e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sun, 19 Feb 2023 17:08:55 +0100 Subject: [PATCH 14/23] deleted accidentaly --- mission/tmtc/VirtualChannel.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mission/tmtc/VirtualChannel.cpp b/mission/tmtc/VirtualChannel.cpp index a33a7dba..64c7b006 100644 --- a/mission/tmtc/VirtualChannel.cpp +++ b/mission/tmtc/VirtualChannel.cpp @@ -44,8 +44,11 @@ ReturnValue_t VirtualChannel::performOperation() { if (linkIsUp) { result = ptme->writeToVc(vcId, data, size); } - tmStore->deleteData(storeId); + if (result != returnvalue::OK) { + return result; + } + count++; if(count == 500) { sif::error << "VirtualChannel: Possible message storm detected" << std::endl; From 3ffdcf388553171d0df67889b10f00a0484b5bf6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 01:53:23 +0100 Subject: [PATCH 15/23] announce mode worsk for heaters --- mission/controller/ThermalController.cpp | 165 +++++++----------- mission/controller/ThermalController.h | 8 +- .../ThermalControllerDefinitions.h | 6 +- mission/devices/HeaterHandler.cpp | 40 +++-- mission/devices/HeaterHandler.h | 2 +- tmtc | 2 +- 6 files changed, 102 insertions(+), 121 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index ecc3566e..70c96734 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -126,105 +126,70 @@ void ThermalController::performControlOperation() { ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) { - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_PLOC_HEATSPREADER, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_PLOC_MISSIONBOARD, - new PoolEntry({1.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_4K_CAMERA, - new PoolEntry({2.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_DAC_HEATSPREADER, - new PoolEntry({3.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_STARTRACKER, - new PoolEntry({4.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_RW1, new PoolEntry({5.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_DRO, new PoolEntry({6.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_SCEX, new PoolEntry({7.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_X8, new PoolEntry({8.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_HPA, new PoolEntry({9.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TX_MODUL, - new PoolEntry({10.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_MPA, new PoolEntry({11.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_ACU, new PoolEntry({12.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_PLPCDU_HEATSPREADER, - new PoolEntry({13.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TCS_BOARD, - new PoolEntry({14.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_MAGNETTORQUER, - new PoolEntry({15.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TMP1075_TCS_0, &tmp1075Tcs0); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TMP1075_TCS_1, &tmp1075Tcs1); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TMP1075_PLPCDU_0, &tmp1075PlPcdu0); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TMP1075_PLPCDU_1, &tmp1075PlPcdu1); - localDataPoolMap.emplace(thermalControllerDefinitions::SENSOR_TMP1075_IF_BOARD, &tmp1075IfBrd); + localDataPoolMap.emplace(tcsCtrl::SENSOR_PLOC_HEATSPREADER, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_PLOC_MISSIONBOARD, new PoolEntry({1.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_4K_CAMERA, new PoolEntry({2.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_DAC_HEATSPREADER, new PoolEntry({3.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_STARTRACKER, new PoolEntry({4.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_RW1, new PoolEntry({5.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_DRO, new PoolEntry({6.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_SCEX, new PoolEntry({7.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_X8, new PoolEntry({8.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_HPA, new PoolEntry({9.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_TX_MODUL, new PoolEntry({10.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_MPA, new PoolEntry({11.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_ACU, new PoolEntry({12.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_PLPCDU_HEATSPREADER, new PoolEntry({13.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_TCS_BOARD, new PoolEntry({14.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_MAGNETTORQUER, new PoolEntry({15.0})); + localDataPoolMap.emplace(tcsCtrl::SENSOR_TMP1075_TCS_0, &tmp1075Tcs0); + localDataPoolMap.emplace(tcsCtrl::SENSOR_TMP1075_TCS_1, &tmp1075Tcs1); + localDataPoolMap.emplace(tcsCtrl::SENSOR_TMP1075_PLPCDU_0, &tmp1075PlPcdu0); + localDataPoolMap.emplace(tcsCtrl::SENSOR_TMP1075_PLPCDU_1, &tmp1075PlPcdu1); + localDataPoolMap.emplace(tcsCtrl::SENSOR_TMP1075_IF_BOARD, &tmp1075IfBrd); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_0_N_LOC_XFYFZM_PT_XF, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_6_R_LOC_XFYBZM_PT_XF, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_1_N_LOC_XBYFZM_PT_XB, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_7_R_LOC_XBYBZM_PT_XB, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_2_N_LOC_XFYBZB_PT_YB, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_8_R_LOC_XBYBZB_PT_YB, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_3_N_LOC_XFYBZF_PT_YF, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_9_R_LOC_XBYBZB_PT_YF, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_4_N_LOC_XMYFZF_PT_ZF, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_10_N_LOC_XMYBZF_PT_ZF, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_5_N_LOC_XFYMZB_PT_ZB, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::SUS_11_R_LOC_XBYMZB_PT_ZB, - new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_0_N_LOC_XFYFZM_PT_XF, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_6_R_LOC_XFYBZM_PT_XF, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_1_N_LOC_XBYFZM_PT_XB, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_7_R_LOC_XBYBZM_PT_XB, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_2_N_LOC_XFYBZB_PT_YB, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_8_R_LOC_XBYBZB_PT_YB, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_3_N_LOC_XFYBZF_PT_YF, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_9_R_LOC_XBYBZB_PT_YF, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_4_N_LOC_XMYFZF_PT_ZF, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_10_N_LOC_XMYBZF_PT_ZF, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_5_N_LOC_XFYMZB_PT_ZB, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::SUS_11_R_LOC_XBYMZB_PT_ZB, new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::COMPONENT_RW, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::COMPONENT_RW, new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_Q7S, new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::BATTERY_TEMP_1, - new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::BATTERY_TEMP_2, - new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::BATTERY_TEMP_3, - new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::BATTERY_TEMP_4, - new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_RW1, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_RW2, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_RW3, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_RW4, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_STAR_TRACKER, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_SYRLINKS_POWER_AMPLIFIER, - new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_SYRLINKS_BASEBAND_BOARD, - new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_MGT, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_ACU, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_PDU1, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_PDU2, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_1_P60DOCK, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_2_P60DOCK, new PoolEntry({0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_GYRO_0_SIDE_A, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_GYRO_1_SIDE_A, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_GYRO_2_SIDE_B, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_GYRO_3_SIDE_B, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_MGM_0_SIDE_A, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_MGM_2_SIDE_B, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::TEMP_ADC_PAYLOAD_PCDU, - new PoolEntry({0.0})); - localDataPoolMap.emplace(thermalControllerDefinitions::HEATER_SWITCH_LIST, &heaterSwitchStates); - localDataPoolMap.emplace(thermalControllerDefinitions::HEATER_CURRENT, &heaterCurrent); + localDataPoolMap.emplace(tcsCtrl::TEMP_Q7S, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::BATTERY_TEMP_1, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::BATTERY_TEMP_2, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::BATTERY_TEMP_3, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::BATTERY_TEMP_4, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_RW1, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_RW2, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_RW3, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_RW4, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_STAR_TRACKER, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_SYRLINKS_POWER_AMPLIFIER, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_SYRLINKS_BASEBAND_BOARD, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_MGT, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_ACU, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_PDU1, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_PDU2, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_1_P60DOCK, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_2_P60DOCK, new PoolEntry({0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_GYRO_0_SIDE_A, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_GYRO_1_SIDE_A, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_GYRO_2_SIDE_B, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_GYRO_3_SIDE_B, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_MGM_0_SIDE_A, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_MGM_2_SIDE_B, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::TEMP_ADC_PAYLOAD_PCDU, new PoolEntry({0.0})); + localDataPoolMap.emplace(tcsCtrl::HEATER_SWITCH_LIST, &heaterSwitchStates); + localDataPoolMap.emplace(tcsCtrl::HEATER_CURRENT, &heaterCurrent); poolManager.subscribeForRegularPeriodicPacket( subdp::RegularHkPeriodicParams(sensorTemperatures.getSid(), false, 10.0)); @@ -239,12 +204,14 @@ ReturnValue_t ThermalController::initializeLocalDataPool(localpool::DataPool& lo LocalPoolDataSetBase* ThermalController::getDataSetHandle(sid_t sid) { switch (sid.ownerSetId) { - case thermalControllerDefinitions::SENSOR_TEMPERATURES: + case tcsCtrl::SENSOR_TEMPERATURES: return &sensorTemperatures; - case thermalControllerDefinitions::SUS_TEMPERATURES: + case tcsCtrl::SUS_TEMPERATURES: return &susTemperatures; - case thermalControllerDefinitions::DEVICE_TEMPERATURES: + case tcsCtrl::DEVICE_TEMPERATURES: return &deviceTemperatures; + case tcsCtrl::HEATER_SET: + return &heaterInfo; default: return nullptr; } diff --git a/mission/controller/ThermalController.h b/mission/controller/ThermalController.h index 122ae8f6..a161b0eb 100644 --- a/mission/controller/ThermalController.h +++ b/mission/controller/ThermalController.h @@ -77,10 +77,10 @@ class ThermalController : public ExtendedControllerBase { HeaterHandler& heaterHandler; - thermalControllerDefinitions::SensorTemperatures sensorTemperatures; - thermalControllerDefinitions::SusTemperatures susTemperatures; - thermalControllerDefinitions::DeviceTemperatures deviceTemperatures; - thermalControllerDefinitions::HeaterInfo heaterInfo; + tcsCtrl::SensorTemperatures sensorTemperatures; + tcsCtrl::SusTemperatures susTemperatures; + tcsCtrl::DeviceTemperatures deviceTemperatures; + tcsCtrl::HeaterInfo heaterInfo; lp_vec_t currentVecPdu2 = lp_vec_t(gp_id_t(objects::PDU2_HANDLER, PDU::pool::PDU_CURRENTS)); diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index 57ffdb62..fcea7e6d 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -6,9 +6,9 @@ #include "devices/heaterSwitcherList.h" -namespace thermalControllerDefinitions { +namespace tcsCtrl { -enum SetIds : uint32_t { +enum SetId : uint32_t { SENSOR_TEMPERATURES = 0, DEVICE_TEMPERATURES = 1, SUS_TEMPERATURES = 2, @@ -219,6 +219,6 @@ class HeaterInfo : public StaticLocalDataSet<12> { lp_var_t heaterCurrent = lp_var_t(sid.objectId, PoolIds::HEATER_CURRENT, this); }; -} // namespace thermalControllerDefinitions +} // namespace tcsCtrl #endif /* MISSION_CONTROLLER_CONTROLLERDEFINITIONS_THERMALCONTROLLERDEFINITIONS_H_ */ diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index d42fd390..28085105 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -30,8 +30,8 @@ HeaterHandler::HeaterHandler(object_id_t setObjectId_, GpioIF* gpioInterface_, H if (mainLineSwitcher == nullptr) { throw std::invalid_argument("HeaterHandler::HeaterHandler: Invalid PowerSwitchIF"); } - heaterMutex = MutexFactory::instance()->createMutex(); - if (heaterMutex == nullptr) { + heaterHealthAndStateMutex = MutexFactory::instance()->createMutex(); + if (heaterHealthAndStateMutex == nullptr) { throw std::runtime_error("HeaterHandler::HeaterHandler: Creating Mutex failed"); } auto mqArgs = MqArgs(setObjectId_, static_cast(this)); @@ -114,7 +114,7 @@ void HeaterHandler::readCommandQueue() { continue; } result = modeHelper.handleModeCommand(&command); - if(result == returnvalue::OK) { + if (result == returnvalue::OK) { continue; } } while (result == returnvalue::OK); @@ -141,7 +141,11 @@ ReturnValue_t HeaterHandler::executeAction(ActionId_t actionId, MessageQueueId_t auto action = static_cast(data[1]); // Always accepts OFF commands if (action == SwitchAction::SET_SWITCH_ON) { - HasHealthIF::HealthState health = heater.healthDevice->getHealth(); + HasHealthIF::HealthState health; + { + MutexGuard mg(heaterHealthAndStateMutex); + health = heater.healthDevice->getHealth(); + } if (health == HasHealthIF::FAULTY or health == HasHealthIF::PERMANENT_FAULTY or health == HasHealthIF::NEEDS_RECOVERY) { return HasHealthIF::OBJECT_NOT_HEALTHY; @@ -264,7 +268,10 @@ void HeaterHandler::handleSwitchOnCommand(heater::Switchers heaterIdx) { triggerEvent(GPIO_PULL_HIGH_FAILED, result); } else { triggerEvent(HEATER_WENT_ON, heaterIdx, 0); - heater.switchState = ON; + { + MutexGuard mg(heaterHealthAndStateMutex); + heater.switchState = ON; + } } } else { triggerEvent(SWITCH_ALREADY_ON, heaterIdx); @@ -311,10 +318,9 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) { << " low" << std::endl; triggerEvent(GPIO_PULL_LOW_FAILED, result); } else { - result = heaterMutex->lockMutex(); - heater.switchState = OFF; - if (result == returnvalue::OK) { - heaterMutex->unlockMutex(); + { + MutexGuard mg(heaterHealthAndStateMutex); + heater.switchState = OFF; } triggerEvent(HEATER_WENT_OFF, heaterIdx, 0); // When all switches are off, also main line switch will be turned off @@ -339,7 +345,7 @@ void HeaterHandler::handleSwitchOffCommand(heater::Switchers heaterIdx) { } HeaterHandler::SwitchState HeaterHandler::checkSwitchState(heater::Switchers switchNr) const { - MutexGuard mg(heaterMutex); + MutexGuard mg(heaterHealthAndStateMutex); return heaterVec.at(switchNr).switchState; } @@ -354,8 +360,16 @@ ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, SwitchState void HeaterHandler::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode, submode); + + SwitchState states[helper.heaters.size()]; + { + MutexGuard mg(heaterHealthAndStateMutex); + for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { + states[idx] = heaterVec[idx].switchState; + } + } for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { - if (heaterVec[idx].switchState == SWITCH_ON) { + if (states[idx] == ON) { EventManagerIF::triggerEvent(helper.heaters[idx].first->getObjectId(), MODE_INFO, MODE_ON, 0); } else { EventManagerIF::triggerEvent(helper.heaters[idx].first->getObjectId(), MODE_INFO, MODE_OFF, @@ -386,7 +400,7 @@ object_id_t HeaterHandler::getObjectId() const { return SystemObject::getObjectI bool HeaterHandler::allSwitchesOff() { bool allSwitchesOrd = false; - MutexGuard mg(heaterMutex); + MutexGuard mg(heaterHealthAndStateMutex); /* Or all switches. As soon one switch is on, allSwitchesOrd will be true */ for (power::Switch_t switchNr = 0; switchNr < heater::NUMBER_OF_SWITCHES; switchNr++) { allSwitchesOrd = allSwitchesOrd || heaterVec.at(switchNr).switchState; @@ -419,7 +433,7 @@ uint32_t HeaterHandler::getSwitchDelayMs(void) const { return 2000; } HasHealthIF::HealthState HeaterHandler::getHealth(heater::Switchers heater) { auto* healthDev = heaterVec.at(heater).healthDevice; if (healthDev != nullptr) { - MutexGuard mg(heaterMutex); + MutexGuard mg(heaterHealthAndStateMutex); return healthDev->getHealth(); } return HasHealthIF::HealthState::FAULTY; diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index ecb77ad1..9a776058 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -135,7 +135,7 @@ class HeaterHandler : public ExecutableObjectIF, HeaterMap heaterVec = {}; - MutexIF* heaterMutex = nullptr; + MutexIF* heaterHealthAndStateMutex = nullptr; HeaterHelper helper; ModeHelper modeHelper; diff --git a/tmtc b/tmtc index 556060a3..d1f96cb8 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 556060a3f3e204e7a171385d31a3ec409755c6b1 +Subproject commit d1f96cb83d287ea6f7714631fa944eb2c7fe17b8 From 582c8e8eff8cb48ffa04625efcb42c0fd21fb9fe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 02:28:57 +0100 Subject: [PATCH 16/23] some more fixes so heater info works --- mission/controller/ThermalController.cpp | 11 +++++++--- .../ThermalControllerDefinitions.h | 2 +- mission/devices/HeaterHandler.cpp | 22 +++++++++++++------ mission/devices/HeaterHandler.h | 3 ++- tmtc | 2 +- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/mission/controller/ThermalController.cpp b/mission/controller/ThermalController.cpp index 70c96734..235ad83e 100644 --- a/mission/controller/ThermalController.cpp +++ b/mission/controller/ThermalController.cpp @@ -113,11 +113,16 @@ void ThermalController::performControlOperation() { deviceTemperatures.commit(); } + std::array heaterStates; + heaterHandler.getAllSwitchStates(heaterStates); { PoolReadGuard pg(&heaterInfo); - PoolReadGuard pg2(¤tVecPdu2); - if (pg.getReadResult() == returnvalue::OK and pg2.getReadResult() == returnvalue::OK) { - heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; + std::memcpy(heaterInfo.heaterSwitchState.value, heaterStates.data(), 8); + { + PoolReadGuard pg2(¤tVecPdu2); + if (pg.getReadResult() == returnvalue::OK and pg2.getReadResult() == returnvalue::OK) { + heaterInfo.heaterCurrent.value = currentVecPdu2.value[PDU2::Channels::TCS_HEATER_IN]; + } } } diff --git a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h index fcea7e6d..e7c95218 100644 --- a/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h +++ b/mission/controller/controllerdefinitions/ThermalControllerDefinitions.h @@ -208,7 +208,7 @@ class SusTemperatures : public StaticLocalDataSet { lp_var_t(sid.objectId, PoolIds::SUS_11_R_LOC_XBYMZB_PT_ZB, this); }; -class HeaterInfo : public StaticLocalDataSet<12> { +class HeaterInfo : public StaticLocalDataSet<3> { public: HeaterInfo(HasLocalDataPoolIF* owner) : StaticLocalDataSet(owner, HEATER_SET) {} HeaterInfo(object_id_t objectId) : StaticLocalDataSet(sid_t(objectId, HEATER_SET)) {} diff --git a/mission/devices/HeaterHandler.cpp b/mission/devices/HeaterHandler.cpp index 28085105..0b495d53 100644 --- a/mission/devices/HeaterHandler.cpp +++ b/mission/devices/HeaterHandler.cpp @@ -361,13 +361,8 @@ ReturnValue_t HeaterHandler::switchHeater(heater::Switchers heater, SwitchState void HeaterHandler::announceMode(bool recursive) { triggerEvent(MODE_INFO, mode, submode); - SwitchState states[helper.heaters.size()]; - { - MutexGuard mg(heaterHealthAndStateMutex); - for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { - states[idx] = heaterVec[idx].switchState; - } - } + std::array states; + getAllSwitchStates(states); for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { if (states[idx] == ON) { EventManagerIF::triggerEvent(helper.heaters[idx].first->getObjectId(), MODE_INFO, MODE_ON, 0); @@ -398,6 +393,19 @@ ModeTreeChildIF& HeaterHandler::getModeTreeChildIF() { return *this; } object_id_t HeaterHandler::getObjectId() const { return SystemObject::getObjectId(); } +ReturnValue_t HeaterHandler::getAllSwitchStates(std::array& statesBuf) { + { + MutexGuard mg(heaterHealthAndStateMutex); + if (mg.getLockResult() != returnvalue::OK) { + return returnvalue::FAILED; + } + for (unsigned idx = 0; idx < helper.heaters.size(); idx++) { + statesBuf[idx] = heaterVec[idx].switchState; + } + } + return returnvalue::OK; +} + bool HeaterHandler::allSwitchesOff() { bool allSwitchesOrd = false; MutexGuard mg(heaterHealthAndStateMutex); diff --git a/mission/devices/HeaterHandler.h b/mission/devices/HeaterHandler.h index 9a776058..ffc38440 100644 --- a/mission/devices/HeaterHandler.h +++ b/mission/devices/HeaterHandler.h @@ -59,6 +59,7 @@ class HeaterHandler : public ExecutableObjectIF, static const ReturnValue_t COMMAND_ALREADY_WAITING = MAKE_RETURN_CODE(0xA5); enum CmdSourceParam : uint8_t { INTERNAL = 0, EXTERNAL = 1 }; + enum SwitchState : uint8_t { ON = 1, OFF = 0 }; /** Device command IDs */ static const DeviceCommandId_t SWITCH_HEATER = 0x0; @@ -67,11 +68,11 @@ class HeaterHandler : public ExecutableObjectIF, PowerSwitchIF* mainLineSwitcherObjectId, power::Switch_t mainLineSwitch); ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) override; + ReturnValue_t getAllSwitchStates(std::array& statesBuf); virtual ~HeaterHandler(); protected: - enum SwitchState : bool { ON = true, OFF = false }; enum SwitchAction : uint8_t { SET_SWITCH_OFF, SET_SWITCH_ON, NONE }; ReturnValue_t switchHeater(heater::Switchers heater, SwitchState switchState); diff --git a/tmtc b/tmtc index d1f96cb8..5f082cd9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d1f96cb83d287ea6f7714631fa944eb2c7fe17b8 +Subproject commit 5f082cd9fccdaa304f00d92c1f25cdd6a7d8ed0b From b5b80cef972f054fd0995c4370904a06261d1188 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 02:59:28 +0100 Subject: [PATCH 17/23] fixed regression in max31865 code --- CHANGELOG.md | 4 + fsfw | 2 +- linux/ObjectFactory.cpp | 4 +- linux/devices/CMakeLists.txt | 2 +- ...evelHandler.cpp => Max31865RtdPolling.cpp} | 84 +++++++++---------- ...LowlevelHandler.h => Max31865RtdPolling.h} | 8 +- 6 files changed, 52 insertions(+), 52 deletions(-) rename linux/devices/{Max31865RtdLowlevelHandler.cpp => Max31865RtdPolling.cpp} (81%) rename linux/devices/{Max31865RtdLowlevelHandler.h => Max31865RtdPolling.h} (92%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37503174..4a397de6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,10 @@ change warranting a new major release: - CFDP Funnel bugfix: CCSDS wrapping was buggy and works properly now. - CMakeLists.txt fix which broke CI/CD builds when server could not retrieve full git SHA. +- Possible regression in the MAX31865 polling task: Using a `ManualCsLockGuard` for reconfiguring + and then polling the sensor is problematic, invalid sensor values will be read. + CS probably needs to be de-asserted or some other HW/SPI specific issue. Letting the SPI ComIF + do the locking does the job. ## Changed diff --git a/fsfw b/fsfw index c3279852..2efff4d2 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c32798522283d89028b7c1ecd3bd33b8391e1a39 +Subproject commit 2efff4d2c5ef82b5b62567ab1bb0ee53aeed6a5a diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 1686eb03..e3162a07 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include @@ -278,7 +278,7 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF, TcsBoardAssembly* tcsBoardAss = ObjectFactory::createTcsBoardAssy(*pwrSwitcher); // Create special low level reader communication interface - new Max31865RtdReader(objects::SPI_RTD_COM_IF, comIF, gpioComIF); + new Max31865RtdPolling(objects::SPI_RTD_COM_IF, comIF, gpioComIF); for (uint8_t idx = 0; idx < NUM_RTDS; idx++) { rtdCookies[idx] = new SpiCookie(cookieArgs[idx].first, cookieArgs[idx].second, MAX31865::MAX_REPLY_SIZE, spi::RTD_MODE, spi::RTD_SPEED); diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 7251b802..58b6d021 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -3,7 +3,7 @@ if(EIVE_BUILD_GPSD_GPS_HANDLER) endif() target_sources( - ${OBSW_NAME} PRIVATE Max31865RtdLowlevelHandler.cpp ScexUartReader.cpp + ${OBSW_NAME} PRIVATE Max31865RtdPolling.cpp ScexUartReader.cpp ScexDleParser.cpp ScexHelper.cpp RwPollingTask.cpp) add_subdirectory(ploc) diff --git a/linux/devices/Max31865RtdLowlevelHandler.cpp b/linux/devices/Max31865RtdPolling.cpp similarity index 81% rename from linux/devices/Max31865RtdLowlevelHandler.cpp rename to linux/devices/Max31865RtdPolling.cpp index 0af22bfa..a22ec145 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.cpp +++ b/linux/devices/Max31865RtdPolling.cpp @@ -1,8 +1,7 @@ -#include "Max31865RtdLowlevelHandler.h" - #include #include #include +#include #define OBSW_RTD_AUTO_MODE 1 @@ -17,16 +16,17 @@ static constexpr uint8_t BASE_CFG = (MAX31865::ConvMode::NORM_OFF << MAX31865::CfgBitPos::CONV_MODE); #endif -Max31865RtdReader::Max31865RtdReader(object_id_t objectId, SpiComIF* lowLevelComIF, GpioIF* gpioIF) +Max31865RtdPolling::Max31865RtdPolling(object_id_t objectId, SpiComIF* lowLevelComIF, + GpioIF* gpioIF) : SystemObject(objectId), rtds(EiveMax31855::NUM_RTDS), comIF(lowLevelComIF), gpioIF(gpioIF) { readerMutex = MutexFactory::instance()->createMutex(); } -ReturnValue_t Max31865RtdReader::performOperation(uint8_t operationCode) { +ReturnValue_t Max31865RtdPolling::performOperation(uint8_t operationCode) { using namespace MAX31865; ReturnValue_t result = returnvalue::OK; static_cast(result); - // Stopwatch watch; + Stopwatch watch; if (periodicInitHandling()) { #if OBSW_RTD_AUTO_MODE == 0 // 10 ms delay for VBIAS startup @@ -49,17 +49,16 @@ ReturnValue_t Max31865RtdReader::performOperation(uint8_t operationCode) { return periodicReadHandling(); } -bool Max31865RtdReader::rtdIsActive(uint8_t idx) { +bool Max31865RtdPolling::rtdIsActive(uint8_t idx) { if (rtds[idx]->on and rtds[idx]->db.active and rtds[idx]->db.configured) { return true; } return false; } -bool Max31865RtdReader::periodicInitHandling() { +bool Max31865RtdPolling::periodicInitHandling() { using namespace MAX31865; ReturnValue_t result = returnvalue::OK; - for (auto& rtd : rtds) { if (rtd == nullptr) { continue; @@ -70,11 +69,9 @@ bool Max31865RtdReader::periodicInitHandling() { return false; } if ((rtd->on or rtd->db.active) and not rtd->db.configured and rtd->cd.hasTimedOut()) { - ManualCsLockWrapper mg1(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); - if (mg1.lockResult != returnvalue::OK or mg1.gpioResult != returnvalue::OK) { - sif::error << "Max31865RtdReader::periodicInitHandling: Manual CS lock failed" << std::endl; - continue; - } + // Please note that using the manual CS lock wrapper here is problematic. Might be a SPI + // or hardware specific issue where the CS needs to be pulled high and then low again + // between transfers result = writeCfgReg(rtd->spiCookie, BASE_CFG); if (result != returnvalue::OK) { handleSpiError(rtd, result, "writeCfgReg"); @@ -115,7 +112,7 @@ bool Max31865RtdReader::periodicInitHandling() { return someRtdUsable; } -ReturnValue_t Max31865RtdReader::periodicReadReqHandling() { +ReturnValue_t Max31865RtdPolling::periodicReadReqHandling() { using namespace MAX31865; // Now request one shot config for all active RTDs for (auto& rtd : rtds) { @@ -139,7 +136,7 @@ ReturnValue_t Max31865RtdReader::periodicReadReqHandling() { return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::periodicReadHandling() { +ReturnValue_t Max31865RtdPolling::periodicReadHandling() { using namespace MAX31865; auto result = returnvalue::OK; // Now read the RTD values @@ -153,11 +150,9 @@ ReturnValue_t Max31865RtdReader::periodicReadHandling() { return returnvalue::FAILED; } if (rtdIsActive(rtd->idx)) { - ManualCsLockWrapper mg1(csLock, gpioIF, rtd->spiCookie, csTimeoutType, csTimeoutMs); - if (mg1.lockResult != returnvalue::OK or mg1.gpioResult != returnvalue::OK) { - sif::error << "Max31865RtdReader::periodicInitHandling: Manual CS lock failed" << std::endl; - continue; - } + // Please note that using the manual CS lock wrapper here is problematic. Might be a SPI + // or hardware specific issue where the CS needs to be pulled high and then low again + // between transfers uint16_t rtdVal = 0; bool faultBitSet = false; result = writeCfgReg(rtd->spiCookie, BASE_CFG); @@ -166,6 +161,7 @@ ReturnValue_t Max31865RtdReader::periodicReadHandling() { continue; } result = readRtdVal(rtd->spiCookie, rtdVal, faultBitSet); + // sif::debug << "RTD Val: " << rtdVal << std::endl; if (result != returnvalue::OK) { handleSpiError(rtd, result, "readRtdVal"); continue; @@ -191,7 +187,7 @@ ReturnValue_t Max31865RtdReader::periodicReadHandling() { return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::initializeInterface(CookieIF* cookie) { +ReturnValue_t Max31865RtdPolling::initializeInterface(CookieIF* cookie) { if (cookie == nullptr) { throw std::invalid_argument("Invalid MAX31865 Reader Cookie"); } @@ -211,8 +207,8 @@ ReturnValue_t Max31865RtdReader::initializeInterface(CookieIF* cookie) { return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* sendData, - size_t sendLen) { +ReturnValue_t Max31865RtdPolling::sendMessage(CookieIF* cookie, const uint8_t* sendData, + size_t sendLen) { if (cookie == nullptr) { return returnvalue::FAILED; } @@ -308,14 +304,14 @@ ReturnValue_t Max31865RtdReader::sendMessage(CookieIF* cookie, const uint8_t* se return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } +ReturnValue_t Max31865RtdPolling::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { +ReturnValue_t Max31865RtdPolling::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, - size_t* size) { +ReturnValue_t Max31865RtdPolling::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, + size_t* size) { MutexGuard mg(readerMutex); if (mg.getLockResult() != returnvalue::OK) { // TODO: Emit warning @@ -338,13 +334,13 @@ ReturnValue_t Max31865RtdReader::readReceivedMessage(CookieIF* cookie, uint8_t** return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::writeCfgReg(SpiCookie* cookie, uint8_t cfg) { +ReturnValue_t Max31865RtdPolling::writeCfgReg(SpiCookie* cookie, uint8_t cfg) { using namespace MAX31865; return writeNToReg(cookie, CONFIG, 1, &cfg, nullptr); } -ReturnValue_t Max31865RtdReader::writeBiasSel(MAX31865::Bias bias, SpiCookie* cookie, - uint8_t baseCfg) { +ReturnValue_t Max31865RtdPolling::writeBiasSel(MAX31865::Bias bias, SpiCookie* cookie, + uint8_t baseCfg) { using namespace MAX31865; if (bias == MAX31865::Bias::OFF) { baseCfg &= ~(1 << CfgBitPos::BIAS_SEL); @@ -354,7 +350,7 @@ ReturnValue_t Max31865RtdReader::writeBiasSel(MAX31865::Bias bias, SpiCookie* co return writeCfgReg(cookie, baseCfg); } -ReturnValue_t Max31865RtdReader::clearFaultStatus(SpiCookie* cookie) { +ReturnValue_t Max31865RtdPolling::clearFaultStatus(SpiCookie* cookie) { using namespace MAX31865; // Read back the current configuration to avoid overwriting it when clearing te fault status uint8_t currentCfg = 0; @@ -368,7 +364,7 @@ ReturnValue_t Max31865RtdReader::clearFaultStatus(SpiCookie* cookie) { return writeCfgReg(cookie, currentCfg); } -ReturnValue_t Max31865RtdReader::readCfgReg(SpiCookie* cookie, uint8_t& cfg) { +ReturnValue_t Max31865RtdPolling::readCfgReg(SpiCookie* cookie, uint8_t& cfg) { using namespace MAX31865; uint8_t* replyPtr = nullptr; auto result = readNFromReg(cookie, CONFIG, 1, &replyPtr); @@ -378,19 +374,19 @@ ReturnValue_t Max31865RtdReader::readCfgReg(SpiCookie* cookie, uint8_t& cfg) { return result; } -ReturnValue_t Max31865RtdReader::writeLowThreshold(SpiCookie* cookie, uint16_t val) { +ReturnValue_t Max31865RtdPolling::writeLowThreshold(SpiCookie* cookie, uint16_t val) { using namespace MAX31865; uint8_t cmd[2] = {static_cast((val >> 8) & 0xff), static_cast(val & 0xff)}; return writeNToReg(cookie, LOW_THRESHOLD, 2, cmd, nullptr); } -ReturnValue_t Max31865RtdReader::writeHighThreshold(SpiCookie* cookie, uint16_t val) { +ReturnValue_t Max31865RtdPolling::writeHighThreshold(SpiCookie* cookie, uint16_t val) { using namespace MAX31865; uint8_t cmd[2] = {static_cast((val >> 8) & 0xff), static_cast(val & 0xff)}; return writeNToReg(cookie, HIGH_THRESHOLD, 2, cmd, nullptr); } -ReturnValue_t Max31865RtdReader::readLowThreshold(SpiCookie* cookie, uint16_t& lowThreshold) { +ReturnValue_t Max31865RtdPolling::readLowThreshold(SpiCookie* cookie, uint16_t& lowThreshold) { using namespace MAX31865; uint8_t* replyPtr = nullptr; auto result = readNFromReg(cookie, LOW_THRESHOLD, 2, &replyPtr); @@ -400,7 +396,7 @@ ReturnValue_t Max31865RtdReader::readLowThreshold(SpiCookie* cookie, uint16_t& l return result; } -ReturnValue_t Max31865RtdReader::readHighThreshold(SpiCookie* cookie, uint16_t& highThreshold) { +ReturnValue_t Max31865RtdPolling::readHighThreshold(SpiCookie* cookie, uint16_t& highThreshold) { using namespace MAX31865; uint8_t* replyPtr = nullptr; auto result = readNFromReg(cookie, HIGH_THRESHOLD, 2, &replyPtr); @@ -410,8 +406,8 @@ ReturnValue_t Max31865RtdReader::readHighThreshold(SpiCookie* cookie, uint16_t& return result; } -ReturnValue_t Max31865RtdReader::writeNToReg(SpiCookie* cookie, uint8_t reg, size_t n, uint8_t* cmd, - uint8_t** reply) { +ReturnValue_t Max31865RtdPolling::writeNToReg(SpiCookie* cookie, uint8_t reg, size_t n, + uint8_t* cmd, uint8_t** reply) { using namespace MAX31865; if (n > cmdBuf.size() - 1) { return returnvalue::FAILED; @@ -423,7 +419,7 @@ ReturnValue_t Max31865RtdReader::writeNToReg(SpiCookie* cookie, uint8_t reg, siz return comIF->sendMessage(cookie, cmdBuf.data(), n + 1); } -ReturnValue_t Max31865RtdReader::readRtdVal(SpiCookie* cookie, uint16_t& val, bool& faultBitSet) { +ReturnValue_t Max31865RtdPolling::readRtdVal(SpiCookie* cookie, uint16_t& val, bool& faultBitSet) { using namespace MAX31865; uint8_t* replyPtr = nullptr; auto result = readNFromReg(cookie, RTD, 2, &replyPtr); @@ -438,8 +434,8 @@ ReturnValue_t Max31865RtdReader::readRtdVal(SpiCookie* cookie, uint16_t& val, bo return result; } -ReturnValue_t Max31865RtdReader::readNFromReg(SpiCookie* cookie, uint8_t reg, size_t n, - uint8_t** reply) { +ReturnValue_t Max31865RtdPolling::readNFromReg(SpiCookie* cookie, uint8_t reg, size_t n, + uint8_t** reply) { using namespace MAX31865; if (n > 4) { return returnvalue::FAILED; @@ -465,15 +461,15 @@ ReturnValue_t Max31865RtdReader::readNFromReg(SpiCookie* cookie, uint8_t reg, si return returnvalue::OK; } -ReturnValue_t Max31865RtdReader::handleSpiError(Max31865ReaderCookie* cookie, ReturnValue_t result, - const char* ctx) { +ReturnValue_t Max31865RtdPolling::handleSpiError(Max31865ReaderCookie* cookie, ReturnValue_t result, + const char* ctx) { cookie->db.spiErrorCount.value += 1; sif::warning << "Max31865RtdReader::handleSpiError: " << ctx << " | Failed with result " << result << std::endl; return result; } -ReturnValue_t Max31865RtdReader::initialize() { +ReturnValue_t Max31865RtdPolling::initialize() { csLock = comIF->getCsMutex(); return SystemObject::initialize(); } diff --git a/linux/devices/Max31865RtdLowlevelHandler.h b/linux/devices/Max31865RtdPolling.h similarity index 92% rename from linux/devices/Max31865RtdLowlevelHandler.h rename to linux/devices/Max31865RtdPolling.h index 4854ef3b..a34c8e53 100644 --- a/linux/devices/Max31865RtdLowlevelHandler.h +++ b/linux/devices/Max31865RtdPolling.h @@ -35,11 +35,11 @@ struct Max31865ReaderCookie : public CookieIF { EiveMax31855::ReadOutStruct db; }; -class Max31865RtdReader : public SystemObject, - public ExecutableObjectIF, - public DeviceCommunicationIF { +class Max31865RtdPolling : public SystemObject, + public ExecutableObjectIF, + public DeviceCommunicationIF { public: - Max31865RtdReader(object_id_t objectId, SpiComIF* lowLevelComIF, GpioIF* gpioIF); + Max31865RtdPolling(object_id_t objectId, SpiComIF* lowLevelComIF, GpioIF* gpioIF); ReturnValue_t performOperation(uint8_t operationCode) override; ReturnValue_t initialize() override; From b3dd2ec57a46cfa8d975e6bc450fdf82e5cde6f6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 11:11:10 +0100 Subject: [PATCH 18/23] merge conflict --- linux/devices/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/devices/CMakeLists.txt b/linux/devices/CMakeLists.txt index 99556957..17d842ea 100644 --- a/linux/devices/CMakeLists.txt +++ b/linux/devices/CMakeLists.txt @@ -2,7 +2,7 @@ if(EIVE_BUILD_GPSD_GPS_HANDLER) target_sources(${OBSW_NAME} PRIVATE GpsHyperionLinuxController.cpp) endif() -<<<<<<< HEAD +target_sources( ${OBSW_NAME} PRIVATE Max31865RtdPolling.cpp ScexUartReader.cpp ImtqPollingTask.cpp ScexDleParser.cpp ScexHelper.cpp RwPollingTask.cpp) From 62e7e23512593ab3bda6c801e78ba4f2ee9a7904 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 11:23:27 +0100 Subject: [PATCH 19/23] prep v1.29.0 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 259234a5..688cdceb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ cmake_minimum_required(VERSION 3.13) set(OBSW_VERSION_MAJOR 1) -set(OBSW_VERSION_MINOR 28) -set(OBSW_VERSION_REVISION 1) +set(OBSW_VERSION_MINOR 29) +set(OBSW_VERSION_REVISION 0) # set(CMAKE_VERBOSE TRUE) From 1bdfd5f8ea062b93e358277dc64f8f9b1d88e570 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 11:29:18 +0100 Subject: [PATCH 20/23] prep v1.29.0 --- CHANGELOG.md | 32 +++++++++++++++++++++----------- tmtc | 2 +- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6aec8ab..fe2ef411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,27 @@ change warranting a new major release: # [unreleased] +# [v1.29.0] + +eive-tmtc: v2.13.0 + +## Changed + +- Refactored IMTQ handlers to also perform low level I2C communication tasks in separate thread. + This avoids the various delays needed for I2C communication with that device inside the ACS PST. + (e.g. 1 ms delay between each transfer, or 10 ms integration delay for MGM measurements). + +## Added + +- Added new heater info set for the TCS controller. This set contains the heater switch states + and the current draw. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 +- The HeaterHandler now exposes a mode which reflects whether the heater power + is on or off. It also triggers mode events for its heater children objects + which show whether the specific heaters are on or off. The heater handler + will be part of the TCS tree. + PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 + # [v1.28.1] ## Fixed @@ -32,9 +53,6 @@ change warranting a new major release: ## Changed - Add `-Wshadow=local` shadowing warnings and fixed all of them -- Refactored IMTQ handlers to also perform low level I2C communication tasks in separate thread. - This avoids the various delays needed for I2C communication with that device inside the ACS PST. - (e.g. 1 ms delay between each transfer, or 10 ms integration delay for MGM measurements). - Updated generated CSV files: Support for skip directive and explicit "No description" info string - The polling threads for actuator polling now have a slightly higher priority than the ACS PST @@ -42,14 +60,6 @@ change warranting a new major release: ## Added -- Added new heater info set for the TCS controller. This set contains the heater switch states - and the current draw. - PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 -- The HeaterHandler now exposes a mode which reflects whether the heater power - is on or off. It also triggers mode events for its heater children objects - which show whether the specific heaters are on or off. The heater handler - will be part of the TCS tree. - PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/351 - git post checkout hook which initializes and updates the submodules automatically. diff --git a/tmtc b/tmtc index 5f082cd9..4ced2d0b 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 5f082cd9fccdaa304f00d92c1f25cdd6a7d8ed0b +Subproject commit 4ced2d0b185f9949662c946ca71fe666ac25e411 From 7aa977efdf2e66dbcc0e8b594dee1d237225174d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 11:32:51 +0100 Subject: [PATCH 21/23] move changelog entry --- CHANGELOG.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a230adad..2134fe20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,15 @@ change warranting a new major release: # [unreleased] +## Fixed + +- Limit number of handled messages for core TM handlers: + - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/391 + - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/390 + - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/389 +- HeaterHandler better handling for faulty message reception + Issue: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/388 + # [v1.29.0] eive-tmtc: v2.13.0 @@ -63,15 +72,6 @@ eive-tmtc: v2.13.0 - git post checkout hook which initializes and updates the submodules automatically. -## Fixed - -- Limit number of handled messages for core TM handlers: - - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/391 - - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/390 - - https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/389 -- HeaterHandler better handling for faulty message reception - Issue: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/issues/388 - # [v1.28.0] 2023-02-17 eive-tmtc: v2.12.7 From d9ef0f9a9df91f67948f25daa5e2e6a0e0f742b4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 11:39:56 +0100 Subject: [PATCH 22/23] small tweak --- CHANGELOG.md | 4 ++++ linux/devices/Max31865RtdPolling.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe2ef411..ddfaf36b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ change warranting a new major release: # [unreleased] +# [v1.29.1] + +- Disable stopwatch in MAX31865 polling task + # [v1.29.0] eive-tmtc: v2.13.0 diff --git a/linux/devices/Max31865RtdPolling.cpp b/linux/devices/Max31865RtdPolling.cpp index a22ec145..e59c2ef2 100644 --- a/linux/devices/Max31865RtdPolling.cpp +++ b/linux/devices/Max31865RtdPolling.cpp @@ -26,7 +26,7 @@ ReturnValue_t Max31865RtdPolling::performOperation(uint8_t operationCode) { using namespace MAX31865; ReturnValue_t result = returnvalue::OK; static_cast(result); - Stopwatch watch; + // Stopwatch watch; if (periodicInitHandling()) { #if OBSW_RTD_AUTO_MODE == 0 // 10 ms delay for VBIAS startup From 243088252c2065e063792ea46274cc3db5d3380a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 21 Feb 2023 11:41:38 +0100 Subject: [PATCH 23/23] bump revision --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 688cdceb..076c9ae7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ cmake_minimum_required(VERSION 3.13) set(OBSW_VERSION_MAJOR 1) set(OBSW_VERSION_MINOR 29) -set(OBSW_VERSION_REVISION 0) +set(OBSW_VERSION_REVISION 1) # set(CMAKE_VERBOSE TRUE)