From 33773179a729f466e6cb99e01c5c79e80c10483f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 13 Apr 2023 23:54:23 +0200 Subject: [PATCH] custom FDIR for tmp devices --- bsp_q7s/core/ObjectFactory.cpp | 15 +-- dummies/helperFactory.cpp | 4 +- linux/ObjectFactory.cpp | 6 +- linux/acs/StrComHandler.cpp | 2 +- mission/genericFactory.cpp | 4 +- mission/system/CMakeLists.txt | 2 +- mission/system/fdir/CMakeLists.txt | 1 - mission/system/objects/CMakeLists.txt | 5 +- mission/system/objects/SyrlinksAssembly.cpp | 57 ------------ mission/system/objects/SyrlinksAssembly.h | 20 ---- mission/system/systemTree.cpp | 2 +- mission/system/tcs/CMakeLists.txt | 3 + mission/system/{fdir => tcs}/RtdFdir.cpp | 0 mission/system/{fdir => tcs}/RtdFdir.h | 0 .../{objects => tcs}/TcsBoardAssembly.cpp | 0 .../{objects => tcs}/TcsBoardAssembly.h | 0 .../system/{objects => tcs}/TcsSubsystem.cpp | 0 .../system/{objects => tcs}/TcsSubsystem.h | 0 mission/system/tcs/TmpDevFdir.cpp | 91 +++++++++++++++++++ mission/system/tcs/TmpDevFdir.h | 20 ++++ mission/system/{tree => tcs}/tcsModeTree.cpp | 0 mission/system/{tree => tcs}/tcsModeTree.h | 2 +- mission/system/tree/CMakeLists.txt | 2 +- unittest/controller/testThermalController.cpp | 4 +- 24 files changed, 139 insertions(+), 101 deletions(-) delete mode 100644 mission/system/fdir/CMakeLists.txt delete mode 100644 mission/system/objects/SyrlinksAssembly.cpp delete mode 100644 mission/system/objects/SyrlinksAssembly.h create mode 100644 mission/system/tcs/CMakeLists.txt rename mission/system/{fdir => tcs}/RtdFdir.cpp (100%) rename mission/system/{fdir => tcs}/RtdFdir.h (100%) rename mission/system/{objects => tcs}/TcsBoardAssembly.cpp (100%) rename mission/system/{objects => tcs}/TcsBoardAssembly.h (100%) rename mission/system/{objects => tcs}/TcsSubsystem.cpp (100%) rename mission/system/{objects => tcs}/TcsSubsystem.h (100%) create mode 100644 mission/system/tcs/TmpDevFdir.cpp create mode 100644 mission/system/tcs/TmpDevFdir.h rename mission/system/{tree => tcs}/tcsModeTree.cpp (100%) rename mission/system/{tree => tcs}/tcsModeTree.h (84%) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 72c042c1..964d728b 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -27,8 +27,9 @@ #include #include #include +#include #include -#include +#include #include "OBSWConfig.h" #include "bsp_q7s/boardtest/Q7STestTask.h" @@ -62,17 +63,15 @@ #include "mission/system/acs/acsModeTree.h" #include "mission/system/com/SyrlinksFdir.h" #include "mission/system/com/comModeTree.h" -#include "mission/system/fdir/RtdFdir.h" -#include "mission/system/objects/TcsBoardAssembly.h" #include "mission/system/power/GomspacePowerFdir.h" +#include "mission/system/tcs/RtdFdir.h" +#include "mission/system/tcs/TcsBoardAssembly.h" +#include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" -#include "mission/system/tree/tcsModeTree.h" #include "mission/tmtc/tmFilters.h" #include "mission/utility/GlobalConfigHandler.h" #include "tmtc/pusIds.h" -using gpio::Direction; -using gpio::Levels; #if OBSW_TEST_LIBGPIOD == 1 #include "linux/boardtest/LibgpiodTest.h" #endif @@ -123,6 +122,9 @@ using gpio::Levels; #include "mission/system/acs/AcsBoardAssembly.h" #include "mission/tmtc/TmFunnelHandler.h" +using gpio::Direction; +using gpio::Levels; + ResetArgs RESET_ARGS_GNSS; std::atomic_bool LINK_STATE = CcsdsIpCoreHandler::LINK_DOWN; std::atomic_bool PTME_LOCKED = false; @@ -164,6 +166,7 @@ void ObjectFactory::createTmpComponents() { new I2cCookie(tmpDevIds[idx].second, TMP1075::MAX_REPLY_LENGTH, q7s::I2C_PS_EIVE)); auto* tmpDevHandler = new Tmp1075Handler(tmpDevIds[idx].first, objects::I2C_COM_IF, tmpDevCookies[idx]); + tmpDevHandler->setCustomFdir(new TmpDevFdir(tmpDevIds[idx].first)); tmpDevHandler->connectModeTreeParent(satsystem::tcs::SUBSYSTEM); // TODO: Remove this after TCS subsystem was added // These devices are connected to the 3V3 stack and should be powered permanently. Therefore, diff --git a/dummies/helperFactory.cpp b/dummies/helperFactory.cpp index 5a7d1d5b..98d2ecfa 100644 --- a/dummies/helperFactory.cpp +++ b/dummies/helperFactory.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include "TemperatureSensorInserter.h" #include "dummies/Max31865Dummy.h" @@ -38,8 +38,8 @@ #include "mission/genericFactory.h" #include "mission/system/acs/acsModeTree.h" #include "mission/system/com/comModeTree.h" +#include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" -#include "mission/system/tree/tcsModeTree.h" #include "mission/tcs/defs.h" void dummy::createDummies(DummyCfg cfg, PowerSwitchIF& pwrSwitcher, GpioIF* gpioIF) { diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index 72f30278..766b5ca2 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -17,8 +17,8 @@ #include #include #include -#include -#include +#include +#include #include #include "OBSWConfig.h" @@ -27,8 +27,8 @@ #include "devices/gpioIds.h" #include "eive/definitions.h" #include "mission/system/acs/acsModeTree.h" +#include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" -#include "mission/system/tree/tcsModeTree.h" #include "mission/tcs/defs.h" void ObjectFactory::createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, diff --git a/linux/acs/StrComHandler.cpp b/linux/acs/StrComHandler.cpp index 3c88a71b..51c66f18 100644 --- a/linux/acs/StrComHandler.cpp +++ b/linux/acs/StrComHandler.cpp @@ -451,7 +451,7 @@ ReturnValue_t StrComHandler::performFlashWrite() { return returnvalue::OK; } result = writeNextSegment(idx); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } if (idx % 50 == 0) { diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index 9889fe9e..dcee17e1 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -47,7 +47,7 @@ #include "mission/cfdp/Config.h" #include "mission/system/acs/RwAssembly.h" #include "mission/system/acs/acsModeTree.h" -#include "mission/system/tree/tcsModeTree.h" +#include "mission/system/tcs/tcsModeTree.h" #include "mission/tcs/defs.h" #include "mission/tmtc/tmFilters.h" #include "objects/systemObjectList.h" diff --git a/mission/system/CMakeLists.txt b/mission/system/CMakeLists.txt index e5473de8..116c0438 100644 --- a/mission/system/CMakeLists.txt +++ b/mission/system/CMakeLists.txt @@ -1,8 +1,8 @@ add_subdirectory(objects) add_subdirectory(tree) add_subdirectory(acs) +add_subdirectory(tcs) add_subdirectory(com) -add_subdirectory(fdir) add_subdirectory(power) target_sources( diff --git a/mission/system/fdir/CMakeLists.txt b/mission/system/fdir/CMakeLists.txt deleted file mode 100644 index 3f0baf01..00000000 --- a/mission/system/fdir/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE RtdFdir.cpp) diff --git a/mission/system/objects/CMakeLists.txt b/mission/system/objects/CMakeLists.txt index b2fe6056..e7c2b6f3 100644 --- a/mission/system/objects/CMakeLists.txt +++ b/mission/system/objects/CMakeLists.txt @@ -1,4 +1,3 @@ target_sources( - ${LIB_EIVE_MISSION} - PRIVATE CamSwitcher.cpp TcsSubsystem.cpp PayloadSubsystem.cpp - Stack5VHandler.cpp PowerStateMachineBase.cpp TcsBoardAssembly.cpp) + ${LIB_EIVE_MISSION} PRIVATE CamSwitcher.cpp PayloadSubsystem.cpp + Stack5VHandler.cpp PowerStateMachineBase.cpp) diff --git a/mission/system/objects/SyrlinksAssembly.cpp b/mission/system/objects/SyrlinksAssembly.cpp deleted file mode 100644 index b5e50924..00000000 --- a/mission/system/objects/SyrlinksAssembly.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "SyrlinksAssembly.h" - -#include - -using namespace returnvalue; - -SyrlinksAssembly::SyrlinksAssembly(object_id_t objectId) : AssemblyBase(objectId) { - ModeListEntry entry; - entry.setObject(objects::SYRLINKS_HANDLER); - entry.setMode(MODE_OFF); - entry.setSubmode(SUBMODE_NONE); - commandTable.insert(entry); -} - -ReturnValue_t SyrlinksAssembly::commandChildren(Mode_t mode, Submode_t submode) { - commandTable[0].setMode(mode); - commandTable[0].setSubmode(submode); - HybridIterator iter(commandTable.begin(), commandTable.end()); - if (recoveryState == RECOVERY_IDLE) { - ReturnValue_t result = checkAndHandleHealthState(mode, submode); - if (result == NEED_TO_CHANGE_HEALTH) { - return OK; - } - } - executeTable(iter); - return returnvalue::OK; -} - -ReturnValue_t SyrlinksAssembly::checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) { - if (childrenMap[objects::SYRLINKS_HANDLER].mode != wantedMode) { - return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; - } - return returnvalue::OK; -} - -ReturnValue_t SyrlinksAssembly::isModeCombinationValid(Mode_t mode, Submode_t submode) { - if (mode == MODE_ON or mode == DeviceHandlerIF::MODE_NORMAL or mode == MODE_OFF) { - return returnvalue::OK; - } - return returnvalue::FAILED; -} - -ReturnValue_t SyrlinksAssembly::checkAndHandleHealthState(Mode_t deviceMode, - Submode_t deviceSubmode) { - HealthState health = healthHelper.healthTable->getHealth(objects::SYRLINKS_HANDLER); - if (health == FAULTY or health == PERMANENT_FAULTY) { - overwriteDeviceHealth(objects::SYRLINKS_HANDLER, health); - return NEED_TO_CHANGE_HEALTH; - } else if (health == EXTERNAL_CONTROL) { - modeHelper.setForced(true); - } - return OK; -} - -void SyrlinksAssembly::handleChildrenLostMode(ReturnValue_t result) { - startTransition(mode, submode); -} diff --git a/mission/system/objects/SyrlinksAssembly.h b/mission/system/objects/SyrlinksAssembly.h deleted file mode 100644 index 314474d3..00000000 --- a/mission/system/objects/SyrlinksAssembly.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef MISSION_SYSTEM_OBJECTS_SYRLINKSASSEMBLY_H_ -#define MISSION_SYSTEM_OBJECTS_SYRLINKSASSEMBLY_H_ -#include - -class SyrlinksAssembly : public AssemblyBase { - public: - SyrlinksAssembly(object_id_t objectId); - - private: - FixedArrayList commandTable; - - ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) override; - ReturnValue_t checkChildrenStateOn(Mode_t wantedMode, Submode_t wantedSubmode) override; - ReturnValue_t isModeCombinationValid(Mode_t mode, Submode_t submode) override; - void handleChildrenLostMode(ReturnValue_t result) override; - - ReturnValue_t checkAndHandleHealthState(Mode_t deviceMode, Submode_t deviceSubmode); -}; - -#endif /* MISSION_SYSTEM_OBJECTS_SYRLINKSASSEMBLY_H_ */ diff --git a/mission/system/systemTree.cpp b/mission/system/systemTree.cpp index 73a6b4b7..37adbaf5 100644 --- a/mission/system/systemTree.cpp +++ b/mission/system/systemTree.cpp @@ -11,8 +11,8 @@ #include "eive/objects.h" #include "mission/com/defs.h" #include "mission/system/acs/acsModeTree.h" +#include "mission/system/tcs/tcsModeTree.h" #include "mission/system/tree/payloadModeTree.h" -#include "mission/system/tree/tcsModeTree.h" #include "treeUtil.h" namespace { diff --git a/mission/system/tcs/CMakeLists.txt b/mission/system/tcs/CMakeLists.txt new file mode 100644 index 00000000..475a2dd2 --- /dev/null +++ b/mission/system/tcs/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources( + ${LIB_EIVE_MISSION} PRIVATE tcsModeTree.cpp TcsSubsystem.cpp + TcsBoardAssembly.cpp RtdFdir.cpp TmpDevFdir.cpp) diff --git a/mission/system/fdir/RtdFdir.cpp b/mission/system/tcs/RtdFdir.cpp similarity index 100% rename from mission/system/fdir/RtdFdir.cpp rename to mission/system/tcs/RtdFdir.cpp diff --git a/mission/system/fdir/RtdFdir.h b/mission/system/tcs/RtdFdir.h similarity index 100% rename from mission/system/fdir/RtdFdir.h rename to mission/system/tcs/RtdFdir.h diff --git a/mission/system/objects/TcsBoardAssembly.cpp b/mission/system/tcs/TcsBoardAssembly.cpp similarity index 100% rename from mission/system/objects/TcsBoardAssembly.cpp rename to mission/system/tcs/TcsBoardAssembly.cpp diff --git a/mission/system/objects/TcsBoardAssembly.h b/mission/system/tcs/TcsBoardAssembly.h similarity index 100% rename from mission/system/objects/TcsBoardAssembly.h rename to mission/system/tcs/TcsBoardAssembly.h diff --git a/mission/system/objects/TcsSubsystem.cpp b/mission/system/tcs/TcsSubsystem.cpp similarity index 100% rename from mission/system/objects/TcsSubsystem.cpp rename to mission/system/tcs/TcsSubsystem.cpp diff --git a/mission/system/objects/TcsSubsystem.h b/mission/system/tcs/TcsSubsystem.h similarity index 100% rename from mission/system/objects/TcsSubsystem.h rename to mission/system/tcs/TcsSubsystem.h diff --git a/mission/system/tcs/TmpDevFdir.cpp b/mission/system/tcs/TmpDevFdir.cpp new file mode 100644 index 00000000..d501dd1a --- /dev/null +++ b/mission/system/tcs/TmpDevFdir.cpp @@ -0,0 +1,91 @@ +#include "TmpDevFdir.h" + +#include +#include +#include +#include + +TmpDevFdir::TmpDevFdir(object_id_t sensorId) + : DeviceHandlerFailureIsolation(sensorId, objects::NO_OBJECT) {} + +ReturnValue_t TmpDevFdir::eventReceived(EventMessage* event) { + if (isFdirInActionOrAreWeFaulty(event)) { + return returnvalue::OK; + } + ReturnValue_t result = returnvalue::FAILED; + switch (event->getEvent()) { + case HasModesIF::MODE_TRANSITION_FAILED: + case HasModesIF::OBJECT_IN_INVALID_MODE: + case DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT: + // We'll try a recovery as long as defined in MAX_REBOOT. + // Might cause some AssemblyBase cycles, so keep number low. + // Ignored for TMP device, no way to power cycle it without going to OFF/BOOT mode. + // handleRecovery(event->getEvent()); + break; + case DeviceHandlerIF::DEVICE_INTERPRETING_REPLY_FAILED: + case DeviceHandlerIF::DEVICE_READING_REPLY_FAILED: + case DeviceHandlerIF::DEVICE_UNREQUESTED_REPLY: + case DeviceHandlerIF::DEVICE_UNKNOWN_REPLY: // Some DH's generate generic reply-ids. + case DeviceHandlerIF::DEVICE_BUILDING_COMMAND_FAILED: + // These faults all mean that there were stupid replies from a device. + // With now way to do a recovery, set the device to faulty immediately. + setFaulty(event->getEvent()); + break; + case DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED: + case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED: + // The two above should never be confirmed. + case DeviceHandlerIF::DEVICE_MISSED_REPLY: + result = sendConfirmationRequest(event); + if (result == returnvalue::OK) { + break; + } + // else + setFaulty(event->getEvent()); + break; + case StorageManagerIF::GET_DATA_FAILED: + case StorageManagerIF::STORE_DATA_FAILED: + // Rather strange bugs, occur in RAW mode only. Ignore. + break; + case DeviceHandlerIF::INVALID_DEVICE_COMMAND: + // Ignore, is bad configuration. We can't do anything in flight. + break; + case HasHealthIF::HEALTH_INFO: + case HasModesIF::MODE_INFO: + case HasModesIF::CHANGING_MODE: + // Do nothing, but mark as handled. + break; + //****Thermal***** + case ThermalComponentIF::COMPONENT_TEMP_LOW: + case ThermalComponentIF::COMPONENT_TEMP_HIGH: + case ThermalComponentIF::COMPONENT_TEMP_OOL_LOW: + case ThermalComponentIF::COMPONENT_TEMP_OOL_HIGH: + // Well, the device is not really faulty, but it is required to stay off as long as possible. + setFaulty(event->getEvent()); + break; + case ThermalComponentIF::TEMP_NOT_IN_OP_RANGE: + // Ignore, is information only. + break; + //*******Default monitoring variables. Are currently not used.***** + // case DeviceHandlerIF::MONITORING_LIMIT_EXCEEDED: + // setFaulty(event->getEvent()); + // break; + // case DeviceHandlerIF::MONITORING_AMBIGUOUS: + // break; + default: + // We don't know the event, someone else should handle it. + return returnvalue::FAILED; + } + return returnvalue::OK; +} + +void TmpDevFdir::eventConfirmed(EventMessage* event) { + switch (event->getEvent()) { + case DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED: + case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED: + case DeviceHandlerIF::DEVICE_MISSED_REPLY: + setFaulty(event->getEvent()); + break; + default: + break; + } +} diff --git a/mission/system/tcs/TmpDevFdir.h b/mission/system/tcs/TmpDevFdir.h new file mode 100644 index 00000000..38cb73b0 --- /dev/null +++ b/mission/system/tcs/TmpDevFdir.h @@ -0,0 +1,20 @@ +#ifndef MISSION_SYSTEM_TCS_TMPDEVFDIR_H_ +#define MISSION_SYSTEM_TCS_TMPDEVFDIR_H_ +#include + +/** + * Special FDIR because we can not simply power cycle the TMP devices which are powered by the + * 3.3 V stack and there is also no way to logically reset or re-configure the TMP devices in + * any way. In general, instead of doing a recovery, the TMP devices should be set faulty + * immediately for the EIVE project. + */ +class TmpDevFdir : public DeviceHandlerFailureIsolation { + public: + TmpDevFdir(object_id_t sensorId); + + private: + ReturnValue_t eventReceived(EventMessage* event) override; + void eventConfirmed(EventMessage* event) override; +}; + +#endif /* MISSION_SYSTEM_TCS_TMPDEVFDIR_H_ */ diff --git a/mission/system/tree/tcsModeTree.cpp b/mission/system/tcs/tcsModeTree.cpp similarity index 100% rename from mission/system/tree/tcsModeTree.cpp rename to mission/system/tcs/tcsModeTree.cpp diff --git a/mission/system/tree/tcsModeTree.h b/mission/system/tcs/tcsModeTree.h similarity index 84% rename from mission/system/tree/tcsModeTree.h rename to mission/system/tcs/tcsModeTree.h index ca576a6d..e5973641 100644 --- a/mission/system/tree/tcsModeTree.h +++ b/mission/system/tcs/tcsModeTree.h @@ -1,7 +1,7 @@ #ifndef MISSION_SYSTEM_TREE_TCSMODETREE_H_ #define MISSION_SYSTEM_TREE_TCSMODETREE_H_ -#include +#include namespace satsystem { namespace tcs { diff --git a/mission/system/tree/CMakeLists.txt b/mission/system/tree/CMakeLists.txt index 8715d8e1..7b546846 100644 --- a/mission/system/tree/CMakeLists.txt +++ b/mission/system/tree/CMakeLists.txt @@ -1 +1 @@ -target_sources(${LIB_EIVE_MISSION} PRIVATE payloadModeTree.cpp tcsModeTree.cpp) +target_sources(${LIB_EIVE_MISSION} PRIVATE payloadModeTree.cpp) diff --git a/unittest/controller/testThermalController.cpp b/unittest/controller/testThermalController.cpp index 0e12d94d..c2166ca0 100644 --- a/unittest/controller/testThermalController.cpp +++ b/unittest/controller/testThermalController.cpp @@ -47,8 +47,8 @@ TEST_CASE("Thermal Controller", "[ThermalController]") { CommandMessage modeMessage; - ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, - HasModesIF::MODE_ON, HasModesIF::SUBMODE_NONE); + ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_ON, + HasModesIF::SUBMODE_NONE); MessageQueueIF* commandQueue = QueueFactory::instance()->createMessageQueue(5, MessageQueueMessage::MAX_MESSAGE_SIZE);