From 7208343b6d41d70c264918ef1ef0277d3663c8c1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Mar 2023 16:01:13 +0100 Subject: [PATCH] basic faulty cb for power switcher component --- src/fsfw/power/PowerSwitcherComponent.cpp | 5 +++++ src/fsfw/power/PowerSwitcherComponent.h | 20 ++++++++++---------- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 5 +++-- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/fsfw/power/PowerSwitcherComponent.cpp b/src/fsfw/power/PowerSwitcherComponent.cpp index b07a7296..c273e6c3 100644 --- a/src/fsfw/power/PowerSwitcherComponent.cpp +++ b/src/fsfw/power/PowerSwitcherComponent.cpp @@ -28,6 +28,9 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) { continue; } } + if (getHealth() == FAULTY) { + performFaultyOperation(); + } if (switcher.active()) { switcher.doStateMachine(); auto currState = switcher.getState(); @@ -117,3 +120,5 @@ ReturnValue_t PowerSwitcherComponent::connectModeTreeParent(HasModeTreeChildrenI object_id_t PowerSwitcherComponent::getObjectId() const { return SystemObject::getObjectId(); } ModeTreeChildIF& PowerSwitcherComponent::getModeTreeChildIF() { return *this; } + +void PowerSwitcherComponent::performFaultyOperation() {} diff --git a/src/fsfw/power/PowerSwitcherComponent.h b/src/fsfw/power/PowerSwitcherComponent.h index 38dddc37..d6fc06cd 100644 --- a/src/fsfw/power/PowerSwitcherComponent.h +++ b/src/fsfw/power/PowerSwitcherComponent.h @@ -1,5 +1,4 @@ -#ifndef _FSFW_POWER_POWERSWITCHERCOMPONENT_H_ -#define _FSFW_POWER_POWERSWITCHERCOMPONENT_H_ +#pragma once #include #include @@ -37,9 +36,11 @@ class PowerSwitcherComponent : public SystemObject, ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; ModeTreeChildIF &getModeTreeChildIF() override; + protected: + PowerSwitcher switcher; + private: MessageQueueIF *queue = nullptr; - PowerSwitcher switcher; Mode_t mode = MODE_OFF; Submode_t submode = 0; @@ -49,24 +50,23 @@ class PowerSwitcherComponent : public SystemObject, void setMode(Mode_t newMode, Submode_t newSubmode); - virtual ReturnValue_t performOperation(uint8_t opCode) override; + ReturnValue_t performOperation(uint8_t opCode) override; ReturnValue_t initialize() override; - MessageQueueId_t getCommandQueue() const override; + [[nodiscard]] MessageQueueId_t getCommandQueue() const override; void getMode(Mode_t *mode, Submode_t *submode) override; ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) override; void startTransition(Mode_t mode, Submode_t submode) override; + virtual void performFaultyOperation(); void setToExternalControl() override; void announceMode(bool recursive) override; ReturnValue_t setHealth(HealthState health) override; HasHealthIF::HealthState getHealth() override; - object_id_t getObjectId() const override; - const HasHealthIF *getOptHealthIF() const override; - const HasModesIF &getModeIF() const override; + [[nodiscard]] object_id_t getObjectId() const override; + [[nodiscard]] const HasHealthIF *getOptHealthIF() const override; + [[nodiscard]] const HasModesIF &getModeIF() const override; }; - -#endif /* _FSFW_POWER_POWERSWITCHERCOMPONENT_H_ */ diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index d343000a..1a85d4d3 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -112,8 +112,9 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s if (i2cCookie->errorCounter < 3) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::sendMessage: Failed to send data to I2C " - "device from " << deviceFile << " with error code " - << errno << ". Error description: " << strerror(errno) << std::endl; + "device from " + << deviceFile << " with error code " << errno + << ". Error description: " << strerror(errno) << std::endl; #endif } return returnvalue::FAILED;