Merge branch 'development' into mueller/master

This commit is contained in:
Robin Müller 2020-12-22 16:38:41 +01:00
commit ba1f8f7171
70 changed files with 1012 additions and 907 deletions

View File

@ -53,6 +53,12 @@ ID for now.
- There is an additional `PERFORM_OPERATION` step for the device handler base. It is important - There is an additional `PERFORM_OPERATION` step for the device handler base. It is important
that DHB users adapt their polling sequence tables to perform this step. This steps allows for aclear distinction between operation and communication steps that DHB users adapt their polling sequence tables to perform this step. This steps allows for aclear distinction between operation and communication steps
- setNormalDatapoolEntriesInvalid is not an abstract method and a default implementation was provided
- getTransitionDelayMs is now an abstract method
### DeviceHandlerIF
- Typo for UNKNOWN_DEVICE_REPLY
### Events ### Events
@ -60,3 +66,7 @@ that DHB users adapt their polling sequence tables to perform this step. This st
allows setting a unique ID. Event.cpp source file removed, functions now allows setting a unique ID. Event.cpp source file removed, functions now
defined in header directly. Namespaces renamed. Functions declared `constexpr` defined in header directly. Namespaces renamed. Functions declared `constexpr`
now now
### Commanding Service Base
- CSB uses the new fsfwconfig::FSFW_CSB_FIFO_DEPTH variable to determine the FIFO depth for each CSB instance. This variable has to be set in the FSFWConfig.h file

100
README.md
View File

@ -1,4 +1,5 @@
![FSFW Logo](logo/FSFW_Logo_V3_bw.png) ![FSFW Logo](logo/FSFW_Logo_V3_bw.png)
# Flight Software Framework (FSFW) # Flight Software Framework (FSFW)
The Flight Software Framework is a C++ Object Oriented Framework for unmanned, The Flight Software Framework is a C++ Object Oriented Framework for unmanned,
@ -14,83 +15,54 @@ The framework is designed for systems, which communicate with external devices,
Therefore, a mode and health system provides control over the states of the software and the controlled devices. Therefore, a mode and health system provides control over the states of the software and the controlled devices.
In addition, a simple mechanism of event based fault detection, isolation and recovery is implemented as well. In addition, a simple mechanism of event based fault detection, isolation and recovery is implemented as well.
The recommended hardware is a microprocessor with more than 2 MB of RAM and 1 MB of non-volatile Memory. The recommended hardware is a microprocessor with more than 1 MB of RAM and 1 MB of non-volatile Memory.
For reference, current Applications use a Cobham Gaisler UT699 (LEON3FT), a ISISPACE IOBC or a Zynq-7020 SoC. For reference, current Applications use a Cobham Gaisler UT699 (LEON3FT), a ISISPACE IOBC or a Zynq-7020 SoC.
The `fsfw` was also tested on the STM32H743ZI-Nucleo board.
## How to Use
The [FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example) provides a good starting point and a demo
to see the FSFW capabilities and build it with the Make or the CMake build system.
Generally, the FSFW is included in a project by compiling the FSFW sources and providing
a configuration folder and adding it to the include path.
A template configuration folder was provided and can be copied into the project root to have
a starting point. The [configuration section](doc/README-config.md#top) provides more specific information about
the possible options.
## Structure ## 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 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. 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. 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. Dynamic Allocation after initialization is discouraged and different solutions are provided in the FSFW to achieve that.
The fsfw uses Run-time type information. The fsfw uses run-time type information but exceptions are not allowed.
Exceptions are not allowed.
### Failure Handling ### Failure Handling
Functions should return a defined ReturnValue_t to signal to the caller that something is gone wrong. 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 HasReturnvaluesIF::makeReturnCode or the Macro MAKE_RETURN can be used. Returnvalues must be unique. For this the function HasReturnvaluesIF::makeReturnCode or the Macro MAKE_RETURN can be used.
The CLASS_ID is a unique id for that type of object. See returnvalues/FwClassIds. The CLASS_ID is a unique id for that type of object. See returnvalues/FwClassIds.
### OSAL ### OSAL
The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS. A independent OSAL called "host" is currently not finished. This aims to be running on windows as well.
The OSAL provides periodic tasks, message queues, clocks and Semaphores as well as Mutexes. The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS.
A independent Host OSAL is in development which will provide abstraction for common type of
host OSes (tested for Linux and Windows, not for MacOS yet).
The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes.
### Core Components ### Core Components
Clock: The FSFW has following core components. More detailed informations can be found in the
* This is a class of static functions that can be used at anytime [core component section](doc/README-core.md#top):
* Leap Seconds must be set if any time conversions from UTC to other times is used
ObjectManager (must be created):
* 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.
``` c++
template <typename T> 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 must be configured by setting this 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;
}
```
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
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 ### Static Ids in the framework
@ -121,13 +93,15 @@ If the communication is based on CCSDS Frames and Space Packets, several classes
If Space Packets are used, a timestamper must be created. If Space Packets are used, a timestamper must be created.
An example can be found in the timemanager folder, this uses CCSDSTime::CDS_short. An example can be found in the timemanager folder, this uses CCSDSTime::CDS_short.
#### DeviceHandling #### Device Handlers
DeviceHandlers are a core component of the FSFW. 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. 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 DH can be tested on different hardware. 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. The DH has mechanisms to monitor the communication with the physical device which allow for FDIR reaction.
Device Handlers can be created by overriding `DeviceHandlerBase`.
A standard FDIR component for the DH will be created automatically but can be overwritten by the user. 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, Health #### Modes, Health
@ -149,10 +123,6 @@ 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. 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. The on-board FDIR uses the health state for isolation and recovery.
## Example config
A example config can be found in defaultcfg/fsfwconfig.
## Unit Tests ## Unit Tests
Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include catch2 itself. Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include catch2 itself.

View File

@ -59,6 +59,11 @@ uint16_t PoolDataSetBase::getFillCount() const {
ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) { ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
if(registeredVariables[count] == nullptr) {
// configuration error.
return HasReturnvaluesIF::RETURN_FAILED;
}
// These checks are often performed by the respective // These checks are often performed by the respective
// variable implementation too, but I guess a double check does not hurt. // variable implementation too, but I guess a double check does not hurt.
if (registeredVariables[count]->getReadWriteMode() != if (registeredVariables[count]->getReadWriteMode() !=

View File

@ -48,7 +48,7 @@ class HousekeepingPacketUpdate;
* @author R. Mueller * @author R. Mueller
*/ */
class LocalDataPoolManager { class LocalDataPoolManager {
template<typename T> friend class LocalPoolVar; template<typename T> friend class LocalPoolVariable;
template<typename T, uint16_t vecSize> friend class LocalPoolVector; template<typename T, uint16_t vecSize> friend class LocalPoolVector;
friend class LocalPoolDataSetBase; friend class LocalPoolDataSetBase;
friend void (Factory::setStaticFrameworkObjectIds)(); friend void (Factory::setStaticFrameworkObjectIds)();

View File

@ -22,10 +22,10 @@
* @ingroup data_pool * @ingroup data_pool
*/ */
template<typename T> template<typename T>
class LocalPoolVar: public LocalPoolObjectBase { class LocalPoolVariable: public LocalPoolObjectBase {
public: public:
//! Default ctor is forbidden. //! Default ctor is forbidden.
LocalPoolVar() = delete; LocalPoolVariable() = delete;
/** /**
* This constructor is used by the data creators to have pool variable * This constructor is used by the data creators to have pool variable
@ -43,7 +43,7 @@ public:
* If nullptr, the variable is not registered. * If nullptr, the variable is not registered.
* @param setReadWriteMode Specify the read-write mode of the pool variable. * @param setReadWriteMode Specify the read-write mode of the pool variable.
*/ */
LocalPoolVar(HasLocalDataPoolIF* hkOwner, lp_id_t poolId, LocalPoolVariable(HasLocalDataPoolIF* hkOwner, lp_id_t poolId,
DataSetIF* dataSet = nullptr, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
@ -64,7 +64,7 @@ public:
* @param setReadWriteMode Specify the read-write mode of the pool variable. * @param setReadWriteMode Specify the read-write mode of the pool variable.
* *
*/ */
LocalPoolVar(object_id_t poolOwner, lp_id_t poolId, LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId,
DataSetIF* dataSet = nullptr, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
/** /**
@ -73,10 +73,10 @@ public:
* @param dataSet * @param dataSet
* @param setReadWriteMode * @param setReadWriteMode
*/ */
LocalPoolVar(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr, LocalPoolVariable(gp_id_t globalPoolId, DataSetIF* dataSet = nullptr,
pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE);
virtual~ LocalPoolVar() {}; virtual~ LocalPoolVariable() {};
/** /**
* @brief This is the local copy of the data pool entry. * @brief This is the local copy of the data pool entry.
@ -118,23 +118,23 @@ public:
ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override;
LocalPoolVar<T> &operator=(const T& newValue); LocalPoolVariable<T> &operator=(const T& newValue);
LocalPoolVar<T> &operator=(const LocalPoolVar<T>& newPoolVariable); LocalPoolVariable<T> &operator=(const LocalPoolVariable<T>& newPoolVariable);
//! Explicit type conversion operator. Allows casting the class to //! Explicit type conversion operator. Allows casting the class to
//! its template type to perform operations on value. //! its template type to perform operations on value.
explicit operator T() const; explicit operator T() const;
bool operator==(const LocalPoolVar<T>& other) const; bool operator==(const LocalPoolVariable<T>& other) const;
bool operator==(const T& other) const; bool operator==(const T& other) const;
bool operator!=(const LocalPoolVar<T>& other) const; bool operator!=(const LocalPoolVariable<T>& other) const;
bool operator!=(const T& other) const; bool operator!=(const T& other) const;
bool operator<(const LocalPoolVar<T>& other) const; bool operator<(const LocalPoolVariable<T>& other) const;
bool operator<(const T& other) const; bool operator<(const T& other) const;
bool operator>(const LocalPoolVar<T>& other) const; bool operator>(const LocalPoolVariable<T>& other) const;
bool operator>(const T& other) const; bool operator>(const T& other) const;
protected: protected:
@ -160,7 +160,7 @@ protected:
// std::ostream is the type for object std::cout // std::ostream is the type for object std::cout
template <typename U> template <typename U>
friend std::ostream& operator<< (std::ostream &out, friend std::ostream& operator<< (std::ostream &out,
const LocalPoolVar<U> &var); const LocalPoolVariable<U> &var);
private: private:
}; };
@ -168,18 +168,18 @@ private:
#include "LocalPoolVariable.tpp" #include "LocalPoolVariable.tpp"
template<class T> template<class T>
using lp_var_t = LocalPoolVar<T>; using lp_var_t = LocalPoolVariable<T>;
using lp_bool_t = LocalPoolVar<uint8_t>; using lp_bool_t = LocalPoolVariable<uint8_t>;
using lp_uint8_t = LocalPoolVar<uint8_t>; using lp_uint8_t = LocalPoolVariable<uint8_t>;
using lp_uint16_t = LocalPoolVar<uint16_t>; using lp_uint16_t = LocalPoolVariable<uint16_t>;
using lp_uint32_t = LocalPoolVar<uint32_t>; using lp_uint32_t = LocalPoolVariable<uint32_t>;
using lp_uint64_t = LocalPoolVar<uint64_t>; using lp_uint64_t = LocalPoolVariable<uint64_t>;
using lp_int8_t = LocalPoolVar<int8_t>; using lp_int8_t = LocalPoolVariable<int8_t>;
using lp_int16_t = LocalPoolVar<int16_t>; using lp_int16_t = LocalPoolVariable<int16_t>;
using lp_int32_t = LocalPoolVar<int32_t>; using lp_int32_t = LocalPoolVariable<int32_t>;
using lp_int64_t = LocalPoolVar<int64_t>; using lp_int64_t = LocalPoolVariable<int64_t>;
using lp_float_t = LocalPoolVar<float>; using lp_float_t = LocalPoolVariable<float>;
using lp_double_t = LocalPoolVar<double>; using lp_double_t = LocalPoolVariable<double>;
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ */ #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVARIABLE_H_ */

View File

@ -6,32 +6,32 @@
#endif #endif
template<typename T> template<typename T>
inline LocalPoolVar<T>::LocalPoolVar(HasLocalDataPoolIF* hkOwner, inline LocalPoolVariable<T>::LocalPoolVariable(HasLocalDataPoolIF* hkOwner,
lp_id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode): lp_id_t poolId, DataSetIF* dataSet, pool_rwm_t setReadWriteMode):
LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {} LocalPoolObjectBase(poolId, hkOwner, dataSet, setReadWriteMode) {}
template<typename T> template<typename T>
inline LocalPoolVar<T>::LocalPoolVar(object_id_t poolOwner, lp_id_t poolId, inline LocalPoolVariable<T>::LocalPoolVariable(object_id_t poolOwner, lp_id_t poolId,
DataSetIF *dataSet, pool_rwm_t setReadWriteMode): DataSetIF *dataSet, pool_rwm_t setReadWriteMode):
LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {} LocalPoolObjectBase(poolOwner, poolId, dataSet, setReadWriteMode) {}
template<typename T> template<typename T>
inline LocalPoolVar<T>::LocalPoolVar(gp_id_t globalPoolId, DataSetIF *dataSet, inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId, DataSetIF *dataSet,
pool_rwm_t setReadWriteMode): pool_rwm_t setReadWriteMode):
LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId, LocalPoolObjectBase(globalPoolId.objectId, globalPoolId.localPoolId,
dataSet, setReadWriteMode){} dataSet, setReadWriteMode){}
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVar<T>::read(dur_millis_t lockTimeout) { inline ReturnValue_t LocalPoolVariable<T>::read(dur_millis_t lockTimeout) {
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING,
lockTimeout); lockTimeout);
return readWithoutLock(); return readWithoutLock();
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVar<T>::readWithoutLock() { inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_WRITE) { if(readWriteMode == pool_rwm_t::VAR_WRITE) {
sif::debug << "LocalPoolVar: Invalid read write " sif::debug << "LocalPoolVar: Invalid read write "
"mode for read() call." << std::endl; "mode for read() call." << std::endl;
@ -53,14 +53,14 @@ inline ReturnValue_t LocalPoolVar<T>::readWithoutLock() {
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVar<T>::commit(dur_millis_t lockTimeout) { inline ReturnValue_t LocalPoolVariable<T>::commit(dur_millis_t lockTimeout) {
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING,
lockTimeout); lockTimeout);
return commitWithoutLock(); return commitWithoutLock();
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVar<T>::commitWithoutLock() { inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
if(readWriteMode == pool_rwm_t::VAR_READ) { if(readWriteMode == pool_rwm_t::VAR_READ) {
sif::debug << "LocalPoolVar: Invalid read write " sif::debug << "LocalPoolVar: Invalid read write "
"mode for commit() call." << std::endl; "mode for commit() call." << std::endl;
@ -81,88 +81,88 @@ inline ReturnValue_t LocalPoolVar<T>::commitWithoutLock() {
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVar<T>::serialize(uint8_t** buffer, size_t* size, inline ReturnValue_t LocalPoolVariable<T>::serialize(uint8_t** buffer, size_t* size,
const size_t max_size, SerializeIF::Endianness streamEndianness) const { const size_t max_size, SerializeIF::Endianness streamEndianness) const {
return SerializeAdapter::serialize(&value, return SerializeAdapter::serialize(&value,
buffer, size ,max_size, streamEndianness); buffer, size ,max_size, streamEndianness);
} }
template<typename T> template<typename T>
inline size_t LocalPoolVar<T>::getSerializedSize() const { inline size_t LocalPoolVariable<T>::getSerializedSize() const {
return SerializeAdapter::getSerializedSize(&value); return SerializeAdapter::getSerializedSize(&value);
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVar<T>::deSerialize(const uint8_t** buffer, inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer,
size_t* size, SerializeIF::Endianness streamEndianness) { size_t* size, SerializeIF::Endianness streamEndianness) {
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
} }
template<typename T> template<typename T>
inline std::ostream& operator<< (std::ostream &out, inline std::ostream& operator<< (std::ostream &out,
const LocalPoolVar<T> &var) { const LocalPoolVariable<T> &var) {
out << var.value; out << var.value;
return out; return out;
} }
template<typename T> template<typename T>
inline LocalPoolVar<T>::operator T() const { inline LocalPoolVariable<T>::operator T() const {
return value; return value;
} }
template<typename T> template<typename T>
inline LocalPoolVar<T> & LocalPoolVar<T>::operator=(const T& newValue) { inline LocalPoolVariable<T> & LocalPoolVariable<T>::operator=(const T& newValue) {
value = newValue; value = newValue;
return *this; return *this;
} }
template<typename T> template<typename T>
inline LocalPoolVar<T>& LocalPoolVar<T>::operator =( inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator =(
const LocalPoolVar<T>& newPoolVariable) { const LocalPoolVariable<T>& newPoolVariable) {
value = newPoolVariable.value; value = newPoolVariable.value;
return *this; return *this;
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator ==(const LocalPoolVar<T> &other) const { inline bool LocalPoolVariable<T>::operator ==(const LocalPoolVariable<T> &other) const {
return this->value == other.value; return this->value == other.value;
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator ==(const T &other) const { inline bool LocalPoolVariable<T>::operator ==(const T &other) const {
return this->value == other; return this->value == other;
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator !=(const LocalPoolVar<T> &other) const { inline bool LocalPoolVariable<T>::operator !=(const LocalPoolVariable<T> &other) const {
return not (*this == other); return not (*this == other);
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator !=(const T &other) const { inline bool LocalPoolVariable<T>::operator !=(const T &other) const {
return not (*this == other); return not (*this == other);
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator <(const LocalPoolVar<T> &other) const { inline bool LocalPoolVariable<T>::operator <(const LocalPoolVariable<T> &other) const {
return this->value < other.value; return this->value < other.value;
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator <(const T &other) const { inline bool LocalPoolVariable<T>::operator <(const T &other) const {
return this->value < other; return this->value < other;
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator >(const LocalPoolVar<T> &other) const { inline bool LocalPoolVariable<T>::operator >(const LocalPoolVariable<T> &other) const {
return not (*this < other); return not (*this < other);
} }
template<typename T> template<typename T>
inline bool LocalPoolVar<T>::operator >(const T &other) const { inline bool LocalPoolVariable<T>::operator >(const T &other) const {
return not (*this < other); return not (*this < other);
} }

View File

@ -15,12 +15,6 @@
//! Can be used to enable additional debugging printouts for developing the FSFW //! Can be used to enable additional debugging printouts for developing the FSFW
#define FSFW_PRINT_VERBOSITY_LEVEL 0 #define FSFW_PRINT_VERBOSITY_LEVEL 0
//! Defines the FIFO depth of each commanding service base which
//! also determines how many commands a CSB service can handle in one cycle
//! simulataneously. This will increase the required RAM for
//! each CSB service !
#define FSFW_CSB_FIFO_DEPTH 6
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
//! additional output which requires the translation files translateObjects //! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiled source files) //! and translateEvents (and their compiled source files)
@ -29,8 +23,8 @@
#if FSFW_OBJ_EVENT_TRANSLATION == 1 #if FSFW_OBJ_EVENT_TRANSLATION == 1
//! Specify whether info events are printed too. //! Specify whether info events are printed too.
#define FSFW_DEBUG_INFO 1 #define FSFW_DEBUG_INFO 1
#include <translateObjects.h> #include "objects/translateObjects.h"
#include <translateEvents.h> #include "events/translateEvents.h"
#else #else
#endif #endif
@ -50,6 +44,12 @@ static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8;
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240; static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120; static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120; static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
//! Defines the FIFO depth of each commanding service base which
//! also determines how many commands a CSB service can handle in one cycle
//! simulataneously. This will increase the required RAM for
//! each CSB service !
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
} }
#endif /* CONFIG_FSFWCONFIG_H_ */ #endif /* CONFIG_FSFWCONFIG_H_ */

View File

@ -3,6 +3,10 @@
#include "OBSWVersion.h" #include "OBSWVersion.h"
#include "objects/systemObjectList.h"
#include "events/subsystemIdRanges.h"
#include "returnvalues/classIds.h"
#ifdef __cplusplus #ifdef __cplusplus
namespace config { namespace config {
#endif #endif

View File

@ -926,11 +926,6 @@ void DeviceHandlerBase::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
setMode(getBaseMode(mode)); setMode(getBaseMode(mode));
} }
uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom,
Mode_t modeTo) {
return 0;
}
ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) { ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) {
if(powerSwitcher == nullptr) { if(powerSwitcher == nullptr) {
return NO_SWITCH; return NO_SWITCH;
@ -1459,3 +1454,11 @@ DeviceCommandId_t DeviceHandlerBase::getPendingCommand() const {
} }
return DeviceHandlerIF::NO_COMMAND; return DeviceHandlerIF::NO_COMMAND;
} }
void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() {
for(const auto& reply: deviceReplyMap) {
if(reply.second.dataSet != nullptr) {
reply.second.dataSet->setValidity(false, true);
}
}
}

View File

@ -254,9 +254,10 @@ protected:
* *
* @param[out] id the device command id that has been built * @param[out] id the device command id that has been built
* @return * @return
* - @c RETURN_OK to send command after setting #rawPacket and #rawPacketLen. * - @c RETURN_OK to send command after setting #rawPacket and
* - @c NOTHING_TO_SEND when no command is to be sent. * #rawPacketLen.
* - Anything else triggers an even with the returnvalue as a parameter. * - @c NOTHING_TO_SEND when no command is to be sent.
* - Anything else triggers an even with the returnvalue as a parameter.
*/ */
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0; virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0;
@ -273,7 +274,8 @@ protected:
* and filling them in doStartUp(), doShutDown() and doTransition() so no * and filling them in doStartUp(), doShutDown() and doTransition() so no
* modes have to be checked here. * modes have to be checked here.
* *
* #rawPacket and #rawPacketLen must be set by this method to the packet to be sent. * #rawPacket and #rawPacketLen must be set by this method to the
* packet to be sent.
* *
* @param[out] id the device command id built * @param[out] id the device command id built
* @return * @return
@ -284,19 +286,23 @@ protected:
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0; virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0;
/** /**
* @brief Build a device command packet from data supplied by a direct command. * @brief Build a device command packet from data supplied by a
* direct command.
* *
* @details * @details
* #rawPacket and #rawPacketLen should be set by this method to the packet to be sent. * #rawPacket and #rawPacketLen should be set by this method to the packet
* The existence of the command in the command map and the command size check * to be sent. The existence of the command in the command map and the
* against 0 are done by the base class. * command size check against 0 are done by the base class.
* *
* @param deviceCommand the command to build, already checked against deviceCommandMap * @param deviceCommand the command to build, already checked against
* deviceCommandMap
* @param commandData pointer to the data from the direct command * @param commandData pointer to the data from the direct command
* @param commandDataLen length of commandData * @param commandDataLen length of commandData
* @return * @return
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen have been set. * - @c RETURN_OK to send command after #rawPacket and #rawPacketLen
* - Anything else triggers an event with the returnvalue as a parameter * have been set.
* - Anything else triggers an event with the
* returnvalue as a parameter
*/ */
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand, virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData, size_t commandDataLen) = 0; const uint8_t * commandData, size_t commandDataLen) = 0;
@ -484,7 +490,7 @@ protected:
* @param modeTo * @param modeTo
* @return time in ms * @return time in ms
*/ */
virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo); virtual uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) = 0;
/** /**
* Return the switches connected to the device. * Return the switches connected to the device.
@ -681,7 +687,7 @@ protected:
//! The dataset used to access housekeeping data related to the //! The dataset used to access housekeeping data related to the
//! respective device reply. Will point to a dataset held by //! respective device reply. Will point to a dataset held by
//! the child handler (if one is specified) //! the child handler (if one is specified)
LocalPoolDataSetBase* dataSet; LocalPoolDataSetBase* dataSet = nullptr;
//! The command that expects this reply. //! The command that expects this reply.
DeviceCommandMap::iterator command; DeviceCommandMap::iterator command;
}; };
@ -743,6 +749,17 @@ protected:
//!< Object which may be the root cause of an identified fault. //!< Object which may be the root cause of an identified fault.
static object_id_t defaultFdirParentId; static object_id_t defaultFdirParentId;
/**
* @brief Set all datapool variables that are update periodically in
* normal mode invalid
* @details
* The default implementation will set all datasets which have been added
* in #fillCommandAndReplyMap to invalid. It will also set all pool
* variables inside the dataset to invalid. The user can override this
* method optionally.
*/
virtual void setNormalDatapoolEntriesInvalid();
/** /**
* Helper function to get pending command. This is useful for devices * Helper function to get pending command. This is useful for devices
* like SPI sensors to identify the last sent command. * like SPI sensors to identify the last sent command.
@ -785,7 +802,6 @@ protected:
* *
* The submode is left unchanged. * The submode is left unchanged.
* *
*
* @param newMode * @param newMode
*/ */
void setMode(Mode_t newMode); void setMode(Mode_t newMode);
@ -838,8 +854,6 @@ protected:
virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom); virtual void doTransition(Mode_t modeFrom, Submode_t subModeFrom);
/** /**
* Is the combination of mode and submode valid?
*
* @param mode * @param mode
* @param submode * @param submode
* @return * @return
@ -850,13 +864,10 @@ protected:
Submode_t submode); Submode_t submode);
/** /**
* Get the Rmap action for the current step. * Get the communication action for the current step.
*
* The step number can be read from #pstStep. * The step number can be read from #pstStep.
* * @return The communication action to execute in this step
* @return The Rmap action to execute in this step
*/ */
virtual CommunicationAction getComAction(); virtual CommunicationAction getComAction();
/** /**
@ -898,8 +909,8 @@ protected:
* It gets space in the #IPCStore, copies data there, then sends a raw reply * It gets space in the #IPCStore, copies data there, then sends a raw reply
* containing the store address. * containing the store address.
* *
* This method is virtual, as the STR has a different channel to send * This method is virtual, as devices can have different channels to send
* raw replies and overwrites it accordingly. * raw replies
* *
* @param data data to send * @param data data to send
* @param len length of @c data * @param len length of @c data
@ -918,7 +929,7 @@ protected:
void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len); void replyRawReplyIfnotWiretapped(const uint8_t *data, size_t len);
/** /**
* notify child about mode change * @brief Notify child about mode change.
*/ */
virtual void modeChanged(void); virtual void modeChanged(void);
@ -950,8 +961,7 @@ protected:
DeviceCommandId_t alternateReplyID = 0); DeviceCommandId_t alternateReplyID = 0);
/** /**
* get the state of the PCDU switches in the datapool * Get the state of the PCDU switches in the local datapool
*
* @return * @return
* - @c PowerSwitchIF::SWITCH_ON if all switches specified * - @c PowerSwitchIF::SWITCH_ON if all switches specified
* by #switches are on * by #switches are on
@ -961,15 +971,6 @@ protected:
*/ */
ReturnValue_t getStateOfSwitches(void); ReturnValue_t getStateOfSwitches(void);
/**
* @brief Set all datapool variables that are update periodically in
* normal mode invalid
* @details TODO: Use local pools
* Child classes should provide an implementation which sets all those
* variables invalid which are set periodically during any normal mode.
*/
virtual void setNormalDatapoolEntriesInvalid() = 0;
/** /**
* build a list of sids and pass it to the #hkSwitcher * build a list of sids and pass it to the #hkSwitcher
*/ */

View File

@ -131,7 +131,7 @@ public:
// Standard codes used in interpretDeviceReply // Standard codes used in interpretDeviceReply
static const ReturnValue_t DEVICE_DID_NOT_EXECUTE = MAKE_RETURN_CODE(0xC0); //the device reported, that it did not execute the command static const ReturnValue_t DEVICE_DID_NOT_EXECUTE = MAKE_RETURN_CODE(0xC0); //the device reported, that it did not execute the command
static const ReturnValue_t DEVICE_REPORTED_ERROR = MAKE_RETURN_CODE(0xC1); static const ReturnValue_t DEVICE_REPORTED_ERROR = MAKE_RETURN_CODE(0xC1);
static const ReturnValue_t UNKNOW_DEVICE_REPLY = MAKE_RETURN_CODE(0xC2); //the deviceCommandId reported by scanforReply is unknown static const ReturnValue_t UNKNOWN_DEVICE_REPLY = MAKE_RETURN_CODE(0xC2); //the deviceCommandId reported by scanforReply is unknown
static const ReturnValue_t DEVICE_REPLY_INVALID = MAKE_RETURN_CODE(0xC3); //syntax etc is correct but still not ok, eg parameters where none are expected static const ReturnValue_t DEVICE_REPLY_INVALID = MAKE_RETURN_CODE(0xC3); //syntax etc is correct but still not ok, eg parameters where none are expected
// Standard codes used in buildCommandFromCommand // Standard codes used in buildCommandFromCommand

21
doc/README-config.md Normal file
View File

@ -0,0 +1,21 @@
## 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.
### 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;
}
```

50
doc/README-core.md Normal file
View File

@ -0,0 +1,50 @@
## 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.
``` c++
template <typename T> 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

View File

@ -0,0 +1 @@
## FSFW DeviceHandlers

View File

@ -1,4 +1,4 @@
#include "../ipc/CommandMessageCleaner.h" #include "CommandMessageCleaner.h"
#include "../devicehandlers/DeviceHandlerMessage.h" #include "../devicehandlers/DeviceHandlerMessage.h"
#include "../health/HealthMessage.h" #include "../health/HealthMessage.h"
@ -7,11 +7,12 @@
#include "../monitoring/MonitoringMessage.h" #include "../monitoring/MonitoringMessage.h"
#include "../subsystem/modes/ModeSequenceMessage.h" #include "../subsystem/modes/ModeSequenceMessage.h"
#include "../tmstorage/TmStoreMessage.h" #include "../tmstorage/TmStoreMessage.h"
#include "../housekeeping/HousekeepingMessage.h"
#include "../parameters/ParameterMessage.h" #include "../parameters/ParameterMessage.h"
void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) { void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) {
switch(message->getMessageType()){ switch(message->getMessageType()){
case messagetypes::MODE_COMMAND: case messagetypes::MODE_COMMAND:
ModeMessage::clear(message); ModeMessage::clear(message);
break; break;
case messagetypes::HEALTH_COMMAND: case messagetypes::HEALTH_COMMAND:
@ -38,6 +39,9 @@ void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) {
case messagetypes::PARAMETER: case messagetypes::PARAMETER:
ParameterMessage::clear(message); ParameterMessage::clear(message);
break; break;
case messagetypes::HOUSEKEEPING:
HousekeepingMessage::clear(message);
break;
default: default:
messagetypes::clearMissionMessage(message); messagetypes::clearMissionMessage(message);
break; break;

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ #ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ #define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
#include <fsfw/ipc/messageQueueDefinitions.h> #include "messageQueueDefinitions.h"
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_IPC_MUTEXFACTORY_H_ #ifndef FSFW_IPC_MUTEXFACTORY_H_
#define FRAMEWORK_IPC_MUTEXFACTORY_H_ #define FSFW_IPC_MUTEXFACTORY_H_
#include "MutexIF.h" #include "MutexIF.h"
/** /**
@ -31,4 +31,4 @@ private:
#endif /* FRAMEWORK_IPC_MUTEXFACTORY_H_ */ #endif /* FSFW_IPC_MUTEXFACTORY_H_ */

View File

@ -16,8 +16,8 @@ public:
<< timeoutMs << " milliseconds!" << std::endl; << timeoutMs << " milliseconds!" << std::endl;
} }
else if(status != HasReturnvaluesIF::RETURN_OK){ else if(status != HasReturnvaluesIF::RETURN_OK){
sif::error << "MutexHelper: Lock of Mutex failed with code " << sif::error << "MutexHelper: Lock of Mutex failed with code "
status << std::endl; << status << std::endl;
} }
} }

View File

@ -72,7 +72,7 @@ protected:
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
LocalPoolVar<T> poolVariable; LocalPoolVariable<T> poolVariable;
}; };
#endif /* FSFW_MONITORING_MONITORBASE_H_ */ #endif /* FSFW_MONITORING_MONITORBASE_H_ */

View File

@ -1,4 +1,4 @@
#include "../../osal/linux/BinarySemaphore.h" #include "BinarySemaphore.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
extern "C" { extern "C" {

View File

@ -76,25 +76,25 @@ timeval Clock::getUptime() {
ReturnValue_t Clock::getUptime(timeval* uptime) { ReturnValue_t Clock::getUptime(timeval* uptime) {
//TODO This is not posix compatible and delivers only seconds precision //TODO This is not posix compatible and delivers only seconds precision
// is the OS not called Linux? // Linux specific file read but more precise.
//Linux specific file read but more precise
double uptimeSeconds; double uptimeSeconds;
if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){ if(std::ifstream("/proc/uptime",std::ios::in) >> uptimeSeconds){
uptime->tv_sec = uptimeSeconds; uptime->tv_sec = uptimeSeconds;
uptime->tv_usec = uptimeSeconds *(double) 1e6 - (uptime->tv_sec *1e6); uptime->tv_usec = uptimeSeconds *(double) 1e6 - (uptime->tv_sec *1e6);
} }
return HasReturnvaluesIF::RETURN_OK;
}
//TODO This is not posix compatible and delivers only seconds precision // Wait for new FSFW Clock function delivering seconds uptime.
// I suggest this is moved into another clock function which will //uint32_t Clock::getUptimeSeconds() {
// deliver second precision later. // //TODO This is not posix compatible and delivers only seconds precision
// struct sysinfo sysInfo; // struct sysinfo sysInfo;
// int result = sysinfo(&sysInfo); // int result = sysinfo(&sysInfo);
// if(result != 0){ // if(result != 0){
// return HasReturnvaluesIF::RETURN_FAILED; // return HasReturnvaluesIF::RETURN_FAILED;
// } // }
// return sysInfo.uptime; // return sysInfo.uptime;
return HasReturnvaluesIF::RETURN_OK; //}
}
ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) { ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) {
timeval uptime; timeval uptime;

View File

@ -3,6 +3,7 @@
#include "../../objectmanager/ObjectManagerIF.h" #include "../../objectmanager/ObjectManagerIF.h"
#include <fstream> #include <fstream>
#include <fcntl.h> /* For O_* constants */ #include <fcntl.h> /* For O_* constants */
#include <sys/stat.h> /* For mode constants */ #include <sys/stat.h> /* For mode constants */
#include <cstring> #include <cstring>

View File

@ -1,10 +1,9 @@
#ifndef OS_LINUX_MUTEX_H_ #ifndef FSFW_OSAL_LINUX_MUTEX_H_
#define OS_LINUX_MUTEX_H_ #define FSFW_OSAL_LINUX_MUTEX_H_
#include "../../ipc/MutexIF.h" #include "../../ipc/MutexIF.h"
#include <pthread.h> #include <pthread.h>
class Mutex : public MutexIF { class Mutex : public MutexIF {
public: public:
Mutex(); Mutex();

View File

@ -1,6 +1,7 @@
#include "../../ipc/MutexFactory.h"
#include "Mutex.h" #include "Mutex.h"
#include "../../ipc/MutexFactory.h"
//TODO: Different variant than the lazy loading in QueueFactory. What's better and why? //TODO: Different variant than the lazy loading in QueueFactory. What's better and why?
MutexFactory* MutexFactory::factoryInstance = new MutexFactory(); MutexFactory* MutexFactory::factoryInstance = new MutexFactory();

View File

@ -1,5 +1,7 @@
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include "PosixThread.h" #include "PosixThread.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
#include <cstring> #include <cstring>
#include <errno.h> #include <errno.h>
@ -149,8 +151,10 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
status = pthread_attr_setstack(&attributes, stackPointer, stackSize); status = pthread_attr_setstack(&attributes, stackPointer, stackSize);
if(status != 0){ if(status != 0){
sif::error << "Posix Thread attribute setStack failed with: " << sif::error << "PosixThread::createTask: pthread_attr_setstack "
strerror(status) << std::endl; " failed with: " << strerror(status) << std::endl;
sif::error << "Make sure the specified stack size is valid and is "
"larger than the minimum allowed stack size." << std::endl;
} }
status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED); status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED);

View File

@ -1,6 +1,7 @@
#include "../../tasks/SemaphoreFactory.h"
#include "BinarySemaphore.h" #include "BinarySemaphore.h"
#include "CountingSemaphore.h" #include "CountingSemaphore.h"
#include "../../tasks/SemaphoreFactory.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr; SemaphoreFactory* SemaphoreFactory::factoryInstance = nullptr;

View File

@ -1,5 +1,6 @@
#include "FixedTimeslotTask.h" #include "FixedTimeslotTask.h"
#include "PeriodicPosixTask.h" #include "PeriodicPosixTask.h"
#include "../../tasks/TaskFactory.h" #include "../../tasks/TaskFactory.h"
#include "../../returnvalues/HasReturnvaluesIF.h" #include "../../returnvalues/HasReturnvaluesIF.h"

View File

@ -1,6 +1,7 @@
#include "Timer.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
#include <errno.h> #include <errno.h>
#include "Timer.h"
Timer::Timer() { Timer::Timer() {
sigevent sigEvent; sigevent sigEvent;

View File

@ -0,0 +1,295 @@
#include "Service3Housekeeping.h"
#include "servicepackets/Service3Packets.h"
#include "../datapoollocal/HasLocalDataPoolIF.h"
Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid,
uint8_t serviceId):
CommandingServiceBase(objectId, apid, serviceId,
NUM_OF_PARALLEL_COMMANDS, COMMAND_TIMEOUT_SECONDS) {}
Service3Housekeeping::~Service3Housekeeping() {}
ReturnValue_t Service3Housekeeping::isValidSubservice(uint8_t subservice) {
switch(static_cast<Subservice>(subservice)) {
case Subservice::ENABLE_PERIODIC_HK_REPORT_GENERATION:
case Subservice::DISABLE_PERIODIC_HK_REPORT_GENERATION:
case Subservice::ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION:
case Subservice::DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION:
case Subservice::REPORT_HK_REPORT_STRUCTURES:
case Subservice::REPORT_DIAGNOSTICS_REPORT_STRUCTURES :
case Subservice::GENERATE_ONE_PARAMETER_REPORT:
case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT:
case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL:
case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL:
return HasReturnvaluesIF::RETURN_OK;
// Telemetry or invalid subservice.
case Subservice::HK_DEFINITIONS_REPORT:
case Subservice::DIAGNOSTICS_DEFINITION_REPORT:
case Subservice::HK_REPORT:
case Subservice::DIAGNOSTICS_REPORT:
default:
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
}
}
ReturnValue_t Service3Housekeeping::getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen,
MessageQueueId_t *id, object_id_t *objectId) {
ReturnValue_t result = checkAndAcquireTargetID(objectId,tcData,tcDataLen);
if(result != RETURN_OK) {
return result;
}
return checkInterfaceAndAcquireMessageQueue(id,objectId);
}
ReturnValue_t Service3Housekeeping::checkAndAcquireTargetID(
object_id_t* objectIdToSet, const uint8_t* tcData, size_t tcDataLen) {
if(SerializeAdapter::deSerialize(objectIdToSet, &tcData, &tcDataLen,
SerializeIF::Endianness::BIG) != HasReturnvaluesIF::RETURN_OK) {
return CommandingServiceBase::INVALID_TC;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
// check HasLocalDataPoolIF property of target
HasLocalDataPoolIF* possibleTarget =
objectManager->get<HasLocalDataPoolIF>(*objectId);
if(possibleTarget == nullptr){
return CommandingServiceBase::INVALID_OBJECT;
}
*messageQueueToSet = possibleTarget->getCommandQueue();
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
uint32_t *state, object_id_t objectId) {
switch(static_cast<Subservice>(subservice)) {
case Subservice::ENABLE_PERIODIC_HK_REPORT_GENERATION:
return prepareReportingTogglingCommand(message, objectId, true, false,
tcData, tcDataLen);
case Subservice::DISABLE_PERIODIC_HK_REPORT_GENERATION:
return prepareReportingTogglingCommand(message, objectId, false, false,
tcData, tcDataLen);
case Subservice::ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION:
return prepareReportingTogglingCommand(message, objectId, true, true,
tcData, tcDataLen);
case Subservice::DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION:
return prepareReportingTogglingCommand(message, objectId, false, true,
tcData, tcDataLen);
case Subservice::REPORT_HK_REPORT_STRUCTURES:
return prepareStructureReportingCommand(message, objectId, false, tcData,
tcDataLen);
case Subservice::REPORT_DIAGNOSTICS_REPORT_STRUCTURES:
return prepareStructureReportingCommand(message, objectId, true, tcData,
tcDataLen);
case Subservice::GENERATE_ONE_PARAMETER_REPORT:
return prepareOneShotReportCommand(message, objectId, false,
tcData, tcDataLen);
case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT:
return prepareOneShotReportCommand(message, objectId, true,
tcData, tcDataLen);
case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL:
return prepareCollectionIntervalModificationCommand(message, objectId,
false, tcData, tcDataLen);
case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL:
return prepareCollectionIntervalModificationCommand(message, objectId,
true, tcData, tcDataLen);
case Subservice::HK_DEFINITIONS_REPORT:
case Subservice::DIAGNOSTICS_DEFINITION_REPORT:
case Subservice::HK_REPORT:
case Subservice::DIAGNOSTICS_REPORT:
// Those are telemetry packets.
return CommandingServiceBase::INVALID_TC;
default:
// should never happen, subservice was already checked.
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand(
CommandMessage *command, object_id_t objectId,
bool enableReporting, bool isDiagnostics,
const uint8_t* tcData, size_t tcDataLen) {
if(tcDataLen < sizeof(sid_t)) {
// TC data should consist of object ID and set ID.
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
HousekeepingMessage::setToggleReportingCommand(command, targetSid,
enableReporting, isDiagnostics);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand(
CommandMessage *command, object_id_t objectId, bool isDiagnostics,
const uint8_t* tcData, size_t tcDataLen) {
if(tcDataLen < sizeof(sid_t)) {
// TC data should consist of object ID and set ID.
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
HousekeepingMessage::setStructureReportingCommand(command, targetSid,
isDiagnostics);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand(
CommandMessage *command, object_id_t objectId, bool isDiagnostics,
const uint8_t *tcData, size_t tcDataLen) {
if(tcDataLen < sizeof(sid_t)) {
// TC data should consist of object ID and set ID.
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
HousekeepingMessage::setOneShotReportCommand(command, targetSid,
isDiagnostics);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand(
CommandMessage *command, object_id_t objectId, bool isDiagnostics,
const uint8_t *tcData, size_t tcDataLen) {
if(tcDataLen < sizeof(sid_t) + sizeof(float)) {
// SID plus the size of the new collection intervL.
return CommandingServiceBase::INVALID_TC;
}
sid_t targetSid = buildSid(objectId, &tcData, &tcDataLen);
float newCollectionInterval = 0;
SerializeAdapter::deSerialize(&newCollectionInterval, &tcData, &tcDataLen,
SerializeIF::Endianness::BIG);
HousekeepingMessage::setCollectionIntervalModificationCommand(command,
targetSid, newCollectionInterval, isDiagnostics);
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state,
CommandMessage* optionalNextCommand, object_id_t objectId,
bool *isStep) {
Command_t command = reply->getCommand();
switch(command) {
case(HousekeepingMessage::HK_REPORT): {
ReturnValue_t result = generateHkReply(reply,
static_cast<uint8_t>(Subservice::HK_REPORT));
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return CommandingServiceBase::EXECUTION_COMPLETE;
}
case(HousekeepingMessage::DIAGNOSTICS_REPORT): {
ReturnValue_t result = generateHkReply(reply,
static_cast<uint8_t>(Subservice::DIAGNOSTICS_REPORT));
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return CommandingServiceBase::EXECUTION_COMPLETE;
}
case(HousekeepingMessage::HK_DEFINITIONS_REPORT): {
return generateHkReply(reply, static_cast<uint8_t>(
Subservice::HK_DEFINITIONS_REPORT));
break;
}
case(HousekeepingMessage::DIAGNOSTICS_DEFINITION_REPORT): {
return generateHkReply(reply, static_cast<uint8_t>(
Subservice::DIAGNOSTICS_DEFINITION_REPORT));
break;
}
case(HousekeepingMessage::HK_REQUEST_SUCCESS): {
return CommandingServiceBase::EXECUTION_COMPLETE;
}
case(HousekeepingMessage::HK_REQUEST_FAILURE): {
failureParameter1 = objectId;
ReturnValue_t error = HasReturnvaluesIF::RETURN_FAILED;
HousekeepingMessage::getHkRequestFailureReply(reply,&error);
failureParameter2 = error;
return CommandingServiceBase::EXECUTION_COMPLETE;
}
default:
sif::error << "Service3Housekeeping::handleReply: Invalid reply with "
<< "reply command " << command << "!" << std::endl;
return CommandingServiceBase::INVALID_REPLY;
}
return HasReturnvaluesIF::RETURN_OK;
}
void Service3Housekeeping::handleUnrequestedReply(
CommandMessage* reply) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
Command_t command = reply->getCommand();
switch(command) {
case(HousekeepingMessage::DIAGNOSTICS_REPORT): {
result = generateHkReply(reply,
static_cast<uint8_t>(Subservice::DIAGNOSTICS_REPORT));
break;
}
case(HousekeepingMessage::HK_REPORT): {
result = generateHkReply(reply,
static_cast<uint8_t>(Subservice::HK_REPORT));
break;
}
default:
sif::error << "Service3Housekeeping::handleUnrequestedReply: Invalid "
<< "reply with " << "reply command " << command << "!"
<< std::endl;
return;
}
if(result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error
sif::debug << "Service3Housekeeping::handleUnrequestedReply:"
<< "Could not generate reply!" << std::endl;
}
}
MessageQueueId_t Service3Housekeeping::getHkQueue() const {
return commandQueue->getId();
}
ReturnValue_t Service3Housekeeping::generateHkReply(
const CommandMessage* hkMessage, uint8_t subserviceId) {
store_address_t storeId;
sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId);
auto resultPair = IPCStore->getData(storeId);
if(resultPair.first != HasReturnvaluesIF::RETURN_OK) {
return resultPair.first;
}
HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size());
return sendTmPacket(static_cast<uint8_t>(subserviceId),
hkPacket.hkData, hkPacket.hkSize, nullptr, 0);
}
sid_t Service3Housekeeping::buildSid(object_id_t objectId,
const uint8_t** tcData, size_t* tcDataLen) {
sid_t targetSid;
targetSid.objectId = objectId;
// skip deserialization of object ID, was already done.
*tcData += sizeof(object_id_t);
*tcDataLen -= sizeof(object_id_t);
// size check is expected to be performed beforehand!
SerializeAdapter::deSerialize(&targetSid.ownerSetId, tcData, tcDataLen,
SerializeIF::Endianness::BIG);
return targetSid;
}

105
pus/Service3Housekeeping.h Normal file
View File

@ -0,0 +1,105 @@
#ifndef FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_
#define FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_
#include "../housekeeping/AcceptsHkPacketsIF.h"
#include "../housekeeping/HousekeepingMessage.h"
#include "../tmtcservices/CommandingServiceBase.h"
/**
* @brief Manges spacecraft housekeeping reports and
* sends pool variables (temperature, GPS data ...) to ground.
*
* @details Full Documentation: ECSS-E70-41A or ECSS-E-ST-70-41C.
* Implementation based on PUS-C
*
* The housekeeping service type provides means to control and adapt the
* spacecraft reporting plan according to the mission phases.
* The housekeeping service type provides the visibility of any
* on-board parameters assembled in housekeeping parameter report structures
* or diagnostic parameter report structures as required for the mission.
* The parameter report structures used by the housekeeping service can
* be predefined on-board or created when needed.
*
* @author R. Mueller
* @ingroup pus_services
*/
class Service3Housekeeping: public CommandingServiceBase,
public AcceptsHkPacketsIF {
public:
static constexpr uint8_t NUM_OF_PARALLEL_COMMANDS = 4;
static constexpr uint16_t COMMAND_TIMEOUT_SECONDS = 60;
Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId);
virtual~ Service3Housekeeping();
protected:
/* CSB abstract functions implementation . See CSB documentation. */
ReturnValue_t isValidSubservice(uint8_t subservice) override;
ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
object_id_t *objectId) override;
ReturnValue_t prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
uint32_t *state, object_id_t objectId) override;
ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state,
CommandMessage* optionalNextCommand, object_id_t objectId,
bool *isStep) override;
virtual MessageQueueId_t getHkQueue() const;
private:
enum class Subservice {
ENABLE_PERIODIC_HK_REPORT_GENERATION = 5, //!< [EXPORT] : [TC]
DISABLE_PERIODIC_HK_REPORT_GENERATION = 6, //!< [EXPORT] : [TC]
ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION = 7, //!< [EXPORT] : [TC]
DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION = 8, //!< [EXPORT] : [TC]
//! [EXPORT] : [TC] Report HK structure by supplying SID
REPORT_HK_REPORT_STRUCTURES = 9,
//! [EXPORT] : [TC] Report Diagnostics structure by supplying SID
REPORT_DIAGNOSTICS_REPORT_STRUCTURES = 11,
//! [EXPORT] : [TM] Report corresponding to Subservice 9 TC
HK_DEFINITIONS_REPORT = 10,
//! [EXPORT] : [TM] Report corresponding to Subservice 11 TC
DIAGNOSTICS_DEFINITION_REPORT = 12,
//! [EXPORT] : [TM] Core packet. Contains Housekeeping data
HK_REPORT = 25,
//! [EXPORT] : [TM] Core packet. Contains diagnostics data
DIAGNOSTICS_REPORT = 26,
/* PUS-C */
GENERATE_ONE_PARAMETER_REPORT = 27, //!< [EXPORT] : [TC]
GENERATE_ONE_DIAGNOSTICS_REPORT = 28, //!< [EXPORT] : [TC]
MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL = 31, //!< [EXPORT] : [TC]
MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL = 32, //!< [EXPORT] : [TC]
};
ReturnValue_t checkAndAcquireTargetID(object_id_t* objectIdToSet,
const uint8_t* tcData, size_t tcDataLen);
ReturnValue_t checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId);
ReturnValue_t generateHkReply(const CommandMessage* hkMessage,
uint8_t subserviceId);
ReturnValue_t prepareReportingTogglingCommand(CommandMessage* command,
object_id_t objectId, bool enableReporting, bool isDiagnostics,
const uint8_t* tcData, size_t tcDataLen);
ReturnValue_t prepareStructureReportingCommand(CommandMessage* command,
object_id_t objectId, bool isDiagnostics, const uint8_t* tcData,
size_t tcDataLen);
ReturnValue_t prepareOneShotReportCommand(CommandMessage* command,
object_id_t objectId, bool isDiagnostics, const uint8_t* tcData,
size_t tcDataLen);
ReturnValue_t prepareCollectionIntervalModificationCommand(
CommandMessage* command, object_id_t objectId, bool isDiagnostics,
const uint8_t* tcData, size_t tcDataLen);
void handleUnrequestedReply(CommandMessage* reply) override;
sid_t buildSid(object_id_t objectId, const uint8_t** tcData,
size_t* tcDataLen);
};
#endif /* FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ */

View File

@ -49,7 +49,7 @@ public:
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
if (failureSubtype == TC_VERIFY::PROGRESS_FAILURE) { if (failureSubtype == tc_verification::PROGRESS_FAILURE) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size, result = SerializeAdapter::serialize(&stepNumber, buffer, size,
maxSize, streamEndianness); maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -77,7 +77,7 @@ public:
size_t size = 0; size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId); size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl); size += sizeof(packetSequenceControl);
if(failureSubtype==TC_VERIFY::PROGRESS_FAILURE){ if(failureSubtype==tc_verification::PROGRESS_FAILURE){
size += SerializeAdapter::getSerializedSize(&stepNumber); size += SerializeAdapter::getSerializedSize(&stepNumber);
} }
size += SerializeAdapter::getSerializedSize(&errorCode); size += SerializeAdapter::getSerializedSize(&errorCode);
@ -131,7 +131,7 @@ public:
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
if (subtype == TC_VERIFY::PROGRESS_SUCCESS) { if (subtype == tc_verification::PROGRESS_SUCCESS) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size, result = SerializeAdapter::serialize(&stepNumber, buffer, size,
maxSize, streamEndianness); maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -145,7 +145,7 @@ public:
size_t size = 0; size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId); size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl); size += sizeof(packetSequenceControl);
if(subtype == TC_VERIFY::PROGRESS_SUCCESS){ if(subtype == tc_verification::PROGRESS_SUCCESS){
size += SerializeAdapter::getSerializedSize(&stepNumber); size += SerializeAdapter::getSerializedSize(&stepNumber);
} }
return size; return size;

View File

@ -0,0 +1,21 @@
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE3PACKETS_H_
#define FSFW_PUS_SERVICEPACKETS_SERVICE3PACKETS_H_
#include <fsfw/housekeeping/HousekeepingMessage.h>
#include <cstdint>
/**
* @brief Subservices 25 and 26: TM packets
* @ingroup spacepackets
*/
class HkPacket { //!< [EXPORT] : [SUBSERVICE] 25, 26
public:
sid_t sid; //!< [EXPORT] : [COMMENT] Structure ID (SID) of housekeeping data.
const uint8_t* hkData; //!< [EXPORT] : [MAXSIZE] Deduced size
size_t hkSize; //!< [EXPORT] : [IGNORE]
HkPacket(sid_t sid, const uint8_t* data, size_t size):
sid(sid), hkData(data), hkSize(size) {}
};
#endif /* FSFW_PUS_SERVICEPACKETS_SERVICE3PACKETS_H_ */

View File

@ -1,305 +0,0 @@
#ifndef FSFW_STORAGEMANAGER_LOCALPOOL_TPP_
#define FSFW_STORAGEMANAGER_LOCALPOOL_TPP_
#ifndef FSFW_STORAGEMANAGER_LOCALPOOL_H_
#error Include LocalPool.h before LocalPool.tpp!
#endif
template<uint8_t NUMBER_OF_POOLS>
inline LocalPool<NUMBER_OF_POOLS>::LocalPool(object_id_t setObjectId,
const uint16_t element_sizes[NUMBER_OF_POOLS],
const uint16_t n_elements[NUMBER_OF_POOLS], bool registered,
bool spillsToHigherPools) :
SystemObject(setObjectId, registered), internalErrorReporter(nullptr),
spillsToHigherPools(spillsToHigherPools)
{
for (uint16_t n = 0; n < NUMBER_OF_POOLS; n++) {
this->element_sizes[n] = element_sizes[n];
this->n_elements[n] = n_elements[n];
store[n] = new uint8_t[n_elements[n] * element_sizes[n]];
size_list[n] = new uint32_t[n_elements[n]];
memset(store[n], 0x00, (n_elements[n] * element_sizes[n]));
//TODO checkme
memset(size_list[n], STORAGE_FREE, (n_elements[n] * sizeof(**size_list)));
}
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::findEmpty(uint16_t pool_index,
uint16_t* element) {
ReturnValue_t status = DATA_STORAGE_FULL;
for (uint16_t foundElement = 0; foundElement < n_elements[pool_index];
foundElement++) {
if (size_list[pool_index][foundElement] == STORAGE_FREE) {
*element = foundElement;
status = RETURN_OK;
break;
}
}
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline void LocalPool<NUMBER_OF_POOLS>::write(store_address_t packet_id,
const uint8_t* data, size_t size) {
uint8_t* ptr;
uint32_t packet_position = getRawPosition(packet_id);
//check size? -> Not necessary, because size is checked before calling this function.
ptr = &store[packet_id.pool_index][packet_position];
memcpy(ptr, data, size);
size_list[packet_id.pool_index][packet_id.packet_index] = size;
}
//Returns page size of 0 in case store_index is illegal
template<uint8_t NUMBER_OF_POOLS>
inline uint32_t LocalPool<NUMBER_OF_POOLS>::getPageSize(uint16_t pool_index) {
if (pool_index < NUMBER_OF_POOLS) {
return element_sizes[pool_index];
} else {
return 0;
}
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::getPoolIndex(
size_t packet_size, uint16_t* poolIndex, uint16_t startAtIndex) {
for (uint16_t n = startAtIndex; n < NUMBER_OF_POOLS; n++) {
//debug << "LocalPool " << getObjectId() << "::getPoolIndex: Pool: " <<
// n << ", Element Size: " << element_sizes[n] << std::endl;
if (element_sizes[n] >= packet_size) {
*poolIndex = n;
return RETURN_OK;
}
}
return DATA_TOO_LARGE;
}
template<uint8_t NUMBER_OF_POOLS>
inline uint32_t LocalPool<NUMBER_OF_POOLS>::getRawPosition(
store_address_t packet_id) {
return packet_id.packet_index * element_sizes[packet_id.pool_index];
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::reserveSpace(
const uint32_t size, store_address_t* address, bool ignoreFault) {
ReturnValue_t status = getPoolIndex(size, &address->pool_index);
if (status != RETURN_OK) {
sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec
<< " )::reserveSpace: Packet too large." << std::endl;
return status;
}
status = findEmpty(address->pool_index, &address->packet_index);
while (status != RETURN_OK && spillsToHigherPools) {
status = getPoolIndex(size, &address->pool_index, address->pool_index + 1);
if (status != RETURN_OK) {
//We don't find any fitting pool anymore.
break;
}
status = findEmpty(address->pool_index, &address->packet_index);
}
if (status == RETURN_OK) {
// if (getObjectId() == objects::IPC_STORE && address->pool_index >= 3) {
// debug << "Reserve: Pool: " << std::dec << address->pool_index <<
// " Index: " << address->packet_index << std::endl;
// }
size_list[address->pool_index][address->packet_index] = size;
} else {
if (!ignoreFault and internalErrorReporter != nullptr) {
internalErrorReporter->storeFull();
}
// error << "LocalPool( " << std::hex << getObjectId() << std::dec
// << " )::reserveSpace: Packet store is full." << std::endl;
}
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline LocalPool<NUMBER_OF_POOLS>::~LocalPool(void) {
for (uint16_t n = 0; n < NUMBER_OF_POOLS; n++) {
delete[] store[n];
delete[] size_list[n];
}
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::addData(
store_address_t* storageId, const uint8_t* data, size_t size,
bool ignoreFault) {
ReturnValue_t status = reserveSpace(size, storageId, ignoreFault);
if (status == RETURN_OK) {
write(*storageId, data, size);
}
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::getFreeElement(
store_address_t* storageId, const size_t size,
uint8_t** p_data, bool ignoreFault) {
ReturnValue_t status = reserveSpace(size, storageId, ignoreFault);
if (status == RETURN_OK) {
*p_data = &store[storageId->pool_index][getRawPosition(*storageId)];
} else {
*p_data = NULL;
}
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline ConstAccessorPair LocalPool<NUMBER_OF_POOLS>::getData(
store_address_t storeId) {
uint8_t* tempData = nullptr;
ConstStorageAccessor constAccessor(storeId, this);
ReturnValue_t status = modifyData(storeId, &tempData, &constAccessor.size_);
constAccessor.constDataPointer = tempData;
return ConstAccessorPair(status, std::move(constAccessor));
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::getData(store_address_t storeId,
ConstStorageAccessor& storeAccessor) {
uint8_t* tempData = nullptr;
ReturnValue_t status = modifyData(storeId, &tempData, &storeAccessor.size_);
storeAccessor.assignStore(this);
storeAccessor.constDataPointer = tempData;
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::getData(
store_address_t packet_id, const uint8_t** packet_ptr, size_t* size) {
uint8_t* tempData = nullptr;
ReturnValue_t status = modifyData(packet_id, &tempData, size);
*packet_ptr = tempData;
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline AccessorPair LocalPool<NUMBER_OF_POOLS>::modifyData(
store_address_t storeId) {
StorageAccessor accessor(storeId, this);
ReturnValue_t status = modifyData(storeId, &accessor.dataPointer,
&accessor.size_);
accessor.assignConstPointer();
return AccessorPair(status, std::move(accessor));
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::modifyData(
store_address_t storeId, StorageAccessor& storeAccessor) {
storeAccessor.assignStore(this);
ReturnValue_t status = modifyData(storeId, &storeAccessor.dataPointer,
&storeAccessor.size_);
storeAccessor.assignConstPointer();
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::modifyData(
store_address_t packet_id, uint8_t** packet_ptr, size_t* size) {
ReturnValue_t status = RETURN_FAILED;
if (packet_id.pool_index >= NUMBER_OF_POOLS) {
return ILLEGAL_STORAGE_ID;
}
if ((packet_id.packet_index >= n_elements[packet_id.pool_index])) {
return ILLEGAL_STORAGE_ID;
}
if (size_list[packet_id.pool_index][packet_id.packet_index]
!= STORAGE_FREE) {
uint32_t packet_position = getRawPosition(packet_id);
*packet_ptr = &store[packet_id.pool_index][packet_position];
*size = size_list[packet_id.pool_index][packet_id.packet_index];
status = RETURN_OK;
} else {
status = DATA_DOES_NOT_EXIST;
}
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::deleteData(
store_address_t packet_id) {
//if (getObjectId() == objects::IPC_STORE && packet_id.pool_index >= 3) {
// debug << "Delete: Pool: " << std::dec << packet_id.pool_index << " Index: "
// << packet_id.packet_index << std::endl;
//}
ReturnValue_t status = RETURN_OK;
uint32_t page_size = getPageSize(packet_id.pool_index);
if ((page_size != 0)
&& (packet_id.packet_index < n_elements[packet_id.pool_index])) {
uint16_t packet_position = getRawPosition(packet_id);
uint8_t* ptr = &store[packet_id.pool_index][packet_position];
memset(ptr, 0, page_size);
//Set free list
size_list[packet_id.pool_index][packet_id.packet_index] = STORAGE_FREE;
} else {
//pool_index or packet_index is too large
sif::error << "LocalPool:deleteData failed." << std::endl;
status = ILLEGAL_STORAGE_ID;
}
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline void LocalPool<NUMBER_OF_POOLS>::clearStore() {
for (uint16_t n = 0; n < NUMBER_OF_POOLS; n++) {
//TODO checkme
memset(size_list[n], STORAGE_FREE, (n_elements[n] * sizeof(**size_list)));
}
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::deleteData(uint8_t* ptr,
size_t size, store_address_t* storeId) {
store_address_t localId;
ReturnValue_t result = ILLEGAL_ADDRESS;
for (uint16_t n = 0; n < NUMBER_OF_POOLS; n++) {
//Not sure if new allocates all stores in order. so better be careful.
if ((store[n] <= ptr) && (&store[n][n_elements[n]*element_sizes[n]]) > ptr) {
localId.pool_index = n;
uint32_t deltaAddress = ptr - store[n];
// Getting any data from the right "block" is ok.
// This is necessary, as IF's sometimes don't point to the first
// element of an object.
localId.packet_index = deltaAddress / element_sizes[n];
result = deleteData(localId);
//if (deltaAddress % element_sizes[n] != 0) {
// error << "Pool::deleteData: address not aligned!" << std::endl;
//}
break;
}
}
if (storeId != NULL) {
*storeId = localId;
}
return result;
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t LocalPool<NUMBER_OF_POOLS>::initialize() {
ReturnValue_t result = SystemObject::initialize();
if (result != RETURN_OK) {
return result;
}
internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
objects::INTERNAL_ERROR_REPORTER);
if (internalErrorReporter == nullptr){
return ObjectManagerIF::INTERNAL_ERR_REPORTER_UNINIT;
}
//Check if any pool size is large than the maximum allowed.
for (uint8_t count = 0; count < NUMBER_OF_POOLS; count++) {
if (element_sizes[count] >= STORAGE_FREE) {
sif::error << "LocalPool::initialize: Pool is too large! "
"Max. allowed size is: " << (STORAGE_FREE - 1) << std::endl;
return StorageManagerIF::POOL_TOO_LARGE;
}
}
return RETURN_OK;
}
#endif /* FSFW_STORAGEMANAGER_LOCALPOOL_TPP_ */

View File

@ -1,56 +0,0 @@
#ifndef FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_
#define FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_
#ifndef FSFW_STORAGEMANAGER_POOLMANAGER_H_
#error Include PoolManager.h before PoolManager.tpp!
#endif
template<uint8_t NUMBER_OF_POOLS>
inline PoolManager<NUMBER_OF_POOLS>::PoolManager(object_id_t setObjectId,
const uint16_t element_sizes[NUMBER_OF_POOLS],
const uint16_t n_elements[NUMBER_OF_POOLS]) :
LocalPool<NUMBER_OF_POOLS>(setObjectId, element_sizes, n_elements, true) {
mutex = MutexFactory::instance()->createMutex();
}
template<uint8_t NUMBER_OF_POOLS>
inline PoolManager<NUMBER_OF_POOLS>::~PoolManager(void) {
MutexFactory::instance()->deleteMutex(mutex);
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::reserveSpace(
const uint32_t size, store_address_t* address, bool ignoreFault) {
MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::reserveSpace(size,
address,ignoreFault);
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(
store_address_t packet_id) {
// debug << "PoolManager( " << translateObject(getObjectId()) <<
// " )::deleteData from store " << packet_id.pool_index <<
// ". id is "<< packet_id.packet_index << std::endl;
MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(packet_id);
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline ReturnValue_t PoolManager<NUMBER_OF_POOLS>::deleteData(uint8_t* buffer,
size_t size, store_address_t* storeId) {
MutexHelper mutexHelper(mutex,MutexIF::WAITING, mutexTimeoutMs);
ReturnValue_t status = LocalPool<NUMBER_OF_POOLS>::deleteData(buffer,
size, storeId);
return status;
}
template<uint8_t NUMBER_OF_POOLS>
inline void PoolManager<NUMBER_OF_POOLS>::setMutexTimeout(
uint32_t mutexTimeoutMs) {
this->mutexTimeout = mutexTimeoutMs;
}
#endif /* FRAMEWORK_STORAGEMANAGER_POOLMANAGER_TPP_ */

View File

@ -77,14 +77,14 @@ ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
tcStatus = queueStatus; tcStatus = queueStatus;
} }
if (tcStatus != RETURN_OK) { if (tcStatus != RETURN_OK) {
this->verifyChannel.sendFailureReport(TC_VERIFY::ACCEPTANCE_FAILURE, this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
currentPacket, tcStatus); currentPacket, tcStatus);
// A failed packet is deleted immediately after reporting, // A failed packet is deleted immediately after reporting,
// otherwise it will block memory. // otherwise it will block memory.
currentPacket->deletePacket(); currentPacket->deletePacket();
return RETURN_FAILED; return RETURN_FAILED;
} else { } else {
this->verifyChannel.sendSuccessReport(TC_VERIFY::ACCEPTANCE_SUCCESS, this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
currentPacket); currentPacket);
return RETURN_OK; return RETURN_OK;
} }

View File

@ -1,9 +1,9 @@
#include "CCSDSTime.h" #include "CCSDSTime.h"
#include <FSFWConfig.h>
#include <cstdio> #include <cstdio>
#include <cinttypes> #include <cinttypes>
#include <cmath> #include <cmath>
#include <FSFWConfig.h>
CCSDSTime::CCSDSTime() { CCSDSTime::CCSDSTime() {
} }
@ -53,8 +53,8 @@ ReturnValue_t CCSDSTime::convertToCcsds(Ccs_mseconds* to,
return RETURN_OK; return RETURN_OK;
} }
ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to,
uint32_t length) { const uint8_t* from, size_t length) {
ReturnValue_t result; ReturnValue_t result;
if (length > 0xFF) { if (length > 0xFF) {
return LENGTH_MISMATCH; return LENGTH_MISMATCH;
@ -72,7 +72,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t*
case CDS: case CDS:
return convertFromCDS(to, from, length); return convertFromCDS(to, from, length);
case CCS: { case CCS: {
uint32_t temp = 0; size_t temp = 0;
return convertFromCCS(to, from, &temp, length); return convertFromCCS(to, from, &temp, length);
} }
@ -81,13 +81,13 @@ ReturnValue_t CCSDSTime::convertFromCcsds(Clock::TimeOfDay_t* to, const uint8_t*
} }
} }
ReturnValue_t CCSDSTime::convertFromCUC(Clock::TimeOfDay_t* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCUC(Clock::TimeOfDay_t* to,
uint8_t length) { const uint8_t* from, uint8_t length) {
return UNSUPPORTED_TIME_FORMAT; return UNSUPPORTED_TIME_FORMAT;
} }
ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to,
uint8_t length) { const uint8_t* from, uint8_t length) {
timeval time; timeval time;
ReturnValue_t result = convertFromCDS(&time, from, NULL, length); ReturnValue_t result = convertFromCDS(&time, from, NULL, length);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
@ -96,8 +96,8 @@ ReturnValue_t CCSDSTime::convertFromCDS(Clock::TimeOfDay_t* to, const uint8_t* f
return convertTimevalToTimeOfDay(to, &time); return convertTimevalToTimeOfDay(to, &time);
} }
ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to,
uint32_t* foundLength, uint32_t maxLength) { const uint8_t* from, size_t* foundLength, size_t maxLength) {
uint8_t subsecondsLength = *from & 0b111; uint8_t subsecondsLength = *from & 0b111;
uint32_t totalLength = subsecondsLength + 8; uint32_t totalLength = subsecondsLength + 8;
if (maxLength < totalLength) { if (maxLength < totalLength) {
@ -152,8 +152,8 @@ ReturnValue_t CCSDSTime::convertFromCCS(Clock::TimeOfDay_t* to, const uint8_t* f
} }
ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to,
uint8_t length) { const uint8_t* from, uint8_t length) {
if (length < 19) { if (length < 19) {
return RETURN_FAILED; return RETURN_FAILED;
} }
@ -395,7 +395,7 @@ ReturnValue_t CCSDSTime::convertToCcsds(OBT_FLP* to, const timeval* from) {
} }
ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from,
uint32_t* foundLength, uint32_t maxLength) { size_t* foundLength, size_t maxLength) {
//We don't expect ascii here. SHOULDDO //We don't expect ascii here. SHOULDDO
uint8_t codeIdentification = (*from >> 4); uint8_t codeIdentification = (*from >> 4);
switch (codeIdentification) { switch (codeIdentification) {
@ -413,7 +413,7 @@ ReturnValue_t CCSDSTime::convertFromCcsds(timeval* to, const uint8_t* from,
} }
ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, const uint8_t* from,
uint32_t* foundLength, uint32_t maxLength) { size_t* foundLength, size_t maxLength) {
if (maxLength < 1) { if (maxLength < 1) {
return INVALID_TIME_FORMAT; return INVALID_TIME_FORMAT;
} }
@ -491,7 +491,7 @@ ReturnValue_t CCSDSTime::convertTimevalToTimeOfDay(Clock::TimeOfDay_t* to,
} }
ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from,
uint32_t* foundLength, uint32_t maxLength) { size_t* foundLength, size_t maxLength) {
uint8_t pField = *from; uint8_t pField = *from;
from++; from++;
//Check epoch //Check epoch
@ -556,12 +556,12 @@ ReturnValue_t CCSDSTime::convertFromCDS(timeval* to, const uint8_t* from,
} }
ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField, ReturnValue_t CCSDSTime::convertFromCUC(timeval* to, uint8_t pField,
const uint8_t* from, uint32_t* foundLength, uint32_t maxLength) { const uint8_t* from, size_t* foundLength, size_t maxLength) {
uint32_t secs = 0; uint32_t secs = 0;
uint32_t subSeconds = 0; uint32_t subSeconds = 0;
uint8_t nCoarse = ((pField & 0b1100) >> 2) + 1; uint8_t nCoarse = ((pField & 0b1100) >> 2) + 1;
uint8_t nFine = (pField & 0b11); uint8_t nFine = (pField & 0b11);
uint32_t totalLength = nCoarse + nFine; size_t totalLength = nCoarse + nFine;
if (foundLength != NULL) { if (foundLength != NULL) {
*foundLength = totalLength; *foundLength = totalLength;
} }
@ -593,7 +593,7 @@ uint32_t CCSDSTime::subsecondsToMicroseconds(uint16_t subseconds) {
} }
ReturnValue_t CCSDSTime::convertFromCCS(timeval* to, const uint8_t* from, ReturnValue_t CCSDSTime::convertFromCCS(timeval* to, const uint8_t* from,
uint32_t* foundLength, uint32_t maxLength) { size_t* foundLength, size_t maxLength) {
Clock::TimeOfDay_t tempTime; Clock::TimeOfDay_t tempTime;
ReturnValue_t result = convertFromCCS(&tempTime, from, foundLength, ReturnValue_t result = convertFromCCS(&tempTime, from, foundLength,
maxLength); maxLength);

View File

@ -1,11 +1,13 @@
#ifndef CCSDSTIME_H_ #ifndef FSFW_TIMEMANAGER_CCSDSTIME_H_
#define CCSDSTIME_H_ #define FSFW_TIMEMANAGER_CCSDSTIME_H_
// COULDDO: have calls in Clock.h which return time quality and use timespec accordingly // COULDDO: have calls in Clock.h which return time quality and use timespec accordingly
#include "Clock.h" #include "Clock.h"
#include "clockDefinitions.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include <cstdint> #include <cstdint>
#include <cstddef>
bool operator<(const timeval& lhs, const timeval& rhs); bool operator<(const timeval& lhs, const timeval& rhs);
bool operator<=(const timeval& lhs, const timeval& rhs); bool operator<=(const timeval& lhs, const timeval& rhs);
@ -154,8 +156,8 @@ public:
* - @c LENGTH_MISMATCH if the length does not match the P Field * - @c LENGTH_MISMATCH if the length does not match the P Field
* - @c INVALID_TIME_FORMAT if the format or a value is invalid * - @c INVALID_TIME_FORMAT if the format or a value is invalid
*/ */
static ReturnValue_t convertFromCcsds(Clock::TimeOfDay_t *to, uint8_t const *from, static ReturnValue_t convertFromCcsds(Clock::TimeOfDay_t *to,
uint32_t length); uint8_t const *from, size_t length);
/** /**
* not implemented yet * not implemented yet
@ -165,34 +167,34 @@ public:
* @return * @return
*/ */
static ReturnValue_t convertFromCcsds(timeval *to, uint8_t const *from, static ReturnValue_t convertFromCcsds(timeval *to, uint8_t const *from,
uint32_t* foundLength, uint32_t maxLength); size_t* foundLength, size_t maxLength);
static ReturnValue_t convertFromCUC(Clock::TimeOfDay_t *to, uint8_t const *from, static ReturnValue_t convertFromCUC(Clock::TimeOfDay_t *to,
uint8_t length); uint8_t const *from, uint8_t length);
static ReturnValue_t convertFromCUC(timeval *to, uint8_t const *from, static ReturnValue_t convertFromCUC(timeval *to, uint8_t const *from,
uint32_t* foundLength, uint32_t maxLength); size_t* foundLength, size_t maxLength);
static ReturnValue_t convertFromCUC(timeval *to, uint8_t pField, static ReturnValue_t convertFromCUC(timeval *to, uint8_t pField,
uint8_t const *from, uint32_t* foundLength, uint32_t maxLength); uint8_t const *from, size_t* foundLength, size_t maxLength);
static ReturnValue_t convertFromCCS(timeval *to, uint8_t const *from, static ReturnValue_t convertFromCCS(timeval *to, uint8_t const *from,
uint32_t* foundLength, uint32_t maxLength); size_t* foundLength, size_t maxLength);
static ReturnValue_t convertFromCCS(timeval *to, uint8_t pField, static ReturnValue_t convertFromCCS(timeval *to, uint8_t pField,
uint8_t const *from, uint32_t* foundLength, uint32_t maxLength); uint8_t const *from, size_t* foundLength, size_t maxLength);
static ReturnValue_t convertFromCDS(Clock::TimeOfDay_t *to, uint8_t const *from, static ReturnValue_t convertFromCDS(Clock::TimeOfDay_t *to,
uint8_t length); uint8_t const *from, uint8_t length);
static ReturnValue_t convertFromCDS(timeval *to, uint8_t const *from, static ReturnValue_t convertFromCDS(timeval *to, uint8_t const *from,
uint32_t* foundLength, uint32_t maxLength); size_t* foundLength, size_t maxLength);
static ReturnValue_t convertFromCCS(Clock::TimeOfDay_t *to, uint8_t const *from, static ReturnValue_t convertFromCCS(Clock::TimeOfDay_t *to,
uint32_t* foundLength, uint32_t maxLength); uint8_t const *from, size_t* foundLength, size_t maxLength);
static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from, static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to,
uint8_t length); uint8_t const *from, uint8_t length);
static uint32_t subsecondsToMicroseconds(uint16_t subseconds); static uint32_t subsecondsToMicroseconds(uint16_t subseconds);
private: private:
@ -230,4 +232,4 @@ private:
timeval* from); timeval* from);
}; };
#endif /* CCSDSTIME_H_ */ #endif /* FSFW_TIMEMANAGER_CCSDSTIME_H_ */

View File

@ -1,8 +1,9 @@
#ifndef FSFW_TIMEMANAGER_CLOCK_H_ #ifndef FSFW_TIMEMANAGER_CLOCK_H_
#define FSFW_TIMEMANAGER_CLOCK_H_ #define FSFW_TIMEMANAGER_CLOCK_H_
#include "clockDefinitions.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../ipc/MutexHelper.h" #include "../ipc/MutexFactory.h"
#include "../globalfunctions/timevalOperations.h" #include "../globalfunctions/timevalOperations.h"
#include <cstdint> #include <cstdint>
@ -13,20 +14,17 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
//! Don't use these for time points, type is not large enough for UNIX epoch.
using dur_millis_t = uint32_t;
class Clock { class Clock {
public: public:
typedef struct { typedef struct {
uint32_t year; //!< Year, A.D. uint32_t year; //!< Year, A.D.
uint32_t month; //!< Month, 1 .. 12. uint32_t month; //!< Month, 1 .. 12.
uint32_t day; //!< Day, 1 .. 31. uint32_t day; //!< Day, 1 .. 31.
uint32_t hour; //!< Hour, 0 .. 23. uint32_t hour; //!< Hour, 0 .. 23.
uint32_t minute; //!< Minute, 0 .. 59. uint32_t minute; //!< Minute, 0 .. 59.
uint32_t second; //!< Second, 0 .. 59. uint32_t second; //!< Second, 0 .. 59.
uint32_t usecond; //!< Microseconds, 0 .. 999999 uint32_t usecond; //!< Microseconds, 0 .. 999999
} TimeOfDay_t; } TimeOfDay_t;
/** /**
* This method returns the number of clock ticks per second. * This method returns the number of clock ticks per second.
@ -87,13 +85,17 @@ public:
* Returns the time in microseconds since an OS-defined epoch. * Returns the time in microseconds since an OS-defined epoch.
* The time is returned in a 64 bit unsigned integer. * The time is returned in a 64 bit unsigned integer.
* @param time A pointer to a 64 bit unisigned integer where the data is stored. * @param time A pointer to a 64 bit unisigned integer where the data is stored.
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned. * @return
* - @c RETURN_OK on success.
* - Otherwise, the OS failure code is returned.
*/ */
static ReturnValue_t getClock_usecs(uint64_t* time); static ReturnValue_t getClock_usecs(uint64_t* time);
/** /**
* Returns the time in a TimeOfDay_t struct. * Returns the time in a TimeOfDay_t struct.
* @param time A pointer to a TimeOfDay_t struct. * @param time A pointer to a TimeOfDay_t struct.
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned. * @return
* - @c RETURN_OK on success.
* - Otherwise, the OS failure code is returned.
*/ */
static ReturnValue_t getDateAndTime(TimeOfDay_t* time); static ReturnValue_t getDateAndTime(TimeOfDay_t* time);
@ -101,17 +103,20 @@ public:
* Converts a time of day struct to POSIX seconds. * Converts a time of day struct to POSIX seconds.
* @param time The time of day as input * @param time The time of day as input
* @param timeval The corresponding seconds since the epoch. * @param timeval The corresponding seconds since the epoch.
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned. * @return
* - @c RETURN_OK on success.
* - Otherwise, the OS failure code is returned.
*/ */
static ReturnValue_t convertTimeOfDayToTimeval(const TimeOfDay_t* from, static ReturnValue_t convertTimeOfDayToTimeval(const TimeOfDay_t* from,
timeval* to); timeval* to);
/** /**
* Converts a time represented as seconds and subseconds since unix epoch to days since J2000 * Converts a time represented as seconds and subseconds since unix
* epoch to days since J2000
* *
* @param time seconds since unix epoch * @param time seconds since unix epoch
* @param[out] JD2000 days since J2000 * @param[out] JD2000 days since J2000
* @return \c RETURN_OK * @return @c RETURN_OK
*/ */
static ReturnValue_t convertTimevalToJD2000(timeval time, double* JD2000); static ReturnValue_t convertTimevalToJD2000(timeval time, double* JD2000);
@ -122,7 +127,9 @@ public:
* *
* @param utc timeval, corresponding to UTC time * @param utc timeval, corresponding to UTC time
* @param[out] tt timeval, corresponding to Terrestial Time * @param[out] tt timeval, corresponding to Terrestial Time
* @return \c RETURN_OK on success, \c RETURN_FAILED if leapSeconds are not set * @return
* - @c RETURN_OK on success
* - @c RETURN_FAILED if leapSeconds are not set
*/ */
static ReturnValue_t convertUTCToTT(timeval utc, timeval* tt); static ReturnValue_t convertUTCToTT(timeval utc, timeval* tt);
@ -130,7 +137,9 @@ public:
* Set the Leap Seconds since 1972 * Set the Leap Seconds since 1972
* *
* @param leapSeconds_ * @param leapSeconds_
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned. * @return
* - @c RETURN_OK on success.
* - Otherwise, the OS failure code is returned.
*/ */
static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_); static ReturnValue_t setLeapSeconds(const uint16_t leapSeconds_);
@ -140,13 +149,17 @@ public:
* Must be set before! * Must be set before!
* *
* @param[out] leapSeconds_ * @param[out] leapSeconds_
* @return \c RETURN_OK on success. Otherwise, the OS failure code is returned. * @return
* - @c RETURN_OK on success.
* - Otherwise, the OS failure code is returned.
*/ */
static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_); static ReturnValue_t getLeapSeconds(uint16_t *leapSeconds_);
/** /**
* Function to check and create the Mutex for the clock * Function to check and create the Mutex for the clock
* @return \c RETURN_OK on success. Otherwise \c RETURN_FAILED if not able to create one * @return
* - @c RETURN_OK on success.
* - Otherwise @c RETURN_FAILED if not able to create one
*/ */
static ReturnValue_t checkOrCreateClockMutex(); static ReturnValue_t checkOrCreateClockMutex();

View File

@ -1,14 +1,6 @@
/**
* @file Countdown.cpp
* @brief This file defines the Countdown class.
* @date 21.03.2013
* @author baetz
*/
#include "Countdown.h" #include "Countdown.h"
Countdown::Countdown(uint32_t initialTimeout) : startTime(0), timeout(initialTimeout) { Countdown::Countdown(uint32_t initialTimeout): timeout(initialTimeout) {
} }
Countdown::~Countdown() { Countdown::~Countdown() {

View File

@ -1,18 +1,13 @@
/** #ifndef FSFW_TIMEMANAGER_COUNTDOWN_H_
* @file Countdown.h #define FSFW_TIMEMANAGER_COUNTDOWN_H_
* @brief This file defines the Countdown class.
* @date 21.03.2013
* @author baetz
*/
#ifndef COUNTDOWN_H_
#define COUNTDOWN_H_
#include "Clock.h" #include "Clock.h"
/**
* @brief This file defines the Countdown class.
* @author baetz
*/
class Countdown { class Countdown {
private:
uint32_t startTime;
public: public:
uint32_t timeout; uint32_t timeout;
Countdown(uint32_t initialTimeout = 0); Countdown(uint32_t initialTimeout = 0);
@ -23,9 +18,14 @@ public:
bool isBusy() const; bool isBusy() const;
ReturnValue_t resetTimer(); //!< Use last set timeout value and restart timer. //!< Use last set timeout value and restart timer.
ReturnValue_t resetTimer();
void timeOut(); //!< Make hasTimedOut() return true //!< Make hasTimedOut() return true
void timeOut();
private:
uint32_t startTime = 0;
}; };
#endif /* COUNTDOWN_H_ */ #endif /* FSFW_TIMEMANAGER_COUNTDOWN_H_ */

View File

@ -1,12 +1,7 @@
/** #ifndef FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_
* @file ReceivesTimeInfoIF.h #define FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_
* @brief This file defines the ReceivesTimeInfoIF class.
* @date 26.02.2013
* @author baetz
*/
#ifndef RECEIVESTIMEINFOIF_H_ #include "../ipc/MessageQueueSenderIF.h"
#define RECEIVESTIMEINFOIF_H_
/** /**
* This is a Interface for classes that receive timing information * This is a Interface for classes that receive timing information
@ -28,4 +23,4 @@ public:
}; };
#endif /* RECEIVESTIMEINFOIF_H_ */ #endif /* FSFW_TIMEMANAGER_RECEIVESTIMEINFOIF_H_ */

View File

@ -1,10 +1,3 @@
/**
* @file TimeMessage.cpp
* @brief This file defines the TimeMessage class.
* @date 26.02.2013
* @author baetz
*/
#include "TimeMessage.h" #include "TimeMessage.h"
TimeMessage::TimeMessage() { TimeMessage::TimeMessage() {

View File

@ -1,15 +1,8 @@
/** #ifndef FSFW_TIMEMANAGER_TIMEMESSAGE_H_
* @file TimeMessage.h #define FSFW_TIMEMANAGER_TIMEMESSAGE_H_
* @brief This file defines the TimeMessage class.
* @date 26.02.2013
* @author baetz
*/
#ifndef TIMEMESSAGE_H_
#define TIMEMESSAGE_H_
#include "../ipc/MessageQueueMessage.h"
#include "Clock.h" #include "Clock.h"
#include "../ipc/MessageQueueMessage.h"
#include <cstring> #include <cstring>
class TimeMessage : public MessageQueueMessage { class TimeMessage : public MessageQueueMessage {
@ -53,4 +46,4 @@ public:
uint32_t getCounterValue(); uint32_t getCounterValue();
}; };
#endif /* TIMEMESSAGE_H_ */ #endif /* FSFW_TIMEMANAGER_TIMEMESSAGE_H_ */

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_TIMEMANAGER_TIMESTAMPERIF_H_ #ifndef FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
#define FRAMEWORK_TIMEMANAGER_TIMESTAMPERIF_H_ #define FSFW_TIMEMANAGER_TIMESTAMPERIF_H_
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
@ -25,4 +25,4 @@ public:
#endif /* FRAMEWORK_TIMEMANAGER_TIMESTAMPERIF_H_ */ #endif /* FSFW_TIMEMANAGER_TIMESTAMPERIF_H_ */

View File

@ -0,0 +1,13 @@
#ifndef FSFW_TIMEMANAGER_CLOCKDEFINITIONS_H_
#define FSFW_TIMEMANAGER_CLOCKDEFINITIONS_H_
#include <cstdint>
// I'd also like to include the TimeOfDay_t struct here, but that would
// break code which uses Clock::TimeOfDay_t. Solution would be to use
// a Clock namespace instead of class with static functions.
//! Don't use these for time points, type is not large enough for UNIX epoch.
using dur_millis_t = uint32_t;
#endif /* FSFW_TIMEMANAGER_CLOCKDEFINITIONS_H_ */

View File

@ -139,8 +139,9 @@ public:
static bool isOlderThan(const TmPacketInformation* packet, const timeval* cmpTime){ static bool isOlderThan(const TmPacketInformation* packet, const timeval* cmpTime){
if(packet->isValid()){ if(packet->isValid()){
timeval packetTime = {0,0}; timeval packetTime = {0,0};
uint32_t foundlen = 0; size_t foundlen = 0;
CCSDSTime::convertFromCcsds(&packetTime,&packet->rawTimestamp[0],&foundlen,sizeof(rawTimestamp)); CCSDSTime::convertFromCcsds(&packetTime,
&packet->rawTimestamp[0],&foundlen,sizeof(rawTimestamp));
if(packetTime <= *cmpTime){ if(packetTime <= *cmpTime){
return true; return true;
} }
@ -151,8 +152,9 @@ public:
static bool isNewerThan(const TmPacketInformation* packet, const timeval* cmpTime){ static bool isNewerThan(const TmPacketInformation* packet, const timeval* cmpTime){
if(packet->isValid()){ if(packet->isValid()){
timeval packetTime = {0,0}; timeval packetTime = {0,0};
uint32_t foundlen = 0; size_t foundlen = 0;
CCSDSTime::convertFromCcsds(&packetTime,&packet->rawTimestamp[0],&foundlen,sizeof(rawTimestamp)); CCSDSTime::convertFromCcsds(&packetTime,&packet->rawTimestamp[0],
&foundlen,sizeof(rawTimestamp));
if(packetTime >= *cmpTime){ if(packetTime >= *cmpTime){
return true; return true;
} }
@ -204,8 +206,9 @@ public:
timeval getTime() const { timeval getTime() const {
timeval packetTime = {0,0}; timeval packetTime = {0,0};
uint32_t foundlen = 0; size_t foundlen = 0;
CCSDSTime::convertFromCcsds(&packetTime,&this->rawTimestamp[0],&foundlen,sizeof(rawTimestamp)); CCSDSTime::convertFromCcsds(&packetTime, &this->rawTimestamp[0],
&foundlen,sizeof(rawTimestamp));
return packetTime; return packetTime;
} }

View File

@ -74,7 +74,7 @@ bool TmPacketBase::checkAndSetStamper() {
} }
ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const { ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const {
uint32_t tempSize = 0; size_t tempSize = 0;
return CCSDSTime::convertFromCcsds(timestamp, tmData->data_field.time, return CCSDSTime::convertFromCcsds(timestamp, tmData->data_field.time,
&tempSize, sizeof(tmData->data_field.time)); &tempSize, sizeof(tmData->data_field.time));
} }

View File

@ -1,5 +1,5 @@
#ifndef ACCEPTSTELECOMMANDSIF_H_ #ifndef FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_
#define ACCEPTSTELECOMMANDSIF_H_ #define FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
@ -26,9 +26,9 @@ public:
/** /**
* @brief Getter for the service id. * @brief Getter for the service id.
* @details Any receiving service (at least any PUS service) shall have a * @details Any receiving service (at least any PUS service) shall have a
* service id. If the receiver can handle Telecommands, but for * service ID. If the receiver can handle Telecommands, but for
* some reason has no service id, it shall return 0. * some reason has no service id, it shall return 0.
* @return The service id or 0. * @return The service ID or 0.
*/ */
virtual uint16_t getIdentifier() = 0; virtual uint16_t getIdentifier() = 0;
/** /**
@ -40,4 +40,4 @@ public:
}; };
#endif /* ACCEPTSTELECOMMANDSIF_H_ */ #endif /* FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ */

View File

@ -1,5 +1,5 @@
#ifndef ACCEPTSTELEMETRYIF_H_ #ifndef FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_
#define ACCEPTSTELEMETRYIF_H_ #define FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
/** /**
@ -20,7 +20,8 @@ public:
* receiving message queue. * receiving message queue.
* @return The telemetry reception message queue id. * @return The telemetry reception message queue id.
*/ */
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) = 0; virtual MessageQueueId_t getReportReceptionQueue(
uint8_t virtualChannel = 0) = 0;
}; };
#endif /* ACCEPTSTELEMETRYIF_H_ */ #endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */

View File

@ -1,5 +1,5 @@
#ifndef ACCEPTSVERIFICATIONMESSAGEIF_H_ #ifndef FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_
#define ACCEPTSVERIFICATIONMESSAGEIF_H_ #define FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
@ -12,4 +12,4 @@ public:
}; };
#endif /* ACCEPTSVERIFICATIONMESSAGEIF_H_ */ #endif /* FSFW_TMTCSERVICES_ACCEPTSVERIFICATIONMESSAGEIF_H_ */

View File

@ -1,9 +1,9 @@
#include "../tcdistribution/PUSDistributorIF.h"
#include "AcceptsTelemetryIF.h" #include "AcceptsTelemetryIF.h"
#include "../objectmanager/ObjectManagerIF.h"
#include "CommandingServiceBase.h" #include "CommandingServiceBase.h"
#include "TmTcMessage.h" #include "TmTcMessage.h"
#include "../tcdistribution/PUSDistributorIF.h"
#include "../objectmanager/ObjectManagerIF.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
#include "../tmtcpacket/pus/TcPacketStored.h" #include "../tmtcpacket/pus/TcPacketStored.h"
#include "../tmtcpacket/pus/TmPacketStored.h" #include "../tmtcpacket/pus/TmPacketStored.h"
@ -149,13 +149,13 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
default: default:
if (isStep) { if (isStep) {
verificationReporter.sendFailureReport( verificationReporter.sendFailureReport(
TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
result, ++iter->second.step, failureParameter1, result, ++iter->second.step, failureParameter1,
failureParameter2); failureParameter2);
} else { } else {
verificationReporter.sendFailureReport( verificationReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
result, 0, failureParameter1, failureParameter2); result, 0, failureParameter1, failureParameter2);
} }
@ -184,13 +184,13 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
if (sendResult == RETURN_OK) { if (sendResult == RETURN_OK) {
if (isStep and result != NO_STEP_MESSAGE) { if (isStep and result != NO_STEP_MESSAGE) {
verificationReporter.sendSuccessReport( verificationReporter.sendSuccessReport(
TC_VERIFY::PROGRESS_SUCCESS, tc_verification::PROGRESS_SUCCESS,
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, ++iter->second.step); iter->second.tcInfo.tcSequenceControl, ++iter->second.step);
} }
else { else {
verificationReporter.sendSuccessReport( verificationReporter.sendSuccessReport(
TC_VERIFY::COMPLETION_SUCCESS, tc_verification::COMPLETION_SUCCESS,
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, 0); iter->second.tcInfo.tcSequenceControl, 0);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
@ -200,14 +200,14 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
if (isStep) { if (isStep) {
nextCommand->clearCommandMessage(); nextCommand->clearCommandMessage();
verificationReporter.sendFailureReport( verificationReporter.sendFailureReport(
TC_VERIFY::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, sendResult, iter->second.tcInfo.tcSequenceControl, sendResult,
++iter->second.step, failureParameter1, failureParameter2); ++iter->second.step, failureParameter1, failureParameter2);
} else { } else {
nextCommand->clearCommandMessage(); nextCommand->clearCommandMessage();
verificationReporter.sendFailureReport( verificationReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE, tc_verification::COMPLETION_FAILURE,
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, sendResult, 0, iter->second.tcInfo.tcSequenceControl, sendResult, 0,
failureParameter1, failureParameter2); failureParameter1, failureParameter2);
@ -232,14 +232,14 @@ void CommandingServiceBase::handleRequestQueue() {
if ((packet.getSubService() == 0) if ((packet.getSubService() == 0)
or (isValidSubservice(packet.getSubService()) != RETURN_OK)) { or (isValidSubservice(packet.getSubService()) != RETURN_OK)) {
rejectPacket(TC_VERIFY::START_FAILURE, &packet, INVALID_SUBSERVICE); rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE);
continue; continue;
} }
result = getMessageQueueAndObject(packet.getSubService(), result = getMessageQueueAndObject(packet.getSubService(),
packet.getApplicationData(), packet.getApplicationDataSize(), packet.getApplicationData(), packet.getApplicationDataSize(),
&queue, &objectId); &queue, &objectId);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
rejectPacket(TC_VERIFY::START_FAILURE, &packet, result); rejectPacket(tc_verification::START_FAILURE, &packet, result);
continue; continue;
} }
@ -250,14 +250,14 @@ void CommandingServiceBase::handleRequestQueue() {
if (iter != commandMap.end()) { if (iter != commandMap.end()) {
result = iter->second.fifo.insert(address); result = iter->second.fifo.insert(address);
if (result != RETURN_OK) { if (result != RETURN_OK) {
rejectPacket(TC_VERIFY::START_FAILURE, &packet, OBJECT_BUSY); rejectPacket(tc_verification::START_FAILURE, &packet, OBJECT_BUSY);
} }
} else { } else {
CommandInfo newInfo; //Info will be set by startExecution if neccessary CommandInfo newInfo; //Info will be set by startExecution if neccessary
newInfo.objectId = objectId; newInfo.objectId = objectId;
result = commandMap.insert(queue, newInfo, &iter); result = commandMap.insert(queue, newInfo, &iter);
if (result != RETURN_OK) { if (result != RETURN_OK) {
rejectPacket(TC_VERIFY::START_FAILURE, &packet, BUSY); rejectPacket(tc_verification::START_FAILURE, &packet, BUSY);
} else { } else {
startExecution(&packet, iter); startExecution(&packet, iter);
} }
@ -338,10 +338,10 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
iter->second.tcInfo.tcPacketId = storedPacket->getPacketId(); iter->second.tcInfo.tcPacketId = storedPacket->getPacketId();
iter->second.tcInfo.tcSequenceControl = iter->second.tcInfo.tcSequenceControl =
storedPacket->getPacketSequenceControl(); storedPacket->getPacketSequenceControl();
acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket); acceptPacket(tc_verification::START_SUCCESS, storedPacket);
} else { } else {
command.clearCommandMessage(); command.clearCommandMessage();
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult); rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
} }
break; break;
@ -352,18 +352,18 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
&command); &command);
} }
if (sendResult == RETURN_OK) { if (sendResult == RETURN_OK) {
verificationReporter.sendSuccessReport(TC_VERIFY::START_SUCCESS, verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS,
storedPacket); storedPacket);
acceptPacket(TC_VERIFY::COMPLETION_SUCCESS, storedPacket); acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
} else { } else {
command.clearCommandMessage(); command.clearCommandMessage();
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult); rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
} }
break; break;
default: default:
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, result); rejectPacket(tc_verification::START_FAILURE, storedPacket, result);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);
break; break;
} }
@ -414,7 +414,7 @@ void CommandingServiceBase::checkTimeout() {
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) { for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) { if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
verificationReporter.sendFailureReport( verificationReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
TIMEOUT); TIMEOUT);
checkAndExecuteFifo(iter); checkAndExecuteFifo(iter);

View File

@ -1,18 +1,20 @@
#ifndef FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_ #ifndef FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_
#define FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_ #define FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_
#include "AcceptsTelecommandsIF.h"
#include "VerificationReporter.h"
#include "../objectmanager/SystemObject.h" #include "../objectmanager/SystemObject.h"
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
#include "../tasks/ExecutableObjectIF.h" #include "../tasks/ExecutableObjectIF.h"
#include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueIF.h"
#include "AcceptsTelecommandsIF.h"
#include "VerificationReporter.h"
#include "../ipc/CommandMessage.h" #include "../ipc/CommandMessage.h"
#include "../container/FixedMap.h" #include "../container/FixedMap.h"
#include "../container/FIFO.h" #include "../container/FIFO.h"
#include "../serialize/SerializeIF.h" #include "../serialize/SerializeIF.h"
#include <FSFWConfig.h>
class TcPacketStored; class TcPacketStored;
namespace Factory{ namespace Factory{
@ -40,7 +42,8 @@ class CommandingServiceBase: public SystemObject,
friend void (Factory::setStaticFrameworkObjectIds)(); friend void (Factory::setStaticFrameworkObjectIds)();
public: public:
// We could make this configurable via preprocessor and the FSFWConfig file. // We could make this configurable via preprocessor and the FSFWConfig file.
static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH = 3; static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH =
fsfwconfig::FSFW_CSB_FIFO_DEPTH;
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE; static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE;

View File

@ -1,9 +1,10 @@
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../tcdistribution/PUSDistributorIF.h"
#include "AcceptsTelemetryIF.h"
#include "PusServiceBase.h" #include "PusServiceBase.h"
#include "AcceptsTelemetryIF.h"
#include "PusVerificationReport.h" #include "PusVerificationReport.h"
#include "TmTcMessage.h" #include "TmTcMessage.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../tcdistribution/PUSDistributorIF.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
object_id_t PusServiceBase::packetSource = 0; object_id_t PusServiceBase::packetSource = 0;
@ -41,9 +42,14 @@ void PusServiceBase::handleRequestQueue() {
ReturnValue_t result = RETURN_FAILED; ReturnValue_t result = RETURN_FAILED;
for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) { for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) {
ReturnValue_t status = this->requestQueue->receiveMessage(&message); ReturnValue_t status = this->requestQueue->receiveMessage(&message);
// debug << "PusServiceBase::performOperation: Receiving from MQ ID: " // if(status != MessageQueueIF::EMPTY) {
// << std::hex << this->requestQueue.getId() // sif::debug << "PusServiceBase::performOperation: Receiving from "
// << std::dec << " returned: " << status << std::endl; // << "MQ ID: " << std::hex << "0x" << std::setw(8)
// << std::setfill('0') << this->requestQueue->getId()
// << std::dec << " returned: " << status << std::setfill(' ')
// << std::endl;
// }
if (status == RETURN_OK) { if (status == RETURN_OK) {
this->currentPacket.setStoreAddress(message.getStorageId()); this->currentPacket.setStoreAddress(message.getStorageId());
//info << "Service " << (uint16_t) this->serviceId << //info << "Service " << (uint16_t) this->serviceId <<
@ -55,11 +61,11 @@ void PusServiceBase::handleRequestQueue() {
// ": handleRequest returned: " << (int)return_code << std::endl; // ": handleRequest returned: " << (int)return_code << std::endl;
if (result == RETURN_OK) { if (result == RETURN_OK) {
this->verifyReporter.sendSuccessReport( this->verifyReporter.sendSuccessReport(
TC_VERIFY::COMPLETION_SUCCESS, &this->currentPacket); tc_verification::COMPLETION_SUCCESS, &this->currentPacket);
} }
else { else {
this->verifyReporter.sendFailureReport( this->verifyReporter.sendFailureReport(
TC_VERIFY::COMPLETION_FAILURE, &this->currentPacket, tc_verification::COMPLETION_FAILURE, &this->currentPacket,
result, 0, errorParameter1, errorParameter2); result, 0, errorParameter1, errorParameter2);
} }
this->currentPacket.deletePacket(); this->currentPacket.deletePacket();
@ -74,9 +80,8 @@ void PusServiceBase::handleRequestQueue() {
} }
else { else {
sif::error << "PusServiceBase::performOperation: Service " sif::error << "PusServiceBase::performOperation: Service "
<< (uint16_t) this->serviceId << this->serviceId << ": Error receiving packet. Code: "
<< ": Error receiving packet. Code: " << std::hex << status << std::hex << status << std::dec << std::endl;
<< std::dec << std::endl;
} }
} }
} }
@ -98,19 +103,17 @@ ReturnValue_t PusServiceBase::initialize() {
packetDestination); packetDestination);
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>( PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
packetSource); packetSource);
if ((destService != nullptr) && (distributor != nullptr)) { if (destService == nullptr or distributor == nullptr) {
this->requestQueue->setDefaultDestination(
destService->getReportReceptionQueue());
distributor->registerService(this);
return RETURN_OK;
}
else {
sif::error << "PusServiceBase::PusServiceBase: Service " sif::error << "PusServiceBase::PusServiceBase: Service "
<< (uint32_t) this->serviceId << ": Configuration error." << this->serviceId << ": Configuration error. Make sure "
<< " Make sure packetSource and packetDestination are defined " << "packetSource and packetDestination are defined correctly"
"correctly" << std::endl; << std::endl;
return RETURN_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
this->requestQueue->setDefaultDestination(
destService->getReportReceptionQueue());
distributor->registerService(this);
return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t PusServiceBase::initializeAfterTaskCreation() { ReturnValue_t PusServiceBase::initializeAfterTaskCreation() {

View File

@ -1,14 +1,15 @@
#ifndef FRAMEWORK_TMTCSERVICES_PUSSERVICEBASE_H_ #ifndef FSFW_TMTCSERVICES_PUSSERVICEBASE_H_
#define FRAMEWORK_TMTCSERVICES_PUSSERVICEBASE_H_ #define FSFW_TMTCSERVICES_PUSSERVICEBASE_H_
#include "AcceptsTelecommandsIF.h"
#include "VerificationCodes.h"
#include "VerificationReporter.h"
#include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/ObjectManagerIF.h"
#include "../objectmanager/SystemObject.h" #include "../objectmanager/SystemObject.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../tasks/ExecutableObjectIF.h" #include "../tasks/ExecutableObjectIF.h"
#include "../tmtcpacket/pus/TcPacketStored.h" #include "../tmtcpacket/pus/TcPacketStored.h"
#include "AcceptsTelecommandsIF.h"
#include "VerificationCodes.h"
#include "VerificationReporter.h"
#include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueIF.h"
namespace Factory{ namespace Factory{
@ -156,4 +157,4 @@ private:
void handleRequestQueue(); void handleRequestQueue();
}; };
#endif /* PUSSERVICEBASE_H_ */ #endif /* FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ */

View File

@ -1,5 +1,5 @@
#include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeAdapter.h"
#include "PusVerificationReport.h" #include "../tmtcservices/PusVerificationReport.h"
PusVerificationMessage::PusVerificationMessage() { PusVerificationMessage::PusVerificationMessage() {
} }

View File

@ -7,8 +7,6 @@
#include "../tmtcpacket/pus/TcPacketBase.h" #include "../tmtcpacket/pus/TcPacketBase.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include <cstdint>
class PusVerificationMessage: public MessageQueueMessage { class PusVerificationMessage: public MessageQueueMessage {
private: private:
struct verifciationMessageContent { struct verifciationMessageContent {

View File

@ -1,32 +0,0 @@
/**
* @file ServiceTypes.h
* @brief This file defines the ServiceTypes class.
* @date 11.04.2013
* @author baetz
*/
#ifndef SERVICETYPES_H_
#define SERVICETYPES_H_
namespace SERVICE {
enum ServiceTypes {
TELECOMMAND_VERIFICATION = 1,
DEVICE_COMMAND_DISTRIBUTION = 2,
HOUSEKEEPING_AND_DIAGNOSTIC_DATA_REPORTING = 3,
PARAMETER_STATISTICS_REPORTING = 4,
EVENT_REPORTING = 5,
MEMORY_MANAGEMENT = 6,
FUNCTION_MANAGEMENT = 8,
TIME_MANAGEMENT = 9,
ON_BOARD_OPERATIONS_SCHEDULING = 11,
ON_BOARD_MONITORING = 12,
LARGE_DATA_TRANSFER = 13,
PACKET_FORWARDING_CONTROL = 14,
ON_BOARD_STORAGE_AND_RETRIEVAL = 15,
TEST = 17,
ON_BOARD_OPERATIONS_PROCEDURE = 18,
EVENT_ACTION = 19
};
}
#endif /* SERVICETYPES_H_ */

View File

@ -1,12 +1,6 @@
/** #ifndef FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_
* @file SourceSequenceCounter.h #define FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_
* @brief This file defines the SourceSequenceCounter class.
* @date 04.02.2013
* @author baetz
*/
#ifndef SOURCESEQUENCECOUNTER_H_
#define SOURCESEQUENCECOUNTER_H_
#include "../tmtcpacket/SpacePacketBase.h" #include "../tmtcpacket/SpacePacketBase.h"
class SourceSequenceCounter { class SourceSequenceCounter {
@ -27,4 +21,4 @@ public:
}; };
#endif /* SOURCESEQUENCECOUNTER_H_ */ #endif /* FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ */

View File

@ -1,7 +1,6 @@
#include "../tmtcservices/TmTcBridge.h" #include "TmTcBridge.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#include "../globalfunctions/arrayprinter.h" #include "../globalfunctions/arrayprinter.h"
@ -95,8 +94,9 @@ ReturnValue_t TmTcBridge::handleTm() {
ReturnValue_t status = HasReturnvaluesIF::RETURN_OK; ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
ReturnValue_t result = handleTmQueue(); ReturnValue_t result = handleTmQueue();
if(result != RETURN_OK) { if(result != RETURN_OK) {
sif::error << "TmTcBridge::handleTm: Error handling TM queue!" sif::error << "TmTcBridge::handleTm: Error handling TM queue with "
<< std::endl; << "error code 0x" << std::hex << result << std::dec
<< "!" << std::endl;
status = result; status = result;
} }

View File

@ -1,13 +1,13 @@
#ifndef FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ #ifndef FSFW_TMTCSERVICES_TMTCBRIDGE_H_
#define FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ #define FSFW_TMTCSERVICES_TMTCBRIDGE_H_
#include "AcceptsTelemetryIF.h"
#include "AcceptsTelecommandsIF.h"
#include "../objectmanager/SystemObject.h" #include "../objectmanager/SystemObject.h"
#include "../tmtcservices/AcceptsTelemetryIF.h"
#include "../tasks/ExecutableObjectIF.h" #include "../tasks/ExecutableObjectIF.h"
#include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueIF.h"
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h"
#include "../container/DynamicFIFO.h" #include "../container/DynamicFIFO.h"
#include "../tmtcservices/TmTcMessage.h" #include "../tmtcservices/TmTcMessage.h"
@ -159,4 +159,4 @@ protected:
}; };
#endif /* FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ */ #endif /* FSFW_TMTCSERVICES_TMTCBRIDGE_H_ */

View File

@ -1,5 +1,6 @@
#include "TmTcMessage.h" #include "TmTcMessage.h"
#include <string.h>
#include <cstring>
TmTcMessage::TmTcMessage() { TmTcMessage::TmTcMessage() {
@ -15,15 +16,15 @@ store_address_t TmTcMessage::getStorageId() {
return temp_id; return temp_id;
} }
TmTcMessage::TmTcMessage(store_address_t store_id) { TmTcMessage::TmTcMessage(store_address_t storeId) {
this->messageSize += sizeof(store_address_t); this->messageSize += sizeof(store_address_t);
this->setStorageId(store_id); this->setStorageId(storeId);
} }
size_t TmTcMessage::getMinimumMessageSize() { size_t TmTcMessage::getMinimumMessageSize() {
return this->HEADER_SIZE + sizeof(store_address_t); return this->HEADER_SIZE + sizeof(store_address_t);
} }
void TmTcMessage::setStorageId(store_address_t store_id) { void TmTcMessage::setStorageId(store_address_t storeId) {
memcpy(this->getData(), &store_id, sizeof(store_address_t) ); memcpy(this->getData(), &storeId, sizeof(store_address_t) );
} }

View File

@ -1,5 +1,5 @@
#ifndef TMTCMESSAGE_H_ #ifndef FSFW_TMTCSERVICES_TMTCMESSAGE_H_
#define TMTCMESSAGE_H_ #define FSFW_TMTCSERVICES_TMTCMESSAGE_H_
#include "../ipc/MessageQueueMessage.h" #include "../ipc/MessageQueueMessage.h"
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
@ -10,13 +10,13 @@
* a packet stored in one of the IPC stores (typically a special TM and * a packet stored in one of the IPC stores (typically a special TM and
* a special TC store). This makes passing commands very simple and * a special TC store). This makes passing commands very simple and
* efficient. * efficient.
* \ingroup message_queue * @ingroup message_queue
*/ */
class TmTcMessage : public MessageQueueMessage { class TmTcMessage : public MessageQueueMessage {
protected: protected:
/** /**
* @brief This call always returns the same fixed size of the message. * @brief This call always returns the same fixed size of the message.
* @return Returns HEADER_SIZE + \c sizeof(store_address_t). * @return Returns HEADER_SIZE + @c sizeof(store_address_t).
*/ */
size_t getMinimumMessageSize(); size_t getMinimumMessageSize();
public: public:
@ -29,7 +29,7 @@ public:
* into the message. * into the message.
* @param packet_id The packet id to put into the message. * @param packet_id The packet id to put into the message.
*/ */
TmTcMessage( store_address_t packet_id ); TmTcMessage( store_address_t packetId );
/** /**
* @brief The class's destructor is empty. * @brief The class's destructor is empty.
*/ */
@ -42,9 +42,9 @@ public:
/** /**
* @brief In some cases it might be useful to have a setter for packet id * @brief In some cases it might be useful to have a setter for packet id
* as well. * as well.
* @param packet_id The packet id to put into the message. * @param packetId The packet id to put into the message.
*/ */
void setStorageId( store_address_t packet_id ); void setStorageId( store_address_t packetId );
}; };
#endif /* TMTCMESSAGE_H_ */ #endif /* FSFW_TMTCSERVICES_TMTCMESSAGE_H_ */

View File

@ -1,7 +1,7 @@
#ifndef VERIFICATIONCODES_H_ #ifndef VERIFICATIONCODES_H_
#define VERIFICATIONCODES_H_ #define VERIFICATIONCODES_H_
namespace TC_VERIFY { namespace tc_verification {
enum verification_flags { enum verification_flags {
NONE = 0b0000, NONE = 0b0000,

View File

@ -0,0 +1,56 @@
#include "CatchFactory.h"
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
#include <fsfw/internalError/InternalErrorReporter.h>
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw/storagemanager/PoolManager.h>
/**
* @brief Produces system objects.
* @details
* Build tasks by using SystemObject Interface (Interface).
* Header files of all tasks must be included
* Please note that an object has to implement the system object interface
* if the interface validity is checked or retrieved later by using the
* get<TargetInterface>(object_id) function from the ObjectManagerIF.
*
* Framework objects are created first.
*
* @ingroup init
*/
void Factory::produce(void) {
setStaticFrameworkObjectIds();
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
{
PoolManager::LocalPoolConfig poolCfg = {
{100, 16}, {50, 32}, {25, 64} , {15, 128}, {5, 1024}
};
new PoolManager(objects::TC_STORE, poolCfg);
}
{
PoolManager::LocalPoolConfig poolCfg = {
{100, 16}, {50, 32}, {25, 64} , {15, 128}, {5, 1024}
};
new PoolManager(objects::TM_STORE, poolCfg);
}
{
PoolManager::LocalPoolConfig poolCfg = {
{100, 16}, {50, 32}, {25, 64} , {15, 128}, {5, 1024}
};
new PoolManager(objects::IPC_STORE, poolCfg);
}
}
void Factory::setStaticFrameworkObjectIds() {
}

View File

@ -1,5 +1,5 @@
#ifndef FACTORY_H_ #ifndef FSFW_CATCHFACTORY_H_
#define FACTORY_H_ #define FSFW_CATCHFACTORY_H_
#include <fsfw/objectmanager/SystemObjectIF.h> #include <fsfw/objectmanager/SystemObjectIF.h>
@ -13,4 +13,4 @@ namespace Factory {
} }
#endif /* FACTORY_H_ */ #endif /* FSFW_CATCHFACTORY_H_ */

View File

@ -1,6 +1,5 @@
#include <fsfw/unittest/core/CatchFactory.h>
#include "CatchDefinitions.h" #include "CatchDefinitions.h"
#include "CatchFactory.h"
#include <testcfg/cdatapool/dataPoolInit.h> #include <testcfg/cdatapool/dataPoolInit.h>
#ifdef GCOV #ifdef GCOV
@ -10,15 +9,11 @@
#include "../../objectmanager/ObjectManager.h" #include "../../objectmanager/ObjectManager.h"
#include "../../objectmanager/ObjectManagerIF.h" #include "../../objectmanager/ObjectManagerIF.h"
#include "../../storagemanager/StorageManagerIF.h" #include "../../storagemanager/StorageManagerIF.h"
#include "../../datapool/DataPool.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
/* Global instantiations normally done in main.cpp */ /* Global instantiations normally done in main.cpp */
/* Initialize Data Pool */ /* Initialize Data Pool */
//namespace glob {
DataPool dataPool(datapool::dataPoolInit);
//}
namespace sif { namespace sif {

View File

@ -1,60 +0,0 @@
#include "CatchFactory.h"
#include <fsfw/events/EventManager.h>
#include <fsfw/health/HealthTable.h>
#include <fsfw/internalError/InternalErrorReporter.h>
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw/storagemanager/PoolManager.h>
/**
* @brief Produces system objects.
* @details
* Build tasks by using SystemObject Interface (Interface).
* Header files of all tasks must be included
* Please note that an object has to implement the system object interface
* if the interface validity is checked or retrieved later by using the
* get<TargetInterface>(object_id) function from the ObjectManagerIF.
*
* Framework objects are created first.
*
* @ingroup init
*/
void Factory::produce(void) {
setStaticFrameworkObjectIds();
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
//new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
{
static constexpr uint8_t NUMBER_OF_POOLS = 5;
const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024};
const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5};
new PoolManager<NUMBER_OF_POOLS>(objects::TC_STORE, element_sizes,
n_elements);
}
{
static constexpr uint8_t NUMBER_OF_POOLS = 5;
const uint16_t element_sizes[NUMBER_OF_POOLS] = {16, 32, 64, 128, 1024};
const uint16_t n_elements[NUMBER_OF_POOLS] = {100, 50, 25, 15, 5};
new PoolManager<NUMBER_OF_POOLS>(objects::TM_STORE, element_sizes,
n_elements);
}
{
static constexpr uint8_t NUMBER_OF_POOLS = 6;
const uint16_t element_sizes[NUMBER_OF_POOLS] = {32, 64, 512,
1024, 2048, 4096};
const uint16_t n_elements[NUMBER_OF_POOLS] = {200, 100, 50, 25, 15, 5};
new PoolManager<NUMBER_OF_POOLS>(objects::IPC_STORE, element_sizes,
n_elements);
}
}
void Factory::setStaticFrameworkObjectIds() {
}

View File

@ -1,44 +1,55 @@
#ifndef CONFIG_FSFWCONFIG_H_ #ifndef CONFIG_FSFWCONFIG_H_
#define CONFIG_FSFWCONFIG_H_ #define CONFIG_FSFWCONFIG_H_
#include <FSFWVersion.h> #include <cstddef>
#include <cstdint>
//! Used to determine whether C++ ostreams are used //! Used to determine whether C++ ostreams are used
//! Those can lead to code bloat. //! Those can lead to code bloat.
#define FSFW_CPP_OSTREAM_ENABLED 1 #define FSFW_CPP_OSTREAM_ENABLED 1
//! Reduced printout to further decrese code size //! Reduced printout to further decrease code size
//! Be careful, this also turns off most diagnostic prinouts! //! Be careful, this also turns off most diagnostic prinouts!
#define FSFW_REDUCED_PRINTOUT 0 #define FSFW_ENHANCED_PRINTOUT 0
//! Can be used to enable debugging printouts for developing the FSFW //! Can be used to enable additional debugging printouts for developing the FSFW
#define FSFW_DEBUGGING 0 #define FSFW_PRINT_VERBOSITY_LEVEL 0
//! Defines the FIFO depth of each commanding service base which
//! also determines how many commands a CSB service can handle in one cycle
//! simulataneously. This will increase the required RAM for
//! each CSB service !
#define FSFW_CSB_FIFO_DEPTH 6
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
//! additional output which requires the translation files translateObjects //! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiled source files) //! and translateEvents (and their compiled source files)
#define FSFW_OBJ_EVENT_TRANSLATION 0 #define FSFW_OBJ_EVENT_TRANSLATION 0
//! If -DDEBUG is supplied in the build defines, there will be
//! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiles source files)
#if FSFW_OBJ_EVENT_TRANSLATION == 1 #if FSFW_OBJ_EVENT_TRANSLATION == 1
//! Specify whether info events are printed too. //! Specify whether info events are printed too.
#define FSFW_DEBUG_INFO 1 #define FSFW_DEBUG_INFO 1
#include <translateObjects.h> #include "objects/translateObjects.h"
#include <translateEvents.h> #include "events/translateEvents.h"
#else #else
#endif #endif
//! When using the newlib nano library, C99 support for stdio facilities //! When using the newlib nano library, C99 support for stdio facilities
//! will not be provided. This define should be set to 1 if this is the case. //! will not be provided. This define should be set to 1 if this is the case.
#define FSFW_NO_C99_IO 1 #define FSFW_NO_C99_IO 1
//! Specify whether a special mode store is used for Subsystem components.
#define FSFW_USE_MODESTORE 0
namespace fsfwconfig {
//! Default timestamp size. The default timestamp will be an eight byte CDC
//! short timestamp.
static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8;
//! 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;
//! Defines the FIFO depth of each commanding service base which
//! also determines how many commands a CSB service can handle in one cycle
//! simulataneously. This will increase the required RAM for
//! each CSB service !
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 3;
}
#endif /* CONFIG_FSFWCONFIG_H_ */ #endif /* CONFIG_FSFWCONFIG_H_ */

View File

@ -15,7 +15,7 @@ SHELL = /bin/sh
# (can be overriden by adding CHIP=chip and BOARD=board to the command-line) # (can be overriden by adding CHIP=chip and BOARD=board to the command-line)
# Unit Test can only be run on host machine for now (Linux) # Unit Test can only be run on host machine for now (Linux)
FRAMEWORK_PATH = fsfw FRAMEWORK_PATH = fsfw
FILE_ROOT = $(FRAMEWORK_PATH)/unittest TEST_FILE_ROOT = $(FRAMEWORK_PATH)/unittest
BOARD = unittest BOARD = unittest
LINUX = 1 LINUX = 1
OS_FSFW = linux OS_FSFW = linux
@ -58,9 +58,10 @@ endif
UNIT_TEST = 1 UNIT_TEST = 1
# General folder paths # General folder paths
CONFIG_PATH = $(FILE_ROOT)/config CONFIG_PATH = testcfg
UNIT_TEST_PATH = $(FILE_ROOT)/tests # Core copy has to be copied as well.
CORE_PATH = $(FILE_ROOT)/core CORE_PATH = core
UNIT_TEST_PATH = $(TEST_FILE_ROOT)/tests
# Output file basename # Output file basename
BASENAME = fsfw BASENAME = fsfw
@ -154,8 +155,8 @@ include $(S)/$(notdir $S).mk
endef endef
$(foreach S,$(SUBDIRS),$(eval $(INCLUDE_FILE))) $(foreach S,$(SUBDIRS),$(eval $(INCLUDE_FILE)))
INCLUDES += $(FILE_ROOT) INCLUDES += $(TEST_FILE_ROOT)
INCLUDES += $(FILE_ROOT)/catch2/ INCLUDES += $(TEST_FILE_ROOT)/catch2/
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Source Files # Source Files

View File

@ -6,11 +6,3 @@ CXXSRC += $(wildcard $(CURRENTPATH)/events/*.cpp)
CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp) CXXSRC += $(wildcard $(CURRENTPATH)/*.cpp)
INCLUDES += $(CURRENTPATH) INCLUDES += $(CURRENTPATH)
INCLUDES += $(CURRENTPATH)/objects
INCLUDES += $(CURRENTPATH)/ipc
INCLUDES += $(CURRENTPATH)/pollingsequence
INCLUDES += $(CURRENTPATH)/returnvalues
INCLUDES += $(CURRENTPATH)/tmtc
INCLUDES += $(CURRENTPATH)/events
INCLUDES += $(CURRENTPATH)/devices
INCLUDES += $(CURRENTPATH)/cdatapool