Merge remote-tracking branch 'upstream/mueller/master' into mueller/master
This commit is contained in:
commit
2d28f71eca
@ -106,7 +106,7 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(WARNING_FLAGS
|
||||
-Wall
|
||||
-Wextra
|
||||
|
133
README.md
133
README.md
@ -9,121 +9,40 @@ The initial version of the Flight Software Framework was developed during
|
||||
the Flying Laptop Project by the University of Stuttgart in cooperation
|
||||
with Airbus Defence and Space GmbH.
|
||||
|
||||
## Intended Use
|
||||
## Quick facts
|
||||
|
||||
The framework is designed for systems, which communicate with external devices, perform control loops, receive telecommands and send telemetry, and need to maintain a high level of availability.
|
||||
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.
|
||||
The framework is designed for systems, which communicate with external devices, perform control loops, receive telecommands and send telemetry, and need to maintain a high level of availability. 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.
|
||||
|
||||
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.
|
||||
The `fsfw` was also tested on the STM32H743ZI-Nucleo board.
|
||||
The FSFW provides abstraction layers for operating systems to provide a uniform operating system abstraction layer (OSAL). Some components of this OSAL are required internally by the FSFW but is also very useful for developers to implement the same application logic on different operating systems with a uniform interface.
|
||||
|
||||
## How to Use
|
||||
Currently, the FSFW provides the following OSALs:
|
||||
|
||||
- Linux
|
||||
- Host
|
||||
- FreeRTOS
|
||||
- RTEMS
|
||||
|
||||
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. The `fsfw` was also successfully run on the STM32H743ZI-Nucleo board and on a Raspberry Pi and is currently running on the active satellite mission Flying Laptop.
|
||||
|
||||
## Getting started
|
||||
|
||||
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. It is recommended to evaluate the FSFW by building and playing around with the demo application.
|
||||
|
||||
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 configuration folder and adding it to the include path. There are some functions like `printChar` which are different depending on the target architecture and need to be implemented by the mission developer.
|
||||
|
||||
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.
|
||||
a starting point. The [configuration section](doc/README-config.md#top) provides more specific information about the possible options.
|
||||
|
||||
## Structure
|
||||
## Index
|
||||
|
||||
The general structure is driven by the usage of interfaces provided by objects.
|
||||
The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be widely available, even with older compilers.
|
||||
The FSFW uses dynamic allocation during the initialization but provides static containers during runtime.
|
||||
This simplifies the instantiation of objects and allows the usage of some standard containers.
|
||||
Dynamic Allocation after initialization is discouraged and different solutions are provided in the FSFW to achieve that.
|
||||
The fsfw uses run-time type information but exceptions are not allowed.
|
||||
[1. High-level overview](doc/README-highlevel.md#top) <br>
|
||||
[2. Core components](doc/README-core.md#top) <br>
|
||||
[3. OSAL overview](doc/README-osal.md#top) <br>
|
||||
[4. PUS services](doc/README-pus.md#top) <br>
|
||||
[5. Device Handler overview](doc/README-devicehandlers.md#top) <br>
|
||||
[6. Controller overview](doc/README-controllers.md#top) <br>
|
||||
[7. Local Data Pools](doc/README-localpools.md#top) <br>
|
||||
|
||||
### Failure Handling
|
||||
|
||||
Functions should return a defined ReturnValue_t to signal to the caller that something has gone wrong.
|
||||
Returnvalues must be unique. For this the function 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.
|
||||
|
||||
### OSAL
|
||||
|
||||
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
|
||||
|
||||
The FSFW has following core components. More detailed informations can be found in the
|
||||
[core component section](doc/README-core.md#top):
|
||||
|
||||
1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks with fixed timeslots
|
||||
2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID to the object handles.
|
||||
3. Static Stores: Different stores are provided to store data of variable size (like telecommands or small telemetry) in a pool structure without
|
||||
using dynamic memory allocation. These pools are allocated up front.
|
||||
3. Clock: This module provided common time related functions
|
||||
4. EventManager: This module allows routing of events generated by `SystemObjects`
|
||||
5. HealthTable: A component which stores the health states of objects
|
||||
|
||||
### Static Ids in the framework
|
||||
|
||||
Some parts of the framework use a static routing address for communication.
|
||||
An example setup of ids can be found in the example config in "defaultcft/fsfwconfig/objects/Factory::setStaticFrameworkObjectIds()".
|
||||
|
||||
### Events
|
||||
|
||||
Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT. This works analog to the returnvalues.
|
||||
Every object that needs own EventIds has to get a unique SUBSYSTEM_ID.
|
||||
Every SystemObject can call triggerEvent from the parent class.
|
||||
Therefore, event messages contain the specific EventId and the objectId of the object that has triggered.
|
||||
|
||||
### Internal Communication
|
||||
|
||||
Components communicate mostly over Message through Queues.
|
||||
Those queues are created by calling the singleton QueueFactory::instance()->create().
|
||||
|
||||
### External Communication
|
||||
|
||||
The external communication with the mission control system is mostly up to the user implementation.
|
||||
The FSFW provides PUS Services which can be used to but don't need to be used.
|
||||
The services can be seen as a conversion from a TC to a message based communication and back.
|
||||
|
||||
#### CCSDS Frames, CCSDS Space Packets and PUS
|
||||
|
||||
If the communication is based on CCSDS Frames and Space Packets, several classes can be used to distributed the packets to the corresponding services. Those can be found in tcdistribution.
|
||||
If Space Packets are used, a timestamper must be created.
|
||||
An example can be found in the timemanager folder, this uses CCSDSTime::CDS_short.
|
||||
|
||||
#### Device Handlers
|
||||
|
||||
DeviceHandlers are another important component of the FSFW.
|
||||
The idea is, to have a software counterpart of every physical device to provide a simple mode, health and commanding interface.
|
||||
By separating the underlying Communication Interface with DeviceCommunicationIF, a device handler (DH) can be tested on different hardware.
|
||||
The DH has mechanisms to monitor the communication with the physical device which allow for FDIR reaction.
|
||||
Device Handlers can be created by overriding `DeviceHandlerBase`.
|
||||
A standard FDIR component for the DH will be created automatically but can be overwritten by the user.
|
||||
More information on DeviceHandlers can be found in the related [documentation section](doc/README-devicehandlers.md#top).
|
||||
|
||||
#### Modes, Health
|
||||
|
||||
The two interfaces HasModesIF and HasHealthIF provide access for commanding and monitoring of components.
|
||||
On-board Mode Management is implement in hierarchy system.
|
||||
DeviceHandlers and Controllers are the lowest part of the hierarchy.
|
||||
The next layer are Assemblies. Those assemblies act as a component which handle redundancies of handlers.
|
||||
Assemblies share a common core with the next level which are the Subsystems.
|
||||
|
||||
Those Assemblies are intended to act as auto-generated components from a database which describes the subsystem modes.
|
||||
The definitions contain transition and target tables which contain the DH, Assembly and Controller Modes to be commanded.
|
||||
Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a switch into any higher AOCS mode might first turn on the sensors, than the actuators and the controller as last component.
|
||||
The target table is used to describe the state that is checked continuously by the subsystem.
|
||||
All of this allows System Modes to be generated as Subsystem object as well from the same database.
|
||||
This System contains list of subsystem modes in the transition and target tables.
|
||||
Therefore, it allows a modular system to create system modes and easy commanding of those, because only the highest components must be commanded.
|
||||
|
||||
The health state represents if the component is able to perform its tasks.
|
||||
This can be used to signal the system to avoid using this component instead of a redundant one.
|
||||
The on-board FDIR uses the health state for isolation and recovery.
|
||||
|
||||
## Unit Tests
|
||||
|
||||
Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include catch2 itself.
|
||||
See README.md in the unittest Folder.
|
@ -214,6 +214,10 @@ void PoolDataSetBase::setContainer(PoolVariableIF **variablesContainer) {
|
||||
this->registeredVariables = variablesContainer;
|
||||
}
|
||||
|
||||
PoolVariableIF** PoolDataSetBase::getContainer() const {
|
||||
return registeredVariables;
|
||||
}
|
||||
|
||||
void PoolDataSetBase::setReadCommitProtectionBehaviour(
|
||||
bool protectEveryReadCommit, uint32_t mutexTimeout) {
|
||||
this->protectEveryReadCommitCall = protectEveryReadCommit;
|
||||
|
@ -157,6 +157,7 @@ protected:
|
||||
const size_t maxFillCount = 0;
|
||||
|
||||
void setContainer(PoolVariableIF** variablesContainer);
|
||||
PoolVariableIF** getContainer() const;
|
||||
|
||||
private:
|
||||
bool protectEveryReadCommitCall = false;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "locPoolDefinitions.h"
|
||||
|
||||
#include "../datapool/PoolEntryIF.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../housekeeping/HousekeepingMessage.h"
|
||||
|
||||
@ -92,6 +93,9 @@ public:
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden"
|
||||
<< ". Returning nullptr!" << std::endl;
|
||||
#else
|
||||
fsfw::printWarning("HasLocalDataPoolIF::getPoolObjectHandle: "
|
||||
"Not overriden. Returning nullptr!\n");
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
||||
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if(ipcStore == nullptr) {
|
||||
// error, all destinations invalid
|
||||
// error, all destinations invalid
|
||||
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||
"initialize", HasReturnvaluesIF::RETURN_FAILED,
|
||||
"Could not set IPC store.");
|
||||
@ -65,7 +65,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
||||
else {
|
||||
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||
"initialize", QUEUE_OR_DESTINATION_INVALID);
|
||||
return QUEUE_OR_DESTINATION_INVALID;
|
||||
return QUEUE_OR_DESTINATION_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,8 +308,8 @@ void LocalDataPoolManager::handleChangeResetLogic(
|
||||
// config error!
|
||||
return;
|
||||
}
|
||||
|
||||
for(auto& changeInfo: *hkUpdateResetList) {
|
||||
HkUpdateResetList& listRef = *hkUpdateResetList;
|
||||
for(auto& changeInfo: listRef) {
|
||||
if(changeInfo.dataType != type) {
|
||||
continue;
|
||||
}
|
||||
@ -322,12 +322,16 @@ void LocalDataPoolManager::handleChangeResetLogic(
|
||||
continue;
|
||||
}
|
||||
|
||||
// only one update recipient, we can reset changes status immediately.
|
||||
if(changeInfo.updateCounter <= 1) {
|
||||
toReset->setChanged(false);
|
||||
}
|
||||
if(changeInfo.currentUpdateCounter == 0) {
|
||||
// All recipients have been notified, reset the changed flag.
|
||||
if(changeInfo.currentUpdateCounter <= 1) {
|
||||
toReset->setChanged(false);
|
||||
changeInfo.currentUpdateCounter = 0;
|
||||
}
|
||||
// Not all recipiens have been notified yet, decrement.
|
||||
else {
|
||||
changeInfo.currentUpdateCounter--;
|
||||
}
|
||||
@ -509,10 +513,13 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||
break;
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES):
|
||||
return generateSetStructurePacket(sid, true);
|
||||
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES):
|
||||
return generateSetStructurePacket(sid, false);
|
||||
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): {
|
||||
return generateSetStructurePacket(sid, true);
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): {
|
||||
return generateSetStructurePacket(sid, false);
|
||||
}
|
||||
case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL):
|
||||
case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): {
|
||||
float newCollIntvl = 0;
|
||||
@ -633,7 +640,7 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
||||
}
|
||||
|
||||
if(hkQueue == nullptr) {
|
||||
// error, all destinations invalid
|
||||
// error, no queue available to send packet with.
|
||||
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||
"generateHousekeepingPacket",
|
||||
QUEUE_OR_DESTINATION_INVALID);
|
||||
@ -813,6 +820,11 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
||||
return result;
|
||||
}
|
||||
|
||||
void LocalDataPoolManager::clearReceiversList() {
|
||||
// clear the vector completely and releases allocated memory.
|
||||
HkReceivers().swap(hkReceiversMap);
|
||||
}
|
||||
|
||||
void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
|
||||
const char* functionName, ReturnValue_t error, const char* errorPrint) {
|
||||
if(errorPrint == nullptr) {
|
||||
|
@ -250,6 +250,12 @@ public:
|
||||
LocalDataPoolManager(const LocalDataPoolManager &) = delete;
|
||||
LocalDataPoolManager operator=(const LocalDataPoolManager&) = delete;
|
||||
|
||||
/**
|
||||
* This function can be used to clear the receivers list. This is
|
||||
* intended for test functions and not for regular operations, because
|
||||
* the insertion operations allocate dynamically.
|
||||
*/
|
||||
void clearReceiversList();
|
||||
private:
|
||||
LocalDataPool localPoolMap;
|
||||
//! Every housekeeping data manager has a mutex to protect access
|
||||
|
1
doc/README-controllers.md
Normal file
1
doc/README-controllers.md
Normal file
@ -0,0 +1 @@
|
||||
## Controllers
|
@ -16,9 +16,8 @@ Flight Software Framework
|
||||
* 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 )
|
||||
|
||||
```cpp
|
||||
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.
|
||||
|
@ -1 +1 @@
|
||||
## FSFW DeviceHandlers
|
||||
## Device Handlers
|
||||
|
99
doc/README-highlevel.md
Normal file
99
doc/README-highlevel.md
Normal file
@ -0,0 +1,99 @@
|
||||
# High-level overview
|
||||
|
||||
## Structure
|
||||
|
||||
The general structure is driven by the usage of interfaces provided by objects.
|
||||
The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be widely available, even with older compilers.
|
||||
The FSFW uses dynamic allocation during the initialization but provides static containers during runtime.
|
||||
This simplifies the instantiation of objects and allows the usage of some standard containers.
|
||||
Dynamic Allocation after initialization is discouraged and different solutions are provided in the FSFW to achieve that.
|
||||
The fsfw uses run-time type information but exceptions are not allowed.
|
||||
|
||||
### Failure Handling
|
||||
|
||||
Functions should return a defined ReturnValue_t to signal to the caller that something has gone wrong.
|
||||
Returnvalues must be unique. For this the function 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.
|
||||
|
||||
### OSAL
|
||||
|
||||
The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS.
|
||||
The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes.
|
||||
The [OSAL README](doc/README-osal.md#top) provides more detailed information on provided components and how to use them.
|
||||
|
||||
### Core Components
|
||||
|
||||
The FSFW has following core components. More detailed informations can be found in the
|
||||
[core component section](doc/README-core.md#top):
|
||||
|
||||
1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks with fixed timeslots
|
||||
2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID to the object handles.
|
||||
3. Static Stores: Different stores are provided to store data of variable size (like telecommands or small telemetry) in a pool structure without
|
||||
using dynamic memory allocation. These pools are allocated up front.
|
||||
3. Clock: This module provided common time related functions
|
||||
4. EventManager: This module allows routing of events generated by `SystemObjects`
|
||||
5. HealthTable: A component which stores the health states of objects
|
||||
|
||||
### Static IDs in the framework
|
||||
|
||||
Some parts of the framework use a static routing address for communication.
|
||||
An example setup of ids can be found in the example config in "defaultcft/fsfwconfig/objects/Factory::setStaticFrameworkObjectIds()".
|
||||
|
||||
### Events
|
||||
|
||||
Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT. This works analog to the returnvalues.
|
||||
Every object that needs own EventIds has to get a unique SUBSYSTEM_ID.
|
||||
Every SystemObject can call triggerEvent from the parent class.
|
||||
Therefore, event messages contain the specific EventId and the objectId of the object that has triggered.
|
||||
|
||||
### Internal Communication
|
||||
|
||||
Components communicate mostly over Message through Queues.
|
||||
Those queues are created by calling the singleton QueueFactory::instance()->create().
|
||||
|
||||
### External Communication
|
||||
|
||||
The external communication with the mission control system is mostly up to the user implementation.
|
||||
The FSFW provides PUS Services which can be used to but don't need to be used.
|
||||
The services can be seen as a conversion from a TC to a message based communication and back.
|
||||
|
||||
#### CCSDS Frames, CCSDS Space Packets and PUS
|
||||
|
||||
If the communication is based on CCSDS Frames and Space Packets, several classes can be used to distributed the packets to the corresponding services. Those can be found in tcdistribution.
|
||||
If Space Packets are used, a timestamper must be created.
|
||||
An example can be found in the timemanager folder, this uses CCSDSTime::CDS_short.
|
||||
|
||||
#### Device Handlers
|
||||
|
||||
DeviceHandlers are another important component of the FSFW.
|
||||
The idea is, to have a software counterpart of every physical device to provide a simple mode, health and commanding interface.
|
||||
By separating the underlying Communication Interface with DeviceCommunicationIF, a device handler (DH) can be tested on different hardware.
|
||||
The DH has mechanisms to monitor the communication with the physical device which allow for FDIR reaction.
|
||||
Device Handlers can be created by overriding `DeviceHandlerBase`.
|
||||
A standard FDIR component for the DH will be created automatically but can be overwritten by the user.
|
||||
More information on DeviceHandlers can be found in the related [documentation section](doc/README-devicehandlers.md#top).
|
||||
|
||||
#### Modes, Health
|
||||
|
||||
The two interfaces HasModesIF and HasHealthIF provide access for commanding and monitoring of components.
|
||||
On-board Mode Management is implement in hierarchy system.
|
||||
DeviceHandlers and Controllers are the lowest part of the hierarchy.
|
||||
The next layer are Assemblies. Those assemblies act as a component which handle redundancies of handlers.
|
||||
Assemblies share a common core with the next level which are the Subsystems.
|
||||
|
||||
Those Assemblies are intended to act as auto-generated components from a database which describes the subsystem modes.
|
||||
The definitions contain transition and target tables which contain the DH, Assembly and Controller Modes to be commanded.
|
||||
Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a switch into any higher AOCS mode might first turn on the sensors, than the actuators and the controller as last component.
|
||||
The target table is used to describe the state that is checked continuously by the subsystem.
|
||||
All of this allows System Modes to be generated as Subsystem object as well from the same database.
|
||||
This System contains list of subsystem modes in the transition and target tables.
|
||||
Therefore, it allows a modular system to create system modes and easy commanding of those, because only the highest components must be commanded.
|
||||
|
||||
The health state represents if the component is able to perform its tasks.
|
||||
This can be used to signal the system to avoid using this component instead of a redundant one.
|
||||
The on-board FDIR uses the health state for isolation and recovery.
|
||||
|
||||
## Unit Tests
|
||||
|
||||
Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include catch2 itself. More information on how to run these tests can be found in the separate
|
||||
[`fsfw_tests` reposoitory](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_tests)
|
3
doc/README-localpools.md
Normal file
3
doc/README-localpools.md
Normal file
@ -0,0 +1,3 @@
|
||||
## Local Data Pools
|
||||
|
||||
|
32
doc/README-osal.md
Normal file
32
doc/README-osal.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Operating System Abstraction Layer (OSAL)
|
||||
|
||||
Some specific information on the provided OSALs are provided.
|
||||
|
||||
## Linux OSAL
|
||||
|
||||
This OSAL can be used to compile for Linux host systems like Ubuntu 20.04 or for
|
||||
embedded Linux targets like the Raspberry Pi. This OSAL generally requires threading support
|
||||
and real-time functionalities. For most UNIX systems, this is done by adding `-lrt` and `-lpthread` to the linked libraries in the compilation process. The CMake build support provided will do this automatically for the `fsfw` target. It should be noted that most UNIX systems need to be configured specifically to allow the real-time functionalities required by the FSFW.
|
||||
|
||||
More information on how to set up a Linux system accordingly can be found in the
|
||||
[Linux README of the FSFW example application](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example/src/branch/master/doc/README-linux.md#top)
|
||||
|
||||
## Hosted OSAL
|
||||
|
||||
This is the newest OSAL. Support for Semaphores has not been implemented yet and will propably be implemented as soon as C++20 with Semaphore support has matured. This OSAL can be used to run the FSFW on any host system, but currently has only been tested on Windows 10 and Ubuntu 20.04. Unlike the other OSALs, it uses dynamic memory allocation (e.g. for the message queue implementation). Cross-platform serial port (USB) support might be added soon.
|
||||
|
||||
## FreeRTOS OSAL
|
||||
|
||||
FreeRTOS is not included and the developer needs to take care of compiling the FreeRTOS sources and adding the `FreeRTOSConfig.h` file location to the include path. This OSAL has only been tested extensively with the pre-emptive scheduler configuration so far but it should in principle also be possible to use a cooperative scheduler. It is recommended to use the `heap_4` allocation scheme. When using newlib (nano), it is also recommended to add `#define configUSE_NEWLIB_REENTRANT` to the FreeRTOS configuration file to ensure thread-safety.
|
||||
|
||||
When using this OSAL, developers also need to provide an implementation for the `vRequestContextSwitchFromISR` function. This has been done because the call to request a context switch from an ISR is generally located in the `portmacro.h` header and is different depending on the target architecture or device.
|
||||
|
||||
## RTEMS OSAL
|
||||
|
||||
The RTEMS OSAL was the first implemented OSAL which is also used on the active satellite Flying Laptop.
|
||||
|
||||
## TCP/IP socket abstraction
|
||||
|
||||
The Linux and Host OSAL provide abstraction layers for the socket API. Currently, only UDP sockets have been imlemented. This is very useful to test TMTC handling either on the host computer directly (targeting localhost with a TMTC application) or on embedded Linux devices, sending TMTC packets via Ethernet.
|
||||
|
||||
|
1
doc/README-pus.md
Normal file
1
doc/README-pus.md
Normal file
@ -0,0 +1 @@
|
||||
## PUS Services
|
@ -1,10 +1,11 @@
|
||||
#include "BinarySemaphore.h"
|
||||
#include "../../serviceinterface/ServiceInterfacePrinter.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
extern "C" {
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
}
|
||||
|
||||
|
||||
BinarySemaphore::BinarySemaphore() {
|
||||
// Using unnamed semaphores for now
|
||||
@ -113,7 +114,8 @@ uint8_t BinarySemaphore::getSemaphoreCounter(sem_t *handle) {
|
||||
}
|
||||
else if(result != 0 and errno == EINVAL) {
|
||||
// Could be called from interrupt, use lightweight printf
|
||||
printf("BinarySemaphore::getSemaphoreCounter: Invalid semaphore\n");
|
||||
fsfw::printError("BinarySemaphore::getSemaphoreCounter: "
|
||||
"Invalid semaphore\n");
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
@ -128,13 +130,17 @@ void BinarySemaphore::initSemaphore(uint8_t initCount) {
|
||||
switch(errno) {
|
||||
case(EINVAL):
|
||||
// Value exceeds SEM_VALUE_MAX
|
||||
case(ENOSYS):
|
||||
// System does not support process-shared semaphores
|
||||
case(ENOSYS): {
|
||||
// System does not support process-shared semaphores
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "BinarySemaphore: Init failed with" << strerror(errno)
|
||||
<< std::endl;
|
||||
sif::error << "BinarySemaphore: Init failed with "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
fsfw::printError("BinarySemaphore: Init failed with %s\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "../../osal/linux/CountingSemaphore.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount):
|
||||
maxCount(maxCount), initCount(initCount) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "MessageQueue.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
#include <fstream>
|
||||
@ -121,14 +121,16 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
default: {
|
||||
// Failed either the first time or the second time
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex
|
||||
<< name << std::dec << " failed with status: "
|
||||
<< strerror(errno) << std::endl;
|
||||
sif::error << "MessageQueue::MessageQueue: Creating Queue " << name
|
||||
<< " failed with status: " << strerror(errno) << std::endl;
|
||||
#else
|
||||
fsfw::printError("MessageQueue::MessageQueue: Creating Queue %s"
|
||||
" failed with status: %s\n", name, strerror(errno));
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "PosixThread.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
@ -146,16 +146,22 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
if(errno == ENOMEM) {
|
||||
uint64_t stackMb = stackSize/10e6;
|
||||
size_t stackMb = stackSize/10e6;
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: Insufficient memory for"
|
||||
" the requested " << stackMb << " MB" << std::endl;
|
||||
#else
|
||||
fsfw::printError("PosixThread::createTask: Insufficient memory for "
|
||||
"the requested %zu MB\n", stackMb);
|
||||
#endif
|
||||
}
|
||||
else if(errno == EINVAL) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: Wrong alignment argument!"
|
||||
<< std::endl;
|
||||
#else
|
||||
fsfw::printError("PosixThread::createTask: "
|
||||
"Wrong alignment argument!\n");
|
||||
#endif
|
||||
}
|
||||
return;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "TcUnixUdpPollingTask.h"
|
||||
#include "../../globalfunctions/arrayprinter.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
TcUnixUdpPollingTask::TcUnixUdpPollingTask(object_id_t objectId,
|
||||
object_id_t tmtcUnixUdpBridge, size_t frameSize,
|
||||
double timeoutSeconds): SystemObject(objectId),
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "TmTcUnixUdpBridge.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../ipc/MutexHelper.h"
|
||||
|
||||
#include <errno.h>
|
||||
@ -188,12 +188,16 @@ void TmTcUnixUdpBridge::handleBindError() {
|
||||
|
||||
void TmTcUnixUdpBridge::handleSendError() {
|
||||
switch(errno) {
|
||||
default:
|
||||
default: {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "TmTcUnixBridge::handleSendError: "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
fsfw::printError("TmTcUnixBridge::handleSendError: %s\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TmTcUnixUdpBridge::setClientAddressToAny(bool ipAddrAnySet){
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include <fsfw/action/ActionHelper.h>
|
||||
#include <fsfw/ipc/CommandMessage.h>
|
||||
#include <fsfw/unittest/tests/mocks/MessageQueueMockBase.h>
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
|
@ -48,85 +48,4 @@ public:
|
||||
};
|
||||
|
||||
|
||||
class MessageQueueMockBase: public MessageQueueIF {
|
||||
public:
|
||||
MessageQueueId_t myQueueId = 0;
|
||||
bool defaultDestSet = false;
|
||||
bool messageSent = false;
|
||||
|
||||
|
||||
|
||||
bool wasMessageSent() {
|
||||
bool tempMessageSent = messageSent;
|
||||
messageSent = false;
|
||||
return tempMessageSent;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t reply( MessageQueueMessageIF* message ) {
|
||||
messageSent = true;
|
||||
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
};
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
|
||||
MessageQueueId_t *receivedFrom) {
|
||||
(*message) = lastMessage;
|
||||
lastMessage.clear();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) {
|
||||
memcpy(message->getBuffer(), lastMessage.getBuffer(),
|
||||
message->getMessageSize());
|
||||
lastMessage.clear();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t flush(uint32_t* count) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual MessageQueueId_t getLastPartner() const {
|
||||
return tconst::testQueueId;
|
||||
}
|
||||
virtual MessageQueueId_t getId() const {
|
||||
return tconst::testQueueId;
|
||||
}
|
||||
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault = false ) {
|
||||
messageSent = true;
|
||||
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, bool ignoreFault = false ) override {
|
||||
messageSent = true;
|
||||
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message,
|
||||
MessageQueueId_t sentFrom, bool ignoreFault = false ) {
|
||||
messageSent = true;
|
||||
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t sendToDefault( MessageQueueMessageIF* message ) {
|
||||
messageSent = true;
|
||||
lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual void setDefaultDestination(MessageQueueId_t defaultDestination) {
|
||||
myQueueId = defaultDestination;
|
||||
defaultDestSet = true;
|
||||
}
|
||||
|
||||
virtual MessageQueueId_t getDefaultDestination() const {
|
||||
return myQueueId;
|
||||
}
|
||||
virtual bool isDefaultDestinationSet() const {
|
||||
return defaultDestSet;
|
||||
}
|
||||
private:
|
||||
MessageQueueMessage lastMessage;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* UNITTEST_TESTFW_NEWTESTS_TESTACTIONHELPER_H_ */
|
||||
|
@ -2,4 +2,5 @@ target_sources(${TARGET_NAME} PRIVATE
|
||||
LocalPoolVariableTest.cpp
|
||||
LocalPoolVectorTest.cpp
|
||||
DataSetTest.cpp
|
||||
LocalPoolManagerTest.cpp
|
||||
)
|
||||
|
122
unittest/tests/datapoollocal/LocalPoolManagerTest.cpp
Normal file
122
unittest/tests/datapoollocal/LocalPoolManagerTest.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
#include "LocalPoolOwnerBase.h"
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/ipc/CommandMessageCleaner.h>
|
||||
#include <unittest/core/CatchDefinitions.h>
|
||||
|
||||
|
||||
TEST_CASE("LocalPoolManagerTest" , "[LocManTest]") {
|
||||
LocalPoolOwnerBase* poolOwner = objectManager->
|
||||
get<LocalPoolOwnerBase>(objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
REQUIRE(poolOwner != nullptr);
|
||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||
== retval::CATCH_OK);
|
||||
REQUIRE(poolOwner->dataset.assignPointers() == retval::CATCH_OK);
|
||||
MessageQueueMockBase* mqMock = poolOwner->getMockQueueHandle();
|
||||
REQUIRE(mqMock != nullptr);
|
||||
CommandMessage messageSent;
|
||||
uint8_t messagesSent = 0;
|
||||
|
||||
|
||||
SECTION("BasicTest") {
|
||||
// Subscribe for message generation on update.
|
||||
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
|
||||
// Subscribe for an update message.
|
||||
poolOwner->dataset.setChanged(true);
|
||||
// Now the update message should be generated.
|
||||
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||
REQUIRE(mqMock->wasMessageSent() == true);
|
||||
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
|
||||
// Should have been reset.
|
||||
CHECK(poolOwner->dataset.hasChanged() == false);
|
||||
// Set changed again, result should be the same.
|
||||
poolOwner->dataset.setChanged(true);
|
||||
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 1);
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
|
||||
// now subscribe for set update HK as well.
|
||||
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
|
||||
poolOwner->dataset.setChanged(true);
|
||||
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 2);
|
||||
// first message sent should be the update notification, considering
|
||||
// the internal list is a vector checked in insertion order.
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::HK_REPORT));
|
||||
// clear message to avoid memory leak, our mock won't do it for us (yet)
|
||||
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
||||
}
|
||||
|
||||
SECTION("AdvancedTests") {
|
||||
// we need to reset the subscription list because the pool owner
|
||||
// is a global object.
|
||||
poolOwner->resetSubscriptionList();
|
||||
// Subscribe for variable update as well
|
||||
REQUIRE(not poolOwner->dataset.hasChanged());
|
||||
REQUIRE(poolOwner->subscribeWrapperVariableUpdate(lpool::uint8VarId) ==
|
||||
retval::CATCH_OK);
|
||||
lp_var_t<uint8_t>* poolVar = dynamic_cast<lp_var_t<uint8_t>*>(
|
||||
poolOwner->getPoolObjectHandle(lpool::uint8VarId));
|
||||
REQUIRE(poolVar != nullptr);
|
||||
poolVar->setChanged(true);
|
||||
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||
|
||||
// Check update notification was sent.
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 1);
|
||||
// Should have been reset.
|
||||
CHECK(poolVar->hasChanged() == false);
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||
|
||||
// now subscribe for the dataset update (HK and update) again
|
||||
REQUIRE(poolOwner->subscribeWrapperSetUpdate() == retval::CATCH_OK);
|
||||
REQUIRE(poolOwner->subscribeWrapperSetUpdateHk() == retval::CATCH_OK);
|
||||
|
||||
poolOwner->dataset.setChanged(true);
|
||||
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||
// now two messages should be sent.
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 2);
|
||||
mqMock->clearMessages(true);
|
||||
|
||||
poolOwner->dataset.setChanged(true);
|
||||
poolVar->setChanged(true);
|
||||
REQUIRE(poolOwner->hkManager.performHkOperation() == retval::CATCH_OK);
|
||||
// now three messages should be sent.
|
||||
REQUIRE(mqMock->wasMessageSent(&messagesSent) == true);
|
||||
CHECK(messagesSent == 3);
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE));
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::UPDATE_NOTIFICATION_SET));
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) == retval::CATCH_OK);
|
||||
CHECK(messageSent.getCommand() == static_cast<int>(
|
||||
HousekeepingMessage::HK_REPORT));
|
||||
CommandMessageCleaner::clearCommandMessage(&messageSent);
|
||||
REQUIRE(mqMock->receiveMessage(&messageSent) ==
|
||||
static_cast<int>(MessageQueueIF::EMPTY));
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,14 @@
|
||||
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||
|
||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||
#include <fsfw/datapoollocal/LocalDataSet.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||
#include <fsfw/datapoollocal/LocalPoolVector.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <testcfg/objects/systemObjectList.h>
|
||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||
#include <fsfw/unittest/tests/mocks/MessageQueueMockBase.h>
|
||||
|
||||
namespace lpool {
|
||||
static constexpr lp_id_t uint8VarId = 0;
|
||||
@ -14,16 +17,48 @@ static constexpr lp_id_t floatVarId = 1;
|
||||
static constexpr lp_id_t uint32VarId = 2;
|
||||
static constexpr lp_id_t uint16Vec3Id = 3;
|
||||
static constexpr lp_id_t int64Vec2Id = 4;
|
||||
|
||||
static constexpr uint32_t testSetId = 0;
|
||||
static constexpr uint8_t dataSetMaxVariables = 10;
|
||||
static const sid_t testSid = sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE,
|
||||
testSetId);
|
||||
}
|
||||
|
||||
|
||||
class LocalPoolTestDataSet: public LocalDataSet {
|
||||
public:
|
||||
LocalPoolTestDataSet(HasLocalDataPoolIF* owner, uint32_t setId):
|
||||
LocalDataSet(owner, setId, lpool::dataSetMaxVariables) {
|
||||
}
|
||||
|
||||
ReturnValue_t assignPointers() {
|
||||
PoolVariableIF** rawVarArray = getContainer();
|
||||
localPoolVarUint8 = dynamic_cast<lp_var_t<uint8_t>*>(rawVarArray[0]);
|
||||
localPoolVarFloat = dynamic_cast<lp_var_t<float>*>(rawVarArray[1]);
|
||||
localPoolUint16Vec = dynamic_cast<lp_vec_t<uint16_t, 3>*>(
|
||||
rawVarArray[2]);
|
||||
if(localPoolVarUint8 == nullptr or localPoolVarFloat == nullptr or
|
||||
localPoolUint16Vec == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
lp_var_t<uint8_t>* localPoolVarUint8 = nullptr;
|
||||
lp_var_t<float>* localPoolVarFloat = nullptr;
|
||||
lp_vec_t<uint16_t, 3>* localPoolUint16Vec = nullptr;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
class LocalPoolOwnerBase: public SystemObject, public HasLocalDataPoolIF {
|
||||
public:
|
||||
LocalPoolOwnerBase(
|
||||
object_id_t objectId = objects::TEST_LOCAL_POOL_OWNER_BASE):
|
||||
SystemObject(objectId), hkManager(this, messageQueue) {
|
||||
messageQueue = QueueFactory::instance()->createMessageQueue(10);
|
||||
SystemObject(objectId), hkManager(this, messageQueue),
|
||||
dataset(this, lpool::testSetId) {
|
||||
messageQueue = new MessageQueueMockBase();
|
||||
}
|
||||
|
||||
~LocalPoolOwnerBase() {
|
||||
@ -89,22 +124,70 @@ public:
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override {
|
||||
// empty for now
|
||||
return nullptr;
|
||||
return &dataset;
|
||||
}
|
||||
|
||||
virtual LocalPoolObjectBase* getPoolObjectHandle(
|
||||
lp_id_t localPoolId) override {
|
||||
if(localPoolId == lpool::uint8VarId) {
|
||||
return &testUint8;
|
||||
}
|
||||
else if(localPoolId == lpool::uint16Vec3Id) {
|
||||
return &testUint16Vec;
|
||||
}
|
||||
else if(localPoolId == lpool::floatVarId) {
|
||||
return &testFloat;
|
||||
}
|
||||
else if(localPoolId == lpool::int64Vec2Id) {
|
||||
return &testInt64Vec;
|
||||
}
|
||||
else if(localPoolId == lpool::uint32VarId) {
|
||||
return &testUint32;
|
||||
}
|
||||
else {
|
||||
return &testUint8;
|
||||
}
|
||||
}
|
||||
|
||||
MessageQueueMockBase* getMockQueueHandle() const {
|
||||
return dynamic_cast<MessageQueueMockBase*>(messageQueue);
|
||||
}
|
||||
|
||||
ReturnValue_t subscribeWrapperSetUpdate() {
|
||||
return hkManager.subscribeForSetUpdateMessages(lpool::testSetId,
|
||||
objects::NO_OBJECT, MessageQueueIF::NO_QUEUE, false);
|
||||
}
|
||||
|
||||
ReturnValue_t subscribeWrapperSetUpdateHk(bool diagnostics = false) {
|
||||
return hkManager.subscribeForUpdatePackets(lpool::testSid, diagnostics,
|
||||
false, objects::HK_RECEIVER_MOCK);
|
||||
}
|
||||
|
||||
ReturnValue_t subscribeWrapperVariableUpdate(lp_id_t localPoolId) {
|
||||
return hkManager.subscribeForVariableUpdateMessages(localPoolId,
|
||||
MessageQueueIF::NO_QUEUE, objects::NO_OBJECT, false);
|
||||
}
|
||||
|
||||
void resetSubscriptionList() {
|
||||
hkManager.clearReceiversList();
|
||||
}
|
||||
|
||||
LocalDataPoolManager hkManager;
|
||||
LocalPoolTestDataSet dataset;
|
||||
private:
|
||||
|
||||
lp_var_t<uint8_t> testUint8 = lp_var_t<uint8_t>(this, lpool::uint8VarId);
|
||||
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId);
|
||||
lp_var_t<uint8_t> testUint8 = lp_var_t<uint8_t>(this, lpool::uint8VarId,
|
||||
&dataset);
|
||||
lp_var_t<float> testFloat = lp_var_t<float>(this, lpool::floatVarId,
|
||||
&dataset);
|
||||
lp_var_t<uint32_t> testUint32 = lp_var_t<uint32_t>(this, lpool::uint32VarId);
|
||||
|
||||
lp_vec_t<uint16_t, 3> testUint16Vec = lp_vec_t<uint16_t, 3>(this,
|
||||
lpool::uint16Vec3Id);
|
||||
lpool::uint16Vec3Id, &dataset);
|
||||
lp_vec_t<int64_t, 2> testInt64Vec = lp_vec_t<int64_t, 2>(this,
|
||||
lpool::int64Vec2Id);
|
||||
|
||||
MessageQueueIF* messageQueue = nullptr;
|
||||
LocalDataPoolManager hkManager;
|
||||
|
||||
bool initialized = false;
|
||||
bool initializedAfterTaskCreation = false;
|
||||
|
20
unittest/tests/mocks/HkReceiverMock.h
Normal file
20
unittest/tests/mocks/HkReceiverMock.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef FSFW_UNITTEST_TESTS_MOCKS_HKRECEIVERMOCK_H_
|
||||
#define FSFW_UNITTEST_TESTS_MOCKS_HKRECEIVERMOCK_H_
|
||||
|
||||
#include <fsfw/housekeeping/AcceptsHkPacketsIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
|
||||
class HkReceiverMock: public SystemObject, public AcceptsHkPacketsIF {
|
||||
public:
|
||||
HkReceiverMock(object_id_t objectId): SystemObject(objectId) {
|
||||
|
||||
}
|
||||
|
||||
MessageQueueId_t getHkQueue() const {
|
||||
return MessageQueueIF::NO_QUEUE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_UNITTEST_TESTS_MOCKS_HKRECEIVERMOCK_H_ */
|
121
unittest/tests/mocks/MessageQueueMockBase.h
Normal file
121
unittest/tests/mocks/MessageQueueMockBase.h
Normal file
@ -0,0 +1,121 @@
|
||||
#ifndef FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
|
||||
#define FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_
|
||||
|
||||
#include <fsfw/ipc/MessageQueueIF.h>
|
||||
#include <fsfw/ipc/MessageQueueMessage.h>
|
||||
#include <unittest/core/CatchDefinitions.h>
|
||||
#include <cstring>
|
||||
|
||||
#include <queue>
|
||||
|
||||
class MessageQueueMockBase: public MessageQueueIF {
|
||||
public:
|
||||
MessageQueueId_t myQueueId = tconst::testQueueId;
|
||||
uint8_t messageSentCounter = 0;
|
||||
bool defaultDestSet = false;
|
||||
bool messageSent = false;
|
||||
|
||||
|
||||
bool wasMessageSent(uint8_t* messageSentCounter = nullptr,
|
||||
bool resetCounter = true) {
|
||||
bool tempMessageSent = messageSent;
|
||||
messageSent = false;
|
||||
if(messageSentCounter != nullptr) {
|
||||
*messageSentCounter = this->messageSentCounter;
|
||||
}
|
||||
if(resetCounter) {
|
||||
this->messageSentCounter = 0;
|
||||
}
|
||||
return tempMessageSent;
|
||||
}
|
||||
|
||||
virtual ReturnValue_t reply( MessageQueueMessageIF* message ) {
|
||||
//messageSent = true;
|
||||
//lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
return sendMessage(myQueueId, message);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
};
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
|
||||
MessageQueueId_t *receivedFrom) {
|
||||
return receiveMessage(message);
|
||||
}
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) {
|
||||
if(messagesSentQueue.empty()) {
|
||||
return MessageQueueIF::EMPTY;
|
||||
}
|
||||
|
||||
std::memcpy(message->getBuffer(), messagesSentQueue.front().getBuffer(),
|
||||
message->getMessageSize());
|
||||
messagesSentQueue.pop();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual ReturnValue_t flush(uint32_t* count) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual MessageQueueId_t getLastPartner() const {
|
||||
return myQueueId;
|
||||
}
|
||||
virtual MessageQueueId_t getId() const {
|
||||
return myQueueId;
|
||||
}
|
||||
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault = false ) {
|
||||
//messageSent = true;
|
||||
//lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
//return HasReturnvaluesIF::RETURN_OK;
|
||||
return sendMessage(sendTo, message);
|
||||
}
|
||||
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message,
|
||||
MessageQueueId_t sentFrom, bool ignoreFault = false ) {
|
||||
//messageSent = true;
|
||||
//lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
//return HasReturnvaluesIF::RETURN_OK;
|
||||
return sendMessage(myQueueId, message);
|
||||
}
|
||||
virtual ReturnValue_t sendToDefault( MessageQueueMessageIF* message ) {
|
||||
//messageSent = true;
|
||||
//lastMessage = *(dynamic_cast<MessageQueueMessage*>(message));
|
||||
return sendMessage(myQueueId, message);
|
||||
}
|
||||
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, bool ignoreFault = false ) override {
|
||||
messageSent = true;
|
||||
messageSentCounter++;
|
||||
MessageQueueMessage& messageRef = *(
|
||||
dynamic_cast<MessageQueueMessage*>(message));
|
||||
messagesSentQueue.push(messageRef);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
virtual void setDefaultDestination(MessageQueueId_t defaultDestination) {
|
||||
myQueueId = defaultDestination;
|
||||
defaultDestSet = true;
|
||||
}
|
||||
|
||||
virtual MessageQueueId_t getDefaultDestination() const {
|
||||
return myQueueId;
|
||||
}
|
||||
virtual bool isDefaultDestinationSet() const {
|
||||
return defaultDestSet;
|
||||
}
|
||||
|
||||
void clearMessages(bool clearCommandMessages = true) {
|
||||
while(not messagesSentQueue.empty()) {
|
||||
if(clearCommandMessages) {
|
||||
CommandMessage message;
|
||||
std::memcpy(message.getBuffer(),
|
||||
messagesSentQueue.front().getBuffer(),
|
||||
message.getMessageSize());
|
||||
message.clear();
|
||||
}
|
||||
messagesSentQueue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::queue<MessageQueueMessage> messagesSentQueue;
|
||||
//MessageQueueMessage lastMessage;
|
||||
};
|
||||
|
||||
|
||||
#endif /* FSFW_UNITTEST_TESTS_MOCKS_MESSAGEQUEUEMOCKBASE_H_ */
|
@ -21,6 +21,7 @@ namespace objects {
|
||||
TEST_ECHO_COM_IF = 20,
|
||||
TEST_DEVICE = 21,
|
||||
|
||||
HK_RECEIVER_MOCK = 22,
|
||||
TEST_LOCAL_POOL_OWNER_BASE = 25
|
||||
};
|
||||
}
|
||||
|
1
unittest/user/unittest/CMakeLists.txt
Normal file
1
unittest/user/unittest/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
add_subdirectory(core)
|
@ -9,8 +9,8 @@ StorageManagerIF* tglob::getIpcStoreHandle() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Global object manager uninitialized" << std::endl;
|
||||
#else
|
||||
fsfw::printError("Global object manager uninitialized");
|
||||
#endif
|
||||
fsfw::printError("Global object manager uninitialized\n\r");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include <fsfw/tmtcpacket/pus/TmPacketStored.h>
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include <fsfw/tmtcservices/PusServiceBase.h>
|
||||
#include <fsfw/unittest/tests/datapoollocal/LocalPoolOwnerBase.h>
|
||||
#include <fsfw/unittest/tests/mocks/HkReceiverMock.h>
|
||||
|
||||
/**
|
||||
* @brief Produces system objects.
|
||||
@ -30,6 +32,9 @@ void Factory::produce(void) {
|
||||
new HealthTable(objects::HEALTH_TABLE);
|
||||
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
|
||||
|
||||
new LocalPoolOwnerBase (objects::TEST_LOCAL_POOL_OWNER_BASE);
|
||||
new HkReceiverMock(objects::HK_RECEIVER_MOCK);
|
||||
|
||||
{
|
||||
PoolManager::LocalPoolConfig poolCfg = {
|
||||
{100, 16}, {50, 32}, {25, 64} , {15, 128}, {5, 1024}
|
||||
@ -65,7 +70,7 @@ void Factory::setStaticFrameworkObjectIds() {
|
||||
DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
|
||||
DeviceHandlerBase::rawDataReceiverId = objects::PUS_SERVICE_2_DEVICE_ACCESS;
|
||||
|
||||
LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT;
|
||||
LocalDataPoolManager::defaultHkDestination = objects::HK_RECEIVER_MOCK;
|
||||
|
||||
DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user