From 6f0362b9566bd3303a7598517a4ee362d9816bfd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Mar 2022 12:48:15 +0200 Subject: [PATCH 01/18] refactor power module --- src/fsfw/power/CMakeLists.txt | 12 ++++---- src/fsfw/power/DummyPowerSwitcher.cpp | 42 +++++++++++++++++++++++++++ src/fsfw/power/DummyPowerSwitcher.h | 31 ++++++++++++++++++++ src/fsfw/power/Fuse.h | 16 +++++----- src/fsfw/power/PowerSensor.cpp | 4 ++- src/fsfw/power/PowerSwitchIF.h | 7 +++-- src/fsfw/power/PowerSwitcher.cpp | 40 ++++++++++++++++--------- src/fsfw/power/PowerSwitcher.h | 20 ++++++------- src/fsfw/power/definitions.h | 13 +++++++++ 9 files changed, 143 insertions(+), 42 deletions(-) create mode 100644 src/fsfw/power/DummyPowerSwitcher.cpp create mode 100644 src/fsfw/power/DummyPowerSwitcher.h create mode 100644 src/fsfw/power/definitions.h diff --git a/src/fsfw/power/CMakeLists.txt b/src/fsfw/power/CMakeLists.txt index 1c625db1..10e4a44d 100644 --- a/src/fsfw/power/CMakeLists.txt +++ b/src/fsfw/power/CMakeLists.txt @@ -1,7 +1,7 @@ -target_sources(${LIB_FSFW_NAME} - PRIVATE - Fuse.cpp - PowerComponent.cpp - PowerSensor.cpp - PowerSwitcher.cpp +target_sources(${LIB_FSFW_NAME} PRIVATE + Fuse.cpp + PowerComponent.cpp + PowerSensor.cpp + PowerSwitcher.cpp + DummyPowerSwitcher.cpp ) \ No newline at end of file diff --git a/src/fsfw/power/DummyPowerSwitcher.cpp b/src/fsfw/power/DummyPowerSwitcher.cpp new file mode 100644 index 00000000..fe900e72 --- /dev/null +++ b/src/fsfw/power/DummyPowerSwitcher.cpp @@ -0,0 +1,42 @@ +#include "DummyPowerSwitcher.h" + +DummyPowerSwitcher::DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, uint32_t switchDelayMs) +: switcherList(numberOfSwitches), fuseList(numberOfFuses), switchDelayMs(switchDelayMs) { +} + +void DummyPowerSwitcher::setInitialSwitcherList(std::vector switcherList) { + this->switcherList = switcherList; +} + +void DummyPowerSwitcher::setInitialFusesList(std::vector fuseList) { + this->fuseList = fuseList; +} + +ReturnValue_t DummyPowerSwitcher::sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) { + if (switchNr < switcherList.capacity()) { + switcherList[switchNr] = onOff; + } + return RETURN_FAILED; +} + +ReturnValue_t DummyPowerSwitcher::sendFuseOnCommand(uint8_t fuseNr) { + if(fuseNr < fuseList.capacity()) { + fuseList[fuseNr] = FUSE_ON; + } + return RETURN_FAILED; +} + +ReturnValue_t DummyPowerSwitcher::getSwitchState(power::Switch_t switchNr) const { + if (switchNr < switcherList.capacity()) { + return switcherList[switchNr]; + } + return HasReturnvaluesIF::RETURN_FAILED; +} + +ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const { + return RETURN_OK; +} + +uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const { + return 5000; +} diff --git a/src/fsfw/power/DummyPowerSwitcher.h b/src/fsfw/power/DummyPowerSwitcher.h new file mode 100644 index 00000000..39de608d --- /dev/null +++ b/src/fsfw/power/DummyPowerSwitcher.h @@ -0,0 +1,31 @@ +#ifndef FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_ +#define FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_ + +#include "PowerSwitchIF.h" +#include "definitions.h" + +#include +#include + +class DummyPowerSwitcher: public PowerSwitchIF { +public: + DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, uint32_t switchDelayMs = 5000); + + void setInitialSwitcherList(std::vector switcherList); + void setInitialFusesList(std::vector switcherList); + + virtual ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) override; + virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override; + virtual ReturnValue_t getSwitchState(power::Switch_t switchNr) const override; + virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; + virtual uint32_t getSwitchDelayMs(void) const override; + +private: + std::vector switcherList; + std::vector fuseList; + uint32_t switchDelayMs = 5000; +}; + + + +#endif /* FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_ */ diff --git a/src/fsfw/power/Fuse.h b/src/fsfw/power/Fuse.h index e6f9c149..0b57a6a9 100644 --- a/src/fsfw/power/Fuse.h +++ b/src/fsfw/power/Fuse.h @@ -34,14 +34,14 @@ class Fuse : public SystemObject, }; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PCDU_1; - static const Event FUSE_CURRENT_HIGH = MAKE_EVENT( - 1, severity::LOW); //!< PSS detected that current on a fuse is totally out of bounds. - static const Event FUSE_WENT_OFF = - MAKE_EVENT(2, severity::LOW); //!< PSS detected a fuse that went off. - static const Event POWER_ABOVE_HIGH_LIMIT = - MAKE_EVENT(4, severity::LOW); //!< PSS detected a fuse that violates its limits. - static const Event POWER_BELOW_LOW_LIMIT = - MAKE_EVENT(5, severity::LOW); //!< PSS detected a fuse that violates its limits. + //! PSS detected that current on a fuse is totally out of bounds. + static const Event FUSE_CURRENT_HIGH = MAKE_EVENT(1, severity::LOW); + //! PSS detected a fuse that went off. + static const Event FUSE_WENT_OFF = MAKE_EVENT(2, severity::LOW); + //! PSS detected a fuse that violates its limits. + static const Event POWER_ABOVE_HIGH_LIMIT = MAKE_EVENT(4, severity::LOW); + //! PSS detected a fuse that violates its limits. + static const Event POWER_BELOW_LOW_LIMIT = MAKE_EVENT(5, severity::LOW); typedef std::list DeviceList; Fuse(object_id_t fuseObjectId, uint8_t fuseId, sid_t variableSet, VariableIds ids, diff --git a/src/fsfw/power/PowerSensor.cpp b/src/fsfw/power/PowerSensor.cpp index 08ff4724..1936e8ee 100644 --- a/src/fsfw/power/PowerSensor.cpp +++ b/src/fsfw/power/PowerSensor.cpp @@ -15,7 +15,9 @@ PowerSensor::PowerSensor(object_id_t objectId, sid_t setId, VariableIds ids, Def limits.currentMin, limits.currentMax, events.currentLow, events.currentHigh), voltageLimit(objectId, MODULE_ID_VOLTAGE, ids.pidVoltage, confirmationCount, limits.voltageMin, limits.voltageMax, events.voltageLow, events.voltageHigh) { - commandQueue = QueueFactory::instance()->createMessageQueue(); + auto mqArgs = MqArgs(objectId, static_cast(this)); + commandQueue = QueueFactory::instance()->createMessageQueue( + 3, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } PowerSensor::~PowerSensor() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } diff --git a/src/fsfw/power/PowerSwitchIF.h b/src/fsfw/power/PowerSwitchIF.h index a31d8971..71c5523d 100644 --- a/src/fsfw/power/PowerSwitchIF.h +++ b/src/fsfw/power/PowerSwitchIF.h @@ -1,6 +1,7 @@ #ifndef FSFW_POWER_POWERSWITCHIF_H_ #define FSFW_POWER_POWERSWITCHIF_H_ +#include "definitions.h" #include "../events/Event.h" #include "../returnvalues/HasReturnvaluesIF.h" /** @@ -37,11 +38,11 @@ class PowerSwitchIF : public HasReturnvaluesIF { * @param switchNr * @param onOff on == @c SWITCH_ON; off != @c SWITCH_ON */ - virtual void sendSwitchCommand(uint8_t switchNr, ReturnValue_t onOff) const = 0; + virtual ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) = 0; /** * Sends a command to the Power Unit to enable a certain fuse. */ - virtual void sendFuseOnCommand(uint8_t fuseNr) const = 0; + virtual ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) = 0; /** * get the state of the Switches. @@ -51,7 +52,7 @@ class PowerSwitchIF : public HasReturnvaluesIF { * - @c SWITCH_OFF if the specified switch is off. * - @c RETURN_FAILED if an error occured */ - virtual ReturnValue_t getSwitchState(uint8_t switchNr) const = 0; + virtual ReturnValue_t getSwitchState(power::Switch_t switchNr) const = 0; /** * get state of a fuse. * @param fuseNr diff --git a/src/fsfw/power/PowerSwitcher.cpp b/src/fsfw/power/PowerSwitcher.cpp index 0a3f8521..83679772 100644 --- a/src/fsfw/power/PowerSwitcher.cpp +++ b/src/fsfw/power/PowerSwitcher.cpp @@ -1,19 +1,12 @@ +#include "definitions.h" #include "fsfw/power/PowerSwitcher.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -PowerSwitcher::PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2, - PowerSwitcher::State_t setStartState) - : state(setStartState), firstSwitch(setSwitch1), secondSwitch(setSwitch2) {} - -ReturnValue_t PowerSwitcher::initialize(object_id_t powerSwitchId) { - power = ObjectManager::instance()->get(powerSwitchId); - if (power == nullptr) { - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; -} +PowerSwitcher::PowerSwitcher(PowerSwitchIF* switcher, power::Switch_t setSwitch1, + power::Switch_t setSwitch2, PowerSwitcher::State_t setStartState) + : power(switcher), state(setStartState), firstSwitch(setSwitch1), secondSwitch(setSwitch2) {} ReturnValue_t PowerSwitcher::getStateOfSwitches() { SwitchReturn_t result = howManySwitches(); @@ -52,18 +45,37 @@ void PowerSwitcher::commandSwitches(ReturnValue_t onOff) { return; } -void PowerSwitcher::turnOn() { +void PowerSwitcher::turnOn(bool checkCurrentState) { + if(checkCurrentState) { + if(getStateOfSwitches() == PowerSwitchIF::SWITCH_ON) { + state = SWITCH_IS_ON; + return; + } + } commandSwitches(PowerSwitchIF::SWITCH_ON); state = WAIT_ON; } -void PowerSwitcher::turnOff() { +void PowerSwitcher::turnOff(bool checkCurrentState) { + if(checkCurrentState) { + if(getStateOfSwitches() == PowerSwitchIF::SWITCH_OFF) { + state = SWITCH_IS_OFF; + return; + } + } commandSwitches(PowerSwitchIF::SWITCH_OFF); state = WAIT_OFF; } +bool PowerSwitcher::active() { + if(state == WAIT_OFF or state == WAIT_ON) { + return true; + } + return false; +} + PowerSwitcher::SwitchReturn_t PowerSwitcher::howManySwitches() { - if (secondSwitch == NO_SWITCH) { + if (secondSwitch == power::NO_SWITCH) { return ONE_SWITCH; } else { return TWO_SWITCHES; diff --git a/src/fsfw/power/PowerSwitcher.h b/src/fsfw/power/PowerSwitcher.h index c72c241d..853bbb40 100644 --- a/src/fsfw/power/PowerSwitcher.h +++ b/src/fsfw/power/PowerSwitcher.h @@ -14,28 +14,28 @@ class PowerSwitcher : public HasReturnvaluesIF { SWITCH_IS_OFF, SWITCH_IS_ON, }; - State_t state; + static const uint8_t INTERFACE_ID = CLASS_ID::POWER_SWITCHER; static const ReturnValue_t IN_POWER_TRANSITION = MAKE_RETURN_CODE(1); static const ReturnValue_t SWITCH_STATE_MISMATCH = MAKE_RETURN_CODE(2); - PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2 = NO_SWITCH, + PowerSwitcher(PowerSwitchIF* switcher, uint8_t setSwitch1, uint8_t setSwitch2 = power::NO_SWITCH, State_t setStartState = SWITCH_IS_OFF); - ReturnValue_t initialize(object_id_t powerSwitchId); - void turnOn(); - void turnOff(); + void turnOn(bool checkCurrentState = true); + void turnOff(bool checkCurrentState = true); + bool active(); void doStateMachine(); State_t getState(); ReturnValue_t checkSwitchState(); uint32_t getSwitchDelay(); - uint8_t getFirstSwitch() const; - uint8_t getSecondSwitch() const; + power::Switch_t getFirstSwitch() const; + power::Switch_t getSecondSwitch() const; private: - uint8_t firstSwitch; - uint8_t secondSwitch; PowerSwitchIF* power = nullptr; + State_t state; + power::Switch_t firstSwitch = power::NO_SWITCH; + power::Switch_t secondSwitch = power::NO_SWITCH; - static const uint8_t NO_SWITCH = 0xFF; enum SwitchReturn_t { ONE_SWITCH = 1, TWO_SWITCHES = 2 }; ReturnValue_t getStateOfSwitches(); void commandSwitches(ReturnValue_t onOff); diff --git a/src/fsfw/power/definitions.h b/src/fsfw/power/definitions.h new file mode 100644 index 00000000..1e4fe296 --- /dev/null +++ b/src/fsfw/power/definitions.h @@ -0,0 +1,13 @@ +#ifndef FSFW_SRC_FSFW_POWER_DEFINITIONS_H_ +#define FSFW_SRC_FSFW_POWER_DEFINITIONS_H_ + +#include + +namespace power { + +using Switch_t = uint8_t; +static constexpr Switch_t NO_SWITCH = 0xFF; + +} + +#endif /* FSFW_SRC_FSFW_POWER_DEFINITIONS_H_ */ From b32d1da4211c62b024cba4310fbecfaf1af01478 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Mar 2022 12:57:11 +0200 Subject: [PATCH 02/18] this should compile --- src/fsfw/power/DummyPowerSwitcher.cpp | 16 ++++----- src/fsfw/power/DummyPowerSwitcher.h | 14 ++++---- src/fsfw/power/PowerSensor.cpp | 5 ++- src/fsfw/power/PowerSwitchIF.h | 2 +- src/fsfw/power/PowerSwitcher.cpp | 12 +++---- src/fsfw/power/definitions.h | 2 +- src/fsfw/version.cpp | 3 +- src/fsfw/version.h | 2 +- tests/src/fsfw_tests/unit/version.cpp | 50 +++++++++++++-------------- 9 files changed, 50 insertions(+), 56 deletions(-) diff --git a/src/fsfw/power/DummyPowerSwitcher.cpp b/src/fsfw/power/DummyPowerSwitcher.cpp index fe900e72..92d9cfbd 100644 --- a/src/fsfw/power/DummyPowerSwitcher.cpp +++ b/src/fsfw/power/DummyPowerSwitcher.cpp @@ -1,8 +1,8 @@ #include "DummyPowerSwitcher.h" -DummyPowerSwitcher::DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, uint32_t switchDelayMs) -: switcherList(numberOfSwitches), fuseList(numberOfFuses), switchDelayMs(switchDelayMs) { -} +DummyPowerSwitcher::DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, + uint32_t switchDelayMs) + : switcherList(numberOfSwitches), fuseList(numberOfFuses), switchDelayMs(switchDelayMs) {} void DummyPowerSwitcher::setInitialSwitcherList(std::vector switcherList) { this->switcherList = switcherList; @@ -20,7 +20,7 @@ ReturnValue_t DummyPowerSwitcher::sendSwitchCommand(power::Switch_t switchNr, Re } ReturnValue_t DummyPowerSwitcher::sendFuseOnCommand(uint8_t fuseNr) { - if(fuseNr < fuseList.capacity()) { + if (fuseNr < fuseList.capacity()) { fuseList[fuseNr] = FUSE_ON; } return RETURN_FAILED; @@ -33,10 +33,6 @@ ReturnValue_t DummyPowerSwitcher::getSwitchState(power::Switch_t switchNr) const return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const { - return RETURN_OK; -} +ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const { return RETURN_OK; } -uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const { - return 5000; -} +uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const { return 5000; } diff --git a/src/fsfw/power/DummyPowerSwitcher.h b/src/fsfw/power/DummyPowerSwitcher.h index 39de608d..3582f8d7 100644 --- a/src/fsfw/power/DummyPowerSwitcher.h +++ b/src/fsfw/power/DummyPowerSwitcher.h @@ -1,14 +1,14 @@ #ifndef FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_ #define FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_ +#include +#include + #include "PowerSwitchIF.h" #include "definitions.h" -#include -#include - -class DummyPowerSwitcher: public PowerSwitchIF { -public: +class DummyPowerSwitcher : public PowerSwitchIF { + public: DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, uint32_t switchDelayMs = 5000); void setInitialSwitcherList(std::vector switcherList); @@ -20,12 +20,10 @@ public: virtual ReturnValue_t getFuseState(uint8_t fuseNr) const override; virtual uint32_t getSwitchDelayMs(void) const override; -private: + private: std::vector switcherList; std::vector fuseList; uint32_t switchDelayMs = 5000; }; - - #endif /* FSFW_SRC_FSFW_POWER_DUMMYPOWERSWITCHER_H_ */ diff --git a/src/fsfw/power/PowerSensor.cpp b/src/fsfw/power/PowerSensor.cpp index 1936e8ee..e73b12d0 100644 --- a/src/fsfw/power/PowerSensor.cpp +++ b/src/fsfw/power/PowerSensor.cpp @@ -15,9 +15,8 @@ PowerSensor::PowerSensor(object_id_t objectId, sid_t setId, VariableIds ids, Def limits.currentMin, limits.currentMax, events.currentLow, events.currentHigh), voltageLimit(objectId, MODULE_ID_VOLTAGE, ids.pidVoltage, confirmationCount, limits.voltageMin, limits.voltageMax, events.voltageLow, events.voltageHigh) { - auto mqArgs = MqArgs(objectId, static_cast(this)); - commandQueue = QueueFactory::instance()->createMessageQueue( - 3, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); + commandQueue = + QueueFactory::instance()->createMessageQueue(3, MessageQueueMessage::MAX_MESSAGE_SIZE); } PowerSensor::~PowerSensor() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } diff --git a/src/fsfw/power/PowerSwitchIF.h b/src/fsfw/power/PowerSwitchIF.h index 71c5523d..bc883fbc 100644 --- a/src/fsfw/power/PowerSwitchIF.h +++ b/src/fsfw/power/PowerSwitchIF.h @@ -1,9 +1,9 @@ #ifndef FSFW_POWER_POWERSWITCHIF_H_ #define FSFW_POWER_POWERSWITCHIF_H_ -#include "definitions.h" #include "../events/Event.h" #include "../returnvalues/HasReturnvaluesIF.h" +#include "definitions.h" /** * * @brief This interface defines a connection to a device that is capable of diff --git a/src/fsfw/power/PowerSwitcher.cpp b/src/fsfw/power/PowerSwitcher.cpp index 83679772..7608c6e7 100644 --- a/src/fsfw/power/PowerSwitcher.cpp +++ b/src/fsfw/power/PowerSwitcher.cpp @@ -1,6 +1,6 @@ -#include "definitions.h" #include "fsfw/power/PowerSwitcher.h" +#include "definitions.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -46,8 +46,8 @@ void PowerSwitcher::commandSwitches(ReturnValue_t onOff) { } void PowerSwitcher::turnOn(bool checkCurrentState) { - if(checkCurrentState) { - if(getStateOfSwitches() == PowerSwitchIF::SWITCH_ON) { + if (checkCurrentState) { + if (getStateOfSwitches() == PowerSwitchIF::SWITCH_ON) { state = SWITCH_IS_ON; return; } @@ -57,8 +57,8 @@ void PowerSwitcher::turnOn(bool checkCurrentState) { } void PowerSwitcher::turnOff(bool checkCurrentState) { - if(checkCurrentState) { - if(getStateOfSwitches() == PowerSwitchIF::SWITCH_OFF) { + if (checkCurrentState) { + if (getStateOfSwitches() == PowerSwitchIF::SWITCH_OFF) { state = SWITCH_IS_OFF; return; } @@ -68,7 +68,7 @@ void PowerSwitcher::turnOff(bool checkCurrentState) { } bool PowerSwitcher::active() { - if(state == WAIT_OFF or state == WAIT_ON) { + if (state == WAIT_OFF or state == WAIT_ON) { return true; } return false; diff --git a/src/fsfw/power/definitions.h b/src/fsfw/power/definitions.h index 1e4fe296..ed2a0037 100644 --- a/src/fsfw/power/definitions.h +++ b/src/fsfw/power/definitions.h @@ -8,6 +8,6 @@ namespace power { using Switch_t = uint8_t; static constexpr Switch_t NO_SWITCH = 0xFF; -} +} // namespace power #endif /* FSFW_SRC_FSFW_POWER_DEFINITIONS_H_ */ diff --git a/src/fsfw/version.cpp b/src/fsfw/version.cpp index 926e465f..e4a62002 100644 --- a/src/fsfw/version.cpp +++ b/src/fsfw/version.cpp @@ -1,8 +1,9 @@ #include "version.h" -#include "fsfw/FSFWVersion.h" #include +#include "fsfw/FSFWVersion.h" + #ifdef major #undef major #endif diff --git a/src/fsfw/version.h b/src/fsfw/version.h index 7cddf193..bb4d0399 100644 --- a/src/fsfw/version.h +++ b/src/fsfw/version.h @@ -29,7 +29,7 @@ class Version { } friend bool operator>(const Version& v1, const Version& v2) { - return not (v1 < v2) and not (v1 == v2); + return not(v1 < v2) and not(v1 == v2); } friend bool operator<=(const Version& v1, const Version& v2) { return ((v1 == v2) or (v1 < v2)); } diff --git a/tests/src/fsfw_tests/unit/version.cpp b/tests/src/fsfw_tests/unit/version.cpp index 92a930dc..2967dfa5 100644 --- a/tests/src/fsfw_tests/unit/version.cpp +++ b/tests/src/fsfw_tests/unit/version.cpp @@ -17,15 +17,15 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { fsfw::Version v1 = fsfw::Version(1, 1, 1); fsfw::Version v2 = fsfw::Version(1, 1, 1); REQUIRE(v1 == v2); - REQUIRE(not (v1 < v2)); - REQUIRE(not (v1 > v2)); + REQUIRE(not(v1 < v2)); + REQUIRE(not(v1 > v2)); REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); v1.revision -= 1; REQUIRE(v1 != v2); - REQUIRE(not (v1 == v2)); - REQUIRE(not (v1 > v2)); - REQUIRE(not (v1 >= v2)); + REQUIRE(not(v1 == v2)); + REQUIRE(not(v1 > v2)); + REQUIRE(not(v1 >= v2)); REQUIRE(v1 < v2); REQUIRE(v1 <= v2); v1.revision += 1; @@ -33,60 +33,60 @@ TEST_CASE("Version API Tests", "[TestVersionAPI]") { REQUIRE(v1 != v2); REQUIRE(v1 < v2); REQUIRE(v1 <= v2); - REQUIRE(not (v1 == v2)); - REQUIRE(not (v1 > v2)); - REQUIRE(not (v1 >= v2)); + REQUIRE(not(v1 == v2)); + REQUIRE(not(v1 > v2)); + REQUIRE(not(v1 >= v2)); v1.minor += 1; v1.major -= 1; REQUIRE(v1 != v2); REQUIRE(v1 < v2); REQUIRE(v1 <= v2); - REQUIRE(not (v1 == v2)); - REQUIRE(not (v1 > v2)); - REQUIRE(not (v1 >= v2)); + REQUIRE(not(v1 == v2)); + REQUIRE(not(v1 > v2)); + REQUIRE(not(v1 >= v2)); v1.major += 1; REQUIRE(v1 == v2); REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); - REQUIRE(not (v1 != v2)); - REQUIRE(not (v1 > v2)); - REQUIRE(not (v1 < v2)); + REQUIRE(not(v1 != v2)); + REQUIRE(not(v1 > v2)); + REQUIRE(not(v1 < v2)); v1.major += 1; v1.minor -= 1; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); - REQUIRE(not (v1 == v2)); - REQUIRE(not (v1 < v2)); - REQUIRE(not (v1 <= v2)); + REQUIRE(not(v1 == v2)); + REQUIRE(not(v1 < v2)); + REQUIRE(not(v1 <= v2)); v1.major -= 1; v1.minor += 2; v1.revision -= 1; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); - REQUIRE(not (v1 == v2)); - REQUIRE(not (v1 < v2)); - REQUIRE(not (v1 <= v2)); + REQUIRE(not(v1 == v2)); + REQUIRE(not(v1 < v2)); + REQUIRE(not(v1 <= v2)); v1.minor -= 1; v1.revision += 2; REQUIRE(v1 != v2); REQUIRE(v1 > v2); REQUIRE(v1 >= v2); - REQUIRE(not (v1 == v2)); - REQUIRE(not (v1 < v2)); - REQUIRE(not (v1 <= v2)); + REQUIRE(not(v1 == v2)); + REQUIRE(not(v1 < v2)); + REQUIRE(not(v1 <= v2)); v1.revision -= 1; REQUIRE(v1 == v2); REQUIRE(v1 <= v2); REQUIRE(v1 >= v2); - REQUIRE(not (v1 != v2)); + REQUIRE(not(v1 != v2)); #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "v" << fsfw::FSFW_VERSION << std::endl; #endif char verString[10] = {}; fsfw::FSFW_VERSION.getVersion(verString, sizeof(verString)); #if FSFW_DISABLE_PRINTOUT == 0 - printf("v%s\n",verString); + printf("v%s\n", verString); #endif } From 23af1702297e3a614eb9344fbaa66baff464af8f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Mar 2022 12:59:03 +0200 Subject: [PATCH 03/18] small tweaks --- src/fsfw/power/DummyPowerSwitcher.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/fsfw/power/DummyPowerSwitcher.cpp b/src/fsfw/power/DummyPowerSwitcher.cpp index 92d9cfbd..4f18901d 100644 --- a/src/fsfw/power/DummyPowerSwitcher.cpp +++ b/src/fsfw/power/DummyPowerSwitcher.cpp @@ -33,6 +33,11 @@ ReturnValue_t DummyPowerSwitcher::getSwitchState(power::Switch_t switchNr) const return HasReturnvaluesIF::RETURN_FAILED; } -ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const { return RETURN_OK; } +ReturnValue_t DummyPowerSwitcher::getFuseState(uint8_t fuseNr) const { + if (fuseNr < fuseList.capacity()) { + return fuseList[fuseNr]; + } + return HasReturnvaluesIF::RETURN_FAILED; +} -uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const { return 5000; } +uint32_t DummyPowerSwitcher::getSwitchDelayMs(void) const { return switchDelayMs; } From b42987059a165c4b80991391574192e442ffed6b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Mar 2022 17:41:38 +0200 Subject: [PATCH 04/18] make dummy power switcher a system object --- src/fsfw/power/DummyPowerSwitcher.cpp | 9 ++++++--- src/fsfw/power/DummyPowerSwitcher.h | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/fsfw/power/DummyPowerSwitcher.cpp b/src/fsfw/power/DummyPowerSwitcher.cpp index 4f18901d..d0a87288 100644 --- a/src/fsfw/power/DummyPowerSwitcher.cpp +++ b/src/fsfw/power/DummyPowerSwitcher.cpp @@ -1,8 +1,11 @@ #include "DummyPowerSwitcher.h" -DummyPowerSwitcher::DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, - uint32_t switchDelayMs) - : switcherList(numberOfSwitches), fuseList(numberOfFuses), switchDelayMs(switchDelayMs) {} +DummyPowerSwitcher::DummyPowerSwitcher(object_id_t objectId, size_t numberOfSwitches, + size_t numberOfFuses, uint32_t switchDelayMs) + : SystemObject(objectId), + switcherList(numberOfSwitches), + fuseList(numberOfFuses), + switchDelayMs(switchDelayMs) {} void DummyPowerSwitcher::setInitialSwitcherList(std::vector switcherList) { this->switcherList = switcherList; diff --git a/src/fsfw/power/DummyPowerSwitcher.h b/src/fsfw/power/DummyPowerSwitcher.h index 3582f8d7..24e9d648 100644 --- a/src/fsfw/power/DummyPowerSwitcher.h +++ b/src/fsfw/power/DummyPowerSwitcher.h @@ -6,10 +6,12 @@ #include "PowerSwitchIF.h" #include "definitions.h" +#include "fsfw/objectmanager/SystemObject.h" -class DummyPowerSwitcher : public PowerSwitchIF { +class DummyPowerSwitcher : public SystemObject, public PowerSwitchIF { public: - DummyPowerSwitcher(size_t numberOfSwitches, size_t numberOfFuses, uint32_t switchDelayMs = 5000); + DummyPowerSwitcher(object_id_t objectId, size_t numberOfSwitches, size_t numberOfFuses, + uint32_t switchDelayMs = 5000); void setInitialSwitcherList(std::vector switcherList); void setInitialFusesList(std::vector switcherList); From c20be13733b0731c30c1d44eb08caf5e5862eb06 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 1 Apr 2022 16:40:13 +0200 Subject: [PATCH 05/18] change switch type in header as well --- src/fsfw/power/PowerSwitcher.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fsfw/power/PowerSwitcher.h b/src/fsfw/power/PowerSwitcher.h index 853bbb40..279ffacf 100644 --- a/src/fsfw/power/PowerSwitcher.h +++ b/src/fsfw/power/PowerSwitcher.h @@ -18,7 +18,8 @@ class PowerSwitcher : public HasReturnvaluesIF { static const uint8_t INTERFACE_ID = CLASS_ID::POWER_SWITCHER; static const ReturnValue_t IN_POWER_TRANSITION = MAKE_RETURN_CODE(1); static const ReturnValue_t SWITCH_STATE_MISMATCH = MAKE_RETURN_CODE(2); - PowerSwitcher(PowerSwitchIF* switcher, uint8_t setSwitch1, uint8_t setSwitch2 = power::NO_SWITCH, + PowerSwitcher(PowerSwitchIF* switcher, power::Switch_t setSwitch1, + power::Switch_t setSwitch2 = power::NO_SWITCH, State_t setStartState = SWITCH_IS_OFF); void turnOn(bool checkCurrentState = true); void turnOff(bool checkCurrentState = true); From 738f5720432cefb5a40292491babb6cd5d829010 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 1 Apr 2022 18:38:25 +0200 Subject: [PATCH 06/18] added unit tests, minor API change --- src/fsfw/power/DummyPowerSwitcher.cpp | 5 +- src/fsfw/power/DummyPowerSwitcher.h | 2 +- tests/src/fsfw_tests/unit/CMakeLists.txt | 3 + .../src/fsfw_tests/unit/mocks/CMakeLists.txt | 3 + .../unit/mocks/PowerSwitcherMock.cpp | 77 +++++++++++++++++++ .../fsfw_tests/unit/mocks/PowerSwitcherMock.h | 52 +++++++++++++ .../src/fsfw_tests/unit/power/CMakeLists.txt | 3 + .../unit/power/testPowerSwitcher.cpp | 66 ++++++++++++++++ .../unit/testcfg/objects/systemObjectList.h | 3 +- 9 files changed, 210 insertions(+), 4 deletions(-) create mode 100644 tests/src/fsfw_tests/unit/mocks/CMakeLists.txt create mode 100644 tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp create mode 100644 tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h create mode 100644 tests/src/fsfw_tests/unit/power/CMakeLists.txt create mode 100644 tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp diff --git a/src/fsfw/power/DummyPowerSwitcher.cpp b/src/fsfw/power/DummyPowerSwitcher.cpp index d0a87288..799d49aa 100644 --- a/src/fsfw/power/DummyPowerSwitcher.cpp +++ b/src/fsfw/power/DummyPowerSwitcher.cpp @@ -1,8 +1,9 @@ #include "DummyPowerSwitcher.h" DummyPowerSwitcher::DummyPowerSwitcher(object_id_t objectId, size_t numberOfSwitches, - size_t numberOfFuses, uint32_t switchDelayMs) - : SystemObject(objectId), + size_t numberOfFuses, bool registerGlobally, + uint32_t switchDelayMs) + : SystemObject(objectId, registerGlobally), switcherList(numberOfSwitches), fuseList(numberOfFuses), switchDelayMs(switchDelayMs) {} diff --git a/src/fsfw/power/DummyPowerSwitcher.h b/src/fsfw/power/DummyPowerSwitcher.h index 24e9d648..b2dd40d5 100644 --- a/src/fsfw/power/DummyPowerSwitcher.h +++ b/src/fsfw/power/DummyPowerSwitcher.h @@ -11,7 +11,7 @@ class DummyPowerSwitcher : public SystemObject, public PowerSwitchIF { public: DummyPowerSwitcher(object_id_t objectId, size_t numberOfSwitches, size_t numberOfFuses, - uint32_t switchDelayMs = 5000); + bool registerGlobally = true, uint32_t switchDelayMs = 5000); void setInitialSwitcherList(std::vector switcherList); void setInitialFusesList(std::vector switcherList); diff --git a/tests/src/fsfw_tests/unit/CMakeLists.txt b/tests/src/fsfw_tests/unit/CMakeLists.txt index a8d31d88..b5143c3b 100644 --- a/tests/src/fsfw_tests/unit/CMakeLists.txt +++ b/tests/src/fsfw_tests/unit/CMakeLists.txt @@ -11,7 +11,10 @@ target_sources(${FSFW_TEST_TGT} PRIVATE ) add_subdirectory(testcfg) +add_subdirectory(mocks) + add_subdirectory(action) +add_subdirectory(power) add_subdirectory(container) add_subdirectory(osal) add_subdirectory(serialize) diff --git a/tests/src/fsfw_tests/unit/mocks/CMakeLists.txt b/tests/src/fsfw_tests/unit/mocks/CMakeLists.txt new file mode 100644 index 00000000..1b86547c --- /dev/null +++ b/tests/src/fsfw_tests/unit/mocks/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + PowerSwitcherMock.cpp +) diff --git a/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp b/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp new file mode 100644 index 00000000..5c6935e4 --- /dev/null +++ b/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.cpp @@ -0,0 +1,77 @@ +#include "PowerSwitcherMock.h" + +static uint32_t SWITCH_REQUEST_UPDATE_VALUE = 0; + +PowerSwitcherMock::PowerSwitcherMock() {} + +ReturnValue_t PowerSwitcherMock::sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) { + if (switchMap.count(switchNr) == 0) { + switchMap.emplace(switchNr, SwitchInfo(switchNr, onOff)); + } else { + SwitchInfo& info = switchMap.at(switchNr); + info.currentState = onOff; + if (onOff == PowerSwitchIF::SWITCH_ON) { + info.timesCalledOn++; + } else { + info.timesCalledOff++; + } + } + return RETURN_OK; +} + +ReturnValue_t PowerSwitcherMock::sendFuseOnCommand(uint8_t fuseNr) { + if (fuseMap.count(fuseNr) == 0) { + fuseMap.emplace(fuseNr, FuseInfo(fuseNr)); + } else { + FuseInfo& info = fuseMap.at(fuseNr); + info.timesCalled++; + } + return RETURN_OK; +} + +ReturnValue_t PowerSwitcherMock::getSwitchState(power::Switch_t switchNr) const { + if (switchMap.count(switchNr) == 1) { + auto& info = switchMap.at(switchNr); + SWITCH_REQUEST_UPDATE_VALUE++; + return info.currentState; + } + return RETURN_FAILED; +} + +ReturnValue_t PowerSwitcherMock::getFuseState(uint8_t fuseNr) const { + if (fuseMap.count(fuseNr) == 1) { + return FUSE_ON; + } else { + return FUSE_OFF; + } + return RETURN_FAILED; +} + +uint32_t PowerSwitcherMock::getSwitchDelayMs(void) const { return 5000; } + +SwitchInfo::SwitchInfo() : switcher(0) {} + +SwitchInfo::SwitchInfo(power::Switch_t switcher, ReturnValue_t initState) + : switcher(switcher), currentState(initState) {} + +FuseInfo::FuseInfo(uint8_t fuse) : fuse(fuse) {} + +void PowerSwitcherMock::getSwitchInfo(power::Switch_t switcher, SwitchInfo& info) { + if (switchMap.count(switcher) == 1) { + info = switchMap.at(switcher); + } +} + +void PowerSwitcherMock::getFuseInfo(uint8_t fuse, FuseInfo& info) { + if (fuseMap.count(fuse) == 1) { + info = fuseMap.at(fuse); + } +} + +uint32_t PowerSwitcherMock::getAmountSwitchStatWasRequested() { + return SWITCH_REQUEST_UPDATE_VALUE; +} + +void PowerSwitcherMock::initSwitch(power::Switch_t switchNr) { + switchMap.emplace(switchNr, SwitchInfo(switchNr, PowerSwitchIF::SWITCH_OFF)); +} diff --git a/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h b/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h new file mode 100644 index 00000000..3a740e66 --- /dev/null +++ b/tests/src/fsfw_tests/unit/mocks/PowerSwitcherMock.h @@ -0,0 +1,52 @@ +#ifndef FSFW_TESTS_SRC_FSFW_TESTS_UNIT_MOCKS_POWERSWITCHERMOCK_H_ +#define FSFW_TESTS_SRC_FSFW_TESTS_UNIT_MOCKS_POWERSWITCHERMOCK_H_ + +#include + +#include +#include + +struct SwitchInfo { + public: + SwitchInfo(); + SwitchInfo(power::Switch_t switcher, ReturnValue_t initState); + + power::Switch_t switcher; + ReturnValue_t currentState = PowerSwitchIF::SWITCH_OFF; + uint32_t timesCalledOn = 0; + uint32_t timesCalledOff = 0; + uint32_t timesStatusRequested = 0; +}; + +struct FuseInfo { + public: + FuseInfo(uint8_t fuse); + uint8_t fuse; + uint32_t timesCalled = 0; +}; + +class PowerSwitcherMock : public PowerSwitchIF { + public: + PowerSwitcherMock(); + + ReturnValue_t sendSwitchCommand(power::Switch_t switchNr, ReturnValue_t onOff) override; + ReturnValue_t sendFuseOnCommand(uint8_t fuseNr) override; + ReturnValue_t getSwitchState(power::Switch_t switchNr) const override; + ReturnValue_t getFuseState(uint8_t fuseNr) const override; + uint32_t getSwitchDelayMs(void) const override; + + void getSwitchInfo(power::Switch_t switcher, SwitchInfo& info); + void getFuseInfo(uint8_t fuse, FuseInfo& info); + + uint32_t getAmountSwitchStatWasRequested(); + + void initSwitch(power::Switch_t switchNr); + + private: + using SwitchOnOffPair = std::pair; + using FuseOnOffPair = std::pair; + std::map switchMap; + std::map fuseMap; +}; + +#endif /* FSFW_TESTS_SRC_FSFW_TESTS_UNIT_MOCKS_POWERSWITCHERMOCK_H_ */ diff --git a/tests/src/fsfw_tests/unit/power/CMakeLists.txt b/tests/src/fsfw_tests/unit/power/CMakeLists.txt new file mode 100644 index 00000000..667e6f51 --- /dev/null +++ b/tests/src/fsfw_tests/unit/power/CMakeLists.txt @@ -0,0 +1,3 @@ +target_sources(${FSFW_TEST_TGT} PRIVATE + testPowerSwitcher.cpp +) diff --git a/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp b/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp new file mode 100644 index 00000000..c368729d --- /dev/null +++ b/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp @@ -0,0 +1,66 @@ +#include +#include +#include + +#include + +#include "objects/systemObjectList.h" + +TEST_CASE("Power Switcher", "[power-switcher]") { + PowerSwitcherMock mock; + PowerSwitcher switcher(&mock, 1); + DummyPowerSwitcher dummySwitcher(objects::DUMMY_POWER_SWITCHER, 5, 5, false); + PowerSwitcher switcherUsingDummy(&dummySwitcher, 1); + SwitchInfo switchInfo; + mock.initSwitch(1); + + SECTION("Basic Tests") { + REQUIRE(switcher.getFirstSwitch() == 1); + REQUIRE(switcher.getSecondSwitch() == power::NO_SWITCH); + // Default start state + REQUIRE(switcher.getState() == PowerSwitcher::SWITCH_IS_OFF); + switcher.turnOn(true); + REQUIRE(mock.getAmountSwitchStatWasRequested() == 1); + REQUIRE(switcher.getState() == PowerSwitcher::WAIT_ON); + REQUIRE(switcher.active()); + switcher.doStateMachine(); + REQUIRE(switcher.getState() == PowerSwitcher::SWITCH_IS_ON); + mock.getSwitchInfo(1, switchInfo); + REQUIRE(switchInfo.timesCalledOn == 1); + REQUIRE(not switcher.active()); + REQUIRE(mock.getAmountSwitchStatWasRequested() == 2); + switcher.turnOff(false); + REQUIRE(mock.getAmountSwitchStatWasRequested() == 2); + REQUIRE(switcher.getState() == PowerSwitcher::WAIT_OFF); + REQUIRE(switcher.active()); + REQUIRE(switcher.getState() == PowerSwitcher::WAIT_OFF); + switcher.doStateMachine(); + mock.getSwitchInfo(1, switchInfo); + REQUIRE(switcher.getState() == PowerSwitcher::SWITCH_IS_OFF); + REQUIRE(switchInfo.timesCalledOn == 1); + REQUIRE(switchInfo.timesCalledOff == 1); + REQUIRE(not switcher.active()); + REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); + } + + SECTION("Dummy Test") { + // Same tests, but we can't really check the dummy + REQUIRE(switcherUsingDummy.getFirstSwitch() == 1); + REQUIRE(switcherUsingDummy.getSecondSwitch() == power::NO_SWITCH); + REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::SWITCH_IS_OFF); + switcherUsingDummy.turnOn(true); + REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::WAIT_ON); + REQUIRE(switcherUsingDummy.active()); + switcherUsingDummy.doStateMachine(); + REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::SWITCH_IS_ON); + REQUIRE(not switcherUsingDummy.active()); + + switcherUsingDummy.turnOff(false); + REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::WAIT_OFF); + REQUIRE(switcherUsingDummy.active()); + REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::WAIT_OFF); + switcherUsingDummy.doStateMachine(); + REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::SWITCH_IS_OFF); + REQUIRE(not switcherUsingDummy.active()); + } +} diff --git a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h index 3eba1484..3fcd8368 100644 --- a/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h +++ b/tests/src/fsfw_tests/unit/testcfg/objects/systemObjectList.h @@ -21,8 +21,9 @@ enum sourceObjects : uint32_t { HK_RECEIVER_MOCK = 22, TEST_LOCAL_POOL_OWNER_BASE = 25, - SHARED_SET_ID = 26 + SHARED_SET_ID = 26, + DUMMY_POWER_SWITCHER = 27 }; } From 2d0e4ba951da0cf245bfc8b78b5a27552b9dd0cc Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 1 Apr 2022 18:38:54 +0200 Subject: [PATCH 07/18] applied afmt --- hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp | 4 ++-- hal/src/fsfw_hal/linux/uart/UartCookie.cpp | 4 +--- src/fsfw/osal/rtems/PeriodicTask.h | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 52b6dc07..644b488d 100644 --- a/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/hal/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -1,9 +1,9 @@ #include "MgmLIS3MDLHandler.h" -#include "fsfw/datapool/PoolReadGuard.h" - #include +#include "fsfw/datapool/PoolReadGuard.h" + MgmLIS3MDLHandler::MgmLIS3MDLHandler(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, uint32_t transitionDelay) : DeviceHandlerBase(objectId, deviceCommunication, comCookie), diff --git a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp b/hal/src/fsfw_hal/linux/uart/UartCookie.cpp index aa2dd214..3fedc9d4 100644 --- a/hal/src/fsfw_hal/linux/uart/UartCookie.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartCookie.cpp @@ -24,9 +24,7 @@ void UartCookie::setParityEven() { parity = Parity::EVEN; } Parity UartCookie::getParity() const { return parity; } -void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { - bitsPerWord = bitsPerWord_; -} +void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; } BitsPerWord UartCookie::getBitsPerWord() const { return bitsPerWord; } diff --git a/src/fsfw/osal/rtems/PeriodicTask.h b/src/fsfw/osal/rtems/PeriodicTask.h index 24ce4af1..9f47dfc6 100644 --- a/src/fsfw/osal/rtems/PeriodicTask.h +++ b/src/fsfw/osal/rtems/PeriodicTask.h @@ -59,14 +59,13 @@ class PeriodicTask : public RTEMSTaskBase, public PeriodicTaskIF { */ ReturnValue_t addComponent(object_id_t object) override; -/** + /** * Adds an object to the list of objects to be executed. * The objects are executed in the order added. * @param object pointer to the object to add. * @return RETURN_OK on success, RETURN_FAILED if the object could not be added. */ - ReturnValue_t addComponent(ExecutableObjectIF* object) override; - + ReturnValue_t addComponent(ExecutableObjectIF *object) override; uint32_t getPeriodMs() const override; From b764194ed07be714ae42d5bfe0d41dbe74727dc5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 1 Apr 2022 18:43:46 +0200 Subject: [PATCH 08/18] added more unit tests --- tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp b/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp index c368729d..d8523558 100644 --- a/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp +++ b/tests/src/fsfw_tests/unit/power/testPowerSwitcher.cpp @@ -22,6 +22,7 @@ TEST_CASE("Power Switcher", "[power-switcher]") { switcher.turnOn(true); REQUIRE(mock.getAmountSwitchStatWasRequested() == 1); REQUIRE(switcher.getState() == PowerSwitcher::WAIT_ON); + REQUIRE(switcher.checkSwitchState() == PowerSwitcher::IN_POWER_TRANSITION); REQUIRE(switcher.active()); switcher.doStateMachine(); REQUIRE(switcher.getState() == PowerSwitcher::SWITCH_IS_ON); @@ -29,8 +30,10 @@ TEST_CASE("Power Switcher", "[power-switcher]") { REQUIRE(switchInfo.timesCalledOn == 1); REQUIRE(not switcher.active()); REQUIRE(mock.getAmountSwitchStatWasRequested() == 2); + REQUIRE(switcher.checkSwitchState() == HasReturnvaluesIF::RETURN_OK); + REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); switcher.turnOff(false); - REQUIRE(mock.getAmountSwitchStatWasRequested() == 2); + REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); REQUIRE(switcher.getState() == PowerSwitcher::WAIT_OFF); REQUIRE(switcher.active()); REQUIRE(switcher.getState() == PowerSwitcher::WAIT_OFF); @@ -40,7 +43,7 @@ TEST_CASE("Power Switcher", "[power-switcher]") { REQUIRE(switchInfo.timesCalledOn == 1); REQUIRE(switchInfo.timesCalledOff == 1); REQUIRE(not switcher.active()); - REQUIRE(mock.getAmountSwitchStatWasRequested() == 3); + REQUIRE(mock.getAmountSwitchStatWasRequested() == 4); } SECTION("Dummy Test") { @@ -63,4 +66,8 @@ TEST_CASE("Power Switcher", "[power-switcher]") { REQUIRE(switcherUsingDummy.getState() == PowerSwitcher::SWITCH_IS_OFF); REQUIRE(not switcherUsingDummy.active()); } + + SECTION("More Dummy Tests") { + + } } From 572d602b728e63507053014ca8184840761aecc1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Apr 2022 15:42:44 +0200 Subject: [PATCH 09/18] improve changelog, add entry --- CHANGELOG.md | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5181a862..06424aaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,28 +12,43 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes + +- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 +- HAL Devicehandlers: Periodic printout is run-time configurable now +- `oneShotAction` flag in the `TestTask` class is not static anymore +- IPC Message Queue Handling: Allow passing an optional `MqArgs` argument into the MessageQueue + creation call. It allows passing context information and an arbitrary user argument into + the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583 + +### HAL + - HAL Linux SPI: Set the Clock Default State when setting new SPI speed and mode PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/573 - GPIO HAL: `Direction`, `GpioOperation` and `Levels` are enum classes now, which prevents name clashes with Windows defines. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 -- New CMake option `FSFW_HAL_LINUX_ADD_LIBGPIOD` to specifically exclude `gpiod` code. - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/572 -- HAL Devicehandlers: Periodic printout is run-time configurable now -- `oneShotAction` flag in the `TestTask` class is not static anymore - HAL Linux Uart: Baudrate and bits per word are enums now, avoiding misconfigurations PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/585 -- IPC Message Queue Handling: Allow passing an optional `MqArgs` argument into the MessageQueue - creation call. It allows passing context information and an arbitrary user argument into - the message queue. Also streamlined and simplified `MessageQueue` implementation for all OSALs - PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/583 -- Clock: - - `timeval` to `TimeOfDay_t` - - Added Mutex for gmtime calls: (compare http://www.opengate.at/blog/2020/01/timeless/) - - Moved the statics used by Clock in ClockCommon.cpp to this file - - Better check for leap seconds - - Added Unittests for Clock (only getter) + +### Time + +- `timeval` to `TimeOfDay_t` +- Added Mutex for gmtime calls: (compare http://www.opengate.at/blog/2020/01/timeless/) +- Moved the statics used by Clock in ClockCommon.cpp to this file +- Better check for leap seconds +- Added Unittests for Clock (only getter) + +### Power + +- `PowerSwitchIF`: Remove `const` specifier from `sendSwitchCommand` and `sendFuseOnCommand` and + also specify a `ReturnValue_t` return type + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590 +- Extend `PowerSwitcher` module to optionally check current state when calling `turnOn` or + `turnOff`. Tis can be helpful to avoid commanding switches which do not need commanding + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590 ## Removed @@ -49,6 +64,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/559 - Added ETL dependency and improved library dependency management PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/592 +- Add a `DummyPowerSwitcher` module which can be useful for test setups when no PCDU is available + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590 +- New typedef for switcher type + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/590 ## Fixed From b94685e045f5fc6203f8f2a65cb03b757bf01c58 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 25 Apr 2022 15:44:46 +0200 Subject: [PATCH 10/18] added missing PR cross-ref --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06424aaf..5ffb84cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Time +PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/584 and +https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/593 + - `timeval` to `TimeOfDay_t` - Added Mutex for gmtime calls: (compare http://www.opengate.at/blog/2020/01/timeless/) - Moved the statics used by Clock in ClockCommon.cpp to this file From 6308427d03f1c6f116b587861dd927c2c80f5e12 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 May 2022 11:18:56 +0200 Subject: [PATCH 11/18] run auto-formatter over cmakelists.txt --- CMakeLists.txt | 504 ++++++++++++++++++++++++------------------------- 1 file changed, 252 insertions(+), 252 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe3da84..f8ccf115 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,33 +8,33 @@ set(FSFW_REVISION 0) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING - "ETL library major version requirement" -) + "ETL library major version requirement" + ) set(FSFW_ETL_LIB_VERSION ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3 CACHE STRING - "ETL library exact version requirement" -) + "ETL library exact version requirement" + ) set(FSFW_ETL_LINK_TARGET etl::etl) set(FSFW_CATCH2_LIB_MAJOR_VERSION 3 CACHE STRING - "Catch2 library major version requirement" -) + "Catch2 library major version requirement" + ) set(FSFW_CATCH2_LIB_VERSION v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 CACHE STRING - "Catch2 library exact version requirement" -) + "Catch2 library exact version requirement" + ) set(FSFW_ETL_LIB_NAME etl) option(FSFW_GENERATE_SECTIONS - "Generate function and data sections. Required to remove unused code" ON -) + "Generate function and data sections. Required to remove unused code" ON + ) if(FSFW_GENERATE_SECTIONS) - option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) + option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) if(FSFW_BUILD_UNITTESTS) - option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) + option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) endif() option(FSFW_WARNING_SHADOW_LOCAL_GCC "Enable -Wshadow=local warning in GCC" ON) @@ -63,45 +63,45 @@ project(${LIB_FSFW_NAME}) add_library(${LIB_FSFW_NAME}) if(FSFW_BUILD_UNITTESTS) - message(STATUS "Building the FSFW unittests in addition to the static library") - # Check whether the user has already installed Catch2 first - find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION}) - # Not installed, so use FetchContent to download and provide Catch2 - if(NOT Catch2_FOUND) - message(STATUS "Catch2 installation not found. Downloading Catch2 library with FetchContent") - include(FetchContent) + message(STATUS "Building the FSFW unittests in addition to the static library") + # Check whether the user has already installed Catch2 first + find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION}) + # Not installed, so use FetchContent to download and provide Catch2 + if(NOT Catch2_FOUND) + message(STATUS "Catch2 installation not found. Downloading Catch2 library with FetchContent") + include(FetchContent) - FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG ${FSFW_CATCH2_LIB_VERSION} - ) + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG ${FSFW_CATCH2_LIB_VERSION} + ) - list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) - endif() + list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) + endif() - set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) - configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h) - configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h) + set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) + configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h) + configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h) - project(${FSFW_TEST_TGT} CXX C) - add_executable(${FSFW_TEST_TGT}) + project(${FSFW_TEST_TGT} CXX C) + add_executable(${FSFW_TEST_TGT}) - if(FSFW_TESTS_GEN_COV) - message(STATUS "Generating coverage data for the library") - message(STATUS "Targets linking against ${LIB_FSFW_NAME} " - "will be compiled with coverage data as well" - ) - include(FetchContent) - FetchContent_Declare( - cmake-modules - GIT_REPOSITORY https://github.com/bilke/cmake-modules.git - ) - FetchContent_MakeAvailable(cmake-modules) - set(CMAKE_BUILD_TYPE "Debug") - list(APPEND CMAKE_MODULE_PATH ${cmake-modules_SOURCE_DIR}) - include(CodeCoverage) - endif() + if(FSFW_TESTS_GEN_COV) + message(STATUS "Generating coverage data for the library") + message(STATUS "Targets linking against ${LIB_FSFW_NAME} " + "will be compiled with coverage data as well" + ) + include(FetchContent) + FetchContent_Declare( + cmake-modules + GIT_REPOSITORY https://github.com/bilke/cmake-modules.git + ) + FetchContent_MakeAvailable(cmake-modules) + set(CMAKE_BUILD_TYPE "Debug") + list(APPEND CMAKE_MODULE_PATH ${cmake-modules_SOURCE_DIR}) + include(CodeCoverage) + endif() endif() message(STATUS "Finding and/or providing ETL library") @@ -110,34 +110,34 @@ message(STATUS "Finding and/or providing ETL library") find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) # Not installed, so use FetchContent to download and provide etl if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) - message(STATUS - "No ETL installation was found with find_package. Installing and providing " - "etl with FindPackage" + message(STATUS + "No ETL installation was found with find_package. Installing and providing " + "etl with FindPackage" ) - include(FetchContent) + include(FetchContent) - FetchContent_Declare( - ${FSFW_ETL_LIB_NAME} - GIT_REPOSITORY https://github.com/ETLCPP/etl - GIT_TAG ${FSFW_ETL_LIB_VERSION} - ) + FetchContent_Declare( + ${FSFW_ETL_LIB_NAME} + GIT_REPOSITORY https://github.com/ETLCPP/etl + GIT_TAG ${FSFW_ETL_LIB_VERSION} + ) - list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME}) + list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME}) endif() # The documentation for FetchContent recommends declaring all the dependencies # before making them available. We make all declared dependency available here # after their declaration if(FSFW_FETCH_CONTENT_TARGETS) - FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS}) - if(TARGET ${FSFW_ETL_LIB_NAME}) - add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME}) - endif() - if(TARGET Catch2) - # Fixes regression -preview4, to be confirmed in later releases - # Related GitHub issue: https://github.com/catchorg/Catch2/issues/2417 - set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") - endif() + FetchContent_MakeAvailable(${FSFW_FETCH_CONTENT_TARGETS}) + if(TARGET ${FSFW_ETL_LIB_NAME}) + add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME}) + endif() + if(TARGET Catch2) + # Fixes regression -preview4, to be confirmed in later releases + # Related GitHub issue: https://github.com/catchorg/Catch2/issues/2417 + set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") + endif() endif() set(FSFW_CORE_INC_PATH "inc") @@ -146,64 +146,64 @@ set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos) # For configure files target_include_directories(${LIB_FSFW_NAME} PRIVATE - ${CMAKE_CURRENT_BINARY_DIR} -) + ${CMAKE_CURRENT_BINARY_DIR} + ) target_include_directories(${LIB_FSFW_NAME} INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} -) + ${CMAKE_CURRENT_BINARY_DIR} + ) if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 11) - set(CMAKE_CXX_STANDARD_REQUIRED True) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED True) elseif(${CMAKE_CXX_STANDARD} LESS 11) - message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++11 support") + message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++11 support") endif() # Backwards comptability if(OS_FSFW AND NOT FSFW_OSAL) - message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW") - set(FSFW_OSAL OS_FSFW) + message(WARNING "Please pass the FSFW OSAL as FSFW_OSAL instead of OS_FSFW") + set(FSFW_OSAL OS_FSFW) endif() if(NOT FSFW_OSAL) - message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS") - # Assume host OS and autodetermine from OS_FSFW - if(UNIX) - set(FSFW_OSAL "linux" - CACHE STRING - "OS abstraction layer used in the FSFW" - ) - elseif(WIN32) - set(FSFW_OSAL "host" - CACHE STRING "OS abstraction layer used in the FSFW" - ) - endif() + message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS") + # Assume host OS and autodetermine from OS_FSFW + if(UNIX) + set(FSFW_OSAL "linux" + CACHE STRING + "OS abstraction layer used in the FSFW" + ) + elseif(WIN32) + set(FSFW_OSAL "host" + CACHE STRING "OS abstraction layer used in the FSFW" + ) + endif() endif() set(FSFW_OSAL_DEFINITION FSFW_OSAL_HOST) if(FSFW_OSAL MATCHES host) - set(FSFW_OS_NAME "Host") - set(FSFW_OSAL_HOST ON) + set(FSFW_OS_NAME "Host") + set(FSFW_OSAL_HOST ON) elseif(FSFW_OSAL MATCHES linux) - set(FSFW_OS_NAME "Linux") - set(FSFW_OSAL_LINUX ON) + set(FSFW_OS_NAME "Linux") + set(FSFW_OSAL_LINUX ON) elseif(FSFW_OSAL MATCHES freertos) - set(FSFW_OS_NAME "FreeRTOS") - set(FSFW_OSAL_FREERTOS ON) - target_link_libraries(${LIB_FSFW_NAME} PRIVATE - ${LIB_OS_NAME} + set(FSFW_OS_NAME "FreeRTOS") + set(FSFW_OSAL_FREERTOS ON) + target_link_libraries(${LIB_FSFW_NAME} PRIVATE + ${LIB_OS_NAME} ) elseif(FSFW_OSAL STREQUAL rtems) - set(FSFW_OS_NAME "RTEMS") - set(FSFW_OSAL_RTEMS ON) + set(FSFW_OS_NAME "RTEMS") + set(FSFW_OSAL_RTEMS ON) else() - message(WARNING - "Invalid operating system for FSFW specified! Setting to host.." + message(WARNING + "Invalid operating system for FSFW specified! Setting to host.." ) - set(FSFW_OS_NAME "Host") - set(OS_FSFW "host") + set(FSFW_OS_NAME "Host") + set(OS_FSFW "host") endif() configure_file(src/fsfw/FSFW.h.in fsfw/FSFW.h) @@ -214,206 +214,206 @@ message(STATUS "Compiling FSFW for the ${FSFW_OS_NAME} operating system.") add_subdirectory(src) add_subdirectory(tests) if(FSFW_ADD_HAL) - add_subdirectory(hal) + add_subdirectory(hal) endif() add_subdirectory(contrib) if(FSFW_BUILD_DOCS) - add_subdirectory(docs) + add_subdirectory(docs) endif() if(FSFW_BUILD_UNITTESTS) - if(FSFW_TESTS_GEN_COV) - if(CMAKE_COMPILER_IS_GNUCXX) - include(CodeCoverage) + if(FSFW_TESTS_GEN_COV) + if(CMAKE_COMPILER_IS_GNUCXX) + include(CodeCoverage) - # Remove quotes. - separate_arguments(COVERAGE_COMPILER_FLAGS - NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}" - ) + # Remove quotes. + separate_arguments(COVERAGE_COMPILER_FLAGS + NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}" + ) - # Add compile options manually, we don't want coverage for Catch2 - target_compile_options(${FSFW_TEST_TGT} PRIVATE - "${COVERAGE_COMPILER_FLAGS}" - ) - target_compile_options(${LIB_FSFW_NAME} PRIVATE - "${COVERAGE_COMPILER_FLAGS}" - ) + # Add compile options manually, we don't want coverage for Catch2 + target_compile_options(${FSFW_TEST_TGT} PRIVATE + "${COVERAGE_COMPILER_FLAGS}" + ) + target_compile_options(${LIB_FSFW_NAME} PRIVATE + "${COVERAGE_COMPILER_FLAGS}" + ) - # Exclude directories here - if(WIN32) - set(GCOVR_ADDITIONAL_ARGS - "--exclude-throw-branches" - "--exclude-unreachable-branches" - ) - set(COVERAGE_EXCLUDES - "/c/msys64/mingw64/*" "*/fsfw_hal/*" - ) - elseif(UNIX) - set(COVERAGE_EXCLUDES - "/usr/include/*" "/usr/bin/*" "Catch2/*" - "/usr/local/include/*" "*/fsfw_tests/*" - "*/catch2-src/*" "*/fsfw_hal/*" - ) - endif() + # Exclude directories here + if(WIN32) + set(GCOVR_ADDITIONAL_ARGS + "--exclude-throw-branches" + "--exclude-unreachable-branches" + ) + set(COVERAGE_EXCLUDES + "/c/msys64/mingw64/*" "*/fsfw_hal/*" + ) + elseif(UNIX) + set(COVERAGE_EXCLUDES + "/usr/include/*" "/usr/bin/*" "Catch2/*" + "/usr/local/include/*" "*/fsfw_tests/*" + "*/catch2-src/*" "*/fsfw_hal/*" + ) + endif() - target_link_options(${FSFW_TEST_TGT} PRIVATE - -fprofile-arcs - -ftest-coverage - ) - target_link_options(${LIB_FSFW_NAME} PRIVATE - -fprofile-arcs - -ftest-coverage - ) - # Need to specify this as an interface, otherwise there will the compile issues - target_link_options(${LIB_FSFW_NAME} INTERFACE - -fprofile-arcs - -ftest-coverage - ) + target_link_options(${FSFW_TEST_TGT} PRIVATE + -fprofile-arcs + -ftest-coverage + ) + target_link_options(${LIB_FSFW_NAME} PRIVATE + -fprofile-arcs + -ftest-coverage + ) + # Need to specify this as an interface, otherwise there will the compile issues + target_link_options(${LIB_FSFW_NAME} INTERFACE + -fprofile-arcs + -ftest-coverage + ) - if(WIN32) - setup_target_for_coverage_gcovr_html( - NAME ${FSFW_TEST_TGT}_coverage - EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - ) - else() - setup_target_for_coverage_lcov( - NAME ${FSFW_TEST_TGT}_coverage - EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - ) - endif() - endif() + if(WIN32) + setup_target_for_coverage_gcovr_html( + NAME ${FSFW_TEST_TGT}_coverage + EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT} + ) + else() + setup_target_for_coverage_lcov( + NAME ${FSFW_TEST_TGT}_coverage + EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT} + ) + endif() endif() - target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME}) + endif() + target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME}) endif() # The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. # If this is not given, we include the default configuration and emit a warning. if(NOT FSFW_CONFIG_PATH) - set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig) - if(NOT FSFW_BUILD_DOCS) - message(WARNING "Flight Software Framework configuration path not set!") - message(WARNING "Setting default configuration from ${DEF_CONF_PATH} ..") - endif() - add_subdirectory(${DEF_CONF_PATH}) - set(FSFW_CONFIG_PATH ${DEF_CONF_PATH}) + set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig) + if(NOT FSFW_BUILD_DOCS) + message(WARNING "Flight Software Framework configuration path not set!") + message(WARNING "Setting default configuration from ${DEF_CONF_PATH} ..") + endif() + add_subdirectory(${DEF_CONF_PATH}) + set(FSFW_CONFIG_PATH ${DEF_CONF_PATH}) endif() # FSFW might be part of a possibly complicated folder structure, so we # extract the absolute path of the fsfwconfig folder. if(IS_ABSOLUTE ${FSFW_CONFIG_PATH}) - set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH}) + set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH}) else() - get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE - ${FSFW_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR} - ) + get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE + ${FSFW_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR} + ) endif() foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS}) - if(IS_ABSOLUTE ${INCLUDE_PATH}) - set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") - else() - get_filename_component(CURR_ABS_INC_PATH - ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}) - endif() + if(IS_ABSOLUTE ${INCLUDE_PATH}) + set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") + else() + get_filename_component(CURR_ABS_INC_PATH + ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}) + endif() - if(CMAKE_VERBOSE) - message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}") - endif() + if(CMAKE_VERBOSE) + message(STATUS "FSFW include path: ${CURR_ABS_INC_PATH}") + endif() - list(APPEND FSFW_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH}) + list(APPEND FSFW_ADD_INC_PATHS_ABS ${CURR_ABS_INC_PATH}) endforeach() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - if(NOT DEFINED FSFW_WARNING_FLAGS) - set(FSFW_WARNING_FLAGS - -Wall - -Wextra - -Wimplicit-fallthrough=1 - -Wno-unused-parameter - -Wno-psabi - -Wduplicated-cond # check for duplicate conditions - -Wduplicated-branches # check for duplicate branches - -Wlogical-op # Search for bitwise operations instead of logical - -Wnull-dereference # Search for NULL dereference - -Wundef # Warn if undefind marcos are used - -Wformat=2 # Format string problem detection - -Wformat-overflow=2 # Formatting issues in printf - -Wformat-truncation=2 # Formatting issues in printf - -Wformat-security # Search for dangerous printf operations - -Wstrict-overflow=3 # Warn if integer overflows might happen - -Warray-bounds=2 # Some array bounds violations will be found - -Wshift-overflow=2 # Search for bit left shift overflows ( Date: Mon, 9 May 2022 15:54:29 +0200 Subject: [PATCH 12/18] indentation --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef96f1df..909255be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,10 @@ set(LIB_FSFW_NAME fsfw) project(${LIB_FSFW_NAME}) if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED True) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED True) elseif(${CMAKE_CXX_STANDARD} LESS 17) - message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++17 support") + message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++17 support") endif() set(FSFW_VERSION 4) From d11f898f70cb394c0be2450779dac4f5ad995e35 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 12 May 2022 15:02:06 +0200 Subject: [PATCH 13/18] update dummy power switcher docs --- src/fsfw/power/DummyPowerSwitcher.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/fsfw/power/DummyPowerSwitcher.h b/src/fsfw/power/DummyPowerSwitcher.h index b2dd40d5..6ccd8dd7 100644 --- a/src/fsfw/power/DummyPowerSwitcher.h +++ b/src/fsfw/power/DummyPowerSwitcher.h @@ -8,6 +8,13 @@ #include "definitions.h" #include "fsfw/objectmanager/SystemObject.h" +/** + * @brief This component can be used to simulate a power switcher like a + * Power Control Distribution Unit (PCDU) + * @details + * The dummy switcher will simply cache the commanded fuse and switch states and return them + * in the according switch getter functions. In that sense, it simulates an ideal PCDU. + */ class DummyPowerSwitcher : public SystemObject, public PowerSwitchIF { public: DummyPowerSwitcher(object_id_t objectId, size_t numberOfSwitches, size_t numberOfFuses, From 3046822e88f06e7d44d449f7c5a757d0ba6f49e3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 12 May 2022 17:27:39 +0200 Subject: [PATCH 14/18] run cmake-format --- CMakeLists.txt | 312 ++++++++++++++++++++++--------------------------- 1 file changed, 141 insertions(+), 171 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c172439..db606b83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,24 +18,28 @@ set(FSFW_REVISION 0) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) set(FSFW_ETL_LIB_NAME etl) -set(FSFW_ETL_LIB_MAJOR_VERSION 20 CACHE STRING - "ETL library major version requirement" - ) -set(FSFW_ETL_LIB_VERSION ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3 CACHE STRING - "ETL library exact version requirement" - ) +set(FSFW_ETL_LIB_MAJOR_VERSION + 20 + CACHE STRING "ETL library major version requirement") +set(FSFW_ETL_LIB_VERSION + ${FSFW_ETL_LIB_MAJOR_VERSION}.27.3 + CACHE STRING "ETL library exact version requirement") set(FSFW_ETL_LINK_TARGET etl::etl) -set(FSFW_CATCH2_LIB_MAJOR_VERSION 3 CACHE STRING - "Catch2 library major version requirement" - ) -set(FSFW_CATCH2_LIB_VERSION v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 CACHE STRING - "Catch2 library exact version requirement" - ) +set(FSFW_CATCH2_LIB_MAJOR_VERSION + 3 + CACHE STRING "Catch2 library major version requirement") +set(FSFW_CATCH2_LIB_VERSION + v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 + CACHE STRING "Catch2 library exact version requirement") -# Keep this off by default for now. See PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 -# for information which keeping this on by default is problematic -option(FSFW_ENABLE_IPO "Enable interprocedural optimization or link-time optimization if available" OFF) +# Keep this off by default for now. See PR: +# https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/616 for information which +# keeping this on by default is problematic +option( + FSFW_ENABLE_IPO + "Enable interprocedural optimization or link-time optimization if available" + OFF) if(FSFW_ENABLE_IPO) include(CheckIPOSupported) check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR) @@ -45,13 +49,13 @@ if(FSFW_ENABLE_IPO) endif() option(FSFW_GENERATE_SECTIONS - "Generate function and data sections. Required to remove unused code" ON - ) + "Generate function and data sections. Required to remove unused code" ON) if(FSFW_GENERATE_SECTIONS) option(FSFW_REMOVE_UNUSED_CODE "Remove unused code" ON) endif() -option(FSFW_BUILD_UNITTESTS "Build unittest binary in addition to static library" OFF) +option(FSFW_BUILD_UNITTESTS + "Build unittest binary in addition to static library" OFF) option(FSFW_BUILD_DOCS "Build documentation with Sphinx and Doxygen" OFF) if(FSFW_BUILD_UNITTESTS) option(FSFW_TESTS_GEN_COV "Generate coverage data for unittests" ON) @@ -75,54 +79,56 @@ option(FSFW_ADD_TMSTORAGE "Compile with tm storage components" OFF) # Contrib sources option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) - set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) add_library(${LIB_FSFW_NAME}) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) - set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION + TRUE) endif() if(FSFW_BUILD_UNITTESTS) - message(STATUS "Building the FSFW unittests in addition to the static library") + message( + STATUS "Building the FSFW unittests in addition to the static library") # Check whether the user has already installed Catch2 first find_package(Catch2 ${FSFW_CATCH2_LIB_MAJOR_VERSION}) # Not installed, so use FetchContent to download and provide Catch2 if(NOT Catch2_FOUND) - message(STATUS "Catch2 installation not found. Downloading Catch2 library with FetchContent") + message( + STATUS + "Catch2 installation not found. Downloading Catch2 library with FetchContent" + ) include(FetchContent) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG ${FSFW_CATCH2_LIB_VERSION} - ) + GIT_TAG ${FSFW_CATCH2_LIB_VERSION}) list(APPEND FSFW_FETCH_CONTENT_TARGETS Catch2) endif() set(FSFW_CONFIG_PATH tests/src/fsfw_tests/unit/testcfg) configure_file(tests/src/fsfw_tests/unit/testcfg/FSFWConfig.h.in FSFWConfig.h) - configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in tests/TestsConfig.h) + configure_file(tests/src/fsfw_tests/unit/testcfg/TestsConfig.h.in + tests/TestsConfig.h) project(${FSFW_TEST_TGT} CXX C) add_executable(${FSFW_TEST_TGT}) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) - set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + set_property(TARGET ${FSFW_TEST_TGT} PROPERTY INTERPROCEDURAL_OPTIMIZATION + TRUE) endif() if(FSFW_TESTS_GEN_COV) message(STATUS "Generating coverage data for the library") message(STATUS "Targets linking against ${LIB_FSFW_NAME} " - "will be compiled with coverage data as well" - ) + "will be compiled with coverage data as well") include(FetchContent) FetchContent_Declare( - cmake-modules - GIT_REPOSITORY https://github.com/bilke/cmake-modules.git - ) + cmake-modules GIT_REPOSITORY https://github.com/bilke/cmake-modules.git) FetchContent_MakeAvailable(cmake-modules) set(CMAKE_BUILD_TYPE "Debug") list(APPEND CMAKE_MODULE_PATH ${cmake-modules_SOURCE_DIR}) @@ -136,17 +142,16 @@ message(STATUS "Finding and/or providing ETL library") find_package(${FSFW_ETL_LIB_NAME} ${FSFW_ETL_LIB_MAJOR_VERSION} QUIET) # Not installed, so use FetchContent to download and provide etl if(NOT ${FSFW_ETL_LIB_NAME}_FOUND) - message(STATUS - "No ETL installation was found with find_package. Installing and providing " - "etl with FindPackage" - ) + message( + STATUS + "No ETL installation was found with find_package. Installing and providing " + "etl with FindPackage") include(FetchContent) FetchContent_Declare( ${FSFW_ETL_LIB_NAME} GIT_REPOSITORY https://github.com/ETLCPP/etl - GIT_TAG ${FSFW_ETL_LIB_VERSION} - ) + GIT_TAG ${FSFW_ETL_LIB_VERSION}) list(APPEND FSFW_FETCH_CONTENT_TARGETS ${FSFW_ETL_LIB_NAME}) endif() @@ -160,8 +165,8 @@ if(FSFW_FETCH_CONTENT_TARGETS) add_library(${FSFW_ETL_LINK_TARGET} ALIAS ${FSFW_ETL_LIB_NAME}) endif() if(TARGET Catch2) - # Fixes regression -preview4, to be confirmed in later releases - # Related GitHub issue: https://github.com/catchorg/Catch2/issues/2417 + # Fixes regression -preview4, to be confirmed in later releases Related + # GitHub issue: https://github.com/catchorg/Catch2/issues/2417 set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") endif() endif() @@ -171,12 +176,9 @@ set(FSFW_CORE_INC_PATH "inc") set_property(CACHE FSFW_OSAL PROPERTY STRINGS host linux rtems freertos) # For configure files -target_include_directories(${LIB_FSFW_NAME} PRIVATE - ${CMAKE_CURRENT_BINARY_DIR} - ) -target_include_directories(${LIB_FSFW_NAME} INTERFACE - ${CMAKE_CURRENT_BINARY_DIR} - ) +target_include_directories(${LIB_FSFW_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(${LIB_FSFW_NAME} + INTERFACE ${CMAKE_CURRENT_BINARY_DIR}) # Backwards comptability if(OS_FSFW AND NOT FSFW_OSAL) @@ -188,14 +190,13 @@ if(NOT FSFW_OSAL) message(STATUS "No OS for FSFW via FSFW_OSAL set. Assuming host OS") # Assume host OS and autodetermine from OS_FSFW if(UNIX) - set(FSFW_OSAL "linux" - CACHE STRING - "OS abstraction layer used in the FSFW" - ) + set(FSFW_OSAL + "linux" + CACHE STRING "OS abstraction layer used in the FSFW") elseif(WIN32) - set(FSFW_OSAL "host" - CACHE STRING "OS abstraction layer used in the FSFW" - ) + set(FSFW_OSAL + "host" + CACHE STRING "OS abstraction layer used in the FSFW") endif() endif() @@ -211,16 +212,13 @@ elseif(FSFW_OSAL MATCHES linux) elseif(FSFW_OSAL MATCHES freertos) set(FSFW_OS_NAME "FreeRTOS") set(FSFW_OSAL_FREERTOS ON) - target_link_libraries(${LIB_FSFW_NAME} PRIVATE - ${LIB_OS_NAME} - ) + target_link_libraries(${LIB_FSFW_NAME} PRIVATE ${LIB_OS_NAME}) elseif(FSFW_OSAL STREQUAL rtems) set(FSFW_OS_NAME "RTEMS") set(FSFW_OSAL_RTEMS ON) else() - message(WARNING - "Invalid operating system for FSFW specified! Setting to host.." - ) + message( + WARNING "Invalid operating system for FSFW specified! Setting to host..") set(FSFW_OS_NAME "Host") set(OS_FSFW "host") endif() @@ -246,69 +244,57 @@ if(FSFW_BUILD_UNITTESTS) include(CodeCoverage) # Remove quotes. - separate_arguments(COVERAGE_COMPILER_FLAGS - NATIVE_COMMAND "${COVERAGE_COMPILER_FLAGS}" - ) + separate_arguments(COVERAGE_COMPILER_FLAGS NATIVE_COMMAND + "${COVERAGE_COMPILER_FLAGS}") # Add compile options manually, we don't want coverage for Catch2 - target_compile_options(${FSFW_TEST_TGT} PRIVATE - "${COVERAGE_COMPILER_FLAGS}" - ) - target_compile_options(${LIB_FSFW_NAME} PRIVATE - "${COVERAGE_COMPILER_FLAGS}" - ) + target_compile_options(${FSFW_TEST_TGT} + PRIVATE "${COVERAGE_COMPILER_FLAGS}") + target_compile_options(${LIB_FSFW_NAME} + PRIVATE "${COVERAGE_COMPILER_FLAGS}") # Exclude directories here if(WIN32) - set(GCOVR_ADDITIONAL_ARGS - "--exclude-throw-branches" - "--exclude-unreachable-branches" - ) - set(COVERAGE_EXCLUDES - "/c/msys64/mingw64/*" "*/fsfw_hal/*" - ) + set(GCOVR_ADDITIONAL_ARGS "--exclude-throw-branches" + "--exclude-unreachable-branches") + set(COVERAGE_EXCLUDES "/c/msys64/mingw64/*" "*/fsfw_hal/*") elseif(UNIX) set(COVERAGE_EXCLUDES - "/usr/include/*" "/usr/bin/*" "Catch2/*" - "/usr/local/include/*" "*/fsfw_tests/*" - "*/catch2-src/*" "*/fsfw_hal/*" - ) + "/usr/include/*" + "/usr/bin/*" + "Catch2/*" + "/usr/local/include/*" + "*/fsfw_tests/*" + "*/catch2-src/*" + "*/fsfw_hal/*") endif() - target_link_options(${FSFW_TEST_TGT} PRIVATE - -fprofile-arcs - -ftest-coverage - ) - target_link_options(${LIB_FSFW_NAME} PRIVATE - -fprofile-arcs - -ftest-coverage - ) - # Need to specify this as an interface, otherwise there will the compile issues - target_link_options(${LIB_FSFW_NAME} INTERFACE - -fprofile-arcs - -ftest-coverage - ) + target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs + -ftest-coverage) + target_link_options(${LIB_FSFW_NAME} PRIVATE -fprofile-arcs + -ftest-coverage) + # Need to specify this as an interface, otherwise there will the compile + # issues + target_link_options(${LIB_FSFW_NAME} INTERFACE -fprofile-arcs + -ftest-coverage) if(WIN32) setup_target_for_coverage_gcovr_html( - NAME ${FSFW_TEST_TGT}_coverage - EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - ) + NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT}) else() setup_target_for_coverage_lcov( - NAME ${FSFW_TEST_TGT}_coverage - EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - ) + NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} + DEPENDENCIES ${FSFW_TEST_TGT}) endif() endif() endif() - target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 ${LIB_FSFW_NAME}) + target_link_libraries(${FSFW_TEST_TGT} PRIVATE Catch2::Catch2 + ${LIB_FSFW_NAME}) endif() -# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. -# If this is not given, we include the default configuration and emit a warning. +# The project CMakeLists file has to set the FSFW_CONFIG_PATH and add it. If +# this is not given, we include the default configuration and emit a warning. if(NOT FSFW_CONFIG_PATH) set(DEF_CONF_PATH misc/defaultcfg/fsfwconfig) if(NOT FSFW_BUILD_DOCS) @@ -319,22 +305,21 @@ if(NOT FSFW_CONFIG_PATH) set(FSFW_CONFIG_PATH ${DEF_CONF_PATH}) endif() -# FSFW might be part of a possibly complicated folder structure, so we -# extract the absolute path of the fsfwconfig folder. +# FSFW might be part of a possibly complicated folder structure, so we extract +# the absolute path of the fsfwconfig folder. if(IS_ABSOLUTE ${FSFW_CONFIG_PATH}) set(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH}) else() - get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE - ${FSFW_CONFIG_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR} - ) + get_filename_component(FSFW_CONFIG_PATH_ABSOLUTE ${FSFW_CONFIG_PATH} REALPATH + BASE_DIR ${CMAKE_SOURCE_DIR}) endif() foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS}) if(IS_ABSOLUTE ${INCLUDE_PATH}) set(CURR_ABS_INC_PATH "${INCLUDE_PATH}") else() - get_filename_component(CURR_ABS_INC_PATH - ${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR}) + get_filename_component(CURR_ABS_INC_PATH ${INCLUDE_PATH} REALPATH BASE_DIR + ${CMAKE_SOURCE_DIR}) endif() if(CMAKE_VERBOSE) @@ -347,43 +332,39 @@ endforeach() if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(NOT DEFINED FSFW_WARNING_FLAGS) set(FSFW_WARNING_FLAGS - -Wall - -Wextra - -Wimplicit-fallthrough=1 - -Wno-unused-parameter - -Wno-psabi - -Wduplicated-cond # check for duplicate conditions - -Wduplicated-branches # check for duplicate branches - -Wlogical-op # Search for bitwise operations instead of logical - -Wnull-dereference # Search for NULL dereference - -Wundef # Warn if undefind marcos are used - -Wformat=2 # Format string problem detection - -Wformat-overflow=2 # Formatting issues in printf - -Wformat-truncation=2 # Formatting issues in printf - -Wformat-security # Search for dangerous printf operations - -Wstrict-overflow=3 # Warn if integer overflows might happen - -Warray-bounds=2 # Some array bounds violations will be found - -Wshift-overflow=2 # Search for bit left shift overflows ( Date: Fri, 13 May 2022 11:34:44 +0200 Subject: [PATCH 15/18] add cmake-format command to shell script --- scripts/apply-clang-format.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh index 27202324..d3aa1d1a 100755 --- a/scripts/apply-clang-format.sh +++ b/scripts/apply-clang-format.sh @@ -3,6 +3,12 @@ if [[ ! -f README.md ]]; then cd .. fi +cmake_fmt="python3 -m cmake-format" +if command -v ${cmake_fmt} &> /dev/null + cmake_fmt_cmd=${cmake_fmt} -i CMakeLists.txt + eval ${cmake_fmt_cmd} +then + find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i From 9e3d5b6a0cb7ead82ba0991ef238520214258302 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 May 2022 11:35:18 +0200 Subject: [PATCH 16/18] small fix --- scripts/apply-clang-format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh index d3aa1d1a..b4a44c43 100755 --- a/scripts/apply-clang-format.sh +++ b/scripts/apply-clang-format.sh @@ -5,7 +5,7 @@ fi cmake_fmt="python3 -m cmake-format" if command -v ${cmake_fmt} &> /dev/null - cmake_fmt_cmd=${cmake_fmt} -i CMakeLists.txt + cmake_fmt_cmd="${cmake_fmt} -i CMakeLists.txt" eval ${cmake_fmt_cmd} then From ad0b6f1ed1132a9d41c3e10b407fef9220f395f3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 May 2022 11:35:59 +0200 Subject: [PATCH 17/18] another small fix --- scripts/apply-clang-format.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh index b4a44c43..6ea055f9 100755 --- a/scripts/apply-clang-format.sh +++ b/scripts/apply-clang-format.sh @@ -4,10 +4,10 @@ if [[ ! -f README.md ]]; then fi cmake_fmt="python3 -m cmake-format" -if command -v ${cmake_fmt} &> /dev/null +if command -v ${cmake_fmt} &> /dev/null; then cmake_fmt_cmd="${cmake_fmt} -i CMakeLists.txt" eval ${cmake_fmt_cmd} -then +fi find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i From deee4c43c0c6e7dff860bb8ead16480560e26f7b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 May 2022 11:37:58 +0200 Subject: [PATCH 18/18] finally this works --- scripts/apply-clang-format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh index 6ea055f9..97783e95 100755 --- a/scripts/apply-clang-format.sh +++ b/scripts/apply-clang-format.sh @@ -3,7 +3,7 @@ if [[ ! -f README.md ]]; then cd .. fi -cmake_fmt="python3 -m cmake-format" +cmake_fmt="cmake-format" if command -v ${cmake_fmt} &> /dev/null; then cmake_fmt_cmd="${cmake_fmt} -i CMakeLists.txt" eval ${cmake_fmt_cmd}