diff --git a/CHANGELOG.md b/CHANGELOG.md index 0860e342..cde62562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ list yields a list of all related PRs for each release. # [v1.11.0] +## Added + + +- Custom Syrlinks FDIR which disabled most of the default FDIR functionality + + ## Changed - PCDU handler only called once in PST, but can handle multiple messages now diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 6c7d31a1..d45b58b7 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -1,5 +1,8 @@ #include "ObjectFactory.h" +#include +#include + #include "OBSWConfig.h" #include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/callbacks/gnssCallback.h" @@ -37,11 +40,11 @@ #include "linux/obc/PdecHandler.h" #include "linux/obc/Ptme.h" #include "linux/obc/PtmeConfig.h" -#include "mission/system/AcsBoardFdir.h" -#include "mission/system/RtdFdir.h" #include "mission/system/SusAssembly.h" -#include "mission/system/SusFdir.h" #include "mission/system/TcsBoardAssembly.h" +#include "mission/system/fdir/AcsBoardFdir.h" +#include "mission/system/fdir/RtdFdir.h" +#include "mission/system/fdir/SusFdir.h" #include "tmtc/apid.h" #include "tmtc/pusIds.h" @@ -251,14 +254,22 @@ void ObjectFactory::createPcduComponents(LinuxLibgpioIF* gpioComIF, PowerSwitchI CspCookie* pdu1CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU1); CspCookie* pdu2CspCookie = new CspCookie(PDU::MAX_REPLY_LENGTH, addresses::PDU2); CspCookie* acuCspCookie = new CspCookie(ACU::MAX_REPLY_LENGTH, addresses::ACU); - /* Device Handler */ + + auto p60Fdir = new GomspacePowerFdir(objects::P60DOCK_HANDLER); P60DockHandler* p60dockhandler = - new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie); + new P60DockHandler(objects::P60DOCK_HANDLER, objects::CSP_COM_IF, p60DockCspCookie, p60Fdir); + + auto pdu1Fdir = new GomspacePowerFdir(objects::PDU1_HANDLER); PDU1Handler* pdu1handler = - new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie); + new PDU1Handler(objects::PDU1_HANDLER, objects::CSP_COM_IF, pdu1CspCookie, pdu1Fdir); + + auto pdu2Fdir = new GomspacePowerFdir(objects::PDU2_HANDLER); PDU2Handler* pdu2handler = - new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie); - ACUHandler* acuhandler = new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie); + new PDU2Handler(objects::PDU2_HANDLER, objects::CSP_COM_IF, pdu2CspCookie, pdu2Fdir); + + auto acuFdir = new GomspacePowerFdir(objects::ACU_HANDLER); + ACUHandler* acuhandler = + new ACUHandler(objects::ACU_HANDLER, objects::CSP_COM_IF, acuCspCookie, acuFdir); auto pcduHandler = new PCDUHandler(objects::PCDU_HANDLER, 50); /** @@ -641,8 +652,10 @@ void ObjectFactory::createSyrlinksComponents(PowerSwitchIF* pwrSwitcher) { syrlinks::MAX_REPLY_SIZE, UartModes::NON_CANONICAL); syrlinksUartCookie->setParityEven(); - auto syrlinksHandler = new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, - syrlinksUartCookie, pcdu::PDU1_CH1_SYRLINKS_12V); + auto syrlinksFdir = new SyrlinksFdir(objects::SYRLINKS_HK_HANDLER); + auto syrlinksHandler = + new SyrlinksHkHandler(objects::SYRLINKS_HK_HANDLER, objects::UART_COM_IF, syrlinksUartCookie, + pcdu::PDU1_CH1_SYRLINKS_12V, syrlinksFdir); syrlinksHandler->setPowerSwitcher(pwrSwitcher); #if OBSW_DEBUG_SYRLINKS == 1 syrlinksHandler->setDebugMode(true); diff --git a/common/config/commonSubsystemIds.h b/common/config/commonSubsystemIds.h index cd692231..c3e6c5a2 100644 --- a/common/config/commonSubsystemIds.h +++ b/common/config/commonSubsystemIds.h @@ -30,6 +30,7 @@ enum: uint8_t { PDU1_HANDLER = 133, PDU2_HANDLER = 134, ACU_HANDLER = 135, + SYRLINKS = 136, COMMON_SUBSYSTEM_ID_END }; } diff --git a/linux/ObjectFactory.cpp b/linux/ObjectFactory.cpp index d6e53005..23311229 100644 --- a/linux/ObjectFactory.cpp +++ b/linux/ObjectFactory.cpp @@ -9,10 +9,10 @@ #include #include #include -#include #include -#include #include +#include +#include #include "OBSWConfig.h" #include "devConf.h" diff --git a/mission/devices/ACUHandler.cpp b/mission/devices/ACUHandler.cpp index 0fdad639..f881479d 100644 --- a/mission/devices/ACUHandler.cpp +++ b/mission/devices/ACUHandler.cpp @@ -2,8 +2,9 @@ #include "OBSWConfig.h" -ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) - : GomspaceDeviceHandler(objectId, comIF, comCookie, ACU::MAX_CONFIGTABLE_ADDRESS, +ACUHandler::ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + FailureIsolationBase *customFdir) + : GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, ACU::MAX_CONFIGTABLE_ADDRESS, ACU::MAX_HKTABLE_ADDRESS, ACU::HK_TABLE_REPLY_SIZE), acuHkTableDataset(this) {} diff --git a/mission/devices/ACUHandler.h b/mission/devices/ACUHandler.h index fdaf184a..16a7c6db 100644 --- a/mission/devices/ACUHandler.h +++ b/mission/devices/ACUHandler.h @@ -12,7 +12,8 @@ */ class ACUHandler : public GomspaceDeviceHandler { public: - ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + ACUHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + FailureIsolationBase* customFdir); virtual ~ACUHandler(); void setDebugMode(bool enable); diff --git a/mission/devices/GomspaceDeviceHandler.cpp b/mission/devices/GomspaceDeviceHandler.cpp index d24abfe3..fca84cb6 100644 --- a/mission/devices/GomspaceDeviceHandler.cpp +++ b/mission/devices/GomspaceDeviceHandler.cpp @@ -7,9 +7,10 @@ #include "devicedefinitions/powerDefinitions.h" GomspaceDeviceHandler::GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, - CookieIF* comCookie, uint16_t maxConfigTableAddress, + CookieIF* comCookie, FailureIsolationBase* customFdir, + uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, uint16_t hkTableReplySize) - : DeviceHandlerBase(objectId, comIF, comCookie), + : DeviceHandlerBase(objectId, comIF, comCookie, customFdir), maxConfigTableAddress(maxConfigTableAddress), maxHkTableAddress(maxHkTableAddress), hkTableReplySize(hkTableReplySize) { diff --git a/mission/devices/GomspaceDeviceHandler.h b/mission/devices/GomspaceDeviceHandler.h index 7c1555bc..ea09b374 100644 --- a/mission/devices/GomspaceDeviceHandler.h +++ b/mission/devices/GomspaceDeviceHandler.h @@ -38,8 +38,8 @@ class GomspaceDeviceHandler : public DeviceHandlerBase { * device. */ GomspaceDeviceHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, - uint16_t maxConfigTableAddress, uint16_t maxHkTableAddress, - uint16_t hkTableReplySize); + FailureIsolationBase *customFdir, uint16_t maxConfigTableAddress, + uint16_t maxHkTableAddress, uint16_t hkTableReplySize); virtual ~GomspaceDeviceHandler(); /** diff --git a/mission/devices/P60DockHandler.cpp b/mission/devices/P60DockHandler.cpp index 8436044e..f1df649d 100644 --- a/mission/devices/P60DockHandler.cpp +++ b/mission/devices/P60DockHandler.cpp @@ -4,9 +4,11 @@ #include "OBSWConfig.h" -P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) - : GomspaceDeviceHandler(objectId, comIF, comCookie, P60Dock::MAX_CONFIGTABLE_ADDRESS, - P60Dock::MAX_HKTABLE_ADDRESS, P60Dock::HK_TABLE_REPLY_SIZE), +P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + FailureIsolationBase *customFdir) + : GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, + P60Dock::MAX_CONFIGTABLE_ADDRESS, P60Dock::MAX_HKTABLE_ADDRESS, + P60Dock::HK_TABLE_REPLY_SIZE), coreHk(this), auxHk(this) {} diff --git a/mission/devices/P60DockHandler.h b/mission/devices/P60DockHandler.h index 3834bb6b..25a9db35 100644 --- a/mission/devices/P60DockHandler.h +++ b/mission/devices/P60DockHandler.h @@ -21,7 +21,8 @@ class P60DockHandler : public GomspaceDeviceHandler { //! [EXPORT] : [COMMENT] Battery mode has changed. P1: Old mode. P2: New mode static constexpr Event BATT_MODE_CHANGED = event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM); - P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + P60DockHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + FailureIsolationBase* customFdir); virtual ~P60DockHandler(); void setDebugMode(bool enable); diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index 10d12cf8..8e9f1918 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -100,14 +100,9 @@ void PCDUHandler::readCommandQueue() { for (result = commandQueue->receiveMessage(&command); result == RETURN_OK; result = commandQueue->receiveMessage(&command)) { - result = commandQueue->receiveMessage(&command); - if (result != RETURN_OK) { - return; - } - result = poolManager.handleHousekeepingMessage(&command); if (result == RETURN_OK) { - return; + continue; } } } diff --git a/mission/devices/PDU1Handler.cpp b/mission/devices/PDU1Handler.cpp index a466375f..44f8fb04 100644 --- a/mission/devices/PDU1Handler.cpp +++ b/mission/devices/PDU1Handler.cpp @@ -5,8 +5,9 @@ #include "devices/powerSwitcherList.h" -PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) - : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, +PDU1Handler::PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + FailureIsolationBase *customFdir) + : GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, PDU::MAX_CONFIGTABLE_ADDRESS, PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE), coreHk(this), auxHk(this) {} diff --git a/mission/devices/PDU1Handler.h b/mission/devices/PDU1Handler.h index 845f57ec..d900bb15 100644 --- a/mission/devices/PDU1Handler.h +++ b/mission/devices/PDU1Handler.h @@ -21,7 +21,8 @@ */ class PDU1Handler : public GomspaceDeviceHandler { public: - PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + PDU1Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + FailureIsolationBase* customFdir); virtual ~PDU1Handler(); virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/devices/PDU2Handler.cpp b/mission/devices/PDU2Handler.cpp index e5d88644..1476f95d 100644 --- a/mission/devices/PDU2Handler.cpp +++ b/mission/devices/PDU2Handler.cpp @@ -5,8 +5,9 @@ #include "devices/powerSwitcherList.h" -PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie) - : GomspaceDeviceHandler(objectId, comIF, comCookie, PDU::MAX_CONFIGTABLE_ADDRESS, +PDU2Handler::PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF *comCookie, + FailureIsolationBase *customFdir) + : GomspaceDeviceHandler(objectId, comIF, comCookie, customFdir, PDU::MAX_CONFIGTABLE_ADDRESS, PDU::MAX_HKTABLE_ADDRESS, PDU::HK_TABLE_REPLY_SIZE), coreHk(this), auxHk(this) {} diff --git a/mission/devices/PDU2Handler.h b/mission/devices/PDU2Handler.h index 2680c80e..e16130fd 100644 --- a/mission/devices/PDU2Handler.h +++ b/mission/devices/PDU2Handler.h @@ -21,7 +21,8 @@ */ class PDU2Handler : public GomspaceDeviceHandler { public: - PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie); + PDU2Handler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, + FailureIsolationBase* customFdir); virtual ~PDU2Handler(); virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, diff --git a/mission/devices/SyrlinksHkHandler.cpp b/mission/devices/SyrlinksHkHandler.cpp index 2cc506dc..5ddeffbc 100644 --- a/mission/devices/SyrlinksHkHandler.cpp +++ b/mission/devices/SyrlinksHkHandler.cpp @@ -5,8 +5,8 @@ #include "OBSWConfig.h" SyrlinksHkHandler::SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch) - : DeviceHandlerBase(objectId, comIF, comCookie), + power::Switch_t powerSwitch, FailureIsolationBase* customFdir) + : DeviceHandlerBase(objectId, comIF, comCookie, customFdir), rxDataset(this), txDataset(this), temperatureSet(this), diff --git a/mission/devices/SyrlinksHkHandler.h b/mission/devices/SyrlinksHkHandler.h index 0237e8c3..e629359c 100644 --- a/mission/devices/SyrlinksHkHandler.h +++ b/mission/devices/SyrlinksHkHandler.h @@ -20,7 +20,7 @@ class SyrlinksHkHandler : public DeviceHandlerBase { public: SyrlinksHkHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie, - power::Switch_t powerSwitch); + power::Switch_t powerSwitch, FailureIsolationBase* customFdir); virtual ~SyrlinksHkHandler(); /** diff --git a/mission/devices/devicedefinitions/SyrlinksDefinitions.h b/mission/devices/devicedefinitions/SyrlinksDefinitions.h index a816dc29..7e3b6a20 100644 --- a/mission/devices/devicedefinitions/SyrlinksDefinitions.h +++ b/mission/devices/devicedefinitions/SyrlinksDefinitions.h @@ -1,8 +1,14 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_SYRLINKSDEFINITIONS_H_ +#include + namespace syrlinks { +static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYRLINKS; + +static constexpr Event FDIR_REACTION_IGNORED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM); + static const DeviceCommandId_t NONE = 0; static const DeviceCommandId_t RESET_UNIT = 1; /** Reads out all status registers */ diff --git a/mission/devices/devicedefinitions/powerDefinitions.h b/mission/devices/devicedefinitions/powerDefinitions.h index 746bda34..1cffa835 100644 --- a/mission/devices/devicedefinitions/powerDefinitions.h +++ b/mission/devices/devicedefinitions/powerDefinitions.h @@ -15,6 +15,8 @@ static constexpr Event SWITCH_CMD_SENT = event::makeEvent(SUBSYSTEM_ID, 0, sever static constexpr Event SWITCH_HAS_CHANGED = event::makeEvent(SUBSYSTEM_ID, 1, severity::INFO); static constexpr Event SWITCHING_Q7S_DENIED = event::makeEvent(SUBSYSTEM_ID, 2, severity::MEDIUM); +static constexpr Event FDIR_REACTION_IGNORED = event::makeEvent(SUBSYSTEM_ID, 3, severity::MEDIUM); + } // namespace power #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_POWERDEFINITIONS_H_ */ diff --git a/mission/system/CMakeLists.txt b/mission/system/CMakeLists.txt index 59418a07..b6f4baab 100644 --- a/mission/system/CMakeLists.txt +++ b/mission/system/CMakeLists.txt @@ -10,8 +10,6 @@ target_sources(${LIB_EIVE_MISSION} PRIVATE PowerStateMachineBase.cpp DualLaneAssemblyBase.cpp TcsBoardAssembly.cpp +) - AcsBoardFdir.cpp - SusFdir.cpp - RtdFdir.cpp -) \ No newline at end of file +add_subdirectory(fdir) diff --git a/mission/system/AcsBoardFdir.cpp b/mission/system/fdir/AcsBoardFdir.cpp similarity index 100% rename from mission/system/AcsBoardFdir.cpp rename to mission/system/fdir/AcsBoardFdir.cpp diff --git a/mission/system/AcsBoardFdir.h b/mission/system/fdir/AcsBoardFdir.h similarity index 100% rename from mission/system/AcsBoardFdir.h rename to mission/system/fdir/AcsBoardFdir.h diff --git a/mission/system/fdir/CMakeLists.txt b/mission/system/fdir/CMakeLists.txt new file mode 100644 index 00000000..c5414fe8 --- /dev/null +++ b/mission/system/fdir/CMakeLists.txt @@ -0,0 +1,7 @@ +target_sources(${LIB_EIVE_MISSION} PRIVATE + AcsBoardFdir.cpp + RtdFdir.cpp + SusFdir.cpp + SyrlinksFdir.cpp + GomspacePowerFdir.cpp +) diff --git a/mission/system/fdir/GomspacePowerFdir.cpp b/mission/system/fdir/GomspacePowerFdir.cpp new file mode 100644 index 00000000..f7475491 --- /dev/null +++ b/mission/system/fdir/GomspacePowerFdir.cpp @@ -0,0 +1,128 @@ +#include "GomspacePowerFdir.h" + +#include "fsfw/devicehandlers/DeviceHandlerIF.h" +#include "fsfw/health/HealthTableIF.h" +#include "fsfw/modes/HasModesIF.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/power/Fuse.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/thermal/ThermalComponentIF.h" +#include "mission/devices/devicedefinitions/powerDefinitions.h" + +GomspacePowerFdir::GomspacePowerFdir(object_id_t devId, object_id_t parentId) + : DeviceHandlerFailureIsolation(devId, parentId) {} + +ReturnValue_t GomspacePowerFdir::eventReceived(EventMessage* event) { + if (isFdirInActionOrAreWeFaulty(event)) { + return RETURN_OK; + } + ReturnValue_t result = RETURN_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. + // handleRecovery(event->getEvent()); + triggerEvent(power::FDIR_REACTION_IGNORED, event->getEvent(), 0); + 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. + if (strangeReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(power::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + 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 == HasReturnvaluesIF::RETURN_OK) { + break; + } + // else + if (missedReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(power::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + 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; + //****Power***** + case PowerSwitchIF::SWITCH_WENT_OFF: + if (powerConfirmation != MessageQueueIF::NO_QUEUE) { + result = sendConfirmationRequest(event, powerConfirmation); + if (result == RETURN_OK) { + setFdirState(DEVICE_MIGHT_BE_OFF); + } + } + break; + case Fuse::FUSE_WENT_OFF: + // Not so good, because PCDU reacted. + case Fuse::POWER_ABOVE_HIGH_LIMIT: + // Better, because software detected over-current. + setFaulty(event->getEvent()); + break; + case Fuse::POWER_BELOW_LOW_LIMIT: + // Device might got stuck during boot, retry. + // handleRecovery(event->getEvent()); + triggerEvent(power::FDIR_REACTION_IGNORED, event->getEvent(), 0); + 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 RETURN_FAILED; + } + return RETURN_OK; +} + +void GomspacePowerFdir::eventConfirmed(EventMessage* event) { + switch (event->getEvent()) { + case DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED: + case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED: + case DeviceHandlerIF::DEVICE_MISSED_REPLY: + if (missedReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(power::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + break; + case PowerSwitchIF::SWITCH_WENT_OFF: + // This means the switch went off only for one device. + // handleRecovery(event->getEvent()); + triggerEvent(power::FDIR_REACTION_IGNORED, event->getEvent(), 0); + break; + default: + break; + } +} diff --git a/mission/system/fdir/GomspacePowerFdir.h b/mission/system/fdir/GomspacePowerFdir.h new file mode 100644 index 00000000..1a9b4b97 --- /dev/null +++ b/mission/system/fdir/GomspacePowerFdir.h @@ -0,0 +1,15 @@ +#ifndef MISSION_SYSTEM_FDIR_GOMSPACEPOWERFDIR_H_ +#define MISSION_SYSTEM_FDIR_GOMSPACEPOWERFDIR_H_ + +#include + +class GomspacePowerFdir : public DeviceHandlerFailureIsolation { + public: + GomspacePowerFdir(object_id_t devId, object_id_t parentId = objects::NO_OBJECT); + + private: + ReturnValue_t eventReceived(EventMessage* event) override; + void eventConfirmed(EventMessage* event) override; +}; + +#endif /* MISSION_SYSTEM_FDIR_GOMSPACEPOWERFDIR_H_ */ diff --git a/mission/system/RtdFdir.cpp b/mission/system/fdir/RtdFdir.cpp similarity index 100% rename from mission/system/RtdFdir.cpp rename to mission/system/fdir/RtdFdir.cpp diff --git a/mission/system/RtdFdir.h b/mission/system/fdir/RtdFdir.h similarity index 100% rename from mission/system/RtdFdir.h rename to mission/system/fdir/RtdFdir.h diff --git a/mission/system/SusFdir.cpp b/mission/system/fdir/SusFdir.cpp similarity index 100% rename from mission/system/SusFdir.cpp rename to mission/system/fdir/SusFdir.cpp diff --git a/mission/system/SusFdir.h b/mission/system/fdir/SusFdir.h similarity index 100% rename from mission/system/SusFdir.h rename to mission/system/fdir/SusFdir.h diff --git a/mission/system/fdir/SyrlinksFdir.cpp b/mission/system/fdir/SyrlinksFdir.cpp new file mode 100644 index 00000000..c35427db --- /dev/null +++ b/mission/system/fdir/SyrlinksFdir.cpp @@ -0,0 +1,128 @@ +#include "SyrlinksFdir.h" + +#include "fsfw/devicehandlers/DeviceHandlerIF.h" +#include "fsfw/health/HealthTableIF.h" +#include "fsfw/modes/HasModesIF.h" +#include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/power/Fuse.h" +#include "fsfw/serviceinterface/ServiceInterfaceStream.h" +#include "fsfw/thermal/ThermalComponentIF.h" +#include "mission/devices/devicedefinitions/SyrlinksDefinitions.h" + +SyrlinksFdir::SyrlinksFdir(object_id_t syrlinksId) + : DeviceHandlerFailureIsolation(syrlinksId, objects::NO_OBJECT) {} + +ReturnValue_t SyrlinksFdir::eventReceived(EventMessage* event) { + if (isFdirInActionOrAreWeFaulty(event)) { + return RETURN_OK; + } + ReturnValue_t result = RETURN_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. + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + 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. + if (strangeReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + 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 == HasReturnvaluesIF::RETURN_OK) { + break; + } + // else + if (missedReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + 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; + //****Power***** + case PowerSwitchIF::SWITCH_WENT_OFF: + if (powerConfirmation != MessageQueueIF::NO_QUEUE) { + result = sendConfirmationRequest(event, powerConfirmation); + if (result == RETURN_OK) { + setFdirState(DEVICE_MIGHT_BE_OFF); + } + } + break; + case Fuse::FUSE_WENT_OFF: + // Not so good, because PCDU reacted. + case Fuse::POWER_ABOVE_HIGH_LIMIT: + // Better, because software detected over-current. + setFaulty(event->getEvent()); + break; + case Fuse::POWER_BELOW_LOW_LIMIT: + // Device might got stuck during boot, retry. + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + 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 RETURN_FAILED; + } + return RETURN_OK; +} + +void SyrlinksFdir::eventConfirmed(EventMessage* event) { + switch (event->getEvent()) { + case DeviceHandlerIF::DEVICE_SENDING_COMMAND_FAILED: + case DeviceHandlerIF::DEVICE_REQUESTING_REPLY_FAILED: + case DeviceHandlerIF::DEVICE_MISSED_REPLY: + if (missedReplyCount.incrementAndCheck()) { + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + } + break; + case PowerSwitchIF::SWITCH_WENT_OFF: + // This means the switch went off only for one device. + // handleRecovery(event->getEvent()); + triggerEvent(syrlinks::FDIR_REACTION_IGNORED, event->getEvent(), 0); + break; + default: + break; + } +} diff --git a/mission/system/fdir/SyrlinksFdir.h b/mission/system/fdir/SyrlinksFdir.h new file mode 100644 index 00000000..e56714e9 --- /dev/null +++ b/mission/system/fdir/SyrlinksFdir.h @@ -0,0 +1,15 @@ +#ifndef MISSION_DEVICES_SYRLINKSFDIR_H_ +#define MISSION_DEVICES_SYRLINKSFDIR_H_ + +#include + +class SyrlinksFdir : public DeviceHandlerFailureIsolation { + public: + SyrlinksFdir(object_id_t syrlinksId); + + private: + ReturnValue_t eventReceived(EventMessage* event) override; + void eventConfirmed(EventMessage* event) override; +}; + +#endif /* MISSION_DEVICES_SYRLINKSFDIR_H_ */ diff --git a/tmtc b/tmtc index 76da8042..168b6622 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 76da8042a4601087e99fa856af241afe9e43695d +Subproject commit 168b662288175f9db77a5796a02f38cb66911092