diff --git a/CHANGELOG.md b/CHANGELOG.md index cc006de4..8cb09d57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added +- functions to configure pus routing - FreeRTOS monotonic clock which is not subjected to time jumps of the system clock - add CFDP subsystem ID https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/742 diff --git a/src/fsfw/devicehandlers/AssemblyBase.cpp b/src/fsfw/devicehandlers/AssemblyBase.cpp index c22bd4ee..a04c2826 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.cpp +++ b/src/fsfw/devicehandlers/AssemblyBase.cpp @@ -71,7 +71,8 @@ bool AssemblyBase::handleChildrenChangedHealth() { if (iter == childrenMap.end()) { return false; } - HealthState healthState = healthHelper.healthTable->getHealth(convertToDeviceObjectId(iter->first)); + HealthState healthState = + healthHelper.healthTable->getHealth(convertToDeviceObjectId(iter->first)); if (healthState == HasHealthIF::NEEDS_RECOVERY) { triggerEvent(TRYING_RECOVERY, iter->first, 0); recoveryState = RECOVERY_STARTED; @@ -91,16 +92,15 @@ bool AssemblyBase::handleChildrenChangedHealth() { void AssemblyBase::handleChildrenTransition() { if (commandsOutstanding <= 0) { switch (internalState) { - case STATE_NEED_SECOND_STEP: - { + case STATE_NEED_SECOND_STEP: { internalState = STATE_SECOND_STEP; ReturnValue_t result = commandChildren(targetMode, targetSubmode); - if(result == NEED_SECOND_STEP) { + if (result == NEED_SECOND_STEP) { internalState = STATE_NEED_SECOND_STEP; } return; } - case STATE_OVERWRITE_HEALTH: { + case STATE_OVERWRITE_HEALTH: { internalState = STATE_SINGLE_STEP; ReturnValue_t result = commandChildren(mode, submode); if (result == NEED_SECOND_STEP) { @@ -269,15 +269,14 @@ void AssemblyBase::overwriteDeviceHealth(object_id_t objectId, HasHealthIF::Heal triggerEvent(OVERWRITING_HEALTH, objectId, oldHealth); internalState = STATE_OVERWRITE_HEALTH; modeHelper.setForced(true); - if(childrenMap.find(objectId) != childrenMap.end()) { + if (childrenMap.find(objectId) != childrenMap.end()) { sendHealthCommand(childrenMap.at(objectId).commandQueue, EXTERNAL_CONTROL); } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << std::hex << SystemObject::getObjectId() << ": invalid mode table entry" - << std::endl; + sif::debug << std::hex << SystemObject::getObjectId() << ": invalid mode table entry" + << std::endl; #endif } - } void AssemblyBase::triggerModeHelperEvents(Mode_t mode, Submode_t submode) { diff --git a/src/fsfw/events/Event.h b/src/fsfw/events/Event.h index 73a5fbbf..e45c7762 100644 --- a/src/fsfw/events/Event.h +++ b/src/fsfw/events/Event.h @@ -22,7 +22,7 @@ constexpr EventId_t getEventId(Event event) { return (event & 0xFFFF); } constexpr EventSeverity_t getSeverity(Event event) { return ((event >> 16) & 0xFF); } -template +template constexpr Event makeEvent() { static_assert(uniqueEventId < 100, "The unique event ID must be smaller than 100!"); return (eventSeverity << 16) + (subsystemId * 100) + uniqueEventId; diff --git a/src/fsfw/osal/common/UdpTcPollingTask.cpp b/src/fsfw/osal/common/UdpTcPollingTask.cpp index 4304fdd2..092ebfbc 100644 --- a/src/fsfw/osal/common/UdpTcPollingTask.cpp +++ b/src/fsfw/osal/common/UdpTcPollingTask.cpp @@ -41,7 +41,7 @@ UdpTcPollingTask::UdpTcPollingTask(object_id_t objectId, object_id_t tmtcUdpBrid [[noreturn]] ReturnValue_t UdpTcPollingTask::performOperation(uint8_t opCode) { /* Sender Address is cached here. */ - struct sockaddr senderAddress {}; + struct sockaddr senderAddress{}; socklen_t senderAddressSize = sizeof(senderAddress); /* Poll for new UDP datagrams in permanent loop. */ diff --git a/src/fsfw/osal/freertos/Clock.cpp b/src/fsfw/osal/freertos/Clock.cpp index 43ff7b72..8c7f36c2 100644 --- a/src/fsfw/osal/freertos/Clock.cpp +++ b/src/fsfw/osal/freertos/Clock.cpp @@ -5,8 +5,8 @@ #include "FreeRTOS.h" #include "fsfw/globalfunctions/timevalOperations.h" -#include "fsfw/serviceinterface/ServiceInterfacePrinter.h" #include "fsfw/osal/freertos/Timekeeper.h" +#include "fsfw/serviceinterface/ServiceInterfacePrinter.h" #include "task.h" // TODO sanitize input? @@ -48,7 +48,7 @@ ReturnValue_t Clock::getClock(timeval* time) { } ReturnValue_t Clock::getClockMonotonic(timeval* time) { - *time = Timekeeper::instance()->getMonotonicClockOffset() + getUptime(); + *time = Timekeeper::instance()->getMonotonicClockOffset() + getUptime(); return returnvalue::OK; } diff --git a/src/fsfw/osal/freertos/Timekeeper.cpp b/src/fsfw/osal/freertos/Timekeeper.cpp index ca0fe5d0..078d88cb 100644 --- a/src/fsfw/osal/freertos/Timekeeper.cpp +++ b/src/fsfw/osal/freertos/Timekeeper.cpp @@ -18,11 +18,11 @@ Timekeeper* Timekeeper::instance() { } void Timekeeper::setOffset(const timeval& offset) { - if (not monotonicClockInitialized) { - this->monotonicClockOffset = offset; - monotonicClockInitialized = true; - } - this->offset = offset; + if (not monotonicClockInitialized) { + this->monotonicClockOffset = offset; + monotonicClockInitialized = true; + } + this->offset = offset; } timeval Timekeeper::ticksToTimeval(TickType_t ticks) { @@ -40,6 +40,4 @@ timeval Timekeeper::ticksToTimeval(TickType_t ticks) { TickType_t Timekeeper::getTicks() { return xTaskGetTickCount(); } -const timeval Timekeeper::getMonotonicClockOffset() const { - return monotonicClockOffset; -} +const timeval Timekeeper::getMonotonicClockOffset() const { return monotonicClockOffset; } diff --git a/src/fsfw/osal/host/Clock.cpp b/src/fsfw/osal/host/Clock.cpp index 1515d472..12149e1c 100644 --- a/src/fsfw/osal/host/Clock.cpp +++ b/src/fsfw/osal/host/Clock.cpp @@ -173,7 +173,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { } ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) { - struct tm time_tm {}; + struct tm time_tm{}; time_tm.tm_year = from->year - 1900; time_tm.tm_mon = from->month - 1; diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 7bedfadb..c61e1dd4 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -79,7 +79,6 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod } if (healthHelper.healthTable->hasHealth(convertToDeviceObjectId(object))) { - switch (healthHelper.healthTable->getHealth(convertToDeviceObjectId(object))) { case NEEDS_RECOVERY: case FAULTY: @@ -354,6 +353,4 @@ ReturnValue_t SubsystemBase::registerChild(object_id_t childObjectId, MessageQue return returnvalue::OK; } -object_id_t SubsystemBase::convertToDeviceObjectId(object_id_t id) { - return id; -} \ No newline at end of file +object_id_t SubsystemBase::convertToDeviceObjectId(object_id_t id) { return id; } \ No newline at end of file diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index b7b5e516..c5d80aa4 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -18,6 +18,10 @@ PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, Storag PusDistributor::~PusDistributor() = default; +void PusDistributor::setVerificationReporter(object_id_t verificationReporter_) { + verificationReporter = verificationReporter_; +} + ReturnValue_t PusDistributor::selectDestination(MessageQueueId_t& destId) { #if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1 store_address_t storeId = currentMessage.getStorageId(); @@ -131,8 +135,7 @@ ReturnValue_t PusDistributor::initialize() { return ObjectManagerIF::CHILD_INIT_FAILED; } if (verifyChannel == nullptr) { - verifyChannel = - ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); + verifyChannel = ObjectManager::instance()->get(verificationReporter); if (verifyChannel == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index f10c9d9b..0e379480 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -43,6 +43,10 @@ class PusDistributor : public TcDistributorBase, [[nodiscard]] MessageQueueId_t getRequestQueue() const override; ReturnValue_t initialize() override; [[nodiscard]] uint32_t getIdentifier() const override; + /** + * @brief Can be used to set the verification reporter if another than the default should be used + */ + void setVerificationReporter(object_id_t verificationReporter_); protected: struct ServiceInfo { @@ -75,6 +79,8 @@ class PusDistributor : public TcDistributorBase, */ ReturnValue_t tcStatus; + object_id_t verificationReporter = objects::VERIFICATION_REPORTER; + /** * This method reads the packet service, checks if such a service is * registered and forwards the packet to the destination. diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 0cdcc653..b0b2143f 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -128,7 +128,7 @@ ReturnValue_t CommandingServiceBase::initialize() { if (verificationReporter == nullptr) { verificationReporter = - ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); + ObjectManager::instance()->get(verificationReporterId); if (verificationReporter == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -136,6 +136,10 @@ ReturnValue_t CommandingServiceBase::initialize() { return returnvalue::OK; } +void CommandingServiceBase::setVerificationReporter(object_id_t verificationReporterId_) { + verificationReporterId = verificationReporterId_; +} + void CommandingServiceBase::handleCommandQueue() { CommandMessage reply; ReturnValue_t result; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 92369b58..baf1ba76 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -126,6 +126,8 @@ class CommandingServiceBase : public SystemObject, ReturnValue_t initialize() override; + void setVerificationReporter(object_id_t verificationReporterId_); + /** * Implementation of ExecutableObjectIF function * @@ -262,6 +264,8 @@ class CommandingServiceBase : public SystemObject, const uint16_t timeoutSeconds; + object_id_t verificationReporterId = objects::VERIFICATION_REPORTER; + PusTcReader tcReader; TmStoreHelper tmStoreHelper; TmSendHelper tmSendHelper; diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index a82a6f97..581b851a 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -111,7 +111,7 @@ ReturnValue_t PusServiceBase::initialize() { } if (psbParams.pusDistributor == nullptr) { - psbParams.pusDistributor = ObjectManager::instance()->get(PUS_DISTRIBUTOR); + psbParams.pusDistributor = ObjectManager::instance()->get(pusDistributor); if (psbParams.pusDistributor != nullptr) { registerService(*psbParams.pusDistributor); } @@ -126,7 +126,7 @@ ReturnValue_t PusServiceBase::initialize() { if (psbParams.verifReporter == nullptr) { psbParams.verifReporter = - ObjectManager::instance()->get(objects::VERIFICATION_REPORTER); + ObjectManager::instance()->get(verificationReporter); if (psbParams.verifReporter == nullptr) { return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -134,6 +134,14 @@ ReturnValue_t PusServiceBase::initialize() { return returnvalue::OK; } +void PusServiceBase::setPusDistributor(object_id_t pusDistributor_) { + pusDistributor = pusDistributor_; +} + +void PusServiceBase::setVerificationReporter(object_id_t verificationReporter_) { + verificationReporter = verificationReporter_; +} + void PusServiceBase::setTcPool(StorageManagerIF& tcPool) { psbParams.tcPool = &tcPool; } void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index ed48995e..133eada8 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -201,6 +201,9 @@ class PusServiceBase : public ExecutableObjectIF, void setTaskIF(PeriodicTaskIF* taskHandle) override; [[nodiscard]] const char* getName() const override; + void setPusDistributor(object_id_t pusDistributor_); + void setVerificationReporter(object_id_t verificationReporter_); + protected: /** * @brief Handle to the underlying task @@ -228,6 +231,9 @@ class PusServiceBase : public ExecutableObjectIF, static object_id_t PACKET_DESTINATION; static object_id_t PUS_DISTRIBUTOR; + object_id_t pusDistributor = PUS_DISTRIBUTOR; + object_id_t verificationReporter = objects::VERIFICATION_REPORTER; + private: void handleRequestQueue(); }; diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index 80996bae..750e7a9a 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -116,7 +116,7 @@ class CommandExecutor { int currentFd = 0; bool printOutput = true; std::vector readVec; - struct pollfd waiter {}; + struct pollfd waiter{}; SimpleRingBuffer* ringBuffer = nullptr; DynamicFIFO* sizesFifo = nullptr; diff --git a/unittests/tmtcpacket/testPusTmReader.cpp b/unittests/tmtcpacket/testPusTmReader.cpp index 3e96f935..2f8597f5 100644 --- a/unittests/tmtcpacket/testPusTmReader.cpp +++ b/unittests/tmtcpacket/testPusTmReader.cpp @@ -38,7 +38,7 @@ TEST_CASE("PUS TM Reader", "[pus-tm-reader]") { readerPtr->setTimeReader(&timeStamperAndReader); deleteReader = true; } - REQUIRE(not *readerPtr); + REQUIRE(not*readerPtr); REQUIRE(readerPtr->isNull()); REQUIRE(readerPtr->parseDataWithCrcCheck() == returnvalue::OK); REQUIRE(not readerPtr->isNull());