From 9d626e0a5d8656671f7a846f15186f1d6830c841 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Sep 2022 19:59:02 +0200 Subject: [PATCH 01/63] include correction --- src/fsfw/serviceinterface/ServiceInterfaceStream.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceStream.h b/src/fsfw/serviceinterface/ServiceInterfaceStream.h index 0b3d6745..ca746e7d 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceStream.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceStream.h @@ -1,9 +1,8 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_ -#include - #include "ServiceInterfaceBuffer.h" +#include "fsfw/FSFW.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 From a681a4a797cbec134d03289e0845a13eb79d5925 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:37:10 +0200 Subject: [PATCH 02/63] better error printout --- src/fsfw/datapoollocal/LocalPoolObjectBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 82aefc18..9edf02c5 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -48,12 +48,12 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, if (hkOwner == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner - << std::dec << " did not implement the correct interface " + << std::dec << " does not exists or did not implement the correct interface " << "HasLocalDataPoolIF" << std::endl; #else sif::printError( - "LocalPoolVariable: The supplied pool owner 0x%08x did not implement the correct " - "interface HasLocalDataPoolIF\n", + "LocalPoolVariable: The supplied pool owner 0x%08x does not exists or does not implement " + "the correct interface HasLocalDataPoolIF\n", poolOwner); #endif return; From ce7146e468dbe7cb1ad5073e5374288b366105c5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:40:12 +0200 Subject: [PATCH 03/63] printout tweak --- src/fsfw/datapoollocal/LocalPoolObjectBase.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp index 9edf02c5..5575c3d8 100644 --- a/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp +++ b/src/fsfw/datapoollocal/LocalPoolObjectBase.cpp @@ -48,11 +48,11 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, if (hkOwner == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner - << std::dec << " does not exists or did not implement the correct interface " + << std::dec << " does not exist or does not implement the correct interface " << "HasLocalDataPoolIF" << std::endl; #else sif::printError( - "LocalPoolVariable: The supplied pool owner 0x%08x does not exists or does not implement " + "LocalPoolVariable: The supplied pool owner 0x%08x does not exist or does not implement " "the correct interface HasLocalDataPoolIF\n", poolOwner); #endif From 0f027d29d27fd111a0be1e9ba3d683781ad4d6b0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:51:59 +0200 Subject: [PATCH 04/63] doc corrections --- docs/README-highlevel.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index 9005af8d..cf2daee7 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -4,12 +4,14 @@ High-level overview # Structure The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. +The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this +standard, even for micocontrollers. + +The FSFW uses dynamic allocation during the initialization but provides static containers during +runtime.This simplifies the instantiation of objects and allows the usage of some standard +containers. Dynamic Allocation after initialization is discouraged and different solutions are +provided in the FSFW to achieve that. The fsfw uses run-time type information but will not throw +exceptions. # Failure Handling From 8dea13742fa9f469507945f8cacf369eba4f7cfd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:57:39 +0200 Subject: [PATCH 05/63] update rst file --- docs/README-highlevel.md | 9 ++++----- docs/highlevel.rst | 15 ++++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index cf2daee7..23e27da3 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -7,11 +7,10 @@ The general structure is driven by the usage of interfaces provided by objects. The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this standard, even for micocontrollers. -The FSFW uses dynamic allocation during the initialization but provides static containers during -runtime.This simplifies the instantiation of objects and allows the usage of some standard -containers. Dynamic Allocation after initialization is discouraged and different solutions are -provided in the FSFW to achieve that. The fsfw uses run-time type information but will not throw -exceptions. +The FSFW might use dynamic allocation during program initialization but not during runtime. +It offers pool objects, static containers and it also exposes the Embedded Template Library +to allow writing code which does not perform allocation during runtime. The fsfw uses run-time type +information but will not throw exceptions. # Failure Handling diff --git a/docs/highlevel.rst b/docs/highlevel.rst index 3c9baae2..ee35c549 100644 --- a/docs/highlevel.rst +++ b/docs/highlevel.rst @@ -6,13 +6,14 @@ High-level overview Structure ---------- -The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. +The general structure is driven by the usage of interfaces provided by objects. +The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this +standard, even for micocontrollers. + +The FSFW might use dynamic allocation during program initialization but not during runtime. +It offers pool objects, static containers and it also exposes the +`Embedded Template Library `_ to allow writing code which does not perform +allocation during runtime. The fsfw uses run-time type information but will not throw exceptions. Failure Handling ----------------- From 0042372cb6426f92ab56e93e37ae63015c2d2609 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 13:58:13 +0200 Subject: [PATCH 06/63] now that doc server is up, remove markdown files --- docs/README-config.md | 40 -------- docs/README-controllers.md | 1 - docs/README-core.md | 55 ----------- docs/README-devicehandlers.md | 1 - docs/README-highlevel.md | 135 -------------------------- docs/README-localpools.md | 174 ---------------------------------- docs/README-osal.md | 32 ------- docs/README-pus.md | 1 - 8 files changed, 439 deletions(-) delete mode 100644 docs/README-config.md delete mode 100644 docs/README-controllers.md delete mode 100644 docs/README-core.md delete mode 100644 docs/README-devicehandlers.md delete mode 100644 docs/README-highlevel.md delete mode 100644 docs/README-localpools.md delete mode 100644 docs/README-osal.md delete mode 100644 docs/README-pus.md diff --git a/docs/README-config.md b/docs/README-config.md deleted file mode 100644 index d71feb97..00000000 --- a/docs/README-config.md +++ /dev/null @@ -1,40 +0,0 @@ -Configuring the FSFW -====== - -The FSFW can be configured via the `fsfwconfig` folder. A template folder has -been provided to have a starting point for this. The folder should be added -to the include path. The primary configuration file is the `FSFWConfig.h` folder. Some -of the available options will be explained in more detail here. - -# Auto-Translation of Events - -The FSFW allows the automatic translation of events, which allows developers to track triggered -events directly via console output. Using this feature requires: - -1. `FSFW_OBJ_EVENT_TRANSLATION` set to 1 in the configuration file. -2. Special auto-generated translation files which translate event IDs and object IDs into - human readable strings. These files can be generated using the - [modgen Python scripts](https://git.ksat-stuttgart.de/source/modgen.git). -3. The generated translation files for the object IDs should be named `translatesObjects.cpp` - and `translateObjects.h` and should be copied to the `fsfwconfig/objects` folder -4. The generated translation files for the event IDs should be named `translateEvents.cpp` and - `translateEvents.h` and should be copied to the `fsfwconfig/events` folder - -An example implementations of these translation file generators can be found as part -of the [SOURCE project here](https://git.ksat-stuttgart.de/source/sourceobsw/-/tree/development/generators) -or the [FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/generators) - -## Configuring the Event Manager - -The number of allowed subscriptions can be modified with the following -parameters: - -``` c++ -namespace fsfwconfig { -//! Configure the allocated pool sizes for the event manager. -static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; -static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; -static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; -} -``` - diff --git a/docs/README-controllers.md b/docs/README-controllers.md deleted file mode 100644 index 7af0652d..00000000 --- a/docs/README-controllers.md +++ /dev/null @@ -1 +0,0 @@ -## Controllers diff --git a/docs/README-core.md b/docs/README-core.md deleted file mode 100644 index e34890ae..00000000 --- a/docs/README-core.md +++ /dev/null @@ -1,55 +0,0 @@ -## FSFW Core Modules - -These core modules provide the most important functionalities of the -Flight Software Framework - -### Clock - - * This is a class of static functions that can be used at anytime - * Leap Seconds must be set if any time conversions from UTC to other times is used - -### ObjectManager - -* Must be created during program startup -* The component which handles all references. All SystemObjects register at this component. -* Any SystemObject needs to have a unique ObjectId. Those can be managed like objects::framework_objects. -* A reference to an object can be get by calling the following function. T must be the specific Interface you want to call. -A nullptr check of the returning Pointer must be done. This function is based on Run-time type information. - -```cpp -template T* ObjectManagerIF::get( object_id_t id ) -``` -* A typical way to create all objects on startup is a handing a static produce function to the - ObjectManager on creation. By calling objectManager->initialize() the produce function will be - called and all SystemObjects will be initialized afterwards. - -### Event Manager - -* Component which allows routing of events -* Other objects can subscribe to specific events, ranges of events or all events of an object. -* Subscriptions can be done during runtime but should be done during initialization -* Amounts of allowed subscriptions can be configured in `FSFWConfig.h` - -### Health Table - -* A component which holds every health state -* Provides a thread safe way to access all health states without the need of message exchanges - -### Stores - -* The message based communication can only exchange a few bytes of information inside the message - itself. Therefore, additional information can be exchanged with Stores. With this, only the - store address must be exchanged in the message. -* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC - Store is used. For outgoing TM a TM store is used. -* All of them should use the Thread Safe Class storagemanager/PoolManager - -### Tasks - -There are two different types of tasks: - * The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the - insertion to the Tasks. - * FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for - DeviceHandlers, where polling should be in a defined order. An example can be found in - `defaultcfg/fsfwconfig/pollingSequence` folder - diff --git a/docs/README-devicehandlers.md b/docs/README-devicehandlers.md deleted file mode 100644 index 8b6551aa..00000000 --- a/docs/README-devicehandlers.md +++ /dev/null @@ -1 +0,0 @@ -## Device Handlers diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md deleted file mode 100644 index 9005af8d..00000000 --- a/docs/README-highlevel.md +++ /dev/null @@ -1,135 +0,0 @@ -High-level overview -====== - -# Structure - -The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be -widely available, even with older compilers. -The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. -This simplifies the instantiation of objects and allows the usage of some standard containers. -Dynamic Allocation after initialization is discouraged and different solutions are provided in the -FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. - -# Failure Handling - -Functions should return a defined `ReturnValue_t` to signal to the caller that something has -gone wrong. Returnvalues must be unique. For this the function `returnvalue::makeCode` -or the macro `MAKE_RETURN` can be used. The `CLASS_ID` is a unique id for that type of object. -See `returnvalues/FwClassIds` folder. The user can add custom `CLASS_ID`s via the -`fsfwconfig` folder. - -# OSAL - -The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS. -The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes. -The [OSAL README](doc/README-osal.md#top) provides more detailed information on provided components -and how to use them. - -# Core Components - -The FSFW has following core components. More detailed informations can be found in the -[core component section](doc/README-core.md#top): - -1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks - with fixed timeslots -2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID - to the object handles. -3. Static Stores: Different stores are provided to store data of variable size (like telecommands - or small telemetry) in a pool structure without using dynamic memory allocation. - These pools are allocated up front. -3. Clock: This module provided common time related functions -4. EventManager: This module allows routing of events generated by `SystemObjects` -5. HealthTable: A component which stores the health states of objects - -# Static IDs in the framework - -Some parts of the framework use a static routing address for communication. -An example setup of ids can be found in the example config in `defaultcft/fsfwconfig/objects` - inside the function `Factory::setStaticFrameworkObjectIds()`. - -# Events - -Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT. -This works analog to the returnvalues. Every object that needs own EventIds has to get a -unique SUBSYSTEM_ID. Every SystemObject can call triggerEvent from the parent class. -Therefore, event messages contain the specific EventId and the objectId of the object that -has triggered. - -# Internal Communication - -Components communicate mostly via Messages through Queues. -Those queues are created by calling the singleton `QueueFactory::instance()->create()` which -will create `MessageQueue` instances for the used OSAL. - -# External Communication - -The external communication with the mission control system is mostly up to the user implementation. -The FSFW provides PUS Services which can be used to but don't need to be used. -The services can be seen as a conversion from a TC to a message based communication and back. - -## TMTC Communication - -The FSFW provides some components to facilitate TMTC handling via the PUS commands. -For example, a UDP or TCP PUS server socket can be opened on a specific port using the -files located in `osal/common`. The FSFW example uses this functionality to allow sending telecommands -and receiving telemetry using the [TMTC commander application](https://github.com/spacefisch/tmtccmd). -Simple commands like the PUS Service 17 ping service can be tested by simply running the -`tmtc_client_cli.py` or `tmtc_client_gui.py` utility in -the [example tmtc folder](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/tmtc) -while the `fsfw_example` application is running. - -More generally, any class responsible for handling incoming telecommands and sending telemetry -can implement the generic `TmTcBridge` class located in `tmtcservices`. Many applications -also use a dedicated polling task for reading telecommands which passes telecommands -to the `TmTcBridge` implementation. - -## CCSDS Frames, CCSDS Space Packets and PUS - -If the communication is based on CCSDS Frames and Space Packets, several classes can be used to -distributed the packets to the corresponding services. Those can be found in `tcdistribution`. -If Space Packets are used, a timestamper has to be provided by the user. -An example can be found in the `timemanager` folder, which uses `CCSDSTime::CDS_short`. - -# Device Handlers - -DeviceHandlers are another important component of the FSFW. -The idea is, to have a software counterpart of every physical device to provide a simple mode, -health and commanding interface. By separating the underlying Communication Interface with -`DeviceCommunicationIF`, a device handler (DH) can be tested on different hardware. -The DH has mechanisms to monitor the communication with the physical device which allow -for FDIR reaction. Device Handlers can be created by implementing `DeviceHandlerBase`. -A standard FDIR component for the DH will be created automatically but can -be overwritten by the user. More information on DeviceHandlers can be found in the -related [documentation section](doc/README-devicehandlers.md#top). - -# Modes and Health - -The two interfaces `HasModesIF` and `HasHealthIF` provide access for commanding and monitoring -of components. On-board Mode Management is implement in hierarchy system. -DeviceHandlers and Controllers are the lowest part of the hierarchy. -The next layer are Assemblies. Those assemblies act as a component which handle -redundancies of handlers. Assemblies share a common core with the next level which -are the Subsystems. - -Those Assemblies are intended to act as auto-generated components from a database which describes -the subsystem modes. The definitions contain transition and target tables which contain the DH, -Assembly and Controller Modes to be commanded. -Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a -switch into any higher AOCS mode might first turn on the sensors, than the actuators and the -controller as last component. -The target table is used to describe the state that is checked continuously by the subsystem. -All of this allows System Modes to be generated as Subsystem object as well from the same database. -This System contains list of subsystem modes in the transition and target tables. -Therefore, it allows a modular system to create system modes and easy commanding of those, because -only the highest components must be commanded. - -The health state represents if the component is able to perform its tasks. -This can be used to signal the system to avoid using this component instead of a redundant one. -The on-board FDIR uses the health state for isolation and recovery. - -# Unit Tests - -Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include -catch2 itself. More information on how to run these tests can be found in the separate -[`fsfw_tests` reposoitory](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_tests) diff --git a/docs/README-localpools.md b/docs/README-localpools.md deleted file mode 100644 index 1770efb9..00000000 --- a/docs/README-localpools.md +++ /dev/null @@ -1,174 +0,0 @@ -## Local Data Pools Developer Information - -The following text is targeted towards mission software developers which would like -to use the local data pools provided by the FSFW to store data like sensor values so they can be -used by other software objects like controllers as well. If a custom class should have a local -pool which can be used by other software objects as well, following steps have to be performed: - -1. Create a `LocalDataPoolManager` member object in the custom class -2. Implement the `HasLocalDataPoolIF` with specifies the interface between the local pool manager -and the class owning the local pool. - -The local data pool manager is also able to process housekeeping service requests in form -of messages, generate periodic housekeeping packet, generate notification and snapshots of changed -variables and datasets and process notifications and snapshots coming from other objects. -The two former tasks are related to the external interface using telemetry and telecommands (TMTC) -while the later two are related to data consumers like controllers only acting on data change -detected by the data creator instead of checking the data manually each cycle. Two important -framework classes `DeviceHandlerBase` and `ExtendedControllerBase` already perform the two steps -shown above so the steps required are altered slightly. - -### Storing and Accessing pool data - -The pool manager is responsible for thread-safe access of the pool data, but the actual -access to the pool data from the point of view of a mission software developer happens via proxy -classes like pool variable classes. These classes store a copy -of the pool variable with the matching datatype and copy the actual data from the local pool -on a `read` call. Changed variables can then be written to the local pool with a `commit` call. -The `read` and `commit` calls are thread-safe and can be called concurrently from data creators -and data consumers. Generally, a user will create a dataset class which in turn groups all -cohesive pool variables. These sets simply iterator over the list of variables and call the -`read` and `commit` functions of each variable. The following diagram shows the -high-level architecture of the local data pools. - -.. image:: ../misc/logo/FSFW_Logo_V3_bw.png - :alt: FSFW Logo - - -An example is shown for using the local data pools with a Gyroscope. -For example, the following code shows an implementation to access data from a Gyroscope taken -from the SOURCE CubeSat project: - -```cpp -class GyroPrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> { -public: - /** - * Constructor for data users - * @param gyroId - */ - GyroPrimaryDataset(object_id_t gyroId): - StaticLocalDataSet(sid_t(gyroId, gyrodefs::GYRO_DATA_SET_ID)) { - setAllVariablesReadOnly(); - } - - lp_var_t angVelocityX = lp_var_t(sid.objectId, - gyrodefs::ANGULAR_VELOCITY_X, this); - lp_var_t angVelocityY = lp_var_t(sid.objectId, - gyrodefs::ANGULAR_VELOCITY_Y, this); - lp_var_t angVelocityZ = lp_var_t(sid.objectId, - gyrodefs::ANGULAR_VELOCITY_Z, this); -private: - - friend class GyroHandler; - /** - * Constructor for data creator - * @param hkOwner - */ - GyroPrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, gyrodefs::GYRO_DATA_SET_ID) {} -}; -``` - -There is a public constructor for users which sets all variables to read-only and there is a -constructor for the GyroHandler data creator by marking it private and declaring the `GyroHandler` -as a friend class. Both the atittude controller and the `GyroHandler` can now -use the same class definition to access the pool variables with `read` and `commit` semantics -in a thread-safe way. Generally, each class requiring access will have the set class as a member -class. The data creator will also be generally a `DeviceHandlerBase` subclass and some additional -steps are necessary to expose the set for housekeeping purposes. - -### Using the local data pools in a `DeviceHandlerBase` subclass - -It is very common to store data generated by devices like a sensor into a pool which can -then be used by other objects. Therefore, the `DeviceHandlerBase` already has a -local pool. Using the aforementioned example, our `GyroHandler` will now have the set class -as a member: - -```cpp -class GyroHandler: ... { - -public: - ... -private: - ... - GyroPrimaryDataset gyroData; - ... -}; -``` - -The constructor used for the creators expects the owner class as a parameter, so we initialize -the object in the `GyroHandler` constructor like this: - -```cpp -GyroHandler::GyroHandler(object_id_t objectId, object_id_t comIF, - CookieIF *comCookie, uint8_t switchId): - DeviceHandlerBase(objectId, comIF, comCookie), switchId(switchId), - gyroData(this) {} -``` - -We need to assign the set to a reply ID used in the `DeviceHandlerBase`. -The combination of the `GyroHandler` object ID and the reply ID will be the 64-bit structure ID -`sid_t` and is used to globally identify the set, for example when requesting housekeeping data or -generating update messages. We need to assign our custom set class in some way so that the local -pool manager can access the custom data sets as well. -By default, the `getDataSetHandle` will take care of this tasks. The default implementation for a -`DeviceHandlerBase` subclass will use the internal command map to retrieve -a handle to a dataset from a given reply ID. Therefore, -we assign the set in the `fillCommandAndReplyMap` function: - -```cpp -void GyroHandler::fillCommandAndReplyMap() { - ... - this->insertInCommandAndReplyMap(gyrodefs::GYRO_DATA, 3, &gyroData); - ... -} -``` - -Now, we need to create the actual pool entries as well, using the `initializeLocalDataPool` -function. Here, we also immediately subscribe for periodic housekeeping packets -with an interval of 4 seconds. They are still disabled in this example and can be enabled -with a housekeeping service command. - -```cpp -ReturnValue_t GyroHandler::initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_X, - new PoolEntry({0.0})); - localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Y, - new PoolEntry({0.0})); - localDataPoolMap.emplace(gyrodefs::ANGULAR_VELOCITY_Z, - new PoolEntry({0.0})); - localDataPoolMap.emplace(gyrodefs::GENERAL_CONFIG_REG42, - new PoolEntry({0})); - localDataPoolMap.emplace(gyrodefs::RANGE_CONFIG_REG43, - new PoolEntry({0})); - - poolManager.subscribeForPeriodicPacket(gyroData.getSid(), false, 4.0, false); - return returnvalue::OK; -} -``` - -Now, if we receive some sensor data and converted them into the right format, -we can write it into the pool like this, using a guard class to ensure the set is commited back -in any case: - -```cpp -PoolReadGuard readHelper(&gyroData); -if(readHelper.getReadResult() == returnvalue::OK) { - if(not gyroData.isValid()) { - gyroData.setValidity(true, true); - } - - gyroData.angVelocityX = angularVelocityX; - gyroData.angVelocityY = angularVelocityY; - gyroData.angVelocityZ = angularVelocityZ; -} -``` - -The guard class will commit the changed data on destruction automatically. - -### Using the local data pools in a `ExtendedControllerBase` subclass - -Coming soon - - diff --git a/docs/README-osal.md b/docs/README-osal.md deleted file mode 100644 index 6f8ce60f..00000000 --- a/docs/README-osal.md +++ /dev/null @@ -1,32 +0,0 @@ -# Operating System Abstraction Layer (OSAL) - -Some specific information on the provided OSALs are provided. - -## Linux OSAL - -This OSAL can be used to compile for Linux host systems like Ubuntu 20.04 or for -embedded Linux targets like the Raspberry Pi. This OSAL generally requires threading support -and real-time functionalities. For most UNIX systems, this is done by adding `-lrt` and `-lpthread` to the linked libraries in the compilation process. The CMake build support provided will do this automatically for the `fsfw` target. It should be noted that most UNIX systems need to be configured specifically to allow the real-time functionalities required by the FSFW. - -More information on how to set up a Linux system accordingly can be found in the -[Linux README of the FSFW example application](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example/src/branch/master/doc/README-linux.md#top) - -## Hosted OSAL - -This is the newest OSAL. Support for Semaphores has not been implemented yet and will propably be implemented as soon as C++20 with Semaphore support has matured. This OSAL can be used to run the FSFW on any host system, but currently has only been tested on Windows 10 and Ubuntu 20.04. Unlike the other OSALs, it uses dynamic memory allocation (e.g. for the message queue implementation). Cross-platform serial port (USB) support might be added soon. - -## FreeRTOS OSAL - -FreeRTOS is not included and the developer needs to take care of compiling the FreeRTOS sources and adding the `FreeRTOSConfig.h` file location to the include path. This OSAL has only been tested extensively with the pre-emptive scheduler configuration so far but it should in principle also be possible to use a cooperative scheduler. It is recommended to use the `heap_4` allocation scheme. When using newlib (nano), it is also recommended to add `#define configUSE_NEWLIB_REENTRANT` to the FreeRTOS configuration file to ensure thread-safety. - -When using this OSAL, developers also need to provide an implementation for the `vRequestContextSwitchFromISR` function. This has been done because the call to request a context switch from an ISR is generally located in the `portmacro.h` header and is different depending on the target architecture or device. - -## RTEMS OSAL - -The RTEMS OSAL was the first implemented OSAL which is also used on the active satellite Flying Laptop. - -## TCP/IP socket abstraction - -The Linux and Host OSAL provide abstraction layers for the socket API. Currently, only UDP sockets have been imlemented. This is very useful to test TMTC handling either on the host computer directly (targeting localhost with a TMTC application) or on embedded Linux devices, sending TMTC packets via Ethernet. - - diff --git a/docs/README-pus.md b/docs/README-pus.md deleted file mode 100644 index 928d2eda..00000000 --- a/docs/README-pus.md +++ /dev/null @@ -1 +0,0 @@ -## PUS Services From bcbbc9763a80af27e7ccd0d1ebd0342d13ad5eb0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 15 Sep 2022 14:00:01 +0200 Subject: [PATCH 07/63] markdown update not required, will be removed --- docs/README-highlevel.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/README-highlevel.md b/docs/README-highlevel.md index 23e27da3..9005af8d 100644 --- a/docs/README-highlevel.md +++ b/docs/README-highlevel.md @@ -4,13 +4,12 @@ High-level overview # Structure The general structure is driven by the usage of interfaces provided by objects. -The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this -standard, even for micocontrollers. - -The FSFW might use dynamic allocation during program initialization but not during runtime. -It offers pool objects, static containers and it also exposes the Embedded Template Library -to allow writing code which does not perform allocation during runtime. The fsfw uses run-time type -information but will not throw exceptions. +The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be +widely available, even with older compilers. +The FSFW uses dynamic allocation during the initialization but provides static containers during runtime. +This simplifies the instantiation of objects and allows the usage of some standard containers. +Dynamic Allocation after initialization is discouraged and different solutions are provided in the +FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed. # Failure Handling From 9a2146fa2df0a5e5e5a5d5bc61e24c7b344b06d3 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 11:36:29 +0200 Subject: [PATCH 08/63] added impressum and datenschutz in sphinx documentation --- docs/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 62b17192..eb0f94cd 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,6 +50,11 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # html_theme = 'alabaster' +html_theme_options = { + "extra_nav_links": {"Impressum" : "https://www.uni-stuttgart.de/impressum", "Datenschutz": "https://info.irs.uni-stuttgart.de/datenschutz/datenschutzWebmit.html"} +} + + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". From 3b8ca09299cbe3de03364c0f622a8d8cf2ecebce Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 13:46:03 +0200 Subject: [PATCH 09/63] prepared docker for documentation rsync --- automation/Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/automation/Dockerfile b/automation/Dockerfile index 5bd7d382..1bd39b3f 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get --yes upgrade #tzdata is a dependency, won't install otherwise ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz +RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz rsync RUN python3 -m pip install sphinx breathe @@ -23,3 +23,7 @@ RUN git clone https://github.com/ETLCPP/etl.git && \ #ssh needs a valid user to work RUN adduser --uid 114 jenkins + +#add documentation server to known hosts +RUN echo "|1|/LzCV4BuTmTb2wKnD146l9fTKgQ=|NJJtVjvWbtRt8OYqFgcYRnMQyVw= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts +RUN echo "|1|CcBvBc3EG03G+XM5rqRHs6gK/Gg=|oGeJQ+1I8NGI2THIkJsW92DpTzs= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts \ No newline at end of file From 0fea22d0319a86304ebe83805f9adfdfeaccc2ee Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 14:06:28 +0200 Subject: [PATCH 10/63] switching to rsync and deploying to web documentation --- automation/Jenkinsfile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 8b123fa9..63acab58 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -5,7 +5,7 @@ pipeline { } agent { docker { - image 'fsfw-ci:d5' + image 'fsfw-ci:d6' args '--network host' } } @@ -52,14 +52,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/development/*' - sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/development' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/development' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/development/*' - sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/development' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/development' } } } @@ -73,14 +71,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/master/*' - sh 'scp -o StrictHostKeyChecking=no -r docs/sphinx/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/master' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/master' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'ssh -o StrictHostKeyChecking=no buildfix@documentation.intra.irs.uni-stuttgart.de rm -rf /mnt/data/www/html/fsfw/coverage/master/*' - sh 'scp -o StrictHostKeyChecking=no -r fsfw-tests_coverage/* buildfix@documentation.intra.irs.uni-stuttgart.de:/mnt/data/www/html/fsfw/coverage/master' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/master' } } } From 5488ee715f9327c9f7d791adb762b8d7d0eebf48 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 14:07:12 +0200 Subject: [PATCH 11/63] testing deployment of documentation --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 63acab58..fcbe1a7b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From c0000a863595490d7a6c420c4b8729133bc2c263 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 14:14:10 +0200 Subject: [PATCH 12/63] testing deployment of both development and master doc --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index fcbe1a7b..022bbad0 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'master' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 33530f2819bb84566f9d105d2284a898d924e219 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:04:35 +0200 Subject: [PATCH 13/63] adding Impressum and Datenschutz to lcov output --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5e45a8c..e2572b20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -326,7 +326,8 @@ if(FSFW_BUILD_TESTS) "/usr/local/include/*" "*/fsfw_tests/*" "*/catch2-src/*" - "*/fsfw_hal/*") + "*/fsfw_hal/*" + "unittests/*") endif() target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs @@ -345,7 +346,8 @@ if(FSFW_BUILD_TESTS) else() setup_target_for_coverage_lcov( NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT}) + DEPENDENCIES ${FSFW_TEST_TGT} + GENHTML_ARGS --html-epilog ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) endif() endif() endif() From 292fe3e5e4526c5aa35049033dd50c1851f66a93 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:11:57 +0200 Subject: [PATCH 14/63] forgot epilog file --- unittests/lcov_epilog.html | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 unittests/lcov_epilog.html diff --git a/unittests/lcov_epilog.html b/unittests/lcov_epilog.html new file mode 100644 index 00000000..6ed9a1b2 --- /dev/null +++ b/unittests/lcov_epilog.html @@ -0,0 +1,2 @@ +
Impressum Datenschutz
+ From 5c3bb13834933dedbaca62013b14776d2ea1221a Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:31:07 +0200 Subject: [PATCH 15/63] Revert "testing deployment of both development and master doc" This reverts commit c0000a863595490d7a6c420c4b8729133bc2c263. --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 022bbad0..fcbe1a7b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'mohr/documentation_ci' + branch 'master' } steps { dir(DOCDDIR) { From 12d0c23c13c36774cadaf8a264f7396497960105 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:31:17 +0200 Subject: [PATCH 16/63] Revert "testing deployment of documentation" This reverts commit 5488ee715f9327c9f7d791adb762b8d7d0eebf48. --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index fcbe1a7b..63acab58 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { From 9e6c1d60e51a927f0e9efe49bbebf1363e6570cd Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 17:54:41 +0200 Subject: [PATCH 17/63] another ci check --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 63acab58..fcbe1a7b 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 4f3361eb2b3af9554ac0d2f154a4c434b7eae21c Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 18:33:47 +0200 Subject: [PATCH 18/63] another ci check --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index fcbe1a7b..022bbad0 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'master' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 775d5632de48fa4c6fb549f0c2b8d1bff4cfd362 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 23 Sep 2022 20:26:45 +0200 Subject: [PATCH 19/63] update to ssh connection to doc server --- automation/Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 022bbad0..0f457213 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -52,12 +52,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/development' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/development' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/development' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/development' } } } @@ -71,12 +71,12 @@ pipeline { sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..' sh 'make Sphinx' sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/master' + sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/master' } } dir(BUILDDIR) { sshagent(credentials: ['documentation-buildfix']) { - sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:~/www/fsfw/coverage/master' + sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/master' } } } From c54d9d7ba684f046d784fe35c3f0eafa7cd5f2e4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Sep 2022 14:15:11 +0200 Subject: [PATCH 20/63] add some tests --- unittests/tmtcpacket/testCcsdsCreator.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/unittests/tmtcpacket/testCcsdsCreator.cpp b/unittests/tmtcpacket/testCcsdsCreator.cpp index 2b043717..d73e5252 100644 --- a/unittests/tmtcpacket/testCcsdsCreator.cpp +++ b/unittests/tmtcpacket/testCcsdsCreator.cpp @@ -14,11 +14,17 @@ TEST_CASE("CCSDS Creator", "[ccsds-creator]") { size_t serLen = 0; SECTION("Constexpr Helpers") { - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22, true) == 0x1822); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22, true) == 0x0822); - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22, false) == 0x1022); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22, false) == 0x0022); + + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff, true) == 0x1fff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff, true) == 0xfff); + + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff, false) == 0x17ff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff, false) == 0x7ff); } SECTION("Basic Test") { From 78314ad9668a2e01408a0111f7f306bbb468a40f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Sep 2022 16:47:23 +0200 Subject: [PATCH 21/63] this makes a bit more sense --- src/fsfw/devicehandlers/ChildHandlerBase.cpp | 11 +++-------- src/fsfw/devicehandlers/ChildHandlerBase.h | 3 +-- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 10 ---------- src/fsfw/devicehandlers/DeviceHandlerBase.h | 3 ++- src/fsfw/pus/Service5EventReporting.cpp | 4 ++-- src/fsfw/subsystem/SubsystemBase.cpp | 13 ++++++++++--- 6 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.cpp b/src/fsfw/devicehandlers/ChildHandlerBase.cpp index ecd4cfc8..39a3a20f 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.cpp +++ b/src/fsfw/devicehandlers/ChildHandlerBase.cpp @@ -3,17 +3,12 @@ #include "fsfw/subsystem/SubsystemBase.h" ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, - CookieIF* cookie, object_id_t hkDestination, - uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, - object_id_t parent, FailureIsolationBase* customFdir, - size_t cmdQueueSize) + CookieIF* cookie, object_id_t parent, + FailureIsolationBase* customFdir, size_t cmdQueueSize) : DeviceHandlerBase(setObjectId, deviceCommunication, cookie, (customFdir == nullptr ? &childHandlerFdir : customFdir), cmdQueueSize), parentId(parent), - childHandlerFdir(setObjectId) { - this->setHkDestination(hkDestination); - this->setThermalStateRequestPoolIds(thermalStatePoolId, thermalRequestPoolId); -} + childHandlerFdir(setObjectId) {} ChildHandlerBase::~ChildHandlerBase() {} diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.h b/src/fsfw/devicehandlers/ChildHandlerBase.h index 19d48a24..8145c391 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.h +++ b/src/fsfw/devicehandlers/ChildHandlerBase.h @@ -7,8 +7,7 @@ class ChildHandlerBase : public DeviceHandlerBase { public: ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF* cookie, - object_id_t hkDestination, uint32_t thermalStatePoolId, - uint32_t thermalRequestPoolId, object_id_t parent = objects::NO_OBJECT, + object_id_t parent = objects::NO_OBJECT, FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20); virtual ~ChildHandlerBase(); diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 6a5db265..db9c147b 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -132,14 +132,6 @@ ReturnValue_t DeviceHandlerBase::initialize() { new DeviceHandlerFailureIsolation(this->getObjectId(), defaultFdirParentId); } - if (this->parent != objects::NO_OBJECT) { - HasModesIF* modeIF = ObjectManager::instance()->get(this->parent); - HasHealthIF* healthIF = ObjectManager::instance()->get(this->parent); - if (modeIF != nullptr and healthIF != nullptr) { - setParentQueue(modeIF->getCommandQueue()); - } - } - communicationInterface = ObjectManager::instance()->get(deviceCommunicationId); if (communicationInterface == nullptr) { @@ -1578,8 +1570,6 @@ MessageQueueId_t DeviceHandlerBase::getCommanderQueueId(DeviceCommandId_t replyI void DeviceHandlerBase::setCustomFdir(FailureIsolationBase* fdir) { this->fdirInstance = fdir; } -void DeviceHandlerBase::setParent(object_id_t parent) { this->parent = parent; } - void DeviceHandlerBase::setPowerSwitcher(PowerSwitchIF* switcher) { this->powerSwitcher = switcher; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 7c93e921..52ae473b 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -104,7 +104,6 @@ class DeviceHandlerBase : public DeviceHandlerIF, FailureIsolationBase *fdirInstance = nullptr, size_t cmdQueueSize = 20); void setCustomFdir(FailureIsolationBase *fdir); - void setParent(object_id_t parent); void setPowerSwitcher(PowerSwitchIF *switcher); void setHkDestination(object_id_t hkDestination); @@ -200,6 +199,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, virtual object_id_t getObjectId() const override; /** + * This is a helper method for classes which are parent nodes in the mode tree. + * It registers the passed queue as the destination for mode and health messages. * @param parentQueueId */ virtual void setParentQueue(MessageQueueId_t parentQueueId); diff --git a/src/fsfw/pus/Service5EventReporting.cpp b/src/fsfw/pus/Service5EventReporting.cpp index c1affa6f..b4b9b03d 100644 --- a/src/fsfw/pus/Service5EventReporting.cpp +++ b/src/fsfw/pus/Service5EventReporting.cpp @@ -15,8 +15,8 @@ Service5EventReporting::Service5EventReporting(PsbParams params, size_t maxNumbe maxNumberReportsPerCycle(maxNumberReportsPerCycle) { auto mqArgs = MqArgs(getObjectId(), static_cast(this)); psbParams.name = "PUS 5 Event Reporting"; - eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth, - MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); + eventQueue = QueueFactory::instance()->createMessageQueue( + messageQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs); } Service5EventReporting::~Service5EventReporting() { diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 2ae2cb77..cfad43e9 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -1,8 +1,9 @@ #include "fsfw/subsystem/SubsystemBase.h" +#include "fsfw/FSFW.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" -#include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw/serviceinterface.h" SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t initialMode, uint16_t commandQueueDepth) @@ -158,7 +159,7 @@ ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue, bo MessageQueueId_t SubsystemBase::getCommandQueue() const { return commandQueue->getId(); } ReturnValue_t SubsystemBase::initialize() { - MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE; + MessageQueueId_t also = MessageQueueIF::NO_QUEUE; ReturnValue_t result = SystemObject::initialize(); if (result != returnvalue::OK) { @@ -240,8 +241,14 @@ ReturnValue_t SubsystemBase::handleModeReply(CommandMessage* message) { } ReturnValue_t SubsystemBase::checkTable(HybridIterator tableIter) { - for (; tableIter.value != NULL; ++tableIter) { + for (; tableIter.value != nullptr; ++tableIter) { if (childrenMap.find(tableIter.value->getObject()) == childrenMap.end()) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + using namespace std; + sif::warning << "SubsystemBase::checkTable: Could not find Object " << setfill('0') << hex + << "0x" << setw(8) << tableIter.value->getObject() << " in object " << setw(8) + << "0x" << getObjectId() << dec << std::endl; +#endif return TABLE_CONTAINS_INVALID_OBJECT_ID; } } From 77f7fa2ef125635d87ad9fd3f0cf79e1cd74d071 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Sep 2022 16:48:23 +0200 Subject: [PATCH 22/63] typo --- src/fsfw/subsystem/SubsystemBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index cfad43e9..a7d75fea 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -159,7 +159,7 @@ ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue, bo MessageQueueId_t SubsystemBase::getCommandQueue() const { return commandQueue->getId(); } ReturnValue_t SubsystemBase::initialize() { - MessageQueueId_t also = MessageQueueIF::NO_QUEUE; + MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE; ReturnValue_t result = SystemObject::initialize(); if (result != returnvalue::OK) { From 3de0ae5a485b8538e178fef1c5bd33441b54ceb7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Sep 2022 17:20:18 +0200 Subject: [PATCH 23/63] DHB bug --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 3968142c..4f1c4367 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -517,16 +517,16 @@ ReturnValue_t DeviceHandlerBase::updatePeriodicReply(bool enable, DeviceCommandI if (enable) { info->active = true; if (info->countdown != nullptr) { - info->delayCycles = info->maxDelayCycles; - } else { info->countdown->resetTimer(); + } else { + info->delayCycles = info->maxDelayCycles; } } else { info->active = false; if (info->countdown != nullptr) { - info->delayCycles = 0; - } else { info->countdown->timeOut(); + } else { + info->delayCycles = 0; } } } From 7c5308429ca61b041800626bb03387ae12a5e585 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Sep 2022 19:21:24 +0200 Subject: [PATCH 24/63] this seems to work --- src/fsfw/controller/ControllerBase.cpp | 36 ++++++------------- src/fsfw/controller/ControllerBase.h | 14 ++++++-- .../controller/ExtendedControllerBase.cpp | 5 ++- src/fsfw/controller/ExtendedControllerBase.h | 2 +- src/fsfw/subsystem/CMakeLists.txt | 3 +- src/fsfw/subsystem/HasModeTreeChildrenIF.h | 13 +++++++ src/fsfw/subsystem/ModeTreeChildIF.h | 15 ++++++++ src/fsfw/subsystem/SubsystemBase.cpp | 17 +++++++++ src/fsfw/subsystem/SubsystemBase.h | 20 ++++++----- src/fsfw/subsystem/helper.cpp | 13 +++++++ src/fsfw/subsystem/helper.h | 14 ++++++++ .../subsystem/modes/ModeTreeConnectionIF.h | 13 +++++++ .../integration/controller/TestController.cpp | 4 +-- .../integration/controller/TestController.h | 2 +- 14 files changed, 127 insertions(+), 44 deletions(-) create mode 100644 src/fsfw/subsystem/HasModeTreeChildrenIF.h create mode 100644 src/fsfw/subsystem/ModeTreeChildIF.h create mode 100644 src/fsfw/subsystem/helper.cpp create mode 100644 src/fsfw/subsystem/helper.h create mode 100644 src/fsfw/subsystem/modes/ModeTreeConnectionIF.h diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index 80c08590..e071b3ee 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -4,11 +4,10 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/subsystem/SubsystemBase.h" +#include "fsfw/subsystem/helper.h" -ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId, - size_t commandQueueDepth) +ControllerBase::ControllerBase(object_id_t setObjectId, size_t commandQueueDepth) : SystemObject(setObjectId), - parentId(parentId), mode(MODE_OFF), submode(SUBMODE_NONE), modeHelper(this), @@ -25,28 +24,6 @@ ReturnValue_t ControllerBase::initialize() { if (result != returnvalue::OK) { return result; } - - MessageQueueId_t parentQueue = 0; - if (parentId != objects::NO_OBJECT) { - auto* parent = ObjectManager::instance()->get(parentId); - if (parent == nullptr) { - return returnvalue::FAILED; - } - parentQueue = parent->getCommandQueue(); - - parent->registerChild(getObjectId()); - } - - result = healthHelper.initialize(parentQueue); - if (result != returnvalue::OK) { - return result; - } - - result = modeHelper.initialize(parentQueue); - if (result != returnvalue::OK) { - return result; - } - return returnvalue::OK; } @@ -120,3 +97,12 @@ void ControllerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; } void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {} ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return returnvalue::OK; } + +const HasHealthIF* ControllerBase::getOptHealthIF() const { return this; } + +const HasModesIF& ControllerBase::getModeIF() const { return *this; } + +ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent, + const ModeTreeChildIF& child) { + return modetree::connectModeTreeParent(parent, child, healthHelper, modeHelper); +} diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 56c28585..8f9a1497 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -6,6 +6,9 @@ #include "fsfw/modes/HasModesIF.h" #include "fsfw/modes/ModeHelper.h" #include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/subsystem/HasModeTreeChildrenIF.h" +#include "fsfw/subsystem/ModeTreeChildIF.h" +#include "fsfw/subsystem/modes/ModeTreeConnectionIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/PeriodicTaskIF.h" @@ -18,13 +21,18 @@ class ControllerBase : public HasModesIF, public HasHealthIF, public ExecutableObjectIF, + public ModeTreeChildIF, + public ModeTreeConnectionIF, public SystemObject { public: static const Mode_t MODE_NORMAL = 2; - ControllerBase(object_id_t setObjectId, object_id_t parentId, size_t commandQueueDepth = 3); + ControllerBase(object_id_t setObjectId, size_t commandQueueDepth = 3); ~ControllerBase() override; + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent, + const ModeTreeChildIF &child) override; + /** SystemObject override */ ReturnValue_t initialize() override; @@ -38,6 +46,8 @@ class ControllerBase : public HasModesIF, ReturnValue_t performOperation(uint8_t opCode) override; void setTaskIF(PeriodicTaskIF *task) override; ReturnValue_t initializeAfterTaskCreation() override; + const HasHealthIF *getOptHealthIF() const override; + const HasModesIF &getModeIF() const override; protected: /** @@ -56,8 +66,6 @@ class ControllerBase : public HasModesIF, ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) override = 0; - const object_id_t parentId; - Mode_t mode; Submode_t submode; diff --git a/src/fsfw/controller/ExtendedControllerBase.cpp b/src/fsfw/controller/ExtendedControllerBase.cpp index 4d5c90c8..58db3563 100644 --- a/src/fsfw/controller/ExtendedControllerBase.cpp +++ b/src/fsfw/controller/ExtendedControllerBase.cpp @@ -1,8 +1,7 @@ #include "fsfw/controller/ExtendedControllerBase.h" -ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t parentId, - size_t commandQueueDepth) - : ControllerBase(objectId, parentId, commandQueueDepth), +ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, size_t commandQueueDepth) + : ControllerBase(objectId, commandQueueDepth), poolManager(this, commandQueue), actionHelper(this, commandQueue) {} diff --git a/src/fsfw/controller/ExtendedControllerBase.h b/src/fsfw/controller/ExtendedControllerBase.h index b5583a88..04a79528 100644 --- a/src/fsfw/controller/ExtendedControllerBase.h +++ b/src/fsfw/controller/ExtendedControllerBase.h @@ -17,7 +17,7 @@ class ExtendedControllerBase : public ControllerBase, public HasActionsIF, public HasLocalDataPoolIF { public: - ExtendedControllerBase(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth = 3); + ExtendedControllerBase(object_id_t objectId, size_t commandQueueDepth = 3); ~ExtendedControllerBase() override; /* SystemObjectIF overrides */ diff --git a/src/fsfw/subsystem/CMakeLists.txt b/src/fsfw/subsystem/CMakeLists.txt index 164c90f7..95dce8a5 100644 --- a/src/fsfw/subsystem/CMakeLists.txt +++ b/src/fsfw/subsystem/CMakeLists.txt @@ -1,3 +1,4 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE Subsystem.cpp SubsystemBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE Subsystem.cpp SubsystemBase.cpp + helper.cpp) add_subdirectory(modes) diff --git a/src/fsfw/subsystem/HasModeTreeChildrenIF.h b/src/fsfw/subsystem/HasModeTreeChildrenIF.h new file mode 100644 index 00000000..3458d008 --- /dev/null +++ b/src/fsfw/subsystem/HasModeTreeChildrenIF.h @@ -0,0 +1,13 @@ +#ifndef FSFW_SUBSYSTEM_HASMODETREECHILDRENIF_H_ +#define FSFW_SUBSYSTEM_HASMODETREECHILDRENIF_H_ + +#include "ModeTreeChildIF.h" + +class HasModeTreeChildrenIF { + public: + virtual ~HasModeTreeChildrenIF() = default; + virtual ReturnValue_t registerChild(const ModeTreeChildIF& child) = 0; + virtual MessageQueueId_t getCommandQueue() const = 0; +}; + +#endif // FSFW_SUBSYSTEM_HASMODETREECHILDRENIF_H_ diff --git a/src/fsfw/subsystem/ModeTreeChildIF.h b/src/fsfw/subsystem/ModeTreeChildIF.h new file mode 100644 index 00000000..6f8d8d86 --- /dev/null +++ b/src/fsfw/subsystem/ModeTreeChildIF.h @@ -0,0 +1,15 @@ +#ifndef FSFW_SUBSYSTEM_MODETREECHILDIF_H_ +#define FSFW_SUBSYSTEM_MODETREECHILDIF_H_ + +#include +#include + +class ModeTreeChildIF { + public: + virtual ~ModeTreeChildIF() = default; + virtual object_id_t getObjectId() const = 0; + virtual const HasHealthIF* getOptHealthIF() const = 0; + virtual const HasModesIF& getModeIF() const = 0; +}; + +#endif /* FSFW_SUBSYSTEM_MODETREECHILDIF_H_ */ diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index a7d75fea..9f79011e 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -334,3 +334,20 @@ ReturnValue_t SubsystemBase::setHealth(HealthState health) { HasHealthIF::HealthState SubsystemBase::getHealth() { return healthHelper.getHealth(); } void SubsystemBase::modeChanged() {} + +ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) { + ChildInfo info; + + const HasModesIF& modeChild = child.getModeIF(); + // intentional to force an initial command during system startup + info.commandQueue = modeChild.getCommandQueue(); + info.mode = HasModesIF::MODE_UNDEFINED; + info.submode = SUBMODE_NONE; + info.healthChanged = false; + + auto resultPair = childrenMap.emplace(child.getObjectId(), info); + if (not resultPair.second) { + return COULD_NOT_INSERT_CHILD; + } + return returnvalue::OK; +} diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index 69bdfd37..063bca85 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -3,14 +3,15 @@ #include -#include "../container/HybridIterator.h" -#include "../health/HasHealthIF.h" -#include "../health/HealthHelper.h" -#include "../ipc/MessageQueueIF.h" -#include "../modes/HasModesIF.h" -#include "../objectmanager/SystemObject.h" -#include "../returnvalues/returnvalue.h" -#include "../tasks/ExecutableObjectIF.h" +#include "fsfw/container/HybridIterator.h" +#include "fsfw/health/HasHealthIF.h" +#include "fsfw/health/HealthHelper.h" +#include "fsfw/ipc/MessageQueueIF.h" +#include "fsfw/modes/HasModesIF.h" +#include "fsfw/objectmanager/SystemObject.h" +#include "fsfw/returnvalues/returnvalue.h" +#include "fsfw/subsystem/HasModeTreeChildrenIF.h" +#include "fsfw/tasks/ExecutableObjectIF.h" #include "modes/HasModeSequenceIF.h" /** @@ -27,6 +28,7 @@ class SubsystemBase : public SystemObject, public HasModesIF, public HasHealthIF, + public HasModeTreeChildrenIF, public ExecutableObjectIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM_BASE; @@ -129,6 +131,8 @@ class SubsystemBase : public SystemObject, virtual void performChildOperation() = 0; + ReturnValue_t registerChild(const ModeTreeChildIF &child) override; + virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) override = 0; diff --git a/src/fsfw/subsystem/helper.cpp b/src/fsfw/subsystem/helper.cpp new file mode 100644 index 00000000..e65ef5a9 --- /dev/null +++ b/src/fsfw/subsystem/helper.cpp @@ -0,0 +1,13 @@ +#include "helper.h" + +ReturnValue_t modetree::connectModeTreeParent(HasModeTreeChildrenIF& parent, + const ModeTreeChildIF& child, + HealthHelper& healthHelper, ModeHelper& modeHelper) { + ReturnValue_t result = parent.registerChild(child); + if (result != returnvalue::OK) { + return result; + } + healthHelper.setParentQueue(parent.getCommandQueue()); + modeHelper.setParentQueue(parent.getCommandQueue()); + return returnvalue::OK; +} diff --git a/src/fsfw/subsystem/helper.h b/src/fsfw/subsystem/helper.h new file mode 100644 index 00000000..71a5563f --- /dev/null +++ b/src/fsfw/subsystem/helper.h @@ -0,0 +1,14 @@ +#ifndef FSFW_SUBSYSTEM_HELPER_H_ +#define FSFW_SUBSYSTEM_HELPER_H_ + +#include "HasModeTreeChildrenIF.h" +#include "fsfw/health/HealthHelper.h" + +namespace modetree { + +ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent, const ModeTreeChildIF& child, + HealthHelper& healthHelper, ModeHelper& modeHelper); + +} + +#endif /* FSFW_SRC_FSFW_SUBSYSTEM_HELPER_H_ */ diff --git a/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h b/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h new file mode 100644 index 00000000..8f25b2d4 --- /dev/null +++ b/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h @@ -0,0 +1,13 @@ +#ifndef FSFW_SUBSYSTEM_MODES_MODETREECONNECTIONIF_H_ +#define FSFW_SUBSYSTEM_MODES_MODETREECONNECTIONIF_H_ + +#include "fsfw/subsystem/HasModeTreeChildrenIF.h" + +class ModeTreeConnectionIF { + public: + virtual ~ModeTreeConnectionIF() = default; + virtual ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent, + const ModeTreeChildIF &child) = 0; +}; + +#endif /* FSFW_SRC_FSFW_SUBSYSTEM_MODES_MODETREECONNECTIONIF_H_ */ diff --git a/src/fsfw_tests/integration/controller/TestController.cpp b/src/fsfw_tests/integration/controller/TestController.cpp index 2ee4d5fe..c489f336 100644 --- a/src/fsfw_tests/integration/controller/TestController.cpp +++ b/src/fsfw_tests/integration/controller/TestController.cpp @@ -4,8 +4,8 @@ #include #include -TestController::TestController(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth) - : ExtendedControllerBase(objectId, parentId, commandQueueDepth) {} +TestController::TestController(object_id_t objectId, size_t commandQueueDepth) + : ExtendedControllerBase(objectId, commandQueueDepth) {} TestController::~TestController() {} diff --git a/src/fsfw_tests/integration/controller/TestController.h b/src/fsfw_tests/integration/controller/TestController.h index 9898371f..9577bedf 100644 --- a/src/fsfw_tests/integration/controller/TestController.h +++ b/src/fsfw_tests/integration/controller/TestController.h @@ -7,7 +7,7 @@ class TestController : public ExtendedControllerBase { public: - TestController(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth = 10); + TestController(object_id_t objectId, size_t commandQueueDepth = 10); virtual ~TestController(); protected: From f824004897e29bf90c2b02578625ba3d51786fdf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 29 Sep 2022 19:39:37 +0200 Subject: [PATCH 25/63] need to fix all of these TODOs --- src/fsfw/controller/ControllerBase.cpp | 5 +- src/fsfw/controller/ControllerBase.h | 3 +- src/fsfw/devicehandlers/AssemblyBase.cpp | 4 +- src/fsfw/devicehandlers/AssemblyBase.h | 2 +- src/fsfw/devicehandlers/ChildHandlerBase.cpp | 31 +++---- src/fsfw/subsystem/Subsystem.cpp | 4 +- src/fsfw/subsystem/Subsystem.h | 3 +- src/fsfw/subsystem/SubsystemBase.cpp | 84 ++++--------------- src/fsfw/subsystem/SubsystemBase.h | 25 +++--- .../subsystem/modes/ModeTreeConnectionIF.h | 3 +- .../integration/assemblies/TestAssembly.cpp | 17 ++-- 11 files changed, 67 insertions(+), 114 deletions(-) diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index e071b3ee..ee1dba46 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -102,7 +102,6 @@ const HasHealthIF* ControllerBase::getOptHealthIF() const { return this; } const HasModesIF& ControllerBase::getModeIF() const { return *this; } -ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent, - const ModeTreeChildIF& child) { - return modetree::connectModeTreeParent(parent, child, healthHelper, modeHelper); +ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) { + return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper); } diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 8f9a1497..6d9e2937 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -30,8 +30,7 @@ class ControllerBase : public HasModesIF, ControllerBase(object_id_t setObjectId, size_t commandQueueDepth = 3); ~ControllerBase() override; - ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent, - const ModeTreeChildIF &child) override; + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; /** SystemObject override */ ReturnValue_t initialize() override; diff --git a/src/fsfw/devicehandlers/AssemblyBase.cpp b/src/fsfw/devicehandlers/AssemblyBase.cpp index c943a4cf..14575e69 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.cpp +++ b/src/fsfw/devicehandlers/AssemblyBase.cpp @@ -1,7 +1,7 @@ #include "fsfw/devicehandlers/AssemblyBase.h" -AssemblyBase::AssemblyBase(object_id_t objectId, object_id_t parentId, uint16_t commandQueueDepth) - : SubsystemBase(objectId, parentId, MODE_OFF, commandQueueDepth), +AssemblyBase::AssemblyBase(object_id_t objectId, uint16_t commandQueueDepth) + : SubsystemBase(objectId, MODE_OFF, commandQueueDepth), internalState(STATE_NONE), recoveryState(RECOVERY_IDLE), recoveringDevice(childrenMap.end()), diff --git a/src/fsfw/devicehandlers/AssemblyBase.h b/src/fsfw/devicehandlers/AssemblyBase.h index fe1c4218..5e0d826f 100644 --- a/src/fsfw/devicehandlers/AssemblyBase.h +++ b/src/fsfw/devicehandlers/AssemblyBase.h @@ -41,7 +41,7 @@ class AssemblyBase : public SubsystemBase { static const ReturnValue_t NEED_TO_CHANGE_HEALTH = MAKE_RETURN_CODE(0x05); static const ReturnValue_t NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE = MAKE_RETURN_CODE(0xa1); - AssemblyBase(object_id_t objectId, object_id_t parentId, uint16_t commandQueueDepth = 8); + AssemblyBase(object_id_t objectId, uint16_t commandQueueDepth = 8); virtual ~AssemblyBase(); protected: diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.cpp b/src/fsfw/devicehandlers/ChildHandlerBase.cpp index 39a3a20f..50d7b765 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.cpp +++ b/src/fsfw/devicehandlers/ChildHandlerBase.cpp @@ -18,21 +18,22 @@ ReturnValue_t ChildHandlerBase::initialize() { return result; } - MessageQueueId_t parentQueue = 0; - - if (parentId != objects::NO_OBJECT) { - SubsystemBase* parent = ObjectManager::instance()->get(parentId); - if (parent == NULL) { - return returnvalue::FAILED; - } - parentQueue = parent->getCommandQueue(); - - parent->registerChild(getObjectId()); - } - - healthHelper.setParentQueue(parentQueue); - - modeHelper.setParentQueue(parentQueue); + // TODO: Fix this + // MessageQueueId_t parentQueue = 0; + // + // if (parentId != objects::NO_OBJECT) { + // SubsystemBase* parent = ObjectManager::instance()->get(parentId); + // if (parent == NULL) { + // return returnvalue::FAILED; + // } + // parentQueue = parent->getCommandQueue(); + // + // parent->registerChild(getObjectId()); + // } + // + // healthHelper.setParentQueue(parentQueue); + // + // modeHelper.setParentQueue(parentQueue); return returnvalue::OK; } diff --git a/src/fsfw/subsystem/Subsystem.cpp b/src/fsfw/subsystem/Subsystem.cpp index b2af5ac3..085c843a 100644 --- a/src/fsfw/subsystem/Subsystem.cpp +++ b/src/fsfw/subsystem/Subsystem.cpp @@ -9,9 +9,9 @@ #include "fsfw/serialize/SerialLinkedListAdapter.h" #include "fsfw/serialize/SerializeElement.h" -Subsystem::Subsystem(object_id_t setObjectId, object_id_t parent, uint32_t maxNumberOfSequences, +Subsystem::Subsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables) - : SubsystemBase(setObjectId, parent, 0), + : SubsystemBase(setObjectId, 0), isInTransition(false), childrenChangedHealth(false), currentTargetTable(), diff --git a/src/fsfw/subsystem/Subsystem.h b/src/fsfw/subsystem/Subsystem.h index f4e73117..20925821 100644 --- a/src/fsfw/subsystem/Subsystem.h +++ b/src/fsfw/subsystem/Subsystem.h @@ -66,8 +66,7 @@ class Subsystem : public SubsystemBase, public HasModeSequenceIF { * @param maxNumberOfSequences * @param maxNumberOfTables */ - Subsystem(object_id_t setObjectId, object_id_t parent, uint32_t maxNumberOfSequences, - uint32_t maxNumberOfTables); + Subsystem(object_id_t setObjectId, uint32_t maxNumberOfSequences, uint32_t maxNumberOfTables); virtual ~Subsystem(); ReturnValue_t addSequence(SequenceEntry sequence); diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 9f79011e..058bcca9 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -4,14 +4,14 @@ #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface.h" +#include "fsfw/subsystem/helper.h" -SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t initialMode, +SubsystemBase::SubsystemBase(object_id_t setObjectId, Mode_t initialMode, uint16_t commandQueueDepth) : SystemObject(setObjectId), mode(initialMode), healthHelper(this, setObjectId), - modeHelper(this), - parentId(parent) { + modeHelper(this) { auto mqArgs = MqArgs(setObjectId, static_cast(this)); commandQueue = QueueFactory::instance()->createMessageQueue( commandQueueDepth, CommandMessage::MAX_MESSAGE_SIZE, &mqArgs); @@ -19,36 +19,6 @@ SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t SubsystemBase::~SubsystemBase() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } -ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) { - ChildInfo info; - - HasModesIF* child = ObjectManager::instance()->get(objectId); - // This is a rather ugly hack to have the changedHealth info for all - // children available. - HasHealthIF* healthChild = ObjectManager::instance()->get(objectId); - if (child == nullptr) { - if (healthChild == nullptr) { - return CHILD_DOESNT_HAVE_MODES; - } else { - info.commandQueue = healthChild->getCommandQueue(); - info.mode = MODE_OFF; - } - } else { - // intentional to force an initial command during system startup - info.commandQueue = child->getCommandQueue(); - info.mode = HasModesIF::MODE_UNDEFINED; - } - - info.submode = SUBMODE_NONE; - info.healthChanged = false; - - auto resultPair = childrenMap.emplace(objectId, info); - if (not resultPair.second) { - return COULD_NOT_INSERT_CHILD; - } - return returnvalue::OK; -} - ReturnValue_t SubsystemBase::checkStateAgainstTable(HybridIterator tableIter, Submode_t targetSubmode) { std::map::iterator childIter; @@ -88,7 +58,8 @@ void SubsystemBase::executeTable(HybridIterator tableIter, Submod if ((iter = childrenMap.find(object)) == childrenMap.end()) { // illegal table entry, should only happen due to misconfigured mode table #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::debug << std::hex << getObjectId() << ": invalid mode table entry" << std::endl; + sif::debug << std::hex << SystemObject::getObjectId() << ": invalid mode table entry" + << std::endl; #endif continue; } @@ -158,38 +129,7 @@ ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue, bo MessageQueueId_t SubsystemBase::getCommandQueue() const { return commandQueue->getId(); } -ReturnValue_t SubsystemBase::initialize() { - MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE; - ReturnValue_t result = SystemObject::initialize(); - - if (result != returnvalue::OK) { - return result; - } - - if (parentId != objects::NO_OBJECT) { - SubsystemBase* parent = ObjectManager::instance()->get(parentId); - if (parent == nullptr) { - return returnvalue::FAILED; - } - parentQueue = parent->getCommandQueue(); - - parent->registerChild(getObjectId()); - } - - result = healthHelper.initialize(parentQueue); - - if (result != returnvalue::OK) { - return result; - } - - result = modeHelper.initialize(parentQueue); - - if (result != returnvalue::OK) { - return result; - } - - return returnvalue::OK; -} +ReturnValue_t SubsystemBase::initialize() { return SystemObject::initialize(); } ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) { childrenChangedMode = false; @@ -247,7 +187,7 @@ ReturnValue_t SubsystemBase::checkTable(HybridIterator tableIter) using namespace std; sif::warning << "SubsystemBase::checkTable: Could not find Object " << setfill('0') << hex << "0x" << setw(8) << tableIter.value->getObject() << " in object " << setw(8) - << "0x" << getObjectId() << dec << std::endl; + << "0x" << SystemObject::getObjectId() << dec << std::endl; #endif return TABLE_CONTAINS_INVALID_OBJECT_ID; } @@ -333,6 +273,12 @@ ReturnValue_t SubsystemBase::setHealth(HealthState health) { HasHealthIF::HealthState SubsystemBase::getHealth() { return healthHelper.getHealth(); } +ReturnValue_t SubsystemBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) { + return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper); +} + +object_id_t SubsystemBase::getObjectId() const { return SystemObject::getObjectId(); } + void SubsystemBase::modeChanged() {} ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) { @@ -351,3 +297,7 @@ ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) { } return returnvalue::OK; } + +const HasHealthIF* SubsystemBase::getOptHealthIF() const { return this; } + +const HasModesIF& SubsystemBase::getModeIF() const { return *this; } diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index 063bca85..84b89a12 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -1,6 +1,8 @@ #ifndef FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ #define FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ +#include + #include #include "fsfw/container/HybridIterator.h" @@ -29,6 +31,8 @@ class SubsystemBase : public SystemObject, public HasModesIF, public HasHealthIF, public HasModeTreeChildrenIF, + public ModeTreeConnectionIF, + public ModeTreeChildIF, public ExecutableObjectIF { public: static const uint8_t INTERFACE_ID = CLASS_ID::SUBSYSTEM_BASE; @@ -38,24 +42,25 @@ class SubsystemBase : public SystemObject, static const ReturnValue_t COULD_NOT_INSERT_CHILD = MAKE_RETURN_CODE(0x04); static const ReturnValue_t TABLE_CONTAINS_INVALID_OBJECT_ID = MAKE_RETURN_CODE(0x05); - SubsystemBase(object_id_t setObjectId, object_id_t parent, Mode_t initialMode = 0, - uint16_t commandQueueDepth = 8); + SubsystemBase(object_id_t setObjectId, Mode_t initialMode = 0, uint16_t commandQueueDepth = 8); virtual ~SubsystemBase(); virtual MessageQueueId_t getCommandQueue() const override; + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; + /** * Function to register the child objects. * Performs a checks if the child does implement HasHealthIF and/or HasModesIF * - * Also adds them to the internal childrenMap. + * Also adds them to the internal childrenMap. * * @param objectId * @return returnvalue::OK if successful - * CHILD_DOESNT_HAVE_MODES if Child is no HasHealthIF and no HasModesIF - * COULD_NOT_INSERT_CHILD If the Child could not be added to the ChildrenMap + * CHILD_DOESNT_HAVE_MODES if Child is no HasHealthIF and no HasModesIF + * COULD_NOT_INSERT_CHILD If the Child could not be added to the ChildrenMap */ - ReturnValue_t registerChild(object_id_t objectId); + ReturnValue_t registerChild(const ModeTreeChildIF &child) override; virtual ReturnValue_t initialize() override; @@ -90,8 +95,6 @@ class SubsystemBase : public SystemObject, ModeHelper modeHelper; - const object_id_t parentId; - typedef std::map ChildrenMap; ChildrenMap childrenMap; @@ -131,8 +134,6 @@ class SubsystemBase : public SystemObject, virtual void performChildOperation() = 0; - ReturnValue_t registerChild(const ModeTreeChildIF &child) override; - virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode) override = 0; @@ -140,6 +141,10 @@ class SubsystemBase : public SystemObject, virtual void getMode(Mode_t *mode, Submode_t *submode) override; + object_id_t getObjectId() const override; + const HasHealthIF *getOptHealthIF() const override; + const HasModesIF &getModeIF() const override; + virtual void setToExternalControl() override; virtual void announceMode(bool recursive) override; diff --git a/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h b/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h index 8f25b2d4..b86fc10f 100644 --- a/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h +++ b/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h @@ -6,8 +6,7 @@ class ModeTreeConnectionIF { public: virtual ~ModeTreeConnectionIF() = default; - virtual ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent, - const ModeTreeChildIF &child) = 0; + virtual ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) = 0; }; #endif /* FSFW_SRC_FSFW_SUBSYSTEM_MODES_MODETREECONNECTIONIF_H_ */ diff --git a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp index 668120c6..0d72257a 100644 --- a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp +++ b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp @@ -142,14 +142,15 @@ ReturnValue_t TestAssembly::initialize() { handler0->setParentQueue(this->getCommandQueue()); handler1->setParentQueue(this->getCommandQueue()); - result = registerChild(deviceHandler0Id); - if (result != returnvalue::OK) { - return result; - } - result = registerChild(deviceHandler1Id); - if (result != returnvalue::OK) { - return result; - } + // TODO: Fix this + // result = registerChild(deviceHandler0Id); + // if (result != returnvalue::OK) { + // return result; + // } + // result = registerChild(deviceHandler1Id); + // if (result != returnvalue::OK) { + // return result; + // } return result; } From 10dd8552446e409e40d830e25fb0eed927995764 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 30 Sep 2022 13:30:07 +0200 Subject: [PATCH 26/63] expose child itself in interface --- src/fsfw/controller/ControllerBase.cpp | 4 ++ src/fsfw/controller/ControllerBase.h | 3 +- src/fsfw/devicehandlers/ChildHandlerBase.cpp | 23 ++-------- src/fsfw/devicehandlers/ChildHandlerBase.h | 5 ++- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 19 ++++++++- src/fsfw/devicehandlers/DeviceHandlerBase.h | 16 +++++-- .../{modes => }/ModeTreeConnectionIF.h | 1 + src/fsfw/subsystem/SubsystemBase.cpp | 8 +++- src/fsfw/subsystem/SubsystemBase.h | 4 +- .../integration/assemblies/TestAssembly.cpp | 42 +++++++------------ .../integration/assemblies/TestAssembly.h | 10 ++--- 11 files changed, 73 insertions(+), 62 deletions(-) rename src/fsfw/subsystem/{modes => }/ModeTreeConnectionIF.h (88%) diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index ee1dba46..7c2456af 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -102,6 +102,10 @@ const HasHealthIF* ControllerBase::getOptHealthIF() const { return this; } const HasModesIF& ControllerBase::getModeIF() const { return *this; } +ModeTreeChildIF& ControllerBase::getModeTreeChildIF() { + return *this; +} + ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) { return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper); } diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 6d9e2937..0250cd89 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -8,7 +8,7 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/subsystem/HasModeTreeChildrenIF.h" #include "fsfw/subsystem/ModeTreeChildIF.h" -#include "fsfw/subsystem/modes/ModeTreeConnectionIF.h" +#include "fsfw/subsystem/ModeTreeConnectionIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/PeriodicTaskIF.h" @@ -31,6 +31,7 @@ class ControllerBase : public HasModesIF, ~ControllerBase() override; ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; + ModeTreeChildIF& getModeTreeChildIF() override; /** SystemObject override */ ReturnValue_t initialize() override; diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.cpp b/src/fsfw/devicehandlers/ChildHandlerBase.cpp index 50d7b765..37af39dc 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.cpp +++ b/src/fsfw/devicehandlers/ChildHandlerBase.cpp @@ -3,11 +3,11 @@ #include "fsfw/subsystem/SubsystemBase.h" ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, - CookieIF* cookie, object_id_t parent, + CookieIF* cookie, HasModeTreeChildrenIF& parent, FailureIsolationBase* customFdir, size_t cmdQueueSize) : DeviceHandlerBase(setObjectId, deviceCommunication, cookie, (customFdir == nullptr ? &childHandlerFdir : customFdir), cmdQueueSize), - parentId(parent), + parent(parent), childHandlerFdir(setObjectId) {} ChildHandlerBase::~ChildHandlerBase() {} @@ -18,22 +18,5 @@ ReturnValue_t ChildHandlerBase::initialize() { return result; } - // TODO: Fix this - // MessageQueueId_t parentQueue = 0; - // - // if (parentId != objects::NO_OBJECT) { - // SubsystemBase* parent = ObjectManager::instance()->get(parentId); - // if (parent == NULL) { - // return returnvalue::FAILED; - // } - // parentQueue = parent->getCommandQueue(); - // - // parent->registerChild(getObjectId()); - // } - // - // healthHelper.setParentQueue(parentQueue); - // - // modeHelper.setParentQueue(parentQueue); - - return returnvalue::OK; + return DeviceHandlerBase::connectModeTreeParent(parent); } diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.h b/src/fsfw/devicehandlers/ChildHandlerBase.h index 8145c391..b9f991d6 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.h +++ b/src/fsfw/devicehandlers/ChildHandlerBase.h @@ -1,13 +1,14 @@ #ifndef FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_ #define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_ +#include #include "ChildHandlerFDIR.h" #include "DeviceHandlerBase.h" class ChildHandlerBase : public DeviceHandlerBase { public: ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF* cookie, - object_id_t parent = objects::NO_OBJECT, + HasModeTreeChildrenIF& parent, FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20); virtual ~ChildHandlerBase(); @@ -15,7 +16,7 @@ class ChildHandlerBase : public DeviceHandlerBase { virtual ReturnValue_t initialize(); protected: - const uint32_t parentId; + HasModeTreeChildrenIF& parent; ChildHandlerFDIR childHandlerFdir; }; diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 851fb6ec..cdfec03b 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1,5 +1,6 @@ -#include "fsfw/devicehandlers/DeviceHandlerBase.h" +#include "DeviceHandlerBase.h" +#include "fsfw/subsystem/helper.h" #include "fsfw/datapoollocal/LocalPoolVariable.h" #include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h" #include "fsfw/devicehandlers/DeviceTmReportingWrapper.h" @@ -1591,3 +1592,19 @@ void DeviceHandlerBase::disableCommandsAndReplies() { } } } + +ReturnValue_t DeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenIF &parent) { + return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper); +} + +const HasHealthIF* DeviceHandlerBase::getOptHealthIF() const { + return this; +} + +const HasModesIF& DeviceHandlerBase::getModeIF() const { + return *this; +} + +ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() { + return *this; +} diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 52ae473b..f9c776e0 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -11,6 +11,7 @@ #include "fsfw/action/HasActionsIF.h" #include "fsfw/datapool/PoolVariableIF.h" #include "fsfw/datapoollocal/HasLocalDataPoolIF.h" +#include "fsfw/subsystem/ModeTreeConnectionIF.h" #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/health/HealthHelper.h" #include "fsfw/ipc/MessageQueueIF.h" @@ -84,6 +85,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, public HasModesIF, public HasHealthIF, public HasActionsIF, + public ModeTreeChildIF, + public ModeTreeConnectionIF, public ReceivesParameterMessagesIF, public HasLocalDataPoolIF { friend void(Factory::setStaticFrameworkObjectIds)(); @@ -120,6 +123,10 @@ class DeviceHandlerBase : public DeviceHandlerIF, lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID, lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID, uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID); + + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; + ModeTreeChildIF& getModeTreeChildIF() override; + /** * @brief Helper function to ease device handler development. * This will instruct the transition to MODE_ON immediately @@ -165,7 +172,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * @param counter Specifies which Action to perform * @return returnvalue::OK for successful execution */ - virtual ReturnValue_t performOperation(uint8_t counter) override; + ReturnValue_t performOperation(uint8_t counter) override; /** * @brief Initializes the device handler @@ -175,14 +182,14 @@ class DeviceHandlerBase : public DeviceHandlerIF, * Calls fillCommandAndReplyMap(). * @return */ - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; /** * @brief Intialization steps performed after all tasks have been created. * This function will be called by the executing task. * @return */ - virtual ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t initializeAfterTaskCreation() override; /** Destructor. */ virtual ~DeviceHandlerBase(); @@ -960,6 +967,9 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ LocalDataPoolManager *getHkManagerHandle() override; + const HasHealthIF* getOptHealthIF() const override; + const HasModesIF& getModeIF() const override; + /** * Returns the delay cycle count of a reply. * A count != 0 indicates that the command is already executed. diff --git a/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h b/src/fsfw/subsystem/ModeTreeConnectionIF.h similarity index 88% rename from src/fsfw/subsystem/modes/ModeTreeConnectionIF.h rename to src/fsfw/subsystem/ModeTreeConnectionIF.h index b86fc10f..78e22435 100644 --- a/src/fsfw/subsystem/modes/ModeTreeConnectionIF.h +++ b/src/fsfw/subsystem/ModeTreeConnectionIF.h @@ -7,6 +7,7 @@ class ModeTreeConnectionIF { public: virtual ~ModeTreeConnectionIF() = default; virtual ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) = 0; + virtual ModeTreeChildIF& getModeTreeChildIF() = 0; }; #endif /* FSFW_SRC_FSFW_SUBSYSTEM_MODES_MODETREECONNECTIONIF_H_ */ diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index 058bcca9..b303e323 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -300,4 +300,10 @@ ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) { const HasHealthIF* SubsystemBase::getOptHealthIF() const { return this; } -const HasModesIF& SubsystemBase::getModeIF() const { return *this; } +const HasModesIF& SubsystemBase::getModeIF() const { + return *this; +} + +ModeTreeChildIF& SubsystemBase::getModeTreeChildIF() { + return *this; +} diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index 84b89a12..d3ee34f9 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -1,13 +1,12 @@ #ifndef FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ #define FSFW_SUBSYSTEM_SUBSYSTEMBASE_H_ -#include - #include #include "fsfw/container/HybridIterator.h" #include "fsfw/health/HasHealthIF.h" #include "fsfw/health/HealthHelper.h" +#include "fsfw/subsystem/ModeTreeConnectionIF.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/modes/HasModesIF.h" #include "fsfw/objectmanager/SystemObject.h" @@ -48,6 +47,7 @@ class SubsystemBase : public SystemObject, virtual MessageQueueId_t getCommandQueue() const override; ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; + ModeTreeChildIF& getModeTreeChildIF() override; /** * Function to register the child objects. diff --git a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp index 0d72257a..793e591f 100644 --- a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp +++ b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp @@ -2,19 +2,19 @@ #include -TestAssembly::TestAssembly(object_id_t objectId, object_id_t parentId, object_id_t testDevice0, - object_id_t testDevice1) +TestAssembly::TestAssembly(object_id_t objectId, object_id_t parentId, ModeTreeChildIF& testDevice0, + ModeTreeChildIF& testDevice1) : AssemblyBase(objectId, parentId), - deviceHandler0Id(testDevice0), - deviceHandler1Id(testDevice1) { + deviceHandler0(testDevice0), + deviceHandler1(testDevice1) { ModeListEntry newModeListEntry; - newModeListEntry.setObject(testDevice0); + newModeListEntry.setObject(testDevice0.getObjectId()); newModeListEntry.setMode(MODE_OFF); newModeListEntry.setSubmode(SUBMODE_NONE); commandTable.insert(newModeListEntry); - newModeListEntry.setObject(testDevice1); + newModeListEntry.setObject(testDevice1.getObjectId()); newModeListEntry.setMode(MODE_OFF); newModeListEntry.setSubmode(SUBMODE_NONE); @@ -43,8 +43,8 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { commandTable[1].setMode(MODE_OFF); commandTable[1].setSubmode(SUBMODE_NONE); // We try to prefer 0 here but we try to switch to 1 even if it might fail - if (isDeviceAvailable(deviceHandler0Id)) { - if (childrenMap[deviceHandler0Id].mode == MODE_ON) { + if (isDeviceAvailable(deviceHandler0.getObjectId())) { + if (childrenMap[deviceHandler0.getObjectId()].mode == MODE_ON) { commandTable[0].setMode(mode); commandTable[0].setSubmode(SUBMODE_NONE); } else { @@ -53,7 +53,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { result = NEED_SECOND_STEP; } } else { - if (childrenMap[deviceHandler1Id].mode == MODE_ON) { + if (childrenMap[deviceHandler1.getObjectId()].mode == MODE_ON) { commandTable[1].setMode(mode); commandTable[1].setSubmode(SUBMODE_NONE); } else { @@ -64,7 +64,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { } } else { // Dual Mode Normal - if (childrenMap[deviceHandler0Id].mode == MODE_ON) { + if (childrenMap[deviceHandler0.getObjectId()].mode == MODE_ON) { commandTable[0].setMode(mode); commandTable[0].setSubmode(SUBMODE_NONE); } else { @@ -72,7 +72,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { commandTable[0].setSubmode(SUBMODE_NONE); result = NEED_SECOND_STEP; } - if (childrenMap[deviceHandler1Id].mode == MODE_ON) { + if (childrenMap[deviceHandler1.getObjectId()].mode == MODE_ON) { commandTable[1].setMode(mode); commandTable[1].setSubmode(SUBMODE_NONE); } else { @@ -89,7 +89,7 @@ ReturnValue_t TestAssembly::commandChildren(Mode_t mode, Submode_t submode) { commandTable[1].setMode(MODE_OFF); commandTable[1].setSubmode(SUBMODE_NONE); // We try to prefer 0 here but we try to switch to 1 even if it might fail - if (isDeviceAvailable(deviceHandler0Id)) { + if (isDeviceAvailable(deviceHandler0.getObjectId())) { commandTable[0].setMode(MODE_ON); commandTable[0].setSubmode(SUBMODE_NONE); } else { @@ -133,24 +133,14 @@ ReturnValue_t TestAssembly::initialize() { if (result != returnvalue::OK) { return result; } - handler0 = ObjectManager::instance()->get(deviceHandler0Id); - handler1 = ObjectManager::instance()->get(deviceHandler1Id); + auto* handler0 = ObjectManager::instance()->get(deviceHandler0.getObjectId()); + auto* handler1 = ObjectManager::instance()->get(deviceHandler1.getObjectId()); if ((handler0 == nullptr) or (handler1 == nullptr)) { return returnvalue::FAILED; } - handler0->setParentQueue(this->getCommandQueue()); - handler1->setParentQueue(this->getCommandQueue()); - - // TODO: Fix this - // result = registerChild(deviceHandler0Id); - // if (result != returnvalue::OK) { - // return result; - // } - // result = registerChild(deviceHandler1Id); - // if (result != returnvalue::OK) { - // return result; - // } + handler0->connectModeTreeParent(*this); + handler1->connectModeTreeParent(*this); return result; } diff --git a/src/fsfw_tests/integration/assemblies/TestAssembly.h b/src/fsfw_tests/integration/assemblies/TestAssembly.h index 91ffbf60..86b4fb07 100644 --- a/src/fsfw_tests/integration/assemblies/TestAssembly.h +++ b/src/fsfw_tests/integration/assemblies/TestAssembly.h @@ -7,8 +7,8 @@ class TestAssembly : public AssemblyBase { public: - TestAssembly(object_id_t objectId, object_id_t parentId, object_id_t testDevice0, - object_id_t testDevice1); + TestAssembly(object_id_t objectId, object_id_t parentId, ModeTreeChildIF& testDevice0, + ModeTreeChildIF& testDevice1); virtual ~TestAssembly(); ReturnValue_t initialize() override; @@ -41,10 +41,8 @@ class TestAssembly : public AssemblyBase { private: FixedArrayList commandTable; - object_id_t deviceHandler0Id = 0; - object_id_t deviceHandler1Id = 0; - TestDevice* handler0 = nullptr; - TestDevice* handler1 = nullptr; + ModeTreeChildIF& deviceHandler0; + ModeTreeChildIF& deviceHandler1; bool isDeviceAvailable(object_id_t object); }; From acab5f6bceef581fae64d1c16af19482ec72abcb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 30 Sep 2022 14:14:45 +0200 Subject: [PATCH 27/63] added missing health and mode helper init --- src/fsfw/controller/ControllerBase.cpp | 10 +++++++--- src/fsfw/subsystem/SubsystemBase.cpp | 14 ++++++++++++-- src/fsfw/subsystem/SubsystemBase.h | 8 ++++---- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index 7c2456af..a7ac9092 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -20,11 +20,15 @@ ControllerBase::ControllerBase(object_id_t setObjectId, size_t commandQueueDepth ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue(commandQueue); } ReturnValue_t ControllerBase::initialize() { - ReturnValue_t result = SystemObject::initialize(); - if (result != returnvalue::OK) { + ReturnValue_t result = modeHelper.initialize(); + if(result != returnvalue::OK) { return result; } - return returnvalue::OK; + result = healthHelper.initialize(); + if(result != returnvalue::OK) { + return result; + } + return SystemObject::initialize(); } MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue->getId(); } diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index b303e323..d5400222 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -129,7 +129,17 @@ ReturnValue_t SubsystemBase::updateChildChangedHealth(MessageQueueId_t queue, bo MessageQueueId_t SubsystemBase::getCommandQueue() const { return commandQueue->getId(); } -ReturnValue_t SubsystemBase::initialize() { return SystemObject::initialize(); } +ReturnValue_t SubsystemBase::initialize() { + ReturnValue_t result = modeHelper.initialize(); + if(result != returnvalue::OK) { + return result; + } + result = healthHelper.initialize(); + if(result != returnvalue::OK) { + return result; + } + return SystemObject::initialize(); +} ReturnValue_t SubsystemBase::performOperation(uint8_t opCode) { childrenChangedMode = false; @@ -187,7 +197,7 @@ ReturnValue_t SubsystemBase::checkTable(HybridIterator tableIter) using namespace std; sif::warning << "SubsystemBase::checkTable: Could not find Object " << setfill('0') << hex << "0x" << setw(8) << tableIter.value->getObject() << " in object " << setw(8) - << "0x" << SystemObject::getObjectId() << dec << std::endl; + << setw(0) << "0x" << setw(8) << SystemObject::getObjectId() << dec << std::endl; #endif return TABLE_CONTAINS_INVALID_OBJECT_ID; } diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index d3ee34f9..32c8af0c 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -62,13 +62,13 @@ class SubsystemBase : public SystemObject, */ ReturnValue_t registerChild(const ModeTreeChildIF &child) override; - virtual ReturnValue_t initialize() override; + ReturnValue_t initialize() override; - virtual ReturnValue_t performOperation(uint8_t opCode) override; + ReturnValue_t performOperation(uint8_t opCode) override; - virtual ReturnValue_t setHealth(HealthState health) override; + ReturnValue_t setHealth(HealthState health) override; - virtual HasHealthIF::HealthState getHealth() override; + HasHealthIF::HealthState getHealth() override; protected: struct ChildInfo { From 7877776e248aad4c2a6fcbc5f51f8f791616e6a0 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 30 Sep 2022 14:34:25 +0200 Subject: [PATCH 28/63] one last check --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 0f457213..ec3148bd 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { From 8e362a000c56618335145d159ab97883c53b33a0 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 30 Sep 2022 14:36:25 +0200 Subject: [PATCH 29/63] Revert "one last check" This reverts commit 7877776e248aad4c2a6fcbc5f51f8f791616e6a0. --- automation/Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index ec3148bd..0f457213 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'development' + branch 'mohr/documentation_ci' } steps { dir(DOCDDIR) { From 7b5ae6a445d9de7d8f4af57370000d091faee407 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Fri, 30 Sep 2022 14:40:59 +0200 Subject: [PATCH 30/63] done? --- automation/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index 0f457213..27136606 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -45,7 +45,7 @@ pipeline { } stage('Documentation') { when { - branch 'mohr/documentation_ci' + branch 'development' } steps { dir(DOCDDIR) { @@ -64,7 +64,7 @@ pipeline { } stage('Master Documentation') { when { - branch 'mohr/documentation_ci' + branch 'master' } steps { dir(DOCDDIR) { From 1eceef4645b5a052dbdcd964e7840e7121c57909 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 30 Sep 2022 15:05:32 +0200 Subject: [PATCH 31/63] move retvals --- src/fsfw/container/FixedMap.h | 22 ++++++++++--------- src/fsfw/controller/ControllerBase.cpp | 8 +++---- src/fsfw/controller/ControllerBase.h | 2 +- src/fsfw/devicehandlers/ChildHandlerBase.h | 5 +++-- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 16 +++++--------- src/fsfw/devicehandlers/DeviceHandlerBase.h | 8 +++---- src/fsfw/subsystem/ModeTreeConnectionIF.h | 2 +- src/fsfw/subsystem/Subsystem.cpp | 7 ++++++ src/fsfw/subsystem/SubsystemBase.cpp | 12 ++++------ src/fsfw/subsystem/SubsystemBase.h | 4 ++-- .../integration/assemblies/TestAssembly.cpp | 6 ++--- 11 files changed, 44 insertions(+), 48 deletions(-) diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h index def219d1..6ed6278d 100644 --- a/src/fsfw/container/FixedMap.h +++ b/src/fsfw/container/FixedMap.h @@ -7,6 +7,13 @@ #include "../returnvalues/returnvalue.h" #include "ArrayList.h" +namespace mapdefs { +static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP; +static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); +static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02); +static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03); +} // namespace mapdefs + /** * @brief Map implementation for maps with a pre-defined size. * @details @@ -24,11 +31,6 @@ class FixedMap : public SerializeIF { "derived class from SerializeIF to be serialize-able"); public: - static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP; - static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); - static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02); - static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03); - private: static const key_t EMPTY_SLOT = -1; ArrayList, uint32_t> theMap; @@ -76,10 +78,10 @@ class FixedMap : public SerializeIF { ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr) { if (exists(key) == returnvalue::OK) { - return KEY_ALREADY_EXISTS; + return mapdefs::KEY_ALREADY_EXISTS; } if (_size == theMap.maxSize()) { - return MAP_FULL; + return mapdefs::MAP_FULL; } theMap[_size].first = key; theMap[_size].second = value; @@ -93,7 +95,7 @@ class FixedMap : public SerializeIF { ReturnValue_t insert(std::pair pair) { return insert(pair.first, pair.second); } ReturnValue_t exists(key_t key) const { - ReturnValue_t result = KEY_DOES_NOT_EXIST; + ReturnValue_t result = mapdefs::KEY_DOES_NOT_EXIST; if (findIndex(key) < _size) { result = returnvalue::OK; } @@ -103,7 +105,7 @@ class FixedMap : public SerializeIF { ReturnValue_t erase(Iterator* iter) { uint32_t i; if ((i = findIndex((*iter).value->first)) >= _size) { - return KEY_DOES_NOT_EXIST; + return mapdefs::KEY_DOES_NOT_EXIST; } theMap[i] = theMap[_size - 1]; --_size; @@ -114,7 +116,7 @@ class FixedMap : public SerializeIF { ReturnValue_t erase(key_t key) { uint32_t i; if ((i = findIndex(key)) >= _size) { - return KEY_DOES_NOT_EXIST; + return mapdefs::KEY_DOES_NOT_EXIST; } theMap[i] = theMap[_size - 1]; --_size; diff --git a/src/fsfw/controller/ControllerBase.cpp b/src/fsfw/controller/ControllerBase.cpp index a7ac9092..98907210 100644 --- a/src/fsfw/controller/ControllerBase.cpp +++ b/src/fsfw/controller/ControllerBase.cpp @@ -21,11 +21,11 @@ ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue ReturnValue_t ControllerBase::initialize() { ReturnValue_t result = modeHelper.initialize(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } return SystemObject::initialize(); @@ -106,9 +106,7 @@ const HasHealthIF* ControllerBase::getOptHealthIF() const { return this; } const HasModesIF& ControllerBase::getModeIF() const { return *this; } -ModeTreeChildIF& ControllerBase::getModeTreeChildIF() { - return *this; -} +ModeTreeChildIF& ControllerBase::getModeTreeChildIF() { return *this; } ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) { return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper); diff --git a/src/fsfw/controller/ControllerBase.h b/src/fsfw/controller/ControllerBase.h index 0250cd89..da140e49 100644 --- a/src/fsfw/controller/ControllerBase.h +++ b/src/fsfw/controller/ControllerBase.h @@ -31,7 +31,7 @@ class ControllerBase : public HasModesIF, ~ControllerBase() override; ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; - ModeTreeChildIF& getModeTreeChildIF() override; + ModeTreeChildIF &getModeTreeChildIF() override; /** SystemObject override */ ReturnValue_t initialize() override; diff --git a/src/fsfw/devicehandlers/ChildHandlerBase.h b/src/fsfw/devicehandlers/ChildHandlerBase.h index b9f991d6..c98baf3d 100644 --- a/src/fsfw/devicehandlers/ChildHandlerBase.h +++ b/src/fsfw/devicehandlers/ChildHandlerBase.h @@ -2,14 +2,15 @@ #define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_ #include + #include "ChildHandlerFDIR.h" #include "DeviceHandlerBase.h" class ChildHandlerBase : public DeviceHandlerBase { public: ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF* cookie, - HasModeTreeChildrenIF& parent, - FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20); + HasModeTreeChildrenIF& parent, FailureIsolationBase* customFdir = nullptr, + size_t cmdQueueSize = 20); virtual ~ChildHandlerBase(); diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index cdfec03b..61329366 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1,6 +1,5 @@ #include "DeviceHandlerBase.h" -#include "fsfw/subsystem/helper.h" #include "fsfw/datapoollocal/LocalPoolVariable.h" #include "fsfw/devicehandlers/AcceptsDeviceResponsesIF.h" #include "fsfw/devicehandlers/DeviceTmReportingWrapper.h" @@ -13,6 +12,7 @@ #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/subsystem/SubsystemBase.h" +#include "fsfw/subsystem/helper.h" #include "fsfw/thermal/ThermalComponentIF.h" object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; @@ -1593,18 +1593,12 @@ void DeviceHandlerBase::disableCommandsAndReplies() { } } -ReturnValue_t DeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenIF &parent) { +ReturnValue_t DeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) { return modetree::connectModeTreeParent(parent, *this, healthHelper, modeHelper); } -const HasHealthIF* DeviceHandlerBase::getOptHealthIF() const { - return this; -} +const HasHealthIF* DeviceHandlerBase::getOptHealthIF() const { return this; } -const HasModesIF& DeviceHandlerBase::getModeIF() const { - return *this; -} +const HasModesIF& DeviceHandlerBase::getModeIF() const { return *this; } -ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() { - return *this; -} +ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() { return *this; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index f9c776e0..d7a896d5 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -11,7 +11,6 @@ #include "fsfw/action/HasActionsIF.h" #include "fsfw/datapool/PoolVariableIF.h" #include "fsfw/datapoollocal/HasLocalDataPoolIF.h" -#include "fsfw/subsystem/ModeTreeConnectionIF.h" #include "fsfw/datapoollocal/LocalDataPoolManager.h" #include "fsfw/health/HealthHelper.h" #include "fsfw/ipc/MessageQueueIF.h" @@ -22,6 +21,7 @@ #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" +#include "fsfw/subsystem/ModeTreeConnectionIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/PeriodicTaskIF.h" #include "fsfw/util/dataWrapper.h" @@ -125,7 +125,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID); ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; - ModeTreeChildIF& getModeTreeChildIF() override; + ModeTreeChildIF &getModeTreeChildIF() override; /** * @brief Helper function to ease device handler development. @@ -967,8 +967,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ LocalDataPoolManager *getHkManagerHandle() override; - const HasHealthIF* getOptHealthIF() const override; - const HasModesIF& getModeIF() const override; + const HasHealthIF *getOptHealthIF() const override; + const HasModesIF &getModeIF() const override; /** * Returns the delay cycle count of a reply. diff --git a/src/fsfw/subsystem/ModeTreeConnectionIF.h b/src/fsfw/subsystem/ModeTreeConnectionIF.h index 78e22435..4fe54ada 100644 --- a/src/fsfw/subsystem/ModeTreeConnectionIF.h +++ b/src/fsfw/subsystem/ModeTreeConnectionIF.h @@ -6,7 +6,7 @@ class ModeTreeConnectionIF { public: virtual ~ModeTreeConnectionIF() = default; - virtual ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) = 0; + virtual ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF& parent) = 0; virtual ModeTreeChildIF& getModeTreeChildIF() = 0; }; diff --git a/src/fsfw/subsystem/Subsystem.cpp b/src/fsfw/subsystem/Subsystem.cpp index 085c843a..ad3afb2b 100644 --- a/src/fsfw/subsystem/Subsystem.cpp +++ b/src/fsfw/subsystem/Subsystem.cpp @@ -36,6 +36,13 @@ ReturnValue_t Subsystem::checkSequence(HybridIterator iter, for (; iter.value != nullptr; ++iter) { if (!existsModeTable(iter->getTableId())) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + using namespace std; + sif::warning << "Subsystem::checkSequence: " + << "Object " << setfill('0') << hex << "0x" << setw(8) << getObjectId() + << setw(0) << ": Mode table for mode ID " + << "0x" << setw(8) << iter->getTableId() << " does not exist" << dec << endl; +#endif return TABLE_DOES_NOT_EXIST; } else { ReturnValue_t result = checkTable(getTable(iter->getTableId())); diff --git a/src/fsfw/subsystem/SubsystemBase.cpp b/src/fsfw/subsystem/SubsystemBase.cpp index d5400222..d14e3539 100644 --- a/src/fsfw/subsystem/SubsystemBase.cpp +++ b/src/fsfw/subsystem/SubsystemBase.cpp @@ -131,11 +131,11 @@ MessageQueueId_t SubsystemBase::getCommandQueue() const { return commandQueue->g ReturnValue_t SubsystemBase::initialize() { ReturnValue_t result = modeHelper.initialize(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } result = healthHelper.initialize(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } return SystemObject::initialize(); @@ -310,10 +310,6 @@ ReturnValue_t SubsystemBase::registerChild(const ModeTreeChildIF& child) { const HasHealthIF* SubsystemBase::getOptHealthIF() const { return this; } -const HasModesIF& SubsystemBase::getModeIF() const { - return *this; -} +const HasModesIF& SubsystemBase::getModeIF() const { return *this; } -ModeTreeChildIF& SubsystemBase::getModeTreeChildIF() { - return *this; -} +ModeTreeChildIF& SubsystemBase::getModeTreeChildIF() { return *this; } diff --git a/src/fsfw/subsystem/SubsystemBase.h b/src/fsfw/subsystem/SubsystemBase.h index 32c8af0c..0fbf9f4a 100644 --- a/src/fsfw/subsystem/SubsystemBase.h +++ b/src/fsfw/subsystem/SubsystemBase.h @@ -6,12 +6,12 @@ #include "fsfw/container/HybridIterator.h" #include "fsfw/health/HasHealthIF.h" #include "fsfw/health/HealthHelper.h" -#include "fsfw/subsystem/ModeTreeConnectionIF.h" #include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/modes/HasModesIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/returnvalues/returnvalue.h" #include "fsfw/subsystem/HasModeTreeChildrenIF.h" +#include "fsfw/subsystem/ModeTreeConnectionIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "modes/HasModeSequenceIF.h" @@ -47,7 +47,7 @@ class SubsystemBase : public SystemObject, virtual MessageQueueId_t getCommandQueue() const override; ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; - ModeTreeChildIF& getModeTreeChildIF() override; + ModeTreeChildIF &getModeTreeChildIF() override; /** * Function to register the child objects. diff --git a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp index 793e591f..761d0d3c 100644 --- a/src/fsfw_tests/integration/assemblies/TestAssembly.cpp +++ b/src/fsfw_tests/integration/assemblies/TestAssembly.cpp @@ -3,10 +3,8 @@ #include TestAssembly::TestAssembly(object_id_t objectId, object_id_t parentId, ModeTreeChildIF& testDevice0, - ModeTreeChildIF& testDevice1) - : AssemblyBase(objectId, parentId), - deviceHandler0(testDevice0), - deviceHandler1(testDevice1) { + ModeTreeChildIF& testDevice1) + : AssemblyBase(objectId, parentId), deviceHandler0(testDevice0), deviceHandler1(testDevice1) { ModeListEntry newModeListEntry; newModeListEntry.setObject(testDevice0.getObjectId()); newModeListEntry.setMode(MODE_OFF); From 6f562e5f3ed6ff971cad6e95f3f689f0a9c6e953 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Oct 2022 10:25:58 +0200 Subject: [PATCH 32/63] missing retval conv --- src/fsfw_tests/integration/devices/TestDeviceHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index 01f0494b..fdf02a70 100644 --- a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -646,7 +646,7 @@ ReturnValue_t TestDevice::initializeLocalDataPool(localpool::DataPool& localData /* Subscribe for periodic HK packets but do not enable reporting for now. Non-diangostic with a period of one second */ poolManager.subscribeForRegularPeriodicPacket({sid, false, 1.0}); - return HasReturnvaluesIF::RETURN_OK; + return returnvalue::OK; } ReturnValue_t TestDevice::getParameter(uint8_t domainId, uint8_t uniqueId, From 448d20f3bd3d8844c0a6ee2a0396ba6765b49302 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Oct 2022 10:55:46 +0200 Subject: [PATCH 33/63] small fix for helper --- scripts/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helper.py b/scripts/helper.py index 0ced7186..1b03161b 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -199,7 +199,7 @@ def check_for_cmake_build_dir(build_dir_list: list) -> list: def perform_lcov_operation(directory: str, chdir: bool): if chdir: os.chdir(directory) - cmd_runner("cmake --build . -- fsfw-tests_coverage -j") + cmd_runner("cmake --build -j . -- fsfw-tests_coverage") def determine_build_dir(build_dir_list: List[str]): From c283e0c98889530ac5779d11d8bec816edd5ed80 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 4 Oct 2022 11:02:08 +0200 Subject: [PATCH 34/63] okay this is correct --- scripts/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/helper.py b/scripts/helper.py index 1b03161b..9e7a1607 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -199,7 +199,7 @@ def check_for_cmake_build_dir(build_dir_list: list) -> list: def perform_lcov_operation(directory: str, chdir: bool): if chdir: os.chdir(directory) - cmd_runner("cmake --build -j . -- fsfw-tests_coverage") + cmd_runner("cmake --build . -j -- fsfw-tests_coverage") def determine_build_dir(build_dir_list: List[str]): From 337cb0d6c96ecbeec44ff4b08919dd6a5624dc30 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Oct 2022 10:21:17 +0200 Subject: [PATCH 35/63] hotfix --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 3968142c..046b61a3 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -458,7 +458,7 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(DeviceCommandId_t deviceComm info.expectedReplies = 0; info.isExecuting = false; info.sendReplyTo = NO_COMMANDER; - info.useAlternativeReplyId = alternativeReplyId; + info.useAlternativeReplyId = useAlternativeReply; info.alternativeReplyId = alternativeReplyId; auto resultPair = deviceCommandMap.emplace(deviceCommand, info); if (resultPair.second) { From 221df7ece631213abc12bc786585ea5cb7069ec7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Oct 2022 10:46:29 +0200 Subject: [PATCH 36/63] allow recursive mode announcements --- src/fsfw/pus/CService200ModeCommanding.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index d28df59b..809fb02b 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -20,6 +20,7 @@ ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) { case (Subservice::COMMAND_MODE_COMMAND): case (Subservice::COMMAND_MODE_READ): case (Subservice::COMMAND_MODE_ANNCOUNCE): + case (Subservice::COMMAND_MODE_ANNOUNCE_RECURSIVELY): return returnvalue::OK; default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; From 1d6ccfe5ab63c268e1b62a731eb55d35eac88492 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 10 Oct 2022 11:06:58 +0200 Subject: [PATCH 37/63] Service 200: Add mode announcement support --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 16 ++--- src/fsfw/globalfunctions/DleParser.cpp | 18 +++--- src/fsfw/modes/ModeMessage.cpp | 10 ++++ src/fsfw/modes/ModeMessage.h | 60 +++++++++---------- src/fsfw/pus/CService200ModeCommanding.cpp | 25 +++++--- .../pus/servicepackets/Service200Packets.h | 6 +- src/fsfw_hal/linux/uart/UartComIF.cpp | 3 +- src/fsfw_hal/linux/uart/UartComIF.h | 5 +- src/fsfw_hal/linux/uart/UartCookie.h | 4 +- src/fsfw_hal/linux/uart/helper.cpp | 6 +- src/fsfw_hal/linux/uart/helper.h | 5 +- 11 files changed, 85 insertions(+), 73 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 69fa9399..63124dc8 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1604,12 +1604,12 @@ const HasModesIF& DeviceHandlerBase::getModeIF() const { return *this; } ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() { return *this; } ReturnValue_t DeviceHandlerBase::finishAction(bool success, DeviceCommandId_t action, - ReturnValue_t result) { - auto commandIter = deviceCommandMap.find(action); - if (commandIter == deviceCommandMap.end()) { - return MessageQueueIF::NO_QUEUE; - } - commandIter->second.isExecuting = false; - actionHelper.finish(success, commandIter->second.sendReplyTo, action, result); - return returnvalue::OK; + ReturnValue_t result) { + auto commandIter = deviceCommandMap.find(action); + if (commandIter == deviceCommandMap.end()) { + return MessageQueueIF::NO_QUEUE; + } + commandIter->second.isExecuting = false; + actionHelper.finish(success, commandIter->second.sendReplyTo, action, result); + return returnvalue::OK; } diff --git a/src/fsfw/globalfunctions/DleParser.cpp b/src/fsfw/globalfunctions/DleParser.cpp index 90adfa7a..cc695bab 100644 --- a/src/fsfw/globalfunctions/DleParser.cpp +++ b/src/fsfw/globalfunctions/DleParser.cpp @@ -11,8 +11,7 @@ DleParser::DleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPa : decodeRingBuf(decodeRingBuf), decoder(decoder), encodedBuf(encodedBuf), - decodedBuf(decodedBuf) { -} + decodedBuf(decodedBuf) {} ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { @@ -24,7 +23,7 @@ ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) { ReturnValue_t DleParser::parseRingBuf(size_t& readSize) { ctx.setType(DleParser::ContextType::NONE); size_t availableData = decodeRingBuf.getAvailableReadData(); - if(availableData == 0) { + if (availableData == 0) { return NO_PACKET_FOUND; } if (availableData > encodedBuf.second) { @@ -106,7 +105,7 @@ void DleParser::defaultFoundPacketHandler(uint8_t* packet, size_t len, void* arg } void DleParser::defaultErrorHandler() { - if(ctx.getType() != DleParser::ContextType::ERROR) { + if (ctx.getType() != DleParser::ContextType::ERROR) { errorPrinter("No error"); return; } @@ -126,7 +125,8 @@ void DleParser::defaultErrorHandler() { case (ErrorTypes::ENCODED_BUF_TOO_SMALL): case (ErrorTypes::DECODING_BUF_TOO_SMALL): { char opt[64]; - snprintf(opt, sizeof(opt), ": Too small for packet with length %zu", ctx.decodedPacket.second); + snprintf(opt, sizeof(opt), ": Too small for packet with length %zu", + ctx.decodedPacket.second); if (ctx.error.first == ErrorTypes::ENCODED_BUF_TOO_SMALL) { errorPrinter("Encoded buf too small", opt); } else { @@ -168,10 +168,6 @@ ReturnValue_t DleParser::confirmBytesRead(size_t bytesRead) { return decodeRingBuf.deleteData(bytesRead); } -const DleParser::Context& DleParser::getContext() { - return ctx; -} +const DleParser::Context& DleParser::getContext() { return ctx; } -void DleParser::reset() { - decodeRingBuf.clear(); -} +void DleParser::reset() { decodeRingBuf.clear(); } diff --git a/src/fsfw/modes/ModeMessage.cpp b/src/fsfw/modes/ModeMessage.cpp index ecc52c94..efe6d534 100644 --- a/src/fsfw/modes/ModeMessage.cpp +++ b/src/fsfw/modes/ModeMessage.cpp @@ -24,3 +24,13 @@ void ModeMessage::setCantReachMode(CommandMessage* message, ReturnValue_t reason message->setParameter(reason); message->setParameter2(0); } + +void ModeMessage::setModeAnnounceMessage(CommandMessage& message, bool recursive) { + Command_t cmd; + if (recursive) { + cmd = CMD_MODE_ANNOUNCE_RECURSIVELY; + } else { + cmd = CMD_MODE_ANNOUNCE; + } + message.setCommand(cmd); +} diff --git a/src/fsfw/modes/ModeMessage.h b/src/fsfw/modes/ModeMessage.h index 84429e84..1582ccd4 100644 --- a/src/fsfw/modes/ModeMessage.h +++ b/src/fsfw/modes/ModeMessage.h @@ -1,43 +1,42 @@ #ifndef FSFW_MODES_MODEMESSAGE_H_ #define FSFW_MODES_MODEMESSAGE_H_ -#include "../ipc/CommandMessage.h" +#include "fsfw/ipc/CommandMessage.h" typedef uint32_t Mode_t; typedef uint8_t Submode_t; class ModeMessage { - private: - ModeMessage(); - public: static const uint8_t MESSAGE_ID = messagetypes::MODE_COMMAND; - static const Command_t CMD_MODE_COMMAND = - MAKE_COMMAND_ID(0x01); //!> Command to set the specified Mode, replies are: REPLY_MODE_REPLY, - //! REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies, - //! as this will break the subsystem mode machine!! - static const Command_t CMD_MODE_COMMAND_FORCED = MAKE_COMMAND_ID( - 0xF1); //!> Command to set the specified Mode, regardless of external control flag, replies - //! are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any - //! replies, as this will break the subsystem mode machine!! - static const Command_t REPLY_MODE_REPLY = - MAKE_COMMAND_ID(0x02); //!> Reply to a CMD_MODE_COMMAND or CMD_MODE_READ - static const Command_t REPLY_MODE_INFO = - MAKE_COMMAND_ID(0x03); //!> Unrequested info about the current mode (used for composites to - //! inform their container of a changed mode) - static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID( - 0x04); //!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0 - static const Command_t REPLY_WRONG_MODE_REPLY = - MAKE_COMMAND_ID(0x05); //!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded - //! and a transition started but was aborted; the parameters contain - //! the mode that was reached - static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID( - 0x06); //!> Command to read the current mode and reply with a REPLY_MODE_REPLY - static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID( - 0x07); //!> Command to trigger an ModeInfo Event. This command does NOT have a reply. - static const Command_t CMD_MODE_ANNOUNCE_RECURSIVELY = - MAKE_COMMAND_ID(0x08); //!> Command to trigger an ModeInfo Event and to send this command to - //! every child. This command does NOT have a reply. + //!> Command to set the specified Mode, replies are: REPLY_MODE_REPLY, + //! REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies, + //! as this will break the subsystem mode machine!! + static const Command_t CMD_MODE_COMMAND = MAKE_COMMAND_ID(0x01); + //!> Command to set the specified Mode, regardless of external control flag, replies + //! are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any + //! replies, as this will break the subsystem mode machine!! + static const Command_t CMD_MODE_COMMAND_FORCED = MAKE_COMMAND_ID(0xF1); + //!> Reply to a CMD_MODE_COMMAND or CMD_MODE_READ + static const Command_t REPLY_MODE_REPLY = MAKE_COMMAND_ID(0x02); + //!> Unrequested info about the current mode (used for composites to + //! inform their container of a changed mode) + static const Command_t REPLY_MODE_INFO = MAKE_COMMAND_ID(0x03); + //!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0 + static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID(0x04); + //!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded + //! and a transition started but was aborted; the parameters contain + //! the mode that was reached + static const Command_t REPLY_WRONG_MODE_REPLY = MAKE_COMMAND_ID(0x05); + //!> Command to read the current mode and reply with a REPLY_MODE_REPLY + static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID(0x06); + //!> Command to trigger an ModeInfo Event. This command does NOT have a reply. + static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID(0x07); + //!> Command to trigger an ModeInfo Event and to send this command to + //! every child. This command does NOT have a reply. + static const Command_t CMD_MODE_ANNOUNCE_RECURSIVELY = MAKE_COMMAND_ID(0x08); + + ModeMessage() = delete; static Mode_t getMode(const CommandMessage* message); static Submode_t getSubmode(const CommandMessage* message); @@ -45,6 +44,7 @@ class ModeMessage { static void setModeMessage(CommandMessage* message, Command_t command, Mode_t mode, Submode_t submode); + static void setModeAnnounceMessage(CommandMessage& message, bool recursive); static void setCantReachMode(CommandMessage* message, ReturnValue_t reason); static void clear(CommandMessage* message); }; diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 809fb02b..f5928be7 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -54,15 +54,26 @@ ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue( ReturnValue_t CService200ModeCommanding::prepareCommand(CommandMessage *message, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint32_t *state, object_id_t objectId) { - ModePacket modeCommandPacket; - ReturnValue_t result = - modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); - if (result != returnvalue::OK) { - return result; + ReturnValue_t result = returnvalue::OK; + if (subservice == Subservice::COMMAND_MODE_ANNCOUNCE or + subservice == Subservice::COMMAND_MODE_ANNOUNCE_RECURSIVELY) { + bool recursive = true; + if (subservice == Subservice::COMMAND_MODE_ANNCOUNCE) { + recursive = false; + } + ModeMessage::setModeAnnounceMessage(*message, recursive); + } else { + ModePacket modeCommandPacket; + ReturnValue_t result = + modeCommandPacket.deSerialize(&tcData, &tcDataLen, SerializeIF::Endianness::BIG); + if (result != returnvalue::OK) { + return result; + } + + ModeMessage::setModeMessage(message, ModeMessage::CMD_MODE_COMMAND, modeCommandPacket.getMode(), + modeCommandPacket.getSubmode()); } - ModeMessage::setModeMessage(message, ModeMessage::CMD_MODE_COMMAND, modeCommandPacket.getMode(), - modeCommandPacket.getSubmode()); return result; } diff --git a/src/fsfw/pus/servicepackets/Service200Packets.h b/src/fsfw/pus/servicepackets/Service200Packets.h index 701e3f09..3e1df55a 100644 --- a/src/fsfw/pus/servicepackets/Service200Packets.h +++ b/src/fsfw/pus/servicepackets/Service200Packets.h @@ -1,9 +1,9 @@ #ifndef FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ #define FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ -#include "../../modes/ModeMessage.h" -#include "../../serialize/SerialLinkedListAdapter.h" -#include "../../serialize/SerializeIF.h" +#include "fsfw/modes/ModeMessage.h" +#include "fsfw/serialize/SerialLinkedListAdapter.h" +#include "fsfw/serialize/SerializeIF.h" /** * @brief Subservice 1, 2, 3, 4, 5 diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp index df21da64..0880dec6 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -1,4 +1,5 @@ #include "UartComIF.h" + #include #include #include @@ -458,5 +459,3 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { } return returnvalue::FAILED; } - - diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h index 940938d9..657e0123 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/uart/UartComIF.h @@ -1,15 +1,14 @@ #ifndef BSP_Q7S_COMIF_UARTCOMIF_H_ #define BSP_Q7S_COMIF_UARTCOMIF_H_ -#include "UartCookie.h" -#include "helper.h" - #include #include #include #include +#include "UartCookie.h" +#include "helper.h" /** * @brief This is the communication interface to access serial ports on linux based operating diff --git a/src/fsfw_hal/linux/uart/UartCookie.h b/src/fsfw_hal/linux/uart/UartCookie.h index 6fa2bd1b..670ef72f 100644 --- a/src/fsfw_hal/linux/uart/UartCookie.h +++ b/src/fsfw_hal/linux/uart/UartCookie.h @@ -1,14 +1,12 @@ #ifndef SAM9G20_COMIF_COOKIES_UART_COOKIE_H_ #define SAM9G20_COMIF_COOKIES_UART_COOKIE_H_ -#include "helper.h" - #include #include #include - +#include "helper.h" /** * @brief Cookie for the UartComIF. There are many options available to configure the UART driver. diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp index b451f457..df4b7aa8 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/uart/helper.cpp @@ -1,8 +1,9 @@ #include "helper.h" -#include "fsfw/serviceinterface.h" #include +#include "fsfw/serviceinterface.h" + void uart::setMode(struct termios& options, UartModes mode) { if (mode == UartModes::NON_CANONICAL) { /* Disable canonical mode */ @@ -145,6 +146,5 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { } int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) { - return ioctl(serialPort, TIOCGICOUNT, &icounter); + return ioctl(serialPort, TIOCGICOUNT, &icounter); } - diff --git a/src/fsfw_hal/linux/uart/helper.h b/src/fsfw_hal/linux/uart/helper.h index b6a524d6..515f815b 100644 --- a/src/fsfw_hal/linux/uart/helper.h +++ b/src/fsfw_hal/linux/uart/helper.h @@ -1,8 +1,8 @@ #ifndef FSFW_HAL_LINUX_UART_HELPER_H_ #define FSFW_HAL_LINUX_UART_HELPER_H_ -#include #include +#include enum class Parity { NONE, EVEN, ODD }; @@ -56,7 +56,6 @@ void setBaudrate(struct termios& options, UartBaudRate baud); int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter); -} - +} // namespace uart #endif /* FSFW_HAL_LINUX_UART_HELPER_H_ */ From 77b1a85b47c3bd2cb9f36d92ea31689dc4caa674 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 20 Oct 2022 14:24:03 +0200 Subject: [PATCH 38/63] important bugfix for i2c device com IF --- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 8edeb8ab..11b826ce 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -214,7 +214,7 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, } *buffer = i2cDeviceMapIter->second.replyBuffer.data(); *size = i2cDeviceMapIter->second.replyLen; - + i2cDeviceMapIter->second.replyLen = 0; return returnvalue::OK; } From 1164c21dddc2fb84126a45f7531116423d5a4753 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 14:23:43 +0200 Subject: [PATCH 39/63] iter not a member anymore, more bugfixes --- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 13 +++++-------- src/fsfw_hal/linux/i2c/I2cComIF.h | 2 -- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index 11b826ce..4e57852b 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -41,7 +41,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { size_t maxReplyLen = i2cCookie->getMaxReplyLen(); I2cInstance i2cInstance = {std::vector(maxReplyLen), 0}; @@ -89,7 +89,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " @@ -140,20 +140,19 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not " << "registered in i2cDeviceMap" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; return returnvalue::FAILED; } + i2cDeviceMapIter->second.replyLen = 0; deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage"); @@ -162,7 +161,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } result = openDevice(deviceFile, i2cAddress, &fd); if (result != returnvalue::OK) { - i2cDeviceMapIter->second.replyLen = 0; return result; } @@ -177,7 +175,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe sif::error << "I2cComIF::requestReceiveMessage: Read only " << readLen << " from " << requestLen << " bytes" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen << " bytes" << std::endl; @@ -204,7 +201,7 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not " diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.h b/src/fsfw_hal/linux/i2c/I2cComIF.h index 0a15c3a4..8c44cee0 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.h +++ b/src/fsfw_hal/linux/i2c/I2cComIF.h @@ -36,12 +36,10 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject { }; using I2cDeviceMap = std::unordered_map; - using I2cDeviceMapIter = I2cDeviceMap::iterator; /* In this map all i2c devices will be registered with their address and * the appropriate file descriptor will be stored */ I2cDeviceMap i2cDeviceMap; - I2cDeviceMapIter i2cDeviceMapIter; /** * @brief This function opens an I2C device and binds the opened file From b0c5a49b504708ec9130228100d7bbd49025598d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 14:23:43 +0200 Subject: [PATCH 40/63] iter not a member anymore, more bugfixes --- src/fsfw_hal/linux/i2c/I2cComIF.cpp | 17 +++++++++-------- src/fsfw_hal/linux/i2c/I2cComIF.h | 2 -- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index d7bcaa4c..1ad19e82 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -41,7 +41,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { size_t maxReplyLen = i2cCookie->getMaxReplyLen(); I2cInstance i2cInstance = {std::vector(maxReplyLen), 0}; @@ -89,7 +89,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " @@ -140,20 +140,19 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; return NULLPOINTER; } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not " << "registered in i2cDeviceMap" << std::endl; #endif - i2cDeviceMapIter->second.replyLen = 0; return returnvalue::FAILED; } + i2cDeviceMapIter->second.replyLen = 0; deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage"); @@ -162,7 +161,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } result = openDevice(deviceFile, i2cAddress, &fd); if (result != returnvalue::OK) { - i2cDeviceMapIter->second.replyLen = 0; return result; } @@ -183,7 +181,10 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe #else #endif #endif - i2cDeviceMapIter->second.replyLen = 0; +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen + << " bytes" << std::endl; +#endif return returnvalue::FAILED; } @@ -206,7 +207,7 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, } address_t i2cAddress = i2cCookie->getAddress(); - i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); + auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); if (i2cDeviceMapIter == i2cDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not " diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.h b/src/fsfw_hal/linux/i2c/I2cComIF.h index 0a15c3a4..8c44cee0 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.h +++ b/src/fsfw_hal/linux/i2c/I2cComIF.h @@ -36,12 +36,10 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject { }; using I2cDeviceMap = std::unordered_map; - using I2cDeviceMapIter = I2cDeviceMap::iterator; /* In this map all i2c devices will be registered with their address and * the appropriate file descriptor will be stored */ I2cDeviceMap i2cDeviceMap; - I2cDeviceMapIter i2cDeviceMapIter; /** * @brief This function opens an I2C device and binds the opened file From d8a4675842c2d913218b2c3c341eb6ba346e05ad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 14:30:14 +0200 Subject: [PATCH 41/63] bump changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e2262b..1419c4d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- I2C Bugfixes: Do not keep iterator as member and fix some incorrect handling with the iterator. + Also properly reset the reply size for successfull transfers and erroneous transfers. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/700 - Bugfix for Serial Buffer Stream: Setting `doActive` to false now actually fully disables printing. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680 From 11a22577beac11a4e2d1809c3ccb0ae3444ef1e0 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Tue, 25 Oct 2022 11:28:13 +0200 Subject: [PATCH 42/63] defaultconfig did not build anymore --- misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp index 4d6e91f1..85a733b4 100644 --- a/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp +++ b/misc/defaultcfg/fsfwconfig/objects/FsfwFactory.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include @@ -41,13 +40,9 @@ void Factory::setStaticFrameworkObjectIds() { CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; - VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION; - DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS; DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT; - - TmPacketBase::timeStamperId = objects::NO_OBJECT; } From 1f05e6b297af8a6d310394e959c4d0cf13632831 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 25 Oct 2022 11:30:44 +0200 Subject: [PATCH 43/63] fs retval --- src/fsfw/filesystem/HasFileSystemIF.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/filesystem/HasFileSystemIF.h b/src/fsfw/filesystem/HasFileSystemIF.h index 6f7112ad..24400b1c 100644 --- a/src/fsfw/filesystem/HasFileSystemIF.h +++ b/src/fsfw/filesystem/HasFileSystemIF.h @@ -40,6 +40,7 @@ class HasFileSystemIF { //! [EXPORT] : P1: Can be file system specific error code static constexpr ReturnValue_t GENERIC_FILE_ERROR = MAKE_RETURN_CODE(0); static constexpr ReturnValue_t GENERIC_DIR_ERROR = MAKE_RETURN_CODE(1); + static constexpr ReturnValue_t FILESYSTEM_INACTIVE = MAKE_RETURN_CODE(2); static constexpr ReturnValue_t GENERIC_RENAME_ERROR = MAKE_RETURN_CODE(3); //! [EXPORT] : File system is currently busy From bddc7a7ca69b679c132a6640a2ad2fdd5a47ff07 Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Wed, 26 Oct 2022 13:22:16 +0200 Subject: [PATCH 44/63] minimal first version --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 33 ++++--- src/fsfw/devicehandlers/DeviceHandlerBase.h | 93 +++++++++++++++++-- src/fsfw/devicehandlers/DeviceHandlerIF.h | 43 --------- .../devicehandlers/MgmLIS3MDLHandler.cpp | 4 +- .../devicehandlers/MgmRM3100Handler.cpp | 6 +- .../integration/devices/TestDeviceHandler.cpp | 8 +- unittests/mocks/DeviceHandlerMock.cpp | 2 +- 7 files changed, 115 insertions(+), 74 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 8ab540a0..ae986ca3 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -22,8 +22,6 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device CookieIF* comCookie, FailureIsolationBase* fdirInstance, size_t cmdQueueSize) : SystemObject(setObjectId), - mode(MODE_OFF), - submode(SUBMODE_NONE), wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS), deviceCommunicationId(deviceCommunication), @@ -38,6 +36,8 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device defaultFDIRUsed(fdirInstance == nullptr), switchOffWasReported(false), childTransitionDelay(5000), + mode(MODE_OFF), + submode(SUBMODE_NONE), transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE) { commandQueue = QueueFactory::instance()->createMessageQueue( @@ -352,7 +352,6 @@ void DeviceHandlerBase::doStateMachine() { currentUptime - timeoutStart >= powerSwitcher->getSwitchDelayMs()) { triggerEvent(MODE_TRANSITION_FAILED, PowerSwitchIF::SWITCH_TIMEOUT, 0); setMode(_MODE_POWER_DOWN); - callChildStatemachine(); break; } ReturnValue_t switchState = getStateOfSwitches(); @@ -567,11 +566,23 @@ void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) { void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { /* TODO: This will probably be done by the LocalDataPoolManager now */ // changeHK(mode, submode, false); + + /** + * handle transition from OFF to NORMAL by continuing towards normal when ON is reached + */ + if (newMode == MODE_ON and continueToNormal) { + continueToNormal = false; + mode = _MODE_TO_NORMAL; + return; + } + submode = newSubmode; mode = newMode; modeChanged(); setNormalDatapoolEntriesInvalid(); if (!isTransitionalMode()) { + //clear this flag when a non-transitional Mode is reached to be safe + continueToNormal = false; modeHelper.modeChanged(newMode, newSubmode); announceMode(false); } @@ -1056,8 +1067,7 @@ Mode_t DeviceHandlerBase::getBaseMode(Mode_t transitionMode) { return transitionMode & ~(TRANSITION_MODE_BASE_ACTION_MASK | TRANSITION_MODE_CHILD_ACTION_MASK); } -// SHOULDDO: Allow transition from OFF to NORMAL to reduce complexity in assemblies. And, by the -// way, throw away DHB and write a new one: +// SHOULDDO: throw away DHB and write a new one: // - Include power and thermal completely, but more modular :-) // - Don't use modes for state transitions, reduce FSM (Finte State Machine) complexity. // - Modularization? @@ -1069,11 +1079,10 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, Submode_ if ((mode == MODE_ERROR_ON) && (commandedMode != MODE_OFF)) { return TRANS_NOT_ALLOWED; } - if ((commandedMode == MODE_NORMAL) && (mode == MODE_OFF)) { - return TRANS_NOT_ALLOWED; - } - if ((commandedMode == MODE_ON) && (mode == MODE_OFF) and (thermalSet != nullptr)) { + // Do not check thermal state for MODE_RAW + if ((mode == MODE_OFF) and ((commandedMode == MODE_ON) or (commandedMode == MODE_NORMAL)) and + (thermalSet != nullptr)) { ReturnValue_t result = thermalSet->read(); if (result == returnvalue::OK) { if ((thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) and @@ -1088,6 +1097,7 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, Submode_ } void DeviceHandlerBase::startTransition(Mode_t commandedMode, Submode_t commandedSubmode) { + continueToNormal = false; switch (commandedMode) { case MODE_ON: handleTransitionToOnMode(commandedMode, commandedSubmode); @@ -1117,8 +1127,9 @@ void DeviceHandlerBase::startTransition(Mode_t commandedMode, Submode_t commande case MODE_NORMAL: if (mode != MODE_OFF) { setTransition(MODE_NORMAL, commandedSubmode); - } else { - replyReturnvalueToCommand(HasModesIF::TRANS_NOT_ALLOWED); + } else { // mode is off + continueToNormal = true; + handleTransitionToOnMode(MODE_NORMAL, commandedSubmode); } break; } diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 700e960d..1fc4b1de 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -102,6 +102,54 @@ class DeviceHandlerBase : public DeviceHandlerIF, DeviceHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF *comCookie, FailureIsolationBase *fdirInstance = nullptr, size_t cmdQueueSize = 20); + + /** + * extending the modes of DeviceHandler IF for internal state machine + */ + static constexpr uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20; + static constexpr uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10; + //! This is a transitional state which can not be commanded. The device + //! handler performs all commands to get the device in a state ready to + //! perform commands. When this is completed, the mode changes to @c MODE_ON. + static const Mode_t _MODE_START_UP = TRANSITION_MODE_CHILD_ACTION_MASK | 5; + //! This is a transitional state which can not be commanded. + //! The device handler performs all actions and commands to get the device + //! shut down. When the device is off, the mode changes to @c MODE_OFF. + //! It is possible to set the mode to _MODE_SHUT_DOWN to use the to off + //! transition if available. + static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6; + //! It is possible to set the mode to _MODE_TO_ON to use the to on + //! transition if available. + static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON; + //! It is possible to set the mode to _MODE_TO_RAW to use the to raw + //! transition if available. + static const Mode_t _MODE_TO_RAW = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_RAW; + //! It is possible to set the mode to _MODE_TO_NORMAL to use the to normal + //! transition if available. + static const Mode_t _MODE_TO_NORMAL = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_NORMAL; + //! This is a transitional state which can not be commanded. + //! The device is shut down and ready to be switched off. + //! After the command to set the switch off has been sent, + //! the mode changes to @c _MODE_WAIT_OFF + static const Mode_t _MODE_POWER_DOWN = TRANSITION_MODE_BASE_ACTION_MASK | 1; + //! This is a transitional state which can not be commanded. The device + //! will be switched on in this state. After the command to set the switch + //! on has been sent, the mode changes to @c _MODE_WAIT_ON. + static const Mode_t _MODE_POWER_ON = TRANSITION_MODE_BASE_ACTION_MASK | 2; + //! This is a transitional state which can not be commanded. The switch has + //! been commanded off and the handler waits for it to be off. + //! When the switch is off, the mode changes to @c MODE_OFF. + static const Mode_t _MODE_WAIT_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 3; + //! This is a transitional state which can not be commanded. The switch + //! has been commanded on and the handler waits for it to be on. + //! When the switch is on, the mode changes to @c _MODE_TO_ON. + static const Mode_t _MODE_WAIT_ON = TRANSITION_MODE_BASE_ACTION_MASK | 4; + //! This is a transitional state which can not be commanded. The switch has + //! been commanded off and is off now. This state is only to do an RMAP + //! cycle once more where the doSendRead() function will set the mode to + //! MODE_OFF. The reason to do this is to get rid of stuck packets in the IO Board. + static const Mode_t _MODE_SWITCH_IS_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 5; + void setHkDestination(object_id_t hkDestination); /** @@ -684,15 +732,18 @@ class DeviceHandlerBase : public DeviceHandlerIF, size_t rawPacketLen = 0; /** - * The mode the device handler is currently in. - * This should never be changed directly but only with setMode() - */ - Mode_t mode; + * Get the current mode + * + * set via setMode() + */ + Mode_t getMode(); + /** - * The submode the device handler is currently in. - * This should never be changed directly but only with setMode() - */ - Submode_t submode; + * Get the current Submode + * + * set via setMode() + */ + Submode_t getSubmode; /** This is the counter value from performOperation(). */ uint8_t pstStep = 0; @@ -873,8 +924,8 @@ class DeviceHandlerBase : public DeviceHandlerIF, * Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW). * * If the transition is complete, the mode should be set to the target mode, - * which can be deduced from the current mode which is - * [_MODE_TO_ON, _MODE_TO_NORMAL, _MODE_TO_RAW] + * which can be deduced from the current mode (which is + * [_MODE_TO_ON, _MODE_TO_NORMAL, _MODE_TO_RAW]) using getBaseMode() * * The intended target submode is already set. * The origin submode can be read in subModeFrom. @@ -1170,6 +1221,19 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ uint32_t childTransitionDelay; + /** + * The mode the device handler is currently in. + * This should not be changed directly but only with setMode() + */ + Mode_t mode; + + + /** + * The submode the device handler is currently in. + * This should not be changed directly but only with setMode() + */ + Submode_t submode; + /** * @brief The mode the current transition originated from * @@ -1187,6 +1251,15 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ Submode_t transitionSourceSubMode; + /** + * used to make the state machine continue from ON to NOMAL when + * a Device is commanded to NORMAL in OFF mode + * + * set in startTransition() + * evaluated in setMode() to continue to NORMAL when ON is reached + */ + bool continueToNormal; + /** * read the command queue */ diff --git a/src/fsfw/devicehandlers/DeviceHandlerIF.h b/src/fsfw/devicehandlers/DeviceHandlerIF.h index 1fc63d3b..672f2830 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerIF.h +++ b/src/fsfw/devicehandlers/DeviceHandlerIF.h @@ -24,8 +24,6 @@ class DeviceHandlerIF { static const DeviceCommandId_t RAW_COMMAND_ID = -1; static const DeviceCommandId_t NO_COMMAND_ID = -2; - static constexpr uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20; - static constexpr uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10; using dh_heater_request_t = uint8_t; using dh_thermal_state_t = int8_t; @@ -54,47 +52,6 @@ class DeviceHandlerIF { //! device still is powered. In this mode, only a mode change to @c MODE_OFF //! can be commanded, which tries to switch off the device again. static const Mode_t MODE_ERROR_ON = 4; - //! This is a transitional state which can not be commanded. The device - //! handler performs all commands to get the device in a state ready to - //! perform commands. When this is completed, the mode changes to @c MODE_ON. - static const Mode_t _MODE_START_UP = TRANSITION_MODE_CHILD_ACTION_MASK | 5; - //! This is a transitional state which can not be commanded. - //! The device handler performs all actions and commands to get the device - //! shut down. When the device is off, the mode changes to @c MODE_OFF. - //! It is possible to set the mode to _MODE_SHUT_DOWN to use the to off - //! transition if available. - static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6; - //! It is possible to set the mode to _MODE_TO_ON to use the to on - //! transition if available. - static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON; - //! It is possible to set the mode to _MODE_TO_RAW to use the to raw - //! transition if available. - static const Mode_t _MODE_TO_RAW = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_RAW; - //! It is possible to set the mode to _MODE_TO_NORMAL to use the to normal - //! transition if available. - static const Mode_t _MODE_TO_NORMAL = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_NORMAL; - //! This is a transitional state which can not be commanded. - //! The device is shut down and ready to be switched off. - //! After the command to set the switch off has been sent, - //! the mode changes to @c MODE_WAIT_OFF - static const Mode_t _MODE_POWER_DOWN = TRANSITION_MODE_BASE_ACTION_MASK | 1; - //! This is a transitional state which can not be commanded. The device - //! will be switched on in this state. After the command to set the switch - //! on has been sent, the mode changes to @c MODE_WAIT_ON. - static const Mode_t _MODE_POWER_ON = TRANSITION_MODE_BASE_ACTION_MASK | 2; - //! This is a transitional state which can not be commanded. The switch has - //! been commanded off and the handler waits for it to be off. - //! When the switch is off, the mode changes to @c MODE_OFF. - static const Mode_t _MODE_WAIT_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 3; - //! This is a transitional state which can not be commanded. The switch - //! has been commanded on and the handler waits for it to be on. - //! When the switch is on, the mode changes to @c MODE_TO_ON. - static const Mode_t _MODE_WAIT_ON = TRANSITION_MODE_BASE_ACTION_MASK | 4; - //! This is a transitional state which can not be commanded. The switch has - //! been commanded off and is off now. This state is only to do an RMAP - //! cycle once more where the doSendRead() function will set the mode to - //! MODE_OFF. The reason to do this is to get rid of stuck packets in the IO Board. - static const Mode_t _MODE_SWITCH_IS_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 5; static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CDH; static const Event DEVICE_BUILDING_COMMAND_FAILED = MAKE_EVENT(0, severity::LOW); diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp index 9cb16c35..1ff42890 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.cpp @@ -195,7 +195,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, #endif return DeviceHandlerIF::INVALID_DATA; } - if (mode == _MODE_START_UP) { + if (getMode() == _MODE_START_UP) { commandExecuted = true; } @@ -224,7 +224,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len, return DeviceHandlerIF::INVALID_DATA; } - if (mode == _MODE_START_UP) { + if (getMode() == _MODE_START_UP) { commandExecuted = true; } } diff --git a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp index a32153eb..707ca338 100644 --- a/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp +++ b/src/fsfw_hal/devicehandlers/MgmRM3100Handler.cpp @@ -169,7 +169,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const case (RM3100::CONFIGURE_CYCLE_COUNT): case (RM3100::CONFIGURE_TMRC): { // We can only check whether write was successful with read operation - if (mode == _MODE_START_UP) { + if (getMode() == _MODE_START_UP) { commandExecuted = true; } break; @@ -192,7 +192,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const if (packet[1] == tmrcRegValue) { commandExecuted = true; // Reading TMRC was commanded. Trigger event to inform ground - if (mode != _MODE_START_UP) { + if (getMode() != _MODE_START_UP) { triggerEvent(tmrcSet, tmrcRegValue, 0); } } else { @@ -211,7 +211,7 @@ ReturnValue_t MgmRM3100Handler::interpretDeviceReply(DeviceCommandId_t id, const return DeviceHandlerIF::DEVICE_REPLY_INVALID; } // Reading TMRC was commanded. Trigger event to inform ground - if (mode != _MODE_START_UP) { + if (getMode() != _MODE_START_UP) { uint32_t eventParam1 = (cycleCountX << 16) | cycleCountY; triggerEvent(cycleCountersSet, eventParam1, cycleCountZ); } diff --git a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp index fdf02a70..b6a6f465 100644 --- a/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp +++ b/src/fsfw_tests/integration/devices/TestDeviceHandler.cpp @@ -65,7 +65,7 @@ ReturnValue_t TestDevice::buildNormalDeviceCommand(DeviceCommandId_t* id) { } ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { - if (mode == _MODE_TO_ON) { + if (getMode() == _MODE_TO_ON) { if (fullInfoPrintout) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx @@ -80,7 +80,7 @@ ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { #endif } } - if (mode == _MODE_TO_NORMAL) { + if (getMode() == _MODE_TO_NORMAL) { if (fullInfoPrintout) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx @@ -97,7 +97,7 @@ ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { setMode(MODE_NORMAL); } - if (mode == _MODE_SHUT_DOWN) { + if (getMode() == _MODE_SHUT_DOWN) { if (fullInfoPrintout) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx @@ -118,7 +118,7 @@ ReturnValue_t TestDevice::buildTransitionDeviceCommand(DeviceCommandId_t* id) { } void TestDevice::doTransition(Mode_t modeFrom, Submode_t submodeFrom) { - if (mode == _MODE_TO_NORMAL) { + if (getMode() == _MODE_TO_NORMAL) { if (fullInfoPrintout) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "TestDevice" << deviceIdx diff --git a/unittests/mocks/DeviceHandlerMock.cpp b/unittests/mocks/DeviceHandlerMock.cpp index ef0a23d8..3ad80048 100644 --- a/unittests/mocks/DeviceHandlerMock.cpp +++ b/unittests/mocks/DeviceHandlerMock.cpp @@ -5,7 +5,7 @@ DeviceHandlerMock::DeviceHandlerMock(object_id_t objectId, object_id_t deviceCommunication, CookieIF *comCookie, FailureIsolationBase *fdirInstance) : DeviceHandlerBase(objectId, deviceCommunication, comCookie, fdirInstance) { - mode = MODE_ON; + setMode(MODE_ON); } DeviceHandlerMock::~DeviceHandlerMock() = default; From 60ff411721909bd6e4c34523a2248d8dca2507b1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Oct 2022 17:06:24 +0200 Subject: [PATCH 45/63] improvements for HAL com IFs --- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp | 8 +++---- src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h | 1 - src/fsfw_hal/linux/spi/SpiComIF.cpp | 24 ++++++--------------- src/fsfw_hal/linux/spi/SpiComIF.h | 6 +++--- src/fsfw_hal/linux/uart/UartComIF.cpp | 25 ++++++++-------------- src/fsfw_hal/linux/uart/UartComIF.h | 5 ++--- 6 files changed, 25 insertions(+), 44 deletions(-) diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp index 9113a89a..701de8f0 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.cpp @@ -214,7 +214,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod } ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); + auto gpioMapIter = gpioMap.find(gpioId); if (gpioMapIter == gpioMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LinuxLibgpioIF::pullHigh: Unknown GPIO ID " << gpioId << std::endl; @@ -244,7 +244,7 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { } ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { - gpioMapIter = gpioMap.find(gpioId); + auto gpioMapIter = gpioMap.find(gpioId); if (gpioMapIter == gpioMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LinuxLibgpioIF::pullLow: Unknown GPIO ID " << gpioId << std::endl; @@ -295,7 +295,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegularBase& regul } ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, gpio::Levels& gpioState) { - gpioMapIter = gpioMap.find(gpioId); + auto gpioMapIter = gpioMap.find(gpioId); if (gpioMapIter == gpioMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; @@ -377,7 +377,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck, gpio::GpioTypes expectedType, GpioMap& mapToAdd) { // Cross check with private map - gpioMapIter = gpioMap.find(gpioIdToCheck); + auto gpioMapIter = gpioMap.find(gpioIdToCheck); if (gpioMapIter != gpioMap.end()) { auto& gpioType = gpioMapIter->second->gpioType; bool eraseDuplicateDifferentType = false; diff --git a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h index 337fa1a8..a625770c 100644 --- a/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h +++ b/src/fsfw_hal/linux/gpio/LinuxLibgpioIF.h @@ -44,7 +44,6 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject { // Holds the information and configuration of all used GPIOs GpioUnorderedMap gpioMap; - GpioUnorderedMapIter gpioMapIter; /** * @brief This functions drives line of a GPIO specified by the GPIO ID. diff --git a/src/fsfw_hal/linux/spi/SpiComIF.cpp b/src/fsfw_hal/linux/spi/SpiComIF.cpp index dc30e94b..11db7cfe 100644 --- a/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -15,18 +15,8 @@ #include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/utility.h" -SpiComIF::SpiComIF(object_id_t objectId, std::string devname, GpioIF* gpioComIF) +SpiComIF::SpiComIF(object_id_t objectId, std::string devname, GpioIF& gpioComIF) : SystemObject(objectId), gpioComIF(gpioComIF), dev(std::move(devname)) { - if (gpioComIF == nullptr) { -#if FSFW_VERBOSE_LEVEL >= 1 -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "SpiComIF::SpiComIF: GPIO communication interface invalid!" << std::endl; -#else - sif::printError("SpiComIF::SpiComIF: GPIO communication interface invalid!\n"); -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ -#endif /* FSFW_VERBOSE_LEVEL >= 1 */ - } - csMutex = MutexFactory::instance()->createMutex(); } @@ -75,7 +65,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) { /* Pull CS high in any case to be sure that device is inactive */ gpioId_t gpioId = spiCookie->getChipSelectPin(); if (gpioId != gpio::NO_GPIO) { - gpioComIF->pullHigh(gpioId); + gpioComIF.pullHigh(gpioId); } uint32_t spiSpeed = 0; @@ -215,7 +205,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const return result; } updateLinePolarity(fileDescriptor); - result = gpioComIF->pullLow(gpioId); + result = gpioComIF.pullLow(gpioId); if (result != returnvalue::OK) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -256,7 +246,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const } if (gpioId != gpio::NO_GPIO and not csLockManual) { - gpioComIF->pullHigh(gpioId); + gpioComIF.pullHigh(gpioId); result = csMutex->unlockMutex(); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -317,7 +307,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { #endif return result; } - gpioComIF->pullLow(gpioId); + gpioComIF.pullLow(gpioId); } if (read(fileDescriptor, rxBuf, readSize) != static_cast(readSize)) { @@ -332,7 +322,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) { } if (gpioId != gpio::NO_GPIO and not csLockManual) { - gpioComIF->pullHigh(gpioId); + gpioComIF.pullHigh(gpioId); result = csMutex->unlockMutex(); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -397,7 +387,7 @@ ReturnValue_t SpiComIF::getReadBuffer(address_t spiAddress, uint8_t** buffer) { return returnvalue::OK; } -GpioIF* SpiComIF::getGpioInterface() { return gpioComIF; } +GpioIF& SpiComIF::getGpioInterface() { return gpioComIF; } void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { int retval = ioctl(spiFd, SPI_IOC_WR_MODE, reinterpret_cast(&mode)); diff --git a/src/fsfw_hal/linux/spi/SpiComIF.h b/src/fsfw_hal/linux/spi/SpiComIF.h index c3e39b11..7033ea37 100644 --- a/src/fsfw_hal/linux/spi/SpiComIF.h +++ b/src/fsfw_hal/linux/spi/SpiComIF.h @@ -31,7 +31,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject { static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED = returnvalue::makeCode(spiRetvalId, 2); - SpiComIF(object_id_t objectId, std::string devname, GpioIF* gpioComIF); + SpiComIF(object_id_t objectId, std::string devname, GpioIF& gpioComIF); ReturnValue_t initializeInterface(CookieIF* cookie) override; ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override; @@ -57,7 +57,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject { ReturnValue_t performRegularSendOperation(SpiCookie* spiCookie, const uint8_t* sendData, size_t sendLen); - GpioIF* getGpioInterface(); + GpioIF& getGpioInterface(); void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); void getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& speed) const; @@ -83,7 +83,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject { std::vector replyBuffer; }; - GpioIF* gpioComIF = nullptr; + GpioIF& gpioComIF; std::string dev = ""; /** * Protects the chip select operations. Lock when GPIO is pulled low, unlock after it was diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp index df21da64..9de3ec10 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -16,7 +16,6 @@ UartComIF::~UartComIF() {} ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; if (cookie == nullptr) { return NULLPOINTER; @@ -32,7 +31,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { int fileDescriptor = configureUartPort(uartCookie); if (fileDescriptor < 0) { @@ -193,7 +192,6 @@ void UartComIF::setFixedOptions(struct termios* options) { ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { int fd = 0; std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; if (sendLen == 0) { return returnvalue::OK; @@ -215,7 +213,7 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map" @@ -241,7 +239,6 @@ ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return returnvalue:: ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { @@ -253,7 +250,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL UartModes uartMode = uartCookie->getUartMode(); deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartMode == UartModes::NON_CANONICAL and requestLen == 0) { return returnvalue::OK; @@ -276,7 +273,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } } -ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, +ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen) { ReturnValue_t result = returnvalue::OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); @@ -334,7 +331,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM return result; } -ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, +ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen) { int fd = iter->second.fileDescriptor; auto bufferPtr = iter->second.replyBuffer.data(); @@ -370,7 +367,6 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { @@ -381,7 +377,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter == uartDeviceMap.end()) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map" @@ -401,7 +397,6 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -410,7 +405,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIFLUSH); @@ -421,7 +416,6 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -430,7 +424,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCOFLUSH); @@ -441,7 +435,6 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { std::string deviceFile; - UartDeviceMapIter uartDeviceMapIter; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -450,7 +443,7 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { return NULLPOINTER; } deviceFile = uartCookie->getDeviceFile(); - uartDeviceMapIter = uartDeviceMap.find(deviceFile); + auto uartDeviceMapIter = uartDeviceMap.find(deviceFile); if (uartDeviceMapIter != uartDeviceMap.end()) { int fd = uartDeviceMapIter->second.fileDescriptor; tcflush(fd, TCIOFLUSH); diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h index 940938d9..ea264ddb 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/uart/UartComIF.h @@ -64,7 +64,6 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { }; using UartDeviceMap = std::unordered_map; - using UartDeviceMapIter = UartDeviceMap::iterator; /** * The uart devie map stores informations of initialized uart ports. @@ -103,9 +102,9 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { */ void setDatasizeOptions(struct termios* options, UartCookie* uartCookie); - ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, + ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); - ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, + ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); }; From 1b7e94d718ba8f526dd53324d33d0e577cbfc81b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 26 Oct 2022 18:26:48 +0200 Subject: [PATCH 46/63] this api works as well --- src/fsfw_hal/linux/uart/helper.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp index b451f457..530169f7 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/uart/helper.cpp @@ -71,16 +71,14 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { cfsetospeed(&options, B19200); break; case UartBaudRate::RATE_38400: - cfsetispeed(&options, B38400); - cfsetospeed(&options, B38400); + cfsetspeed(&options, B38400); break; case UartBaudRate::RATE_57600: cfsetispeed(&options, B57600); cfsetospeed(&options, B57600); break; case UartBaudRate::RATE_115200: - cfsetispeed(&options, B115200); - cfsetospeed(&options, B115200); + cfsetspeed(&options, B115200); break; case UartBaudRate::RATE_230400: cfsetispeed(&options, B230400); From 226dc4d8b742fea832861bf70d37dc48beb15dc9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 27 Oct 2022 14:01:35 +0200 Subject: [PATCH 47/63] UIO mapper can handle symlinks now --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 16 ++++++++-------- src/fsfw/globalfunctions/DleParser.cpp | 18 +++++++----------- src/fsfw/tmtcservices/AcceptsTelemetryIF.h | 4 +++- src/fsfw_hal/linux/uart/UartComIF.cpp | 7 +++---- src/fsfw_hal/linux/uart/UartComIF.h | 5 ++--- src/fsfw_hal/linux/uart/UartCookie.h | 4 +--- src/fsfw_hal/linux/uart/helper.cpp | 6 +++--- src/fsfw_hal/linux/uart/helper.h | 5 ++--- src/fsfw_hal/linux/uio/UioMapper.cpp | 19 +++++++++++++++++-- 9 files changed, 46 insertions(+), 38 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index c641eb58..2e157efa 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1603,12 +1603,12 @@ void DeviceHandlerBase::disableCommandsAndReplies() { } ReturnValue_t DeviceHandlerBase::finishAction(bool success, DeviceCommandId_t action, - ReturnValue_t result) { - auto commandIter = deviceCommandMap.find(action); - if (commandIter == deviceCommandMap.end()) { - return MessageQueueIF::NO_QUEUE; - } - commandIter->second.isExecuting = false; - actionHelper.finish(success, commandIter->second.sendReplyTo, action, result); - return returnvalue::OK; + ReturnValue_t result) { + auto commandIter = deviceCommandMap.find(action); + if (commandIter == deviceCommandMap.end()) { + return MessageQueueIF::NO_QUEUE; + } + commandIter->second.isExecuting = false; + actionHelper.finish(success, commandIter->second.sendReplyTo, action, result); + return returnvalue::OK; } diff --git a/src/fsfw/globalfunctions/DleParser.cpp b/src/fsfw/globalfunctions/DleParser.cpp index 90adfa7a..cc695bab 100644 --- a/src/fsfw/globalfunctions/DleParser.cpp +++ b/src/fsfw/globalfunctions/DleParser.cpp @@ -11,8 +11,7 @@ DleParser::DleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPa : decodeRingBuf(decodeRingBuf), decoder(decoder), encodedBuf(encodedBuf), - decodedBuf(decodedBuf) { -} + decodedBuf(decodedBuf) {} ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { @@ -24,7 +23,7 @@ ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) { ReturnValue_t DleParser::parseRingBuf(size_t& readSize) { ctx.setType(DleParser::ContextType::NONE); size_t availableData = decodeRingBuf.getAvailableReadData(); - if(availableData == 0) { + if (availableData == 0) { return NO_PACKET_FOUND; } if (availableData > encodedBuf.second) { @@ -106,7 +105,7 @@ void DleParser::defaultFoundPacketHandler(uint8_t* packet, size_t len, void* arg } void DleParser::defaultErrorHandler() { - if(ctx.getType() != DleParser::ContextType::ERROR) { + if (ctx.getType() != DleParser::ContextType::ERROR) { errorPrinter("No error"); return; } @@ -126,7 +125,8 @@ void DleParser::defaultErrorHandler() { case (ErrorTypes::ENCODED_BUF_TOO_SMALL): case (ErrorTypes::DECODING_BUF_TOO_SMALL): { char opt[64]; - snprintf(opt, sizeof(opt), ": Too small for packet with length %zu", ctx.decodedPacket.second); + snprintf(opt, sizeof(opt), ": Too small for packet with length %zu", + ctx.decodedPacket.second); if (ctx.error.first == ErrorTypes::ENCODED_BUF_TOO_SMALL) { errorPrinter("Encoded buf too small", opt); } else { @@ -168,10 +168,6 @@ ReturnValue_t DleParser::confirmBytesRead(size_t bytesRead) { return decodeRingBuf.deleteData(bytesRead); } -const DleParser::Context& DleParser::getContext() { - return ctx; -} +const DleParser::Context& DleParser::getContext() { return ctx; } -void DleParser::reset() { - decodeRingBuf.clear(); -} +void DleParser::reset() { decodeRingBuf.clear(); } diff --git a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h index 0c5621c8..5b421cf9 100644 --- a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h @@ -23,7 +23,9 @@ class AcceptsTelemetryIF { */ [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const = 0; - [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const { return getReportReceptionQueue(0); } + [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const { + return getReportReceptionQueue(0); + } }; #endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */ diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp index 9de3ec10..0b44e4a5 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -1,4 +1,5 @@ #include "UartComIF.h" + #include #include #include @@ -331,8 +332,8 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM return result; } -ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, - size_t requestLen) { +ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, + UartDeviceMap::iterator& iter, size_t requestLen) { int fd = iter->second.fileDescriptor; auto bufferPtr = iter->second.replyBuffer.data(); // Size check to prevent buffer overflow @@ -451,5 +452,3 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { } return returnvalue::FAILED; } - - diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h index ea264ddb..4bdbd954 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/uart/UartComIF.h @@ -1,15 +1,14 @@ #ifndef BSP_Q7S_COMIF_UARTCOMIF_H_ #define BSP_Q7S_COMIF_UARTCOMIF_H_ -#include "UartCookie.h" -#include "helper.h" - #include #include #include #include +#include "UartCookie.h" +#include "helper.h" /** * @brief This is the communication interface to access serial ports on linux based operating diff --git a/src/fsfw_hal/linux/uart/UartCookie.h b/src/fsfw_hal/linux/uart/UartCookie.h index 6fa2bd1b..670ef72f 100644 --- a/src/fsfw_hal/linux/uart/UartCookie.h +++ b/src/fsfw_hal/linux/uart/UartCookie.h @@ -1,14 +1,12 @@ #ifndef SAM9G20_COMIF_COOKIES_UART_COOKIE_H_ #define SAM9G20_COMIF_COOKIES_UART_COOKIE_H_ -#include "helper.h" - #include #include #include - +#include "helper.h" /** * @brief Cookie for the UartComIF. There are many options available to configure the UART driver. diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp index 530169f7..141f68e3 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/uart/helper.cpp @@ -1,8 +1,9 @@ #include "helper.h" -#include "fsfw/serviceinterface.h" #include +#include "fsfw/serviceinterface.h" + void uart::setMode(struct termios& options, UartModes mode) { if (mode == UartModes::NON_CANONICAL) { /* Disable canonical mode */ @@ -143,6 +144,5 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { } int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) { - return ioctl(serialPort, TIOCGICOUNT, &icounter); + return ioctl(serialPort, TIOCGICOUNT, &icounter); } - diff --git a/src/fsfw_hal/linux/uart/helper.h b/src/fsfw_hal/linux/uart/helper.h index b6a524d6..515f815b 100644 --- a/src/fsfw_hal/linux/uart/helper.h +++ b/src/fsfw_hal/linux/uart/helper.h @@ -1,8 +1,8 @@ #ifndef FSFW_HAL_LINUX_UART_HELPER_H_ #define FSFW_HAL_LINUX_UART_HELPER_H_ -#include #include +#include enum class Parity { NONE, EVEN, ODD }; @@ -56,7 +56,6 @@ void setBaudrate(struct termios& options, UartBaudRate baud); int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter); -} - +} // namespace uart #endif /* FSFW_HAL_LINUX_UART_HELPER_H_ */ diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index 3d7e5987..74d0e41f 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -1,6 +1,7 @@ #include "UioMapper.h" #include +#include #include #include @@ -13,7 +14,21 @@ const char UioMapper::UIO_PATH_PREFIX[] = "/sys/class/uio/"; const char UioMapper::MAP_SUBSTR[] = "/maps/map"; const char UioMapper::SIZE_FILE_PATH[] = "/size"; -UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum(mapNum) {} +UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) { + struct stat buf; + lstat(uioFile.c_str(), &buf); + if (S_ISLNK(buf.st_mode)) { + char* res = realpath(uioFile.c_str(), nullptr); + if (res) { + this->uioFile = res; + } else { + sif::error << "Could not resolve real path of UIO file " << uioFile << std::endl; + } + free(res); + } else { + this->uioFile = std::move(uioFile); + } +} UioMapper::~UioMapper() {} @@ -22,7 +37,7 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss int fd = open(uioFile.c_str(), O_RDWR); if (fd < 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; + sif::error << "UioMapper::getMappedAdress: Invalid UIO device file " << uioFile << std::endl; #endif return returnvalue::FAILED; } From f80566777923ae1e8f619ed2056c7637666be26e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Oct 2022 10:16:59 +0200 Subject: [PATCH 48/63] afmt --- CMakeLists.txt | 12 +++++++++--- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 2 +- src/fsfw/devicehandlers/DeviceHandlerBase.h | 16 +++++++--------- src/fsfw/devicehandlers/DeviceHandlerIF.h | 1 - .../serviceinterface/ServiceInterfaceBuffer.cpp | 1 - src/fsfw_hal/common/CMakeLists.txt | 2 +- src/fsfw_hal/common/printChar.c | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2572b20..cccd51a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,9 +345,15 @@ if(FSFW_BUILD_TESTS) DEPENDENCIES ${FSFW_TEST_TGT}) else() setup_target_for_coverage_lcov( - NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - GENHTML_ARGS --html-epilog ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) + NAME + ${FSFW_TEST_TGT}_coverage + EXECUTABLE + ${FSFW_TEST_TGT} + DEPENDENCIES + ${FSFW_TEST_TGT} + GENHTML_ARGS + --html-epilog + ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) endif() endif() endif() diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index ae986ca3..8bcba7c4 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -581,7 +581,7 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { modeChanged(); setNormalDatapoolEntriesInvalid(); if (!isTransitionalMode()) { - //clear this flag when a non-transitional Mode is reached to be safe + // clear this flag when a non-transitional Mode is reached to be safe continueToNormal = false; modeHelper.modeChanged(newMode, newSubmode); announceMode(false); diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 1fc4b1de..4498284b 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -102,10 +102,9 @@ class DeviceHandlerBase : public DeviceHandlerIF, DeviceHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF *comCookie, FailureIsolationBase *fdirInstance = nullptr, size_t cmdQueueSize = 20); - /** * extending the modes of DeviceHandler IF for internal state machine - */ + */ static constexpr uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20; static constexpr uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10; //! This is a transitional state which can not be commanded. The device @@ -733,16 +732,16 @@ class DeviceHandlerBase : public DeviceHandlerIF, /** * Get the current mode - * + * * set via setMode() - */ + */ Mode_t getMode(); /** * Get the current Submode - * + * * set via setMode() - */ + */ Submode_t getSubmode; /** This is the counter value from performOperation(). */ @@ -1227,7 +1226,6 @@ class DeviceHandlerBase : public DeviceHandlerIF, */ Mode_t mode; - /** * The submode the device handler is currently in. * This should not be changed directly but only with setMode() @@ -1254,10 +1252,10 @@ class DeviceHandlerBase : public DeviceHandlerIF, /** * used to make the state machine continue from ON to NOMAL when * a Device is commanded to NORMAL in OFF mode - * + * * set in startTransition() * evaluated in setMode() to continue to NORMAL when ON is reached - */ + */ bool continueToNormal; /** diff --git a/src/fsfw/devicehandlers/DeviceHandlerIF.h b/src/fsfw/devicehandlers/DeviceHandlerIF.h index 672f2830..c683b2cc 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerIF.h +++ b/src/fsfw/devicehandlers/DeviceHandlerIF.h @@ -24,7 +24,6 @@ class DeviceHandlerIF { static const DeviceCommandId_t RAW_COMMAND_ID = -1; static const DeviceCommandId_t NO_COMMAND_ID = -2; - using dh_heater_request_t = uint8_t; using dh_thermal_state_t = int8_t; diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index 23892dcc..0e73be83 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -3,7 +3,6 @@ #if FSFW_CPP_OSTREAM_ENABLED == 1 #include - #include #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" diff --git a/src/fsfw_hal/common/CMakeLists.txt b/src/fsfw_hal/common/CMakeLists.txt index 1cd9c678..2f4608f8 100644 --- a/src/fsfw_hal/common/CMakeLists.txt +++ b/src/fsfw_hal/common/CMakeLists.txt @@ -1,3 +1,3 @@ add_subdirectory(gpio) -target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) \ No newline at end of file +target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) diff --git a/src/fsfw_hal/common/printChar.c b/src/fsfw_hal/common/printChar.c index 6e02c1df..24fba5c8 100644 --- a/src/fsfw_hal/common/printChar.c +++ b/src/fsfw_hal/common/printChar.c @@ -1,5 +1,5 @@ -#include #include +#include void __attribute__((weak)) printChar(const char* character, bool errStream) { if (errStream) { From 033676ad3b5136c4e2fb9d41309d2f0883f5f2de Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 28 Oct 2022 10:30:48 +0200 Subject: [PATCH 49/63] smaller fixes for DHB --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 10 ++++++++-- src/fsfw/devicehandlers/DeviceHandlerBase.h | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 972aa4fe..7b1929cd 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -573,8 +573,6 @@ void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) { } void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { - /* TODO: This will probably be done by the LocalDataPoolManager now */ - // changeHK(mode, submode, false); /** * handle transition from OFF to NORMAL by continuing towards normal when ON is reached @@ -1595,6 +1593,14 @@ void DeviceHandlerBase::setPowerSwitcher(PowerSwitchIF* switcher) { this->powerSwitcher = switcher; } +Mode_t DeviceHandlerBase::getMode() { + return mode; +} + +Submode_t DeviceHandlerBase::getSubmode() { + return submode; +} + void DeviceHandlerBase::disableCommandsAndReplies() { for (auto& command : deviceCommandMap) { if (command.second.isExecuting) { diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.h b/src/fsfw/devicehandlers/DeviceHandlerBase.h index 3f13c108..65b3ded0 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.h +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.h @@ -755,7 +755,7 @@ class DeviceHandlerBase : public DeviceHandlerIF, * * set via setMode() */ - Submode_t getSubmode; + Submode_t getSubmode(); /** This is the counter value from performOperation(). */ uint8_t pstStep = 0; From e302c89f7465dee400b75a43fd562b4ef1470c24 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Nov 2022 15:48:13 +0100 Subject: [PATCH 50/63] health helper dtor bugfix --- src/fsfw/health/HealthHelper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index bf1a92d2..f6077ea1 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -5,7 +5,11 @@ HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) : objectId(objectId), owner(owner) {} -HealthHelper::~HealthHelper() { healthTable->removeObject(objectId); } +HealthHelper::~HealthHelper() { + if (healthTable != nullptr) { + healthTable->removeObject(objectId); + } +} ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) { switch (message->getCommand()) { From e1d4209fbe06581c36dd0a1b8113dfb56e673613 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Nov 2022 16:07:00 +0100 Subject: [PATCH 51/63] missing fifo pop command --- src/fsfw/osal/common/TcpTmTcServer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/fsfw/osal/common/TcpTmTcServer.cpp b/src/fsfw/osal/common/TcpTmTcServer.cpp index dff959ba..bc2cd152 100644 --- a/src/fsfw/osal/common/TcpTmTcServer.cpp +++ b/src/fsfw/osal/common/TcpTmTcServer.cpp @@ -274,6 +274,8 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent) ConstStorageAccessor storeAccessor(storeId); ReturnValue_t result = tmStore->getData(storeId, storeAccessor); if (result != returnvalue::OK) { + // Invalid entry, pop FIFO + tmtcBridge->tmFifo->pop(); return result; } if (wiretappingEnabled) { From 91ebf98c2851b0470a912c1c3279cb20e10a5490 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 2 Nov 2022 19:35:22 +0100 Subject: [PATCH 52/63] add new ping with data TC --- CMakeLists.txt | 12 +++++++++--- src/fsfw/pus/Service17Test.cpp | 11 +++++++++++ src/fsfw/pus/Service17Test.h | 3 +++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f31cd6bc..0c0d2bb4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -345,9 +345,15 @@ if(FSFW_BUILD_TESTS) DEPENDENCIES ${FSFW_TEST_TGT}) else() setup_target_for_coverage_lcov( - NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - GENHTML_ARGS --html-epilog ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) + NAME + ${FSFW_TEST_TGT}_coverage + EXECUTABLE + ${FSFW_TEST_TGT} + DEPENDENCIES + ${FSFW_TEST_TGT} + GENHTML_ARGS + --html-epilog + ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) endif() endif() endif() diff --git a/src/fsfw/pus/Service17Test.cpp b/src/fsfw/pus/Service17Test.cpp index bea2eeb8..35fc7c9d 100644 --- a/src/fsfw/pus/Service17Test.cpp +++ b/src/fsfw/pus/Service17Test.cpp @@ -1,5 +1,7 @@ #include "fsfw/pus/Service17Test.h" +#include + #include "fsfw/FSFW.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/SystemObject.h" @@ -31,6 +33,15 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) { } return tmHelper.storeAndSendTmPacket(); } + case Subservice::PING_WITH_DATA: { + SerializeElement receivedDataLen = currentPacket.getUserDataLen(); + ReturnValue_t result = + tmHelper.prepareTmPacket(Subservice::PING_WITH_DATA_REPORT_WITH_SIZE, receivedDataLen); + if (result != returnvalue::OK) { + return result; + } + return tmHelper.storeAndSendTmPacket(); + } default: return AcceptsTelecommandsIF::INVALID_SUBSERVICE; } diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index f2ec6e4f..d3b6a6dc 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -32,6 +32,9 @@ class Service17Test : public PusServiceBase { CONNECTION_TEST_REPORT = 2, //! [EXPORT] : [COMMAND] Trigger test reply and test event EVENT_TRIGGER_TEST = 128, + PING_WITH_DATA = 129, + //! [EXPORT] : [COMMAND] Report which reports the sent user data size + PING_WITH_DATA_REPORT_WITH_SIZE = 130 }; explicit Service17Test(PsbParams params); From 6efa482eb09939aebe1c9c4427ae621e3ffa7e81 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Nov 2022 10:10:36 +0100 Subject: [PATCH 53/63] use uniform uart api --- src/fsfw_hal/linux/uart/helper.cpp | 72 ++++++++++-------------------- 1 file changed, 24 insertions(+), 48 deletions(-) diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp index 141f68e3..f9569cd3 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/uart/helper.cpp @@ -16,123 +16,99 @@ void uart::setMode(struct termios& options, UartModes mode) { void uart::setBaudrate(struct termios& options, UartBaudRate baud) { switch (baud) { case UartBaudRate::RATE_50: - cfsetispeed(&options, B50); - cfsetospeed(&options, B50); + cfsetspeed(&options, B50); break; case UartBaudRate::RATE_75: - cfsetispeed(&options, B75); - cfsetospeed(&options, B75); + cfsetspeed(&options, B75); break; case UartBaudRate::RATE_110: - cfsetispeed(&options, B110); - cfsetospeed(&options, B110); + cfsetspeed(&options, B110); break; case UartBaudRate::RATE_134: - cfsetispeed(&options, B134); - cfsetospeed(&options, B134); + cfsetspeed(&options, B134); break; case UartBaudRate::RATE_150: - cfsetispeed(&options, B150); - cfsetospeed(&options, B150); + cfsetspeed(&options, B150); break; case UartBaudRate::RATE_200: cfsetispeed(&options, B200); cfsetospeed(&options, B200); break; case UartBaudRate::RATE_300: - cfsetispeed(&options, B300); - cfsetospeed(&options, B300); + cfsetspeed(&options, B300); break; case UartBaudRate::RATE_600: - cfsetispeed(&options, B600); - cfsetospeed(&options, B600); + cfsetspeed(&options, B600); break; case UartBaudRate::RATE_1200: - cfsetispeed(&options, B1200); - cfsetospeed(&options, B1200); + cfsetspeed(&options, B1200); break; case UartBaudRate::RATE_1800: - cfsetispeed(&options, B1800); - cfsetospeed(&options, B1800); + cfsetspeed(&options, B1800); break; case UartBaudRate::RATE_2400: - cfsetispeed(&options, B2400); - cfsetospeed(&options, B2400); + cfsetspeed(&options, B2400); break; case UartBaudRate::RATE_4800: - cfsetispeed(&options, B4800); - cfsetospeed(&options, B4800); + cfsetspeed(&options, B4800); break; case UartBaudRate::RATE_9600: cfsetispeed(&options, B9600); cfsetospeed(&options, B9600); break; case UartBaudRate::RATE_19200: - cfsetispeed(&options, B19200); - cfsetospeed(&options, B19200); + cfsetspeed(&options, B19200); break; case UartBaudRate::RATE_38400: cfsetspeed(&options, B38400); break; case UartBaudRate::RATE_57600: - cfsetispeed(&options, B57600); - cfsetospeed(&options, B57600); + cfsetspeed(&options, B57600); break; case UartBaudRate::RATE_115200: cfsetspeed(&options, B115200); break; case UartBaudRate::RATE_230400: - cfsetispeed(&options, B230400); - cfsetospeed(&options, B230400); + cfsetspeed(&options, B230400); break; #ifndef __APPLE__ case UartBaudRate::RATE_460800: - cfsetispeed(&options, B460800); - cfsetospeed(&options, B460800); + cfsetspeed(&options, B460800); break; case UartBaudRate::RATE_500000: - cfsetispeed(&options, B500000); - cfsetospeed(&options, B500000); + cfsetspeed(&options, B500000); break; case UartBaudRate::RATE_576000: cfsetispeed(&options, B576000); cfsetospeed(&options, B576000); break; case UartBaudRate::RATE_921600: - cfsetispeed(&options, B921600); - cfsetospeed(&options, B921600); + cfsetspeed(&options, B921600); break; case UartBaudRate::RATE_1000000: - cfsetispeed(&options, B1000000); - cfsetospeed(&options, B1000000); + cfsetspeed(&options, B1000000); break; case UartBaudRate::RATE_1152000: - cfsetispeed(&options, B1152000); - cfsetospeed(&options, B1152000); + cfsetspeed(&options, B1152000); break; case UartBaudRate::RATE_1500000: - cfsetispeed(&options, B1500000); - cfsetospeed(&options, B1500000); + cfsetspeed(&options, B1500000); break; case UartBaudRate::RATE_2000000: - cfsetispeed(&options, B2000000); - cfsetospeed(&options, B2000000); + cfsetspeed(&options, B2000000); break; case UartBaudRate::RATE_2500000: - cfsetispeed(&options, B2500000); - cfsetospeed(&options, B2500000); + cfsetspeed(&options, B2500000); break; case UartBaudRate::RATE_3000000: cfsetispeed(&options, B3000000); cfsetospeed(&options, B3000000); break; case UartBaudRate::RATE_3500000: - cfsetispeed(&options, B3500000); - cfsetospeed(&options, B3500000); + cfsetspeed(&options, B3500000); break; case UartBaudRate::RATE_4000000: - cfsetispeed(&options, B4000000); - cfsetospeed(&options, B4000000); + cfsetspeed(&options, B4000000); break; #endif // ! __APPLE__ default: From 00f1c5bbe924f987e83362cbff92d4c83b3e332c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Nov 2022 10:12:05 +0100 Subject: [PATCH 54/63] missing replacements --- src/fsfw_hal/linux/uart/helper.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp index f9569cd3..c32fed31 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/uart/helper.cpp @@ -31,8 +31,7 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { cfsetspeed(&options, B150); break; case UartBaudRate::RATE_200: - cfsetispeed(&options, B200); - cfsetospeed(&options, B200); + cfsetspeed(&options, B200); break; case UartBaudRate::RATE_300: cfsetspeed(&options, B300); @@ -53,8 +52,7 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { cfsetspeed(&options, B4800); break; case UartBaudRate::RATE_9600: - cfsetispeed(&options, B9600); - cfsetospeed(&options, B9600); + cfsetspeed(&options, B9600); break; case UartBaudRate::RATE_19200: cfsetspeed(&options, B19200); @@ -79,8 +77,7 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { cfsetspeed(&options, B500000); break; case UartBaudRate::RATE_576000: - cfsetispeed(&options, B576000); - cfsetospeed(&options, B576000); + cfsetspeed(&options, B576000); break; case UartBaudRate::RATE_921600: cfsetspeed(&options, B921600); @@ -101,8 +98,7 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { cfsetspeed(&options, B2500000); break; case UartBaudRate::RATE_3000000: - cfsetispeed(&options, B3000000); - cfsetospeed(&options, B3000000); + cfsetspeed(&options, B3000000); break; case UartBaudRate::RATE_3500000: cfsetspeed(&options, B3500000); From e5b5c7d2533cd25dbe53d33be540babf15a3c70b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 3 Nov 2022 10:33:52 +0100 Subject: [PATCH 55/63] higher default MQ depth for events, printout tweak --- src/fsfw/pus/Service5EventReporting.h | 2 +- src/fsfw/tmtcservices/PusServiceBase.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/pus/Service5EventReporting.h b/src/fsfw/pus/Service5EventReporting.h index 1f4e5a3a..0c738226 100644 --- a/src/fsfw/pus/Service5EventReporting.h +++ b/src/fsfw/pus/Service5EventReporting.h @@ -42,7 +42,7 @@ class Service5EventReporting : public PusServiceBase { public: Service5EventReporting(PsbParams params, size_t maxNumberReportsPerCycle = 10, - uint32_t messageQueueDepth = 10); + uint32_t messageQueueDepth = 20); ~Service5EventReporting() override; /*** diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 9598e536..8e0c5c4f 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -27,8 +27,8 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { ReturnValue_t result = performService(); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusService " << psbParams.serviceId << ": performService returned with " - << static_cast(result) << std::endl; + sif::error << "PusService " << static_cast(psbParams.serviceId) << + ": performService returned with " << static_cast(result) << std::endl; #endif return returnvalue::FAILED; } From 672fca5169b017387e58e2ff864913d932c59aa1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 4 Nov 2022 11:08:23 +0100 Subject: [PATCH 56/63] extend uart helper a bit --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 9 +--- src/fsfw/tmtcservices/PusServiceBase.cpp | 4 +- src/fsfw_hal/linux/uart/UartComIF.cpp | 19 +------- src/fsfw_hal/linux/uart/UartComIF.h | 11 ----- src/fsfw_hal/linux/uart/helper.cpp | 44 +++++++++++++++++++ src/fsfw_hal/linux/uart/helper.h | 10 +++++ 6 files changed, 59 insertions(+), 38 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index 7bded0de..559e4cfd 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -566,7 +566,6 @@ void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) { } void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) { - /** * handle transition from OFF to NORMAL by continuing towards normal when ON is reached */ @@ -1584,13 +1583,9 @@ void DeviceHandlerBase::setPowerSwitcher(PowerSwitchIF* switcher) { this->powerSwitcher = switcher; } -Mode_t DeviceHandlerBase::getMode() { - return mode; -} +Mode_t DeviceHandlerBase::getMode() { return mode; } -Submode_t DeviceHandlerBase::getSubmode() { - return submode; -} +Submode_t DeviceHandlerBase::getSubmode() { return submode; } void DeviceHandlerBase::disableCommandsAndReplies() { for (auto& command : deviceCommandMap) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index 8e0c5c4f..fbabbd70 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -27,8 +27,8 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) { ReturnValue_t result = performService(); if (result != returnvalue::OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PusService " << static_cast(psbParams.serviceId) << - ": performService returned with " << static_cast(result) << std::endl; + sif::error << "PusService " << static_cast(psbParams.serviceId) + << ": performService returned with " << static_cast(result) << std::endl; #endif return returnvalue::FAILED; } diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp index 0b44e4a5..a65adb33 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -88,7 +88,7 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { return fd; } - setParityOptions(&options, uartCookie); + uart::setParity(options, uartCookie->getParity()); setStopBitOptions(&options, uartCookie); setDatasizeOptions(&options, uartCookie); setFixedOptions(&options); @@ -114,23 +114,6 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { return fd; } -void UartComIF::setParityOptions(struct termios* options, UartCookie* uartCookie) { - /* Clear parity bit */ - options->c_cflag &= ~PARENB; - switch (uartCookie->getParity()) { - case Parity::EVEN: - options->c_cflag |= PARENB; - options->c_cflag &= ~PARODD; - break; - case Parity::ODD: - options->c_cflag |= PARENB; - options->c_cflag |= PARODD; - break; - default: - break; - } -} - void UartComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) { /* Clear stop field. Sets stop bit to one bit */ options->c_cflag &= ~CSTOPB; diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h index 4bdbd954..fc92921f 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/uart/UartComIF.h @@ -78,17 +78,6 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { */ int configureUartPort(UartCookie* uartCookie); - /** - * @brief This function adds the parity settings to the termios options struct. - * - * @param options Pointer to termios options struct which will be modified to enable or disable - * parity checking. - * @param uartCookie Pointer to uart cookie containing the information about the desired - * parity settings. - * - */ - void setParityOptions(struct termios* options, UartCookie* uartCookie); - void setStopBitOptions(struct termios* options, UartCookie* uartCookie); /** diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp index c32fed31..f38dd3d3 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/uart/helper.cpp @@ -115,6 +115,50 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { } } +void uart::setBitsPerWord(struct termios& options, BitsPerWord bits) { + options.c_cflag &= ~CSIZE; // Clear all the size bits + if (bits == BitsPerWord::BITS_5) { + options.c_cflag |= CS5; + } else if (bits == BitsPerWord::BITS_6) { + options.c_cflag |= CS6; + } else if (bits == BitsPerWord::BITS_7) { + options.c_cflag |= CS7; + } else if (bits == BitsPerWord::BITS_8) { + options.c_cflag |= CS8; + } +} + +void uart::enableRead(struct termios& options) { options.c_cflag |= CREAD; } + +void uart::ignoreCtrlLines(struct termios& options) { options.c_cflag |= CLOCAL; } + +void uart::setParity(struct termios& options, Parity parity) { + /* Clear parity bit */ + options.c_cflag &= ~PARENB; + switch (parity) { + case Parity::EVEN: + options.c_cflag |= PARENB; + options.c_cflag &= ~PARODD; + break; + case Parity::ODD: + options.c_cflag |= PARENB; + options.c_cflag |= PARODD; + break; + default: + break; + } +} + int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) { return ioctl(serialPort, TIOCGICOUNT, &icounter); } + +void uart::setStopbits(struct termios& options, StopBits bits) { + if (bits == StopBits::TWO_STOP_BITS) { + // Use two stop bits + options.c_cflag |= CSTOPB; + } else { + // Clear stop field, only one stop bit used in communication + options.c_cflag &= ~CSTOPB; + } +} diff --git a/src/fsfw_hal/linux/uart/helper.h b/src/fsfw_hal/linux/uart/helper.h index 515f815b..7f067d00 100644 --- a/src/fsfw_hal/linux/uart/helper.h +++ b/src/fsfw_hal/linux/uart/helper.h @@ -54,6 +54,16 @@ void setMode(struct termios& options, UartModes mode); */ void setBaudrate(struct termios& options, UartBaudRate baud); +void setStopbits(struct termios& options, StopBits bits); + +void setBitsPerWord(struct termios& options, BitsPerWord bits); + +void enableRead(struct termios& options); + +void setParity(struct termios& options, Parity parity); + +void ignoreCtrlLines(struct termios& options); + int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter); } // namespace uart From 0e8f5ddd26d586dd40e69f52aef1a63c0d5a9da6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 8 Nov 2022 11:07:56 +0100 Subject: [PATCH 57/63] added missing const specifier --- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp | 2 +- src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp index 605bbd21..262653c9 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.cpp @@ -21,7 +21,7 @@ SpacePacketReader::~SpacePacketReader() = default; inline uint16_t SpacePacketReader::getPacketIdRaw() const { return ccsds::getPacketId(*spHeader); } -const uint8_t* SpacePacketReader::getPacketData() { return packetDataField; } +const uint8_t* SpacePacketReader::getPacketData() const { return packetDataField; } ReturnValue_t SpacePacketReader::setData(uint8_t* data, size_t maxSize_, void* args) { return setInternalFields(data, maxSize_); diff --git a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h index ff22510c..61939217 100644 --- a/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h +++ b/src/fsfw/tmtcpacket/ccsds/SpacePacketReader.h @@ -71,7 +71,7 @@ class SpacePacketReader : public SpacePacketIF, // Helper methods: [[nodiscard]] ReturnValue_t checkSize() const; - const uint8_t* getPacketData(); + const uint8_t* getPacketData() const; ReturnValue_t setReadOnlyData(const uint8_t* data, size_t maxSize); From 530a261e142ae4ab2c7726303e4d571d03200e47 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 15:12:18 +0100 Subject: [PATCH 58/63] dedicated header file for container retvals --- src/fsfw/container/ArrayList.h | 6 +++--- src/fsfw/container/FixedMap.h | 19 ++++++------------- src/fsfw/container/definitions.h | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 src/fsfw/container/definitions.h diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h index f5f74cf1..12bcda99 100644 --- a/src/fsfw/container/ArrayList.h +++ b/src/fsfw/container/ArrayList.h @@ -5,6 +5,8 @@ #include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeIF.h" +#include "definitions.h" + /** * @brief A List that stores its values in an array. * @details @@ -19,8 +21,6 @@ class ArrayList { friend class SerialArrayListAdapter; public: - static const uint8_t INTERFACE_ID = CLASS_ID::ARRAY_LIST; - static const ReturnValue_t FULL = MAKE_RETURN_CODE(0x01); /** * This is the allocating constructor. @@ -187,7 +187,7 @@ class ArrayList { */ ReturnValue_t insert(T entry) { if (size >= maxSize_) { - return FULL; + return containers::LIST_FULL; } entries[size] = entry; ++size; diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h index 6ed6278d..553d3cac 100644 --- a/src/fsfw/container/FixedMap.h +++ b/src/fsfw/container/FixedMap.h @@ -4,16 +4,9 @@ #include #include -#include "../returnvalues/returnvalue.h" +#include "definitions.h" #include "ArrayList.h" -namespace mapdefs { -static const uint8_t INTERFACE_ID = CLASS_ID::FIXED_MAP; -static const ReturnValue_t KEY_ALREADY_EXISTS = MAKE_RETURN_CODE(0x01); -static const ReturnValue_t MAP_FULL = MAKE_RETURN_CODE(0x02); -static const ReturnValue_t KEY_DOES_NOT_EXIST = MAKE_RETURN_CODE(0x03); -} // namespace mapdefs - /** * @brief Map implementation for maps with a pre-defined size. * @details @@ -78,10 +71,10 @@ class FixedMap : public SerializeIF { ReturnValue_t insert(key_t key, T value, Iterator* storedValue = nullptr) { if (exists(key) == returnvalue::OK) { - return mapdefs::KEY_ALREADY_EXISTS; + return containers::KEY_ALREADY_EXISTS; } if (_size == theMap.maxSize()) { - return mapdefs::MAP_FULL; + return containers::MAP_FULL; } theMap[_size].first = key; theMap[_size].second = value; @@ -95,7 +88,7 @@ class FixedMap : public SerializeIF { ReturnValue_t insert(std::pair pair) { return insert(pair.first, pair.second); } ReturnValue_t exists(key_t key) const { - ReturnValue_t result = mapdefs::KEY_DOES_NOT_EXIST; + ReturnValue_t result = containers::KEY_DOES_NOT_EXIST; if (findIndex(key) < _size) { result = returnvalue::OK; } @@ -105,7 +98,7 @@ class FixedMap : public SerializeIF { ReturnValue_t erase(Iterator* iter) { uint32_t i; if ((i = findIndex((*iter).value->first)) >= _size) { - return mapdefs::KEY_DOES_NOT_EXIST; + return containers::KEY_DOES_NOT_EXIST; } theMap[i] = theMap[_size - 1]; --_size; @@ -116,7 +109,7 @@ class FixedMap : public SerializeIF { ReturnValue_t erase(key_t key) { uint32_t i; if ((i = findIndex(key)) >= _size) { - return mapdefs::KEY_DOES_NOT_EXIST; + return containers::KEY_DOES_NOT_EXIST; } theMap[i] = theMap[_size - 1]; --_size; diff --git a/src/fsfw/container/definitions.h b/src/fsfw/container/definitions.h new file mode 100644 index 00000000..23620176 --- /dev/null +++ b/src/fsfw/container/definitions.h @@ -0,0 +1,15 @@ +#ifndef FSFW_CONTAINER_DEFINITIONS_H_ +#define FSFW_CONTAINER_DEFINITIONS_H_ + +#include "fsfw/retval.h" + +using namespace returnvalue; +namespace containers { +static const ReturnValue_t KEY_ALREADY_EXISTS = makeCode(CLASS_ID::FIXED_MAP, 0x01); +static const ReturnValue_t MAP_FULL = makeCode(CLASS_ID::FIXED_MAP, 0x02); +static const ReturnValue_t KEY_DOES_NOT_EXIST = makeCode(CLASS_ID::FIXED_MAP, 0x03); + +static const ReturnValue_t LIST_FULL = makeCode(CLASS_ID::ARRAY_LIST, 0x01); +} // namespace containers + +#endif /* FSFW_CONTAINER_DEFINITIONS_H_ */ From 177c39dd53198a1b05e2f40fc3c5e88e7f7c2e0b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 15:38:34 +0100 Subject: [PATCH 59/63] helper interface implementations --- src/fsfw/container/ArrayList.h | 2 -- src/fsfw/container/FixedMap.h | 2 +- src/fsfw/power/PowerSwitcherComponent.cpp | 18 +++++++++++++++--- src/fsfw/power/PowerSwitcherComponent.h | 11 +++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/fsfw/container/ArrayList.h b/src/fsfw/container/ArrayList.h index 12bcda99..92834558 100644 --- a/src/fsfw/container/ArrayList.h +++ b/src/fsfw/container/ArrayList.h @@ -4,7 +4,6 @@ #include "../returnvalues/returnvalue.h" #include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeIF.h" - #include "definitions.h" /** @@ -21,7 +20,6 @@ class ArrayList { friend class SerialArrayListAdapter; public: - /** * This is the allocating constructor. * It allocates an array of the specified size. diff --git a/src/fsfw/container/FixedMap.h b/src/fsfw/container/FixedMap.h index 553d3cac..ce90d814 100644 --- a/src/fsfw/container/FixedMap.h +++ b/src/fsfw/container/FixedMap.h @@ -4,8 +4,8 @@ #include #include -#include "definitions.h" #include "ArrayList.h" +#include "definitions.h" /** * @brief Map implementation for maps with a pre-defined size. diff --git a/src/fsfw/power/PowerSwitcherComponent.cpp b/src/fsfw/power/PowerSwitcherComponent.cpp index b6b67a83..b07a7296 100644 --- a/src/fsfw/power/PowerSwitcherComponent.cpp +++ b/src/fsfw/power/PowerSwitcherComponent.cpp @@ -3,7 +3,7 @@ #include #include -PowerSwitcherComponent::PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher, +PowerSwitcherComponent::PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF* pwrSwitcher, power::Switch_t pwrSwitch) : SystemObject(objectId), switcher(pwrSwitcher, pwrSwitch), @@ -54,7 +54,7 @@ ReturnValue_t PowerSwitcherComponent::initialize() { MessageQueueId_t PowerSwitcherComponent::getCommandQueue() const { return queue->getId(); } -void PowerSwitcherComponent::getMode(Mode_t *mode, Submode_t *submode) { +void PowerSwitcherComponent::getMode(Mode_t* mode, Submode_t* submode) { *mode = this->mode; *submode = this->submode; } @@ -65,7 +65,7 @@ ReturnValue_t PowerSwitcherComponent::setHealth(HealthState health) { } ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t submode, - uint32_t *msToReachTheMode) { + uint32_t* msToReachTheMode) { *msToReachTheMode = 5000; if (mode != MODE_ON and mode != MODE_OFF) { return TRANS_NOT_ALLOWED; @@ -105,3 +105,15 @@ void PowerSwitcherComponent::setMode(Mode_t newMode, Submode_t newSubmode) { } HasHealthIF::HealthState PowerSwitcherComponent::getHealth() { return healthHelper.getHealth(); } + +const HasHealthIF* PowerSwitcherComponent::getOptHealthIF() const { return this; } + +const HasModesIF& PowerSwitcherComponent::getModeIF() const { return *this; } + +ReturnValue_t PowerSwitcherComponent::connectModeTreeParent(HasModeTreeChildrenIF& parent) { + return parent.registerChild(*this); +} + +object_id_t PowerSwitcherComponent::getObjectId() const { return SystemObject::getObjectId(); } + +ModeTreeChildIF& PowerSwitcherComponent::getModeTreeChildIF() { return *this; } diff --git a/src/fsfw/power/PowerSwitcherComponent.h b/src/fsfw/power/PowerSwitcherComponent.h index 01689bef..38dddc37 100644 --- a/src/fsfw/power/PowerSwitcherComponent.h +++ b/src/fsfw/power/PowerSwitcherComponent.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include #include class PowerSwitchIF; @@ -24,12 +26,17 @@ class PowerSwitchIF; */ class PowerSwitcherComponent : public SystemObject, public ExecutableObjectIF, + public ModeTreeChildIF, + public ModeTreeConnectionIF, public HasModesIF, public HasHealthIF { public: PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher, power::Switch_t pwrSwitch); + ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override; + ModeTreeChildIF &getModeTreeChildIF() override; + private: MessageQueueIF *queue = nullptr; PowerSwitcher switcher; @@ -56,6 +63,10 @@ class PowerSwitcherComponent : public SystemObject, ReturnValue_t setHealth(HealthState health) override; HasHealthIF::HealthState getHealth() override; + + object_id_t getObjectId() const override; + const HasHealthIF *getOptHealthIF() const override; + const HasModesIF &getModeIF() const override; }; #endif /* _FSFW_POWER_POWERSWITCHERCOMPONENT_H_ */ From 194b3e100a036b1fef22566693549b327d48c6a5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 15:53:18 +0100 Subject: [PATCH 60/63] fix compiler error for fixed array list copy ctor --- src/fsfw/container/FixedArrayList.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fsfw/container/FixedArrayList.h b/src/fsfw/container/FixedArrayList.h index fc8be393..78184e35 100644 --- a/src/fsfw/container/FixedArrayList.h +++ b/src/fsfw/container/FixedArrayList.h @@ -20,7 +20,9 @@ class FixedArrayList : public ArrayList { FixedArrayList() : ArrayList(data, MAX_SIZE) {} FixedArrayList(const FixedArrayList& other) : ArrayList(data, MAX_SIZE) { - memcpy(this->data, other.data, sizeof(this->data)); + for (size_t idx = 0; idx < sizeof(data); idx++) { + data[idx] = other.data[idx]; + } this->entries = data; this->size = other.size; } From 6ca1a5c7969198ff01391fa4fbd4fa0a80552543 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 16:11:05 +0100 Subject: [PATCH 61/63] fix unittests --- src/fsfw/container/definitions.h | 9 ++++----- src/fsfw_hal/linux/uio/UioMapper.cpp | 2 ++ unittests/container/TestArrayList.cpp | 2 +- unittests/container/TestFixedArrayList.cpp | 2 +- unittests/container/TestFixedMap.cpp | 18 ++++++++++-------- unittests/mocks/AcceptsTmMock.cpp | 2 +- unittests/mocks/AcceptsTmMock.h | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/fsfw/container/definitions.h b/src/fsfw/container/definitions.h index 23620176..b50ea45d 100644 --- a/src/fsfw/container/definitions.h +++ b/src/fsfw/container/definitions.h @@ -3,13 +3,12 @@ #include "fsfw/retval.h" -using namespace returnvalue; namespace containers { -static const ReturnValue_t KEY_ALREADY_EXISTS = makeCode(CLASS_ID::FIXED_MAP, 0x01); -static const ReturnValue_t MAP_FULL = makeCode(CLASS_ID::FIXED_MAP, 0x02); -static const ReturnValue_t KEY_DOES_NOT_EXIST = makeCode(CLASS_ID::FIXED_MAP, 0x03); +static const ReturnValue_t KEY_ALREADY_EXISTS = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x01); +static const ReturnValue_t MAP_FULL = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x02); +static const ReturnValue_t KEY_DOES_NOT_EXIST = returnvalue::makeCode(CLASS_ID::FIXED_MAP, 0x03); -static const ReturnValue_t LIST_FULL = makeCode(CLASS_ID::ARRAY_LIST, 0x01); +static const ReturnValue_t LIST_FULL = returnvalue::makeCode(CLASS_ID::ARRAY_LIST, 0x01); } // namespace containers #endif /* FSFW_CONTAINER_DEFINITIONS_H_ */ diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index 74d0e41f..e34c209a 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -22,7 +22,9 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) { if (res) { this->uioFile = res; } else { +#if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Could not resolve real path of UIO file " << uioFile << std::endl; +#endif } free(res); } else { diff --git a/unittests/container/TestArrayList.cpp b/unittests/container/TestArrayList.cpp index 69b08faa..0c327685 100644 --- a/unittests/container/TestArrayList.cpp +++ b/unittests/container/TestArrayList.cpp @@ -43,7 +43,7 @@ TEST_CASE("Array List", "[containers]") { for (auto i = 0; i < 20; i++) { REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } - REQUIRE(list.insert(20) == static_cast(ArrayList::FULL)); + REQUIRE(list.insert(20) == static_cast(containers::LIST_FULL)); ArrayList::Iterator it = list.begin(); REQUIRE((*it) == 0); it++; diff --git a/unittests/container/TestFixedArrayList.cpp b/unittests/container/TestFixedArrayList.cpp index 876d6792..f3131c64 100644 --- a/unittests/container/TestFixedArrayList.cpp +++ b/unittests/container/TestFixedArrayList.cpp @@ -31,7 +31,7 @@ TEST_CASE("FixedArrayList Tests", "[containers]") { for (auto i = 1; i < 260; i++) { REQUIRE(list.insert(i) == static_cast(returnvalue::OK)); } - REQUIRE(list.insert(260) == static_cast(ArrayList::FULL)); + REQUIRE(list.insert(260) == static_cast(containers::LIST_FULL)); list.clear(); REQUIRE(list.size == 0); } diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index 8bfe9fed..231edb4f 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -7,6 +7,8 @@ template class FixedMap; +using namespace returnvalue; + TEST_CASE("FixedMap Tests", "[containers]") { INFO("FixedMap Tests"); @@ -24,9 +26,9 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(map.find(i)->second == i + 1); REQUIRE(not map.empty()); } - REQUIRE(map.insert(0, 0) == static_cast(FixedMap::KEY_ALREADY_EXISTS)); - REQUIRE(map.insert(31, 0) == static_cast(FixedMap::MAP_FULL)); - REQUIRE(map.exists(31) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + REQUIRE(map.insert(0, 0) == static_cast(containers::KEY_ALREADY_EXISTS)); + REQUIRE(map.insert(31, 0) == static_cast(containers::MAP_FULL)); + REQUIRE(map.exists(31) == static_cast(containers::KEY_DOES_NOT_EXIST)); REQUIRE(map.size() == 30); REQUIRE(map.full()); { @@ -35,14 +37,14 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(*ptr == 6); REQUIRE(*(map.findValue(6)) == 7); REQUIRE(map.find(31, &ptr) == - static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + static_cast(containers::KEY_DOES_NOT_EXIST)); } REQUIRE(map.getSerializedSize() == (sizeof(uint32_t) + 30 * (sizeof(uint32_t) + sizeof(uint16_t)))); REQUIRE(map.erase(2) == static_cast(returnvalue::OK)); - REQUIRE(map.erase(31) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); - REQUIRE(map.exists(2) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + REQUIRE(map.erase(31) == static_cast(containers::KEY_DOES_NOT_EXIST)); + REQUIRE(map.exists(2) == static_cast(containers::KEY_DOES_NOT_EXIST)); REQUIRE(map.size() == 29); for (auto element : map) { @@ -80,7 +82,7 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(map.find(37)->second == 38); REQUIRE(map.size() == 2); REQUIRE(map.insert(37, 24, nullptr) == - static_cast(FixedMap::KEY_ALREADY_EXISTS)); + static_cast(containers::KEY_ALREADY_EXISTS)); REQUIRE(map.find(37)->second != 24); REQUIRE(map.size() == 2); }; @@ -137,7 +139,7 @@ TEST_CASE("FixedMap Tests", "[containers]") { FixedMap::Iterator it; std::pair pair = std::make_pair(44, 43); it = FixedMap::Iterator(&pair); - REQUIRE(map.erase(&it) == static_cast(FixedMap::KEY_DOES_NOT_EXIST)); + REQUIRE(map.erase(&it) == static_cast(containers::KEY_DOES_NOT_EXIST)); REQUIRE(map.find(45) == map.end()); size_t toLargeMap = 100; const uint8_t* ptr = reinterpret_cast(&toLargeMap); diff --git a/unittests/mocks/AcceptsTmMock.cpp b/unittests/mocks/AcceptsTmMock.cpp index 7b997047..2f718e61 100644 --- a/unittests/mocks/AcceptsTmMock.cpp +++ b/unittests/mocks/AcceptsTmMock.cpp @@ -6,7 +6,7 @@ AcceptsTmMock::AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToR AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) : SystemObject(objects::NO_OBJECT, false), returnedQueue(queueToReturn) {} -MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) { +MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) const { return returnedQueue; } diff --git a/unittests/mocks/AcceptsTmMock.h b/unittests/mocks/AcceptsTmMock.h index d6cc7f85..b12e1094 100644 --- a/unittests/mocks/AcceptsTmMock.h +++ b/unittests/mocks/AcceptsTmMock.h @@ -9,7 +9,7 @@ class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF { AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn); explicit AcceptsTmMock(MessageQueueId_t queueToReturn); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; const char* getName() const override; MessageQueueId_t returnedQueue; From 2a203ae13d0b872189c0a79147c92312a44c08b1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 16:15:28 +0100 Subject: [PATCH 62/63] this not crash --- src/fsfw/container/FixedArrayList.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fsfw/container/FixedArrayList.h b/src/fsfw/container/FixedArrayList.h index 78184e35..6ae7da41 100644 --- a/src/fsfw/container/FixedArrayList.h +++ b/src/fsfw/container/FixedArrayList.h @@ -20,11 +20,11 @@ class FixedArrayList : public ArrayList { FixedArrayList() : ArrayList(data, MAX_SIZE) {} FixedArrayList(const FixedArrayList& other) : ArrayList(data, MAX_SIZE) { - for (size_t idx = 0; idx < sizeof(data); idx++) { - data[idx] = other.data[idx]; - } this->entries = data; this->size = other.size; + for (size_t idx = 0; idx < this->size; idx++) { + data[idx] = other.data[idx]; + } } FixedArrayList& operator=(FixedArrayList other) { From 39946bff58db7c5ac9016ca3156abb059560d9cb Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 10 Nov 2022 17:31:11 +0100 Subject: [PATCH 63/63] some renaming and tweaks for linux serial driver --- CMakeLists.txt | 1 + src/fsfw_hal/linux/CMakeLists.txt | 11 +++-- src/fsfw_hal/linux/serial/CMakeLists.txt | 2 + .../UartComIF.cpp => serial/SerialComIF.cpp} | 40 +++++++++---------- .../UartComIF.h => serial/SerialComIF.h} | 11 +++-- .../SerialCookie.cpp} | 3 +- .../UartCookie.h => serial/SerialCookie.h} | 3 +- .../linux/{uart => serial}/helper.cpp | 3 +- src/fsfw_hal/linux/{uart => serial}/helper.h | 0 src/fsfw_hal/linux/uart/CMakeLists.txt | 1 - unittests/container/TestFixedMap.cpp | 6 +-- 11 files changed, 40 insertions(+), 41 deletions(-) create mode 100644 src/fsfw_hal/linux/serial/CMakeLists.txt rename src/fsfw_hal/linux/{uart/UartComIF.cpp => serial/SerialComIF.cpp} (89%) rename src/fsfw_hal/linux/{uart/UartComIF.h => serial/SerialComIF.h} (93%) rename src/fsfw_hal/linux/{uart/UartCookie.cpp => serial/SerialCookie.cpp} (97%) rename src/fsfw_hal/linux/{uart/UartCookie.h => serial/SerialCookie.h} (98%) rename src/fsfw_hal/linux/{uart => serial}/helper.cpp (99%) rename src/fsfw_hal/linux/{uart => serial}/helper.h (100%) delete mode 100644 src/fsfw_hal/linux/uart/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c0d2bb4..9025537a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,7 @@ if(UNIX) option(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS "Add Linux peripheral drivers" OFF) option(FSFW_HAL_LINUX_ADD_LIBGPIOD "Attempt to add Linux GPIOD drivers" OFF) + option(FSFW_HAL_LINUX_ADD_SERIAL_DRIVERS "Add serial drivers" ON) endif() # Optional sources diff --git a/src/fsfw_hal/linux/CMakeLists.txt b/src/fsfw_hal/linux/CMakeLists.txt index ffa5f5ee..d22d7ff1 100644 --- a/src/fsfw_hal/linux/CMakeLists.txt +++ b/src/fsfw_hal/linux/CMakeLists.txt @@ -5,11 +5,14 @@ endif() target_sources(${LIB_FSFW_NAME} PRIVATE UnixFileGuard.cpp CommandExecutor.cpp utility.cpp) +if(FSFW_HAL_LINUX_ADD_LIBGPIOD) + add_subdirectory(gpio) +endif() +if(FSFW_HAL_LINUX_ADD_SERIAL_DRIVERS) + add_subdirectory(serial) +endif() + if(FSFW_HAL_LINUX_ADD_PERIPHERAL_DRIVERS) - if(FSFW_HAL_LINUX_ADD_LIBGPIOD) - add_subdirectory(gpio) - endif() - add_subdirectory(uart) # Adding those does not really make sense on Apple systems which are generally # host systems. It won't even compile as the headers are missing if(NOT APPLE) diff --git a/src/fsfw_hal/linux/serial/CMakeLists.txt b/src/fsfw_hal/linux/serial/CMakeLists.txt new file mode 100644 index 00000000..07d20d29 --- /dev/null +++ b/src/fsfw_hal/linux/serial/CMakeLists.txt @@ -0,0 +1,2 @@ +target_sources(${LIB_FSFW_NAME} PUBLIC SerialComIF.cpp SerialCookie.cpp + helper.cpp) diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/serial/SerialComIF.cpp similarity index 89% rename from src/fsfw_hal/linux/uart/UartComIF.cpp rename to src/fsfw_hal/linux/serial/SerialComIF.cpp index a65adb33..0fd293a0 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/serial/SerialComIF.cpp @@ -1,7 +1,6 @@ -#include "UartComIF.h" - #include #include +#include #include #include @@ -11,11 +10,11 @@ #include "fsfw/serviceinterface.h" #include "fsfw_hal/linux/utility.h" -UartComIF::UartComIF(object_id_t objectId) : SystemObject(objectId) {} +SerialComIF::SerialComIF(object_id_t objectId) : SystemObject(objectId) {} -UartComIF::~UartComIF() {} +SerialComIF::~SerialComIF() {} -ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { +ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) { std::string deviceFile; if (cookie == nullptr) { @@ -59,7 +58,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { return returnvalue::OK; } -int UartComIF::configureUartPort(UartCookie* uartCookie) { +int SerialComIF::configureUartPort(UartCookie* uartCookie) { struct termios options = {}; std::string deviceFile = uartCookie->getDeviceFile(); @@ -114,7 +113,7 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) { return fd; } -void UartComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) { /* Clear stop field. Sets stop bit to one bit */ options->c_cflag &= ~CSTOPB; switch (uartCookie->getStopBits()) { @@ -126,7 +125,7 @@ void UartComIF::setStopBitOptions(struct termios* options, UartCookie* uartCooki } } -void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCookie) { /* Clear size bits */ options->c_cflag &= ~CSIZE; switch (uartCookie->getBitsPerWord()) { @@ -150,7 +149,7 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook } } -void UartComIF::setFixedOptions(struct termios* options) { +void SerialComIF::setFixedOptions(struct termios* options) { /* Disable RTS/CTS hardware flow control */ options->c_cflag &= ~CRTSCTS; /* Turn on READ & ignore ctrl lines (CLOCAL = 1) */ @@ -173,7 +172,7 @@ void UartComIF::setFixedOptions(struct termios* options) { options->c_oflag &= ~ONLCR; } -ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { +ReturnValue_t SerialComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { int fd = 0; std::string deviceFile; @@ -219,9 +218,9 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, return returnvalue::OK; } -ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } +ReturnValue_t SerialComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; } -ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { +ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { std::string deviceFile; UartCookie* uartCookie = dynamic_cast(cookie); @@ -257,8 +256,8 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL } } -ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, - size_t requestLen) { +ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie, + UartDeviceMap::iterator& iter, size_t requestLen) { ReturnValue_t result = returnvalue::OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); uint8_t currentReadCycles = 0; @@ -315,8 +314,9 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM return result; } -ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, - UartDeviceMap::iterator& iter, size_t requestLen) { +ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie, + UartDeviceMap::iterator& iter, + size_t requestLen) { int fd = iter->second.fileDescriptor; auto bufferPtr = iter->second.replyBuffer.data(); // Size check to prevent buffer overflow @@ -349,7 +349,7 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, return returnvalue::OK; } -ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { +ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { std::string deviceFile; UartCookie* uartCookie = dynamic_cast(cookie); @@ -379,7 +379,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, return returnvalue::OK; } -ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { +ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) { std::string deviceFile; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { @@ -398,7 +398,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { return returnvalue::FAILED; } -ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { +ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) { std::string deviceFile; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { @@ -417,7 +417,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { return returnvalue::FAILED; } -ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { +ReturnValue_t SerialComIF::flushUartTxAndRxBuf(CookieIF* cookie) { std::string deviceFile; UartCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/serial/SerialComIF.h similarity index 93% rename from src/fsfw_hal/linux/uart/UartComIF.h rename to src/fsfw_hal/linux/serial/SerialComIF.h index fc92921f..4953884a 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/serial/SerialComIF.h @@ -3,13 +3,12 @@ #include #include +#include +#include #include #include -#include "UartCookie.h" -#include "helper.h" - /** * @brief This is the communication interface to access serial ports on linux based operating * systems. @@ -19,7 +18,7 @@ * * @author J. Meier */ -class UartComIF : public DeviceCommunicationIF, public SystemObject { +class SerialComIF : public DeviceCommunicationIF, public SystemObject { public: static constexpr uint8_t uartRetvalId = CLASS_ID::HAL_UART; @@ -27,9 +26,9 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject { static constexpr ReturnValue_t UART_READ_SIZE_MISSMATCH = returnvalue::makeCode(uartRetvalId, 2); static constexpr ReturnValue_t UART_RX_BUFFER_TOO_SMALL = returnvalue::makeCode(uartRetvalId, 3); - UartComIF(object_id_t objectId); + SerialComIF(object_id_t objectId); - virtual ~UartComIF(); + virtual ~SerialComIF(); ReturnValue_t initializeInterface(CookieIF* cookie) override; ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override; diff --git a/src/fsfw_hal/linux/uart/UartCookie.cpp b/src/fsfw_hal/linux/serial/SerialCookie.cpp similarity index 97% rename from src/fsfw_hal/linux/uart/UartCookie.cpp rename to src/fsfw_hal/linux/serial/SerialCookie.cpp index 31dbc903..733d84a5 100644 --- a/src/fsfw_hal/linux/uart/UartCookie.cpp +++ b/src/fsfw_hal/linux/serial/SerialCookie.cpp @@ -1,6 +1,5 @@ -#include "UartCookie.h" - #include +#include UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, size_t maxReplyLen, UartModes uartMode) diff --git a/src/fsfw_hal/linux/uart/UartCookie.h b/src/fsfw_hal/linux/serial/SerialCookie.h similarity index 98% rename from src/fsfw_hal/linux/uart/UartCookie.h rename to src/fsfw_hal/linux/serial/SerialCookie.h index 670ef72f..8d0f5fb4 100644 --- a/src/fsfw_hal/linux/uart/UartCookie.h +++ b/src/fsfw_hal/linux/serial/SerialCookie.h @@ -3,11 +3,10 @@ #include #include +#include #include -#include "helper.h" - /** * @brief Cookie for the UartComIF. There are many options available to configure the UART driver. * The constructor only requests for common options like the baudrate. Other options can diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/serial/helper.cpp similarity index 99% rename from src/fsfw_hal/linux/uart/helper.cpp rename to src/fsfw_hal/linux/serial/helper.cpp index f38dd3d3..ba975f2f 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/serial/helper.cpp @@ -1,5 +1,4 @@ -#include "helper.h" - +#include #include #include "fsfw/serviceinterface.h" diff --git a/src/fsfw_hal/linux/uart/helper.h b/src/fsfw_hal/linux/serial/helper.h similarity index 100% rename from src/fsfw_hal/linux/uart/helper.h rename to src/fsfw_hal/linux/serial/helper.h diff --git a/src/fsfw_hal/linux/uart/CMakeLists.txt b/src/fsfw_hal/linux/uart/CMakeLists.txt deleted file mode 100644 index d8daa9ff..00000000 --- a/src/fsfw_hal/linux/uart/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -target_sources(${LIB_FSFW_NAME} PUBLIC UartComIF.cpp UartCookie.cpp helper.cpp) diff --git a/unittests/container/TestFixedMap.cpp b/unittests/container/TestFixedMap.cpp index 231edb4f..83ff975d 100644 --- a/unittests/container/TestFixedMap.cpp +++ b/unittests/container/TestFixedMap.cpp @@ -36,8 +36,7 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(map.find(5, &ptr) == static_cast(returnvalue::OK)); REQUIRE(*ptr == 6); REQUIRE(*(map.findValue(6)) == 7); - REQUIRE(map.find(31, &ptr) == - static_cast(containers::KEY_DOES_NOT_EXIST)); + REQUIRE(map.find(31, &ptr) == static_cast(containers::KEY_DOES_NOT_EXIST)); } REQUIRE(map.getSerializedSize() == @@ -81,8 +80,7 @@ TEST_CASE("FixedMap Tests", "[containers]") { REQUIRE(map.insert(37, 38, nullptr) == static_cast(returnvalue::OK)); REQUIRE(map.find(37)->second == 38); REQUIRE(map.size() == 2); - REQUIRE(map.insert(37, 24, nullptr) == - static_cast(containers::KEY_ALREADY_EXISTS)); + REQUIRE(map.insert(37, 24, nullptr) == static_cast(containers::KEY_ALREADY_EXISTS)); REQUIRE(map.find(37)->second != 24); REQUIRE(map.size() == 2); };