Compare commits

..

5 Commits

Author SHA1 Message Date
20f0707813 remove newline
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
fsfw/fsfw/pipeline/head This commit looks good
2022-08-30 16:04:45 +02:00
8d1777fa0c additional tests
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
2022-08-30 16:02:50 +02:00
d675a789a2 update changelog
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
2022-08-30 14:41:37 +02:00
192255df1c additional test
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
2022-08-30 14:03:33 +02:00
bdd79d060d basic data wrapper unittests
All checks were successful
fsfw/fsfw/pipeline/pr-development This commit looks good
2022-08-30 14:02:58 +02:00
312 changed files with 5136 additions and 7238 deletions

View File

@ -10,46 +10,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [v6.0.0]
## Fixes
- Bugfix for Serial Buffer Stream: Setting `doActive` to false now
actually fully disables printing.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/680
- `TcpTmTcServer.cpp`: The server was actually not able to handle
CCSDS packets which were clumped together. This has been fixed now.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/673
## Added
- Add new `UnsignedByteField` class
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/660
## Changes
- Removed `HasReturnvaluesIF` class in favor of `returnvalue` namespace with `OK` and `FAILED`
constants.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/659
- Overhaul of the TMTC stack, including various changes and improvements
for other modules
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/655
which also includes a migration guide
- Bump Catch2 dependency to regular version `v3.1.0`
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/678
- `SerialBufferAdapter`: Rename `setBuffer` to `setConstBuffer` and update
API to expect `const uint8_t*` accordingly.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/677
- Remove the following user includes from `fsfw/events/Event.h` and
`fsfw/returnvalues/returnvalue.h`:
- `#include "events/subsystemIdRanges.h"`
- `#include "returnvalues/classIds.h"`
The user has to include those themselves now
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/675
- `DeviceHandlerBase`: Set command sender before calling `buildCommandFromCommand`.
This allows finishing action commands immediately inside the function.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/672
- `DeviceHandlerBase`: New signature of `handleDeviceTm` which expects
a `const SerializeIF&` and additional helper variant which expects `const uint8_t*`
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/671
## Added
- Add `util::DataWrapper` class inside the `util` module. This is a tagged union which allows
to specify raw data either as a classic C-style raw pointer and size or as a `SerializeIF`
pointer.
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/668
- Add new `UnsignedByteField` class
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/660
# [v5.0.0] 25.07.2022

View File

@ -80,7 +80,7 @@ set(FSFW_CATCH2_LIB_MAJOR_VERSION
3
CACHE STRING "Catch2 library major version requirement")
set(FSFW_CATCH2_LIB_VERSION
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.1.0
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5
CACHE STRING "Catch2 library exact version requirement")
# Keep this off by default for now. See PR:
@ -326,8 +326,7 @@ if(FSFW_BUILD_TESTS)
"/usr/local/include/*"
"*/fsfw_tests/*"
"*/catch2-src/*"
"*/fsfw_hal/*"
"unittests/*")
"*/fsfw_hal/*")
endif()
target_link_options(${FSFW_TEST_TGT} PRIVATE -fprofile-arcs
@ -346,8 +345,7 @@ if(FSFW_BUILD_TESTS)
else()
setup_target_for_coverage_lcov(
NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT}
DEPENDENCIES ${FSFW_TEST_TGT}
GENHTML_ARGS --html-epilog ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html)
DEPENDENCIES ${FSFW_TEST_TGT})
endif()
endif()
endif()
@ -362,8 +360,7 @@ if(NOT FSFW_CONFIG_PATH)
if(NOT FSFW_BUILD_DOCS)
message(
WARNING
"${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set"
)
"${MSG_PREFIX} Flight Software Framework configuration path not set")
message(
WARNING
"${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..")

View File

@ -175,7 +175,7 @@ cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..
Then you can generate the documentation using
```sh
cmake --build . -- Sphinx -j
cmake --build . -j
```
You can find the generated documentation inside the `docs/sphinx` folder inside the build

View File

@ -5,13 +5,11 @@ RUN apt-get --yes upgrade
#tzdata is a dependency, won't install otherwise
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping python3 pip doxygen graphviz rsync
RUN python3 -m pip install sphinx breathe
RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping
RUN git clone https://github.com/catchorg/Catch2.git && \
cd Catch2 && \
git checkout v3.1.0 && \
git checkout v3.0.0-preview5 && \
cmake -Bbuild -H. -DBUILD_TESTING=OFF && \
cmake --build build/ --target install
@ -20,10 +18,3 @@ RUN git clone https://github.com/ETLCPP/etl.git && \
git checkout 20.28.0 && \
cmake -B build . && \
cmake --install build/
#ssh needs a valid user to work
RUN adduser --uid 114 jenkins
#add documentation server to known hosts
RUN echo "|1|/LzCV4BuTmTb2wKnD146l9fTKgQ=|NJJtVjvWbtRt8OYqFgcYRnMQyVw= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts
RUN echo "|1|CcBvBc3EG03G+XM5rqRHs6gK/Gg=|oGeJQ+1I8NGI2THIkJsW92DpTzs= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNL8ssTonYtgiR/6RRlSIK9WU1ywOcJmxFTLcEblAwH7oifZzmYq3XRfwXrgfMpylEfMFYfCU8JRqtmi19xc21A=" >> /etc/ssh/ssh_known_hosts

View File

@ -1,13 +1,9 @@
pipeline {
environment {
BUILDDIR = 'cmake-build-tests'
DOCDDIR = 'cmake-build-documentation'
BUILDDIR = 'build-tests'
}
agent {
docker {
image 'fsfw-ci:d6'
args '--network host'
}
docker { image 'fsfw-ci:d3'}
}
stages {
stage('Clean') {
@ -43,43 +39,5 @@ pipeline {
}
}
}
stage('Documentation') {
when {
branch 'development'
}
steps {
dir(DOCDDIR) {
sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..'
sh 'make Sphinx'
sshagent(credentials: ['documentation-buildfix']) {
sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/development'
}
}
dir(BUILDDIR) {
sshagent(credentials: ['documentation-buildfix']) {
sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/development'
}
}
}
}
stage('Master Documentation') {
when {
branch 'master'
}
steps {
dir(DOCDDIR) {
sh 'cmake -DFSFW_BUILD_DOCS=ON -DFSFW_OSAL=host ..'
sh 'make Sphinx'
sshagent(credentials: ['documentation-buildfix']) {
sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/master'
}
}
dir(BUILDDIR) {
sshagent(credentials: ['documentation-buildfix']) {
sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/master'
}
}
}
}
}
}

View File

@ -50,11 +50,6 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
#
html_theme = 'alabaster'
html_theme_options = {
"extra_nav_links": {"Impressum" : "https://www.uni-stuttgart.de/impressum", "Datenschutz": "https://info.irs.uni-stuttgart.de/datenschutz/datenschutzWebmit.html"}
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".

View File

@ -7,13 +7,12 @@ Structure
----------
The general structure is driven by the usage of interfaces provided by objects.
The FSFW uses C++17 as baseline. Most modern compilers like GCC should have support for this
standard, even for micocontrollers.
The FSFW might use dynamic allocation during program initialization but not during runtime.
It offers pool objects, static containers and it also exposes the
`Embedded Template Library <https://www.etlcpp.com/>`_ to allow writing code which does not perform
allocation during runtime. The fsfw uses run-time type information but will not throw exceptions.
The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be
widely available, even with older compilers.
The FSFW uses dynamic allocation during the initialization but provides static containers during runtime.
This simplifies the instantiation of objects and allows the usage of some standard containers.
Dynamic Allocation after initialization is discouraged and different solutions are provided in the
FSFW to achieve that. The fsfw uses run-time type information but exceptions are not allowed.
Failure Handling
-----------------

View File

@ -4,10 +4,6 @@
#include <cstddef>
#include <cstdint>
// It is assumed the user has a subsystem and class ID list in some user header files.
// #include "events/subsystemIdRanges.h"
// #include "returnvalues/classIds.h"
//! Used to determine whether C++ ostreams are used which can increase
//! the binary size significantly. If this is disabled,
//! the C stdio functions can be used alternatively

View File

@ -35,8 +35,8 @@ void Factory::produceFsfwObjects(void) {
}
void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::PUS_DISTRIBUTOR = objects::NO_OBJECT;
PusServiceBase::PACKET_DESTINATION = objects::NO_OBJECT;
PusServiceBase::packetSource = objects::NO_OBJECT;
PusServiceBase::packetDestination = objects::NO_OBJECT;
CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;

View File

@ -13,7 +13,7 @@ from shutil import which
from typing import List
UNITTEST_FOLDER_NAME = "cmake-build-tests"
UNITTEST_FOLDER_NAME = "build-tests"
DOCS_FOLDER_NAME = "build-docs"
@ -199,7 +199,7 @@ def check_for_cmake_build_dir(build_dir_list: list) -> list:
def perform_lcov_operation(directory: str, chdir: bool):
if chdir:
os.chdir(directory)
cmd_runner("cmake --build -j . -- fsfw-tests_coverage")
cmd_runner("cmake --build . -- fsfw-tests_coverage -j")
def determine_build_dir(build_dir_list: List[str]):

View File

@ -1,23 +1,24 @@
#include "fsfw/cfdp/CfdpHandler.h"
#include "fsfw/cfdp/CFDPHandler.h"
#include "fsfw/cfdp/CfdpMessage.h"
#include "fsfw/cfdp/CFDPMessage.h"
#include "fsfw/ipc/CommandMessage.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/storagemanager/storeAddress.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
object_id_t CfdpHandler::packetSource = 0;
object_id_t CfdpHandler::packetDestination = 0;
object_id_t CFDPHandler::packetSource = 0;
object_id_t CFDPHandler::packetDestination = 0;
CfdpHandler::CfdpHandler(object_id_t setObjectId, CFDPDistributor* dist)
CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist)
: SystemObject(setObjectId) {
requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION);
distributor = dist;
}
CfdpHandler::~CfdpHandler() = default;
CFDPHandler::~CFDPHandler() {}
ReturnValue_t CfdpHandler::initialize() {
ReturnValue_t CFDPHandler::initialize() {
ReturnValue_t result = SystemObject::initialize();
if (result != returnvalue::OK) {
return result;
@ -26,7 +27,7 @@ ReturnValue_t CfdpHandler::initialize() {
return returnvalue::OK;
}
ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) {
ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "CFDPHandler::handleRequest" << std::endl;
@ -40,17 +41,17 @@ ReturnValue_t CfdpHandler::handleRequest(store_address_t storeId) {
return returnvalue::OK;
}
ReturnValue_t CfdpHandler::performOperation(uint8_t opCode) {
ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) {
ReturnValue_t status = returnvalue::OK;
CommandMessage currentMessage;
for (status = this->requestQueue->receiveMessage(&currentMessage); status == returnvalue::OK;
status = this->requestQueue->receiveMessage(&currentMessage)) {
store_address_t storeId = CfdpMessage::getStoreId(&currentMessage);
store_address_t storeId = CFDPMessage::getStoreId(&currentMessage);
this->handleRequest(storeId);
}
return returnvalue::OK;
}
uint16_t CfdpHandler::getIdentifier() { return 0; }
uint16_t CFDPHandler::getIdentifier() { return 0; }
MessageQueueId_t CfdpHandler::getRequestQueue() { return this->requestQueue->getId(); }
MessageQueueId_t CFDPHandler::getRequestQueue() { return this->requestQueue->getId(); }

View File

@ -12,15 +12,15 @@ namespace Factory {
void setStaticFrameworkObjectIds();
}
class CfdpHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, public SystemObject {
class CFDPHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, public SystemObject {
friend void(Factory::setStaticFrameworkObjectIds)();
public:
CfdpHandler(object_id_t setObjectId, CFDPDistributor* distributor);
CFDPHandler(object_id_t setObjectId, CFDPDistributor* distributor);
/**
* The destructor is empty.
*/
virtual ~CfdpHandler();
virtual ~CFDPHandler();
virtual ReturnValue_t handleRequest(store_address_t storeId);
@ -42,7 +42,7 @@ class CfdpHandler : public ExecutableObjectIF, public AcceptsTelecommandsIF, pub
* The current CFDP packet to be processed.
* It is deleted after handleRequest was executed.
*/
CfdpPacketStored currentPacket;
CFDPPacketStored currentPacket;
static object_id_t packetSource;

View File

@ -0,0 +1,17 @@
#include "CFDPMessage.h"
CFDPMessage::CFDPMessage() {}
CFDPMessage::~CFDPMessage() {}
void CFDPMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) {
message->setParameter(cfdpPacket.raw);
}
store_address_t CFDPMessage::getStoreId(const CommandMessage *message) {
store_address_t storeAddressCFDPPacket;
storeAddressCFDPPacket = message->getParameter();
return storeAddressCFDPPacket;
}
void CFDPMessage::clear(CommandMessage *message) {}

View File

@ -5,14 +5,14 @@
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
class CfdpMessage {
class CFDPMessage {
private:
CfdpMessage();
CFDPMessage();
public:
static const uint8_t MESSAGE_ID = messagetypes::CFDP;
virtual ~CfdpMessage();
virtual ~CFDPMessage();
static void setCommand(CommandMessage* message, store_address_t cfdpPacket);
static store_address_t getStoreId(const CommandMessage* message);

View File

@ -1,4 +1,4 @@
target_sources(${LIB_FSFW_NAME} PRIVATE CfdpHandler.cpp CfdpMessage.cpp)
target_sources(${LIB_FSFW_NAME} PRIVATE CFDPHandler.cpp CFDPMessage.cpp)
add_subdirectory(pdu)
add_subdirectory(tlv)

View File

@ -1,17 +0,0 @@
#include "CfdpMessage.h"
CfdpMessage::CfdpMessage() = default;
CfdpMessage::~CfdpMessage() = default;
void CfdpMessage::setCommand(CommandMessage *message, store_address_t cfdpPacket) {
message->setParameter(cfdpPacket.raw);
}
store_address_t CfdpMessage::getStoreId(const CommandMessage *message) {
store_address_t storeId;
storeId = static_cast<store_address_t>(message->getParameter());
return storeId;
}
void CfdpMessage::clear(CommandMessage *message) {}

View File

@ -21,7 +21,7 @@ cfdp::Lv& cfdp::Lv::operator=(const Lv& other) {
if (value == nullptr or otherSize == 0) {
this->zeroLen = true;
}
this->value.setConstBuffer(value, otherSize);
this->value.setBuffer(value, otherSize);
return *this;
}
@ -70,7 +70,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size,
}
zeroLen = false;
// Zero-copy implementation
value.setConstBuffer(*buffer + 1, lengthField);
value.setBuffer(const_cast<uint8_t*>(*buffer + 1), lengthField);
*buffer += 1 + lengthField;
*size -= 1 + lengthField;
return returnvalue::OK;

View File

@ -75,7 +75,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size,
}
zeroLen = false;
// Zero-copy implementation
value.setConstBuffer(*buffer + 1, lengthField);
value.setBuffer(const_cast<uint8_t *>(*buffer + 1), lengthField);
*buffer += 1 + lengthField;
*size -= 1 + lengthField;
return returnvalue::OK;
@ -96,7 +96,7 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) {
if (len > 0) {
zeroLen = false;
}
this->value.setConstBuffer(value, len);
this->value.setBuffer(value, len);
}
uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; }

View File

@ -6,7 +6,7 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "fsfw/tmtcpacket/SpacePacketBase.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/TmTcMessage.h"

View File

@ -79,7 +79,8 @@ class HasLocalDataPoolIF {
* @param clearMessage If this is set to true, the pool manager will take care of
* clearing the store automatically
*/
virtual void handleChangedDataset(sid_t sid, store_address_t storeId = store_address_t::invalid(),
virtual void handleChangedDataset(sid_t sid,
store_address_t storeId = storeId::INVALID_STORE_ADDRESS,
bool* clearMessage = nullptr) {
if (clearMessage != nullptr) {
*clearMessage = true;
@ -99,7 +100,7 @@ class HasLocalDataPoolIF {
* after the callback.
*/
virtual void handleChangedPoolVariable(gp_id_t gpid,
store_address_t storeId = store_address_t::invalid(),
store_address_t storeId = storeId::INVALID_STORE_ADDRESS,
bool* clearMessage = nullptr) {
if (clearMessage != nullptr) {
*clearMessage = true;

View File

@ -1,5 +1,6 @@
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
#include <array>
#include <cmath>
#include "fsfw/datapoollocal.h"
@ -14,7 +15,6 @@
#include "internal/HasLocalDpIFManagerAttorney.h"
#include "internal/LocalPoolDataSetAttorney.h"
// TODO: Get rid of this. This should be a constructor argument, not something hardcoded in any way
object_id_t LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING;
LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse,
@ -57,7 +57,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
}
if (defaultHkDestination != objects::NO_OBJECT) {
auto* hkPacketReceiver =
AcceptsHkPacketsIF* hkPacketReceiver =
ObjectManager::instance()->get<AcceptsHkPacketsIF>(defaultHkDestination);
if (hkPacketReceiver != nullptr) {
hkDestinationId = hkPacketReceiver->getHkQueue();
@ -209,9 +209,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei
}
/* Prepare and send update snapshot */
timeval now{};
timeval now;
Clock::getClock_timeval(&now);
CCSDSTime::CDS_short cds{};
CCSDSTime::CDS_short cds;
CCSDSTime::convertToCcsds(&cds, &now);
HousekeepingSnapshot updatePacket(
reinterpret_cast<uint8_t*>(&cds), sizeof(cds),
@ -245,9 +245,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(HkReceiver& recei
}
/* Prepare and send update snapshot */
timeval now{};
timeval now;
Clock::getClock_timeval(&now);
CCSDSTime::CDS_short cds{};
CCSDSTime::CDS_short cds;
CCSDSTime::convertToCcsds(&cds, &now);
HousekeepingSnapshot updatePacket(
reinterpret_cast<uint8_t*>(&cds), sizeof(cds),
@ -291,7 +291,12 @@ ReturnValue_t LocalDataPoolManager::addUpdateToStore(HousekeepingSnapshot& updat
void LocalDataPoolManager::handleChangeResetLogic(DataType type, DataId dataId,
MarkChangedIF* toReset) {
for (auto& changeInfo : hkUpdateResetList) {
if (hkUpdateResetList == nullptr) {
/* Config error */
return;
}
HkUpdateResetList& listRef = *hkUpdateResetList;
for (auto& changeInfo : listRef) {
if (changeInfo.dataType != type) {
continue;
}
@ -321,37 +326,38 @@ void LocalDataPoolManager::handleChangeResetLogic(DataType type, DataId dataId,
}
void LocalDataPoolManager::resetHkUpdateResetHelper() {
for (auto& changeInfo : hkUpdateResetList) {
if (hkUpdateResetList == nullptr) {
return;
}
for (auto& changeInfo : *hkUpdateResetList) {
changeInfo.currentUpdateCounter = changeInfo.updateCounter;
}
}
ReturnValue_t LocalDataPoolManager::subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams params) {
return subscribeForPeriodicPacket(params);
ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
float collectionInterval,
bool isDiagnostics,
object_id_t packetDestination) {
AcceptsHkPacketsIF* hkReceiverObject =
ObjectManager::instance()->get<AcceptsHkPacketsIF>(packetDestination);
if (hkReceiverObject == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
}
ReturnValue_t LocalDataPoolManager::subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) {
return subscribeForPeriodicPacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase& params) {
struct HkReceiver hkReceiver;
hkReceiver.dataId.sid = params.sid;
hkReceiver.dataId.sid = sid;
hkReceiver.reportingType = ReportingType::PERIODIC;
hkReceiver.dataType = DataType::DATA_SET;
if (params.receiver == MessageQueueIF::NO_QUEUE) {
hkReceiver.destinationQueue = hkDestinationId;
} else {
hkReceiver.destinationQueue = params.receiver;
}
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if (dataSet != nullptr) {
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, params.enableReporting);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics());
LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, params.collectionInterval,
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval,
owner->getPeriodicOperationFrequency());
}
@ -359,30 +365,27 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(subdp::ParamsBase
return returnvalue::OK;
}
ReturnValue_t LocalDataPoolManager::subscribeForRegularUpdatePacket(
subdp::RegularHkUpdateParams params) {
return subscribeForUpdatePacket(params);
}
ReturnValue_t LocalDataPoolManager::subscribeForDiagUpdatePacket(
subdp::DiagnosticsHkUpdateParams params) {
return subscribeForUpdatePacket(params);
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid, bool isDiagnostics,
bool reportingEnabled,
object_id_t packetDestination) {
AcceptsHkPacketsIF* hkReceiverObject =
ObjectManager::instance()->get<AcceptsHkPacketsIF>(packetDestination);
if (hkReceiverObject == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "subscribeForPeriodicPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
}
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(subdp::ParamsBase& params) {
struct HkReceiver hkReceiver;
hkReceiver.dataId.sid = params.sid;
hkReceiver.dataId.sid = sid;
hkReceiver.reportingType = ReportingType::UPDATE_HK;
hkReceiver.dataType = DataType::DATA_SET;
if (params.receiver == MessageQueueIF::NO_QUEUE) {
hkReceiver.destinationQueue = hkDestinationId;
} else {
hkReceiver.destinationQueue = params.receiver;
}
hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, params.sid);
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if (dataSet != nullptr) {
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, params.isDiagnostics());
LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
}
hkReceivers.push_back(hkReceiver);
@ -433,7 +436,11 @@ ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage(
}
void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, DataId dataId) {
for (auto& updateResetStruct : hkUpdateResetList) {
if (hkUpdateResetList == nullptr) {
hkUpdateResetList = new std::vector<struct HkUpdateResetHelper>();
}
for (auto& updateResetStruct : *hkUpdateResetList) {
if (dataType == DataType::DATA_SET) {
if (updateResetStruct.dataId.sid == dataId.sid) {
updateResetStruct.updateCounter++;
@ -457,7 +464,7 @@ void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType, D
} else {
hkUpdateResetHelper.dataId.localPoolId = dataId.localPoolId;
}
hkUpdateResetList.push_back(hkUpdateResetHelper);
hkUpdateResetList->push_back(hkUpdateResetHelper);
}
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* message) {
@ -632,7 +639,6 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
/* Error, all destinations invalid */
printWarningOrError(sif::OutputTypes::OUT_WARNING, "generateHousekeepingPacket",
QUEUE_OR_DESTINATION_INVALID);
return QUEUE_OR_DESTINATION_INVALID;
}
destination = hkDestinationId;
}
@ -809,7 +815,9 @@ void LocalDataPoolManager::clearReceiversList() {
/* Clear the vector completely and releases allocated memory. */
HkReceivers().swap(hkReceivers);
/* Also clear the reset helper if it exists */
HkUpdateResetList().swap(hkUpdateResetList);
if (hkUpdateResetList != nullptr) {
HkUpdateResetList().swap(*hkUpdateResetList);
}
}
MutexIF* LocalDataPoolManager::getLocalPoolMutex() { return this->mutex; }
@ -869,7 +877,3 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
}
LocalDataPoolManager* LocalDataPoolManager::getPoolManagerHandle() { return this; }
void LocalDataPoolManager::setHkDestinationId(MessageQueueId_t hkDestId) {
hkDestinationId = hkDestId;
}

View File

@ -8,7 +8,6 @@
#include "ProvidesDataPoolSubscriptionIF.h"
#include "fsfw/datapool/DataSetIF.h"
#include "fsfw/datapool/PoolEntry.h"
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h"
#include "fsfw/housekeeping/HousekeepingMessage.h"
#include "fsfw/housekeeping/HousekeepingPacketDownlink.h"
#include "fsfw/housekeeping/PeriodicHousekeepingHelper.h"
@ -81,9 +80,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse,
bool appendValidityBuffer = true);
~LocalDataPoolManager() override;
void setHkDestinationId(MessageQueueId_t hkDestId);
virtual ~LocalDataPoolManager();
/**
* Assigns the queue to use. Make sure to call this in the #initialize
@ -115,6 +112,31 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
virtual ReturnValue_t performHkOperation();
/**
* @brief Subscribe for the generation of periodic packets.
* @details
* This subscription mechanism will generally be used by the data creator
* to generate housekeeping packets which are downlinked directly.
* @return
*/
ReturnValue_t subscribeForPeriodicPacket(
sid_t sid, bool enableReporting, float collectionInterval, bool isDiagnostics,
object_id_t packetDestination = defaultHkDestination) override;
/**
* @brief Subscribe for the generation of packets if the dataset
* is marked as changed.
* @details
* This subscription mechanism will generally be used by the data creator.
* @param sid
* @param isDiagnostics
* @param packetDestination
* @return
*/
ReturnValue_t subscribeForUpdatePacket(
sid_t sid, bool reportingEnabled, bool isDiagnostics,
object_id_t packetDestination = defaultHkDestination) override;
/**
* @brief Subscribe for a notification message which will be sent
* if a dataset has changed.
@ -129,7 +151,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
* Otherwise, only an notification message is sent.
* @return
*/
ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject,
ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId, object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) override;
@ -147,7 +169,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
* Otherwise, only an notification message is sent.
* @return
*/
ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId,
ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId,
object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) override;
@ -230,7 +252,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
void clearReceiversList();
[[nodiscard]] object_id_t getCreatorObjectId() const;
object_id_t getCreatorObjectId() const;
/**
* Get the pointer to the mutex. Can be used to lock the data pool
@ -240,17 +262,9 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
*/
MutexIF* getMutexHandle();
LocalDataPoolManager* getPoolManagerHandle() override;
ReturnValue_t subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams params) override;
ReturnValue_t subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams params) override;
ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override;
ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override;
virtual LocalDataPoolManager* getPoolManagerHandle() override;
protected:
ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params);
ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params);
/** Core data structure for the actual pool data */
localpool::DataPool localPoolMap;
/** Every housekeeping data manager has a mutex to protect access
@ -298,8 +312,8 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
using HkUpdateResetList = std::vector<struct HkUpdateResetHelper>;
/** This list is used to manage creating multiple update packets and only resetting
the update flag if all of them were created. */
HkUpdateResetList hkUpdateResetList = HkUpdateResetList();
the update flag if all of them were created. Will only be created when needed. */
HkUpdateResetList* hkUpdateResetList = nullptr;
/** This is the map holding the actual data. Should only be initialized
* once ! */

View File

@ -48,12 +48,12 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
if (hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner
<< std::dec << " does not exist or does not implement the correct interface "
<< std::dec << " did not implement the correct interface "
<< "HasLocalDataPoolIF" << std::endl;
#else
sif::printError(
"LocalPoolVariable: The supplied pool owner 0x%08x does not exist or does not implement "
"the correct interface HasLocalDataPoolIF\n",
"LocalPoolVariable: The supplied pool owner 0x%08x did not implement the correct "
"interface HasLocalDataPoolIF\n",
poolOwner);
#endif
return;

View File

@ -1,90 +1,24 @@
#ifndef FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_
#define FSFW_DATAPOOLLOCAL_PROVIDESDATAPOOLSUBSCRIPTION_H_
#include "fsfw/housekeeping/AcceptsHkPacketsIF.h"
#include "fsfw/ipc/MessageQueueIF.h"
#include "fsfw/ipc/messageQueueDefinitions.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "../ipc/messageQueueDefinitions.h"
#include "../returnvalues/returnvalue.h"
#include "localPoolDefinitions.h"
namespace subdp {
struct ParamsBase {
ParamsBase(sid_t sid, bool enableReporting, float collectionInterval, bool diagnostics)
: sid(sid),
enableReporting(enableReporting),
collectionInterval(collectionInterval),
diagnostics(diagnostics) {}
[[nodiscard]] bool isDiagnostics() const { return diagnostics; }
sid_t sid;
bool enableReporting;
float collectionInterval;
MessageQueueId_t receiver = MessageQueueIF::NO_QUEUE;
protected:
bool diagnostics;
};
struct RegularHkPeriodicParams : public ParamsBase {
RegularHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval)
: ParamsBase(sid, enableReporting, collectionInterval, false) {}
};
struct DiagnosticsHkPeriodicParams : public ParamsBase {
DiagnosticsHkPeriodicParams(sid_t sid, bool enableReporting, float collectionInterval)
: ParamsBase(sid, enableReporting, collectionInterval, true) {}
};
struct RegularHkUpdateParams : public ParamsBase {
RegularHkUpdateParams(sid_t sid, bool enableReporting)
: ParamsBase(sid, enableReporting, 0.0, false) {}
};
struct DiagnosticsHkUpdateParams : public ParamsBase {
DiagnosticsHkUpdateParams(sid_t sid, bool enableReporting)
: ParamsBase(sid, enableReporting, 0.0, true) {}
};
} // namespace subdp
class ProvidesDataPoolSubscriptionIF {
public:
virtual ~ProvidesDataPoolSubscriptionIF() = default;
virtual ~ProvidesDataPoolSubscriptionIF(){};
/**
* @brief Subscribe for the generation of periodic packets. Used for regular HK packets
* @brief Subscribe for the generation of periodic packets.
* @details
* This subscription mechanism will generally be used by the data creator
* to generate housekeeping packets which are downlinked directly.
* @return
*/
virtual ReturnValue_t subscribeForRegularPeriodicPacket(
subdp::RegularHkPeriodicParams params) = 0;
/**
* @brief Subscribe for the generation of periodic packets. Used for diagnostic packets
* @details
* This subscription mechanism will generally be used by the data creator
* to generate housekeeping packets which are downlinked directly.
* @return
*/
virtual ReturnValue_t subscribeForDiagPeriodicPacket(
subdp::DiagnosticsHkPeriodicParams params) = 0;
[[deprecated(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t
subscribeForPeriodicPacket(sid_t sid, bool enableReporting, float collectionInterval,
bool isDiagnostics,
object_id_t packetDestination = objects::NO_OBJECT) {
if (isDiagnostics) {
subdp::DiagnosticsHkPeriodicParams params(sid, enableReporting, collectionInterval);
return subscribeForDiagPeriodicPacket(params);
} else {
subdp::RegularHkPeriodicParams params(sid, enableReporting, collectionInterval);
return subscribeForRegularPeriodicPacket(params);
}
}
virtual ReturnValue_t subscribeForPeriodicPacket(sid_t sid, bool enableReporting,
float collectionInterval, bool isDiagnostics,
object_id_t packetDestination) = 0;
/**
* @brief Subscribe for the generation of packets if the dataset
* is marked as changed.
@ -95,28 +29,9 @@ class ProvidesDataPoolSubscriptionIF {
* @param packetDestination
* @return
*/
virtual ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) = 0;
virtual ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) = 0;
// virtual ReturnValue_t
// subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics) {
// return subscribeForUpdatePacket(sid, reportingEnabled, isDiagnostics, objects::NO_OBJECT);
// }
[[deprecated(
"Please use the new API which takes all arguments as one wrapper "
"struct")]] virtual ReturnValue_t
subscribeForUpdatePacket(sid_t sid, bool reportingEnabled, bool isDiagnostics,
object_id_t packetDestination = objects::NO_OBJECT) {
if (isDiagnostics) {
subdp::DiagnosticsHkUpdateParams params(sid, reportingEnabled);
return subscribeForDiagUpdatePacket(params);
} else {
subdp::RegularHkUpdateParams params(sid, reportingEnabled);
return subscribeForRegularUpdatePacket(params);
}
}
virtual ReturnValue_t subscribeForUpdatePacket(sid_t sid, bool reportingEnabled,
bool isDiagnostics,
object_id_t packetDestination) = 0;
/**
* @brief Subscribe for a notification message which will be sent
* if a dataset has changed.
@ -131,7 +46,8 @@ class ProvidesDataPoolSubscriptionIF {
* Otherwise, only an notification message is sent.
* @return
*/
virtual ReturnValue_t subscribeForSetUpdateMessage(uint32_t setId, object_id_t destinationObject,
virtual ReturnValue_t subscribeForSetUpdateMessage(const uint32_t setId,
object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) = 0;
/**
@ -148,7 +64,7 @@ class ProvidesDataPoolSubscriptionIF {
* only an notification message is sent.
* @return
*/
virtual ReturnValue_t subscribeForVariableUpdateMessage(lp_id_t localPoolId,
virtual ReturnValue_t subscribeForVariableUpdateMessage(const lp_id_t localPoolId,
object_id_t destinationObject,
MessageQueueId_t targetQueueId,
bool generateSnapshot) = 0;

View File

@ -8,7 +8,6 @@
#include "fsfw/ipc/MessageQueueMessage.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serialize/SerialBufferAdapter.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/subsystem/SubsystemBase.h"
@ -1258,30 +1257,28 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message)
return returnvalue::FAILED;
}
void DeviceHandlerBase::handleDeviceTm(const uint8_t* rawData, size_t rawDataLen,
DeviceCommandId_t replyId, bool forceDirectTm) {
SerialBufferAdapter bufferWrapper(rawData, rawDataLen);
handleDeviceTm(bufferWrapper, replyId, forceDirectTm);
void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t replyId,
bool forceDirectTm) {
if (dataSet == nullptr) {
return;
}
void DeviceHandlerBase::handleDeviceTm(const SerializeIF& dataSet, DeviceCommandId_t replyId,
bool forceDirectTm) {
auto iter = deviceReplyMap.find(replyId);
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
triggerEvent(DEVICE_UNKNOWN_REPLY, replyId);
return;
}
// Regular replies to a command
/* Regular replies to a command */
if (iter->second.command != deviceCommandMap.end()) {
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
if (queueId != NO_COMMANDER) {
// This may fail, but we'll ignore the fault.
actionHelper.reportData(queueId, replyId, const_cast<SerializeIF*>(&dataSet));
/* This may fail, but we'll ignore the fault. */
actionHelper.reportData(queueId, replyId, dataSet);
}
// This check should make sure we get any TM but don't get anything doubled.
/* This check should make sure we get any TM but don't get anything doubled. */
if (wiretappingMode == TM && (requestedRawTraffic != queueId)) {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
@ -1292,17 +1289,22 @@ void DeviceHandlerBase::handleDeviceTm(const SerializeIF& dataSet, DeviceCommand
// hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed)
// it is in
actionHelper.reportData(defaultRawReceiver, replyId, const_cast<SerializeIF*>(&dataSet),
true);
actionHelper.reportData(defaultRawReceiver, replyId, dataSet, true);
}
}
// Unrequested or aperiodic replies
/* Unrequested or aperiodic replies */
else {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
if (wiretappingMode == TM) {
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
}
if (forceDirectTm and defaultRawReceiver != MessageQueueIF::NO_QUEUE) {
// sid_t setSid = sid_t(this->getObjectId(), replyId);
// LocalPoolDataSetBase* dataset = getDataSetHandle(setSid);
// if(dataset != nullptr) {
// poolManager.generateHousekeepingPacket(setSid, dataset, true);
// }
// hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed)
// it is in
@ -1323,10 +1325,10 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId, MessageQueue
} else if (iter->second.isExecuting) {
result = COMMAND_ALREADY_SENT;
} else {
iter->second.sendReplyTo = commandedBy;
result = buildCommandFromCommand(actionId, data, size);
}
if (result == returnvalue::OK) {
iter->second.sendReplyTo = commandedBy;
iter->second.isExecuting = true;
cookieInfo.pendingCommand = iter;
cookieInfo.state = COOKIE_WRITE_READY;

View File

@ -1052,25 +1052,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
bool isAwaitingReply();
/**
* Wrapper function for @handleDeviceTm which wraps the raw buffer with @SerialBufferAdapter.
* For interpreted data, prefer the other function.
* @param rawData
* @param rawDataLen
* @param replyId
* @param forceDirectTm
*/
void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId,
bool forceDirectTm = false);
/**
* Can be used to handle Service 8 data replies. This will also generate the TM wiretapping
* packets accordingly.
* @param dataSet
* @param replyId
* @param forceDirectTm
*/
void handleDeviceTm(const SerializeIF &dataSet, DeviceCommandId_t replyId,
bool forceDirectTm = false);
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false);
// void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId,
// bool forceDirectTm);
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode);

View File

@ -3,10 +3,10 @@
#include "fsfw/serialize/SerializeAdapter.h"
DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId,
const SerializeIF& data)
SerializeIF* data)
: objectId(objectId), actionId(actionId), data(data) {}
DeviceTmReportingWrapper::~DeviceTmReportingWrapper() = default;
DeviceTmReportingWrapper::~DeviceTmReportingWrapper() {}
ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const {
@ -19,14 +19,22 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size
if (result != returnvalue::OK) {
return result;
}
return data.serialize(buffer, size, maxSize, streamEndianness);
return data->serialize(buffer, size, maxSize, streamEndianness);
}
size_t DeviceTmReportingWrapper::getSerializedSize() const {
return sizeof(objectId) + sizeof(ActionId_t) + data.getSerializedSize();
return sizeof(objectId) + sizeof(ActionId_t) + data->getSerializedSize();
}
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) {
return returnvalue::FAILED;
ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness);
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&actionId, buffer, size, streamEndianness);
if (result != returnvalue::OK) {
return result;
}
return data->deSerialize(buffer, size, streamEndianness);
}

View File

@ -7,22 +7,21 @@
class DeviceTmReportingWrapper : public SerializeIF {
public:
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, const SerializeIF& data);
~DeviceTmReportingWrapper() override;
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, SerializeIF* data);
virtual ~DeviceTmReportingWrapper();
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
[[nodiscard]] size_t getSerializedSize() const override;
virtual size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
private:
object_id_t objectId;
ActionId_t actionId;
const SerializeIF& data;
// Deserialization forbidden
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
SerializeIF* data;
};
#endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */

View File

@ -4,6 +4,8 @@
#include <stdint.h>
#include "fwSubsystemIdRanges.h"
// could be moved to more suitable location
#include <events/subsystemIdRanges.h>
using EventId_t = uint16_t;
using EventSeverity_t = uint8_t;

View File

@ -9,8 +9,8 @@
class HealthTable : public HealthTableIF, public SystemObject {
public:
explicit HealthTable(object_id_t objectid);
~HealthTable() override;
HealthTable(object_id_t objectid);
virtual ~HealthTable();
void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs);

View File

@ -1,12 +1,12 @@
#ifndef FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
#define FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_
#include "fsfw/ipc/MessageQueueMessageIF.h"
#include "../ipc/MessageQueueMessageIF.h"
class AcceptsHkPacketsIF {
public:
virtual ~AcceptsHkPacketsIF() = default;
[[nodiscard]] virtual MessageQueueId_t getHkQueue() const = 0;
virtual ~AcceptsHkPacketsIF(){};
virtual MessageQueueId_t getHkQueue() const = 0;
};
#endif /* FRAMEWORK_HOUSEKEEPING_ACCEPTSHKPACKETSIF_H_ */

View File

@ -126,12 +126,11 @@ MessageQueueId_t InternalErrorReporter::getCommandQueue() const {
ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry);
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry);
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry);
poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams(
internalErrorSid, false,
static_cast<float>(getPeriodicOperationFrequency()) / static_cast<float>(1000.0)));
localDataPoolMap.emplace(errorPoolIds::TM_HITS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, new PoolEntry<uint32_t>());
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, new PoolEntry<uint32_t>());
poolManager.subscribeForPeriodicPacket(internalErrorSid, false, getPeriodicOperationFrequency(),
true);
internalErrorDataset.setValidity(true, true);
return returnvalue::OK;
}

View File

@ -72,9 +72,6 @@ class InternalErrorReporter : public SystemObject,
uint32_t queueHits = 0;
uint32_t tmHits = 0;
uint32_t storeHits = 0;
PoolEntry<uint32_t> tmHitsEntry = PoolEntry<uint32_t>();
PoolEntry<uint32_t> storeHitsEntry = PoolEntry<uint32_t>();
PoolEntry<uint32_t> queueHitsEntry = PoolEntry<uint32_t>();
uint32_t getAndResetQueueHits();
void incrementQueueHits();

View File

@ -12,7 +12,7 @@
*/
class InternalErrorReporterIF {
public:
virtual ~InternalErrorReporterIF() = default;
virtual ~InternalErrorReporterIF() {}
/**
* @brief Function to be called if a message queue could not be sent.
* @details OSAL Implementations should call this function to indicate that

View File

@ -8,7 +8,7 @@ MessageQueueBase::MessageQueueBase(MessageQueueId_t id, MessageQueueId_t default
}
}
MessageQueueBase::~MessageQueueBase() = default;
MessageQueueBase::~MessageQueueBase() {}
ReturnValue_t MessageQueueBase::sendToDefault(MessageQueueMessageIF* message) {
return sendToDefaultFrom(message, this->getId(), false);

View File

@ -7,28 +7,28 @@
class MessageQueueBase : public MessageQueueIF {
public:
MessageQueueBase(MessageQueueId_t id, MessageQueueId_t defaultDest, MqArgs* mqArgs);
~MessageQueueBase() override;
virtual ~MessageQueueBase();
// Default implementations for MessageQueueIF where possible
[[nodiscard]] MessageQueueId_t getLastPartner() const override;
[[nodiscard]] MessageQueueId_t getId() const override;
MqArgs& getMqArgs() override;
void setDefaultDestination(MessageQueueId_t defaultDestination) override;
[[nodiscard]] MessageQueueId_t getDefaultDestination() const override;
[[nodiscard]] bool isDefaultDestinationSet() const override;
ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
virtual MessageQueueId_t getLastPartner() const override;
virtual MessageQueueId_t getId() const override;
virtual MqArgs& getMqArgs() override;
virtual void setDefaultDestination(MessageQueueId_t defaultDestination) override;
virtual MessageQueueId_t getDefaultDestination() const override;
virtual bool isDefaultDestinationSet() const override;
virtual ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
bool ignoreFault) override;
ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override;
ReturnValue_t reply(MessageQueueMessageIF* message) override;
ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
virtual ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override;
virtual ReturnValue_t reply(MessageQueueMessageIF* message) override;
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
MessageQueueId_t* receivedFrom) override;
ReturnValue_t sendToDefaultFrom(MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
virtual ReturnValue_t sendToDefaultFrom(MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
bool ignoreFault = false) override;
// OSAL specific, forward the abstract function
ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override = 0;
ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
MessageQueueId_t sentFrom, bool ignoreFault = false) override = 0;
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) = 0;
virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
MessageQueueId_t sentFrom, bool ignoreFault = false) = 0;
protected:
MessageQueueId_t id = MessageQueueIF::NO_QUEUE;

View File

@ -30,7 +30,7 @@ class MessageQueueIF {
//! [EXPORT] : [COMMENT] Returned if the target destination is invalid.
static constexpr ReturnValue_t DESTINATION_INVALID = MAKE_RETURN_CODE(4);
virtual ~MessageQueueIF() = default;
virtual ~MessageQueueIF() {}
/**
* @brief This operation sends a message to the last communication partner.
* @details
@ -82,11 +82,11 @@ class MessageQueueIF {
/**
* @brief This method returns the message queue ID of the last communication partner.
*/
[[nodiscard]] virtual MessageQueueId_t getLastPartner() const = 0;
virtual MessageQueueId_t getLastPartner() const = 0;
/**
* @brief This method returns the message queue ID of this class's message queue.
*/
[[nodiscard]] virtual MessageQueueId_t getId() const = 0;
virtual MessageQueueId_t getId() const = 0;
/**
* @brief With the sendMessage call, a queue message is sent to a receiving queue.
@ -159,9 +159,9 @@ class MessageQueueIF {
/**
* @brief This method is a simple getter for the default destination.
*/
[[nodiscard]] virtual MessageQueueId_t getDefaultDestination() const = 0;
virtual MessageQueueId_t getDefaultDestination() const = 0;
[[nodiscard]] virtual bool isDefaultDestinationSet() const = 0;
virtual bool isDefaultDestinationSet() const = 0;
virtual MqArgs& getMqArgs() = 0;
};

View File

@ -10,10 +10,10 @@ MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize()
}
MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size)
: messageSize(MessageQueueMessage::HEADER_SIZE + size) {
if (size <= MessageQueueMessage::MAX_DATA_SIZE) {
std::memcpy(MessageQueueMessage::getData(), data, size);
this->messageSize = MessageQueueMessage::HEADER_SIZE + size;
: messageSize(this->HEADER_SIZE + size) {
if (size <= this->MAX_DATA_SIZE) {
memcpy(this->getData(), data, size);
this->messageSize = this->HEADER_SIZE + size;
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "MessageQueueMessage: Passed size larger than maximum"
@ -21,23 +21,21 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size)
<< std::endl;
#endif
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
this->messageSize = MessageQueueMessage::HEADER_SIZE;
this->messageSize = this->HEADER_SIZE;
}
}
MessageQueueMessage::~MessageQueueMessage() = default;
MessageQueueMessage::~MessageQueueMessage() {}
const uint8_t* MessageQueueMessage::getBuffer() const { return this->internalBuffer; }
uint8_t* MessageQueueMessage::getBuffer() { return this->internalBuffer; }
const uint8_t* MessageQueueMessage::getData() const {
return this->internalBuffer + MessageQueueMessage::HEADER_SIZE;
return this->internalBuffer + this->HEADER_SIZE;
}
uint8_t* MessageQueueMessage::getData() {
return this->internalBuffer + MessageQueueMessage::HEADER_SIZE;
}
uint8_t* MessageQueueMessage::getData() { return this->internalBuffer + this->HEADER_SIZE; }
MessageQueueId_t MessageQueueMessage::getSender() const {
MessageQueueId_t temp_id;
@ -60,22 +58,14 @@ void MessageQueueMessage::print(bool printWholeMessage) {
}
}
void MessageQueueMessage::clear() {
memset(this->getBuffer(), 0, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
void MessageQueueMessage::clear() { memset(this->getBuffer(), 0, this->MAX_MESSAGE_SIZE); }
size_t MessageQueueMessage::getMessageSize() const { return this->messageSize; }
void MessageQueueMessage::setMessageSize(size_t messageSize_) { this->messageSize = messageSize_; }
void MessageQueueMessage::setMessageSize(size_t messageSize) { this->messageSize = messageSize; }
size_t MessageQueueMessage::getMinimumMessageSize() const {
return MessageQueueMessage::MIN_MESSAGE_SIZE;
}
size_t MessageQueueMessage::getMinimumMessageSize() const { return this->MIN_MESSAGE_SIZE; }
size_t MessageQueueMessage::getMaximumMessageSize() const {
return MessageQueueMessage::MAX_MESSAGE_SIZE;
}
size_t MessageQueueMessage::getMaximumMessageSize() const { return this->MAX_MESSAGE_SIZE; }
size_t MessageQueueMessage::getMaximumDataSize() const {
return MessageQueueMessage::MAX_DATA_SIZE;
}
size_t MessageQueueMessage::getMaximumDataSize() const { return this->MAX_DATA_SIZE; }

View File

@ -25,30 +25,6 @@
*/
class MessageQueueMessage : public MessageQueueMessageIF {
public:
/**
* @brief This constant defines the maximum size of the data content,
* excluding the header.
* @details
* It may be changed if necessary, but in general should be kept
* as small as possible.
*/
static const size_t MAX_DATA_SIZE = 24;
/**
* @brief This constant defines the maximum total size in bytes
* of a sent message.
* @details
* It is the sum of the maximum data and the header size. Be aware that
* this constant is used to define the buffer sizes for every message
* queue in the system. So, a change here may have significant impact on
* the required resources.
*/
static constexpr size_t MAX_MESSAGE_SIZE = MAX_DATA_SIZE + HEADER_SIZE;
/**
* @brief Defines the minimum size of a message where only the
* header is included
*/
static constexpr size_t MIN_MESSAGE_SIZE = HEADER_SIZE;
/**
* @brief The class is initialized empty with this constructor.
* @details
@ -74,12 +50,59 @@ class MessageQueueMessage : public MessageQueueMessageIF {
* @brief As no memory is allocated in this class,
* the destructor is empty.
*/
~MessageQueueMessage() override;
virtual ~MessageQueueMessage();
/**
* @brief The size information of each message is stored in
* this attribute.
* @details
* It is public to simplify usage and to allow for passing the size
* address as a pointer. Care must be taken when inheriting from this class,
* as every child class is responsible for managing the size information by
* itself. When using the class to receive a message, the size information
* is updated automatically.
*
* Please note that the minimum size is limited by the size of the header
* while the maximum size is limited by the maximum allowed message size.
*/
size_t messageSize;
/**
* @brief This constant defines the maximum size of the data content,
* excluding the header.
* @details
* It may be changed if necessary, but in general should be kept
* as small as possible.
*/
static const size_t MAX_DATA_SIZE = 24;
/**
* @brief This constant defines the maximum total size in bytes
* of a sent message.
* @details
* It is the sum of the maximum data and the header size. Be aware that
* this constant is used to define the buffer sizes for every message
* queue in the system. So, a change here may have significant impact on
* the required resources.
*/
static constexpr size_t MAX_MESSAGE_SIZE = MAX_DATA_SIZE + HEADER_SIZE;
/**
* @brief Defines the minimum size of a message where only the
* header is included
*/
static constexpr size_t MIN_MESSAGE_SIZE = HEADER_SIZE;
private:
/**
* @brief This is the internal buffer that contains the
* actual message data.
*/
uint8_t internalBuffer[MAX_MESSAGE_SIZE];
public:
/**
* @brief This method is used to get the complete data of the message.
*/
[[nodiscard]] const uint8_t* getBuffer() const override;
const uint8_t* getBuffer() const override;
/**
* @brief This method is used to get the complete data of the message.
*/
@ -89,7 +112,7 @@ class MessageQueueMessage : public MessageQueueMessageIF {
* @details
* It shall be used by child classes to add data at the right position.
*/
[[nodiscard]] const uint8_t* getData() const override;
const uint8_t* getData() const override;
/**
* @brief This method is used to fetch the data content of the message.
* @details
@ -100,7 +123,7 @@ class MessageQueueMessage : public MessageQueueMessageIF {
* @brief This method is used to extract the sender's message
* queue id information from a received message.
*/
[[nodiscard]] MessageQueueId_t getSender() const override;
MessageQueueId_t getSender() const override;
/**
* @brief With this method, the whole content
* and the message size is set to zero.
@ -115,40 +138,16 @@ class MessageQueueMessage : public MessageQueueMessageIF {
*/
void setSender(MessageQueueId_t setId) override;
[[nodiscard]] size_t getMessageSize() const override;
void setMessageSize(size_t messageSize) override;
[[nodiscard]] size_t getMinimumMessageSize() const override;
[[nodiscard]] size_t getMaximumMessageSize() const override;
[[nodiscard]] size_t getMaximumDataSize() const override;
virtual size_t getMessageSize() const override;
virtual void setMessageSize(size_t messageSize) override;
virtual size_t getMinimumMessageSize() const override;
virtual size_t getMaximumMessageSize() const override;
virtual size_t getMaximumDataSize() const override;
/**
* @brief This is a debug method that prints the content.
*/
void print(bool printWholeMessage);
/**
* TODO: This really should not be public. If it should be possible to pass size address as a
* pointer, add a getter function returning a const reference to the size
* @brief The size information of each message is stored in
* this attribute.
* @details
* It is public to simplify usage and to allow for passing the size
* address as a pointer. Care must be taken when inheriting from this class,
* as every child class is responsible for managing the size information by
* itself. When using the class to receive a message, the size information
* is updated automatically.
*
* Please note that the minimum size is limited by the size of the header
* while the maximum size is limited by the maximum allowed message size.
*/
size_t messageSize;
private:
/**
* @brief This is the internal buffer that contains the
* actual message data.
*/
uint8_t internalBuffer[MAX_MESSAGE_SIZE] = {};
};
#endif /* FSFW_IPC_MESSAGEQUEUEMESSAGE_H_ */

View File

@ -14,7 +14,7 @@ class MessageQueueMessageIF {
*/
static const size_t HEADER_SIZE = sizeof(MessageQueueId_t);
virtual ~MessageQueueMessageIF() = default;
virtual ~MessageQueueMessageIF(){};
/**
* @brief With this method, the whole content and the message
@ -29,7 +29,7 @@ class MessageQueueMessageIF {
* @brief Get read-only pointer to the complete data of the message.
* @return
*/
[[nodiscard]] virtual const uint8_t* getBuffer() const = 0;
virtual const uint8_t* getBuffer() const = 0;
/**
* @brief This method is used to get the complete data of the message.
@ -48,14 +48,14 @@ class MessageQueueMessageIF {
* @brief This method is used to extract the sender's message queue id
* information from a received message.
*/
[[nodiscard]] virtual MessageQueueId_t getSender() const = 0;
virtual MessageQueueId_t getSender() const = 0;
/**
* @brief This method is used to fetch the data content of the message.
* @details
* It shall be used by child classes to add data at the right position.
*/
[[nodiscard]] virtual const uint8_t* getData() const = 0;
virtual const uint8_t* getData() const = 0;
/**
* @brief This method is used to fetch the data content of the message.
* @details
@ -67,28 +67,12 @@ class MessageQueueMessageIF {
* Get constant message size of current message implementation.
* @return
*/
[[nodiscard]] virtual size_t getMessageSize() const = 0;
virtual size_t getMessageSize() const = 0;
/**
* Sets the current message size of a given message
* @param messageSize
*/
virtual void setMessageSize(size_t messageSize) = 0;
/**
* Returns the smallest possible message size, including any headers
* @return
*/
[[nodiscard]] virtual size_t getMinimumMessageSize() const = 0;
/**
* Returns the largest possible message size, including any headers
* @return
*/
[[nodiscard]] virtual size_t getMaximumMessageSize() const = 0;
/**
* Returns the largest possible data size without any headers
* @return
*/
[[nodiscard]] virtual size_t getMaximumDataSize() const = 0;
virtual size_t getMinimumMessageSize() const = 0;
virtual size_t getMaximumMessageSize() const = 0;
virtual size_t getMaximumDataSize() const = 0;
};
#endif /* FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ */

View File

@ -1,14 +1,14 @@
#ifndef FSFW_IPC_MESSAGEQUEUESENDERIF_H_
#define FSFW_IPC_MESSAGEQUEUESENDERIF_H_
#include "../objectmanager/ObjectManagerIF.h"
#include "MessageQueueIF.h"
#include "MessageQueueMessageIF.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
class MessageQueueSenderIF {
public:
virtual ~MessageQueueSenderIF() = default;
MessageQueueSenderIF() = delete;
virtual ~MessageQueueSenderIF() {}
/**
* Allows sending messages without actually "owning" a message queue.
* Not sure whether this is actually a good idea.
@ -16,6 +16,9 @@ class MessageQueueSenderIF {
static ReturnValue_t sendMessage(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
MessageQueueId_t sentFrom = MessageQueueIF::NO_QUEUE,
bool ignoreFault = false);
private:
MessageQueueSenderIF() {}
};
#endif /* FSFW_IPC_MESSAGEQUEUESENDERIF_H_ */

View File

@ -8,7 +8,7 @@
#include "../serialize/SerialLinkedListAdapter.h"
#include "../serialize/SerializeElement.h"
#include "../serviceinterface/ServiceInterface.h"
#include "../timemanager/TimeWriterIF.h"
#include "../timemanager/TimeStamperIF.h"
#include "HasMonitorsIF.h"
#include "MonitoringIF.h"
#include "monitoringConf.h"
@ -34,9 +34,9 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
SerializeElement<T> limitValue;
SerializeElement<ReturnValue_t> oldState;
SerializeElement<ReturnValue_t> newState;
uint8_t rawTimestamp[TimeWriterIF::MAXIMUM_TIMESTAMP_LEN] = {};
uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE] = {};
SerializeElement<SerialBufferAdapter<uint8_t>> timestampSerializer;
TimeWriterIF* timeStamper;
TimeStamperIF* timeStamper;
MonitoringReportContent()
: SerialLinkedListAdapter<SerializeIF>(&parameterObjectId),
monitorId(0),
@ -47,7 +47,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
oldState(0),
newState(0),
timestampSerializer(rawTimestamp, sizeof(rawTimestamp)),
timeStamper(nullptr) {
timeStamper(NULL) {
setAllNext();
}
MonitoringReportContent(gp_id_t globalPoolId, T value, T limitValue, ReturnValue_t oldState,
@ -61,7 +61,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
oldState(oldState),
newState(newState),
timestampSerializer(rawTimestamp, sizeof(rawTimestamp)),
timeStamper(nullptr) {
timeStamper(NULL) {
setAllNext();
if (checkAndSetStamper()) {
timeStamper->addTimeStamp(rawTimestamp, sizeof(rawTimestamp));
@ -79,7 +79,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
}
bool checkAndSetStamper() {
if (timeStamper == nullptr) {
timeStamper = ObjectManager::instance()->get<TimeWriterIF>(timeStamperId);
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId);
if (timeStamper == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MonitoringReportContent::checkAndSetStamper: "

View File

@ -16,7 +16,12 @@ ObjectManager* ObjectManager::instance() {
return objManagerInstance;
}
ObjectManager::ObjectManager() = default;
void ObjectManager::setObjectFactoryFunction(produce_function_t objFactoryFunc, void* factoryArgs) {
this->objectFactoryFunction = objFactoryFunc;
this->factoryArgs = factoryArgs;
}
ObjectManager::ObjectManager() {}
ObjectManager::~ObjectManager() {
for (auto const& iter : objectList) {
@ -48,7 +53,7 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) {
}
ReturnValue_t ObjectManager::remove(object_id_t id) {
if (this->getSystemObject(id) != nullptr) {
if (this->getSystemObject(id) != NULL) {
this->objectList.erase(id);
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "ObjectManager::removeObject: Object " << std::hex
@ -74,6 +79,17 @@ SystemObjectIF* ObjectManager::getSystemObject(object_id_t id) {
}
void ObjectManager::initialize() {
if (objectFactoryFunction == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::initialize: Passed produceObjects "
"functions is nullptr!"
<< std::endl;
#else
sif::printError("ObjectManager::initialize: Passed produceObjects functions is nullptr!\n");
#endif
return;
}
objectFactoryFunction(factoryArgs);
ReturnValue_t result = returnvalue::FAILED;
uint32_t errorCount = 0;
for (auto const& it : objectList) {

View File

@ -21,6 +21,7 @@
*/
class ObjectManager : public ObjectManagerIF {
public:
using produce_function_t = void (*)(void* args);
/**
* Returns the single instance of TaskFactory.
@ -29,13 +30,15 @@ class ObjectManager : public ObjectManagerIF {
*/
static ObjectManager* instance();
void setObjectFactoryFunction(produce_function_t prodFunc, void* args);
template <typename T>
T* get(object_id_t id);
/**
* @brief In the class's destructor, all objects in the list are deleted.
*/
~ObjectManager() override;
virtual ~ObjectManager();
ReturnValue_t insert(object_id_t id, SystemObjectIF* object) override;
ReturnValue_t remove(object_id_t id) override;
void initialize() override;
@ -51,6 +54,8 @@ class ObjectManager : public ObjectManagerIF {
* @param The id of the object to be created.
* @return Returns a pointer to the newly created object or NULL.
*/
produce_function_t objectFactoryFunction = nullptr;
void* factoryArgs = nullptr;
private:
ObjectManager();

View File

@ -33,7 +33,6 @@ enum framework_objects : object_id_t {
TC_STORE = 0x534f0100,
TM_STORE = 0x534f0200,
TIME_STAMPER = 0x53500010,
VERIFICATION_REPORTER = 0x53500020,
FSFW_OBJECTS_END = 0x53ffffff,
NO_OBJECT = 0xFFFFFFFF

View File

@ -161,7 +161,7 @@ void TcpTmTcServer::handleServerOperation(socket_t& connSocket) {
while (true) {
ssize_t retval = recv(connSocket, reinterpret_cast<char*>(receptionBuffer.data()),
receptionBuffer.size(), tcpConfig.tcpFlags);
receptionBuffer.capacity(), tcpConfig.tcpFlags);
if (retval == 0) {
size_t availableReadData = ringBuffer.getAvailableReadData();
if (availableReadData > lastRingBufferSize) {
@ -335,27 +335,31 @@ ReturnValue_t TcpTmTcServer::handleTcRingBufferData(size_t availableReadData) {
}
ringBuffer.readData(receptionBuffer.data(), readAmount, true);
const uint8_t* bufPtr = receptionBuffer.data();
SpacePacketParser::FoundPacketInfo info;
const uint8_t** bufPtrPtr = &bufPtr;
size_t startIdx = 0;
size_t foundSize = 0;
size_t readLen = 0;
while (readLen < readAmount) {
if (spacePacketParser == nullptr) {
return returnvalue::FAILED;
}
spacePacketParser->reset();
while (spacePacketParser->getAmountRead() < readAmount) {
result = spacePacketParser->parseSpacePackets(&bufPtr, readAmount, info);
result =
spacePacketParser->parseSpacePackets(bufPtrPtr, readAmount, startIdx, foundSize, readLen);
switch (result) {
case (SpacePacketParser::NO_PACKET_FOUND):
case (SpacePacketParser::SPLIT_PACKET): {
break;
}
case (returnvalue::OK): {
result = handleTcReception(receptionBuffer.data() + info.startIdx, info.sizeFound);
result = handleTcReception(receptionBuffer.data() + startIdx, foundSize);
if (result != returnvalue::OK) {
status = result;
}
}
}
ringBuffer.deleteData(info.sizeFound);
ringBuffer.deleteData(foundSize);
lastRingBufferSize = ringBuffer.getAvailableReadData();
std::memset(receptionBuffer.data() + startIdx, 0, foundSize);
}
return status;
}

View File

@ -146,7 +146,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
}
ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) {
struct tm time_tm {};
struct tm time_tm;
time_tm.tm_year = from->year - 1900;
time_tm.tm_mon = from->month - 1;

View File

@ -65,11 +65,11 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
// But I will still return a failure here.
return returnvalue::FAILED;
}
auto* targetQueue =
MessageQueue* targetQueue =
dynamic_cast<MessageQueue*>(QueueMapManager::instance()->getMessageQueue(sendTo));
if (targetQueue == nullptr) {
if (not ignoreFault) {
auto* internalErrorReporter =
InternalErrorReporterIF* internalErrorReporter =
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
if (internalErrorReporter != nullptr) {
internalErrorReporter->queueMessageNotSent();
@ -84,7 +84,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
message->getMaximumMessageSize());
} else {
if (not ignoreFault) {
auto* internalErrorReporter =
InternalErrorReporterIF* internalErrorReporter =
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
if (internalErrorReporter != nullptr) {
internalErrorReporter->queueMessageNotSent();

View File

@ -68,7 +68,7 @@ class MessageQueue : public MessageQueueBase {
* @details This is accomplished by using the delete call provided
* by the operating system.
*/
~MessageQueue() override;
virtual ~MessageQueue();
// Implement non-generic MessageQueueIF functions not handled by MessageQueueBase
virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
@ -111,6 +111,8 @@ class MessageQueue : public MessageQueueBase {
size_t messageDepth = 0;
MutexIF* queueLock;
MessageQueueId_t defaultDestination = MessageQueueIF::NO_QUEUE;
};
#endif /* FRAMEWORK_OSAL_HOST_MESSAGEQUEUE_H_ */

View File

@ -13,6 +13,7 @@ ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo,
MessageQueueMessageIF* message,
MessageQueueId_t sentFrom, bool ignoreFault) {
return MessageQueue::sendMessageFromMessageQueue(sendTo, message, sentFrom, ignoreFault);
return returnvalue::OK;
}
QueueFactory* QueueFactory::instance() {
@ -22,9 +23,9 @@ QueueFactory* QueueFactory::instance() {
return factoryInstance;
}
QueueFactory::QueueFactory() = default;
QueueFactory::QueueFactory() {}
QueueFactory::~QueueFactory() = default;
QueueFactory::~QueueFactory() {}
MessageQueueIF* QueueFactory::createMessageQueue(uint32_t messageDepth, size_t maxMessageSize,
MqArgs* args) {

View File

@ -54,7 +54,7 @@ MessageQueueIF* QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId
<< " does not exist in the map" << std::endl;
<< " does not exists in the map!" << std::endl;
#else
sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n",
messageQueueId);

View File

@ -2,22 +2,23 @@
#include <linux/sysinfo.h>
#include <sys/sysinfo.h>
#include <sys/time.h>
#include <time.h>
#include <unistd.h>
#include <ctime>
#include <fstream>
#include "fsfw/ipc/MutexGuard.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
uint32_t Clock::getTicksPerSecond() {
uint32_t Clock::getTicksPerSecond(void) {
uint32_t ticks = sysconf(_SC_CLK_TCK);
return ticks;
}
ReturnValue_t Clock::setClock(const TimeOfDay_t* time) {
timespec timeUnix{};
timeval timeTimeval{};
timespec timeUnix;
timeval timeTimeval;
convertTimeOfDayToTimeval(time, &timeTimeval);
timeUnix.tv_sec = timeTimeval.tv_sec;
timeUnix.tv_nsec = (__syscall_slong_t)timeTimeval.tv_usec * 1000;
@ -31,7 +32,7 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) {
}
ReturnValue_t Clock::setClock(const timeval* time) {
timespec timeUnix{};
timespec timeUnix;
timeUnix.tv_sec = time->tv_sec;
timeUnix.tv_nsec = (__syscall_slong_t)time->tv_usec * 1000;
int status = clock_settime(CLOCK_REALTIME, &timeUnix);
@ -43,7 +44,7 @@ ReturnValue_t Clock::setClock(const timeval* time) {
}
ReturnValue_t Clock::getClock_timeval(timeval* time) {
timespec timeUnix{};
timespec timeUnix;
int status = clock_gettime(CLOCK_REALTIME, &timeUnix);
if (status != 0) {
return returnvalue::FAILED;
@ -54,18 +55,18 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) {
}
ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
timeval timeVal{};
timeval timeVal;
ReturnValue_t result = getClock_timeval(&timeVal);
if (result != returnvalue::OK) {
return result;
}
*time = static_cast<uint64_t>(timeVal.tv_sec) * 1e6 + timeVal.tv_usec;
*time = (uint64_t)timeVal.tv_sec * 1e6 + timeVal.tv_usec;
return returnvalue::OK;
}
timeval Clock::getUptime() {
timeval uptime{};
timeval uptime;
auto result = getUptime(&uptime);
if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -98,7 +99,7 @@ ReturnValue_t Clock::getUptime(timeval* uptime) {
//}
ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) {
timeval uptime{};
timeval uptime;
ReturnValue_t result = getUptime(&uptime);
if (result != returnvalue::OK) {
return result;
@ -108,7 +109,7 @@ ReturnValue_t Clock::getUptime(uint32_t* uptimeMs) {
}
ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
timespec timeUnix{};
timespec timeUnix;
int status = clock_gettime(CLOCK_REALTIME, &timeUnix);
if (status != 0) {
// TODO errno
@ -121,7 +122,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
MutexGuard helper(timeMutex);
// gmtime writes its output in a global buffer which is not Thread Safe
// Therefore we have to use a Mutex here
struct std::tm* timeInfo;
struct tm* timeInfo;
timeInfo = gmtime(&timeUnix.tv_sec);
time->year = timeInfo->tm_year + 1900;
time->month = timeInfo->tm_mon + 1;
@ -135,7 +136,7 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
}
ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from, timeval* to) {
std::tm fromTm{};
tm fromTm;
// Note: Fails for years before AD
fromTm.tm_year = from->year - 1900;
fromTm.tm_mon = from->month - 1;

View File

@ -44,7 +44,7 @@ store_address_t ParameterMessage::getParameterLoadCommand(const CommandMessage*
*pfc = packedParamSettings >> 16 & 0xff;
*rows = packedParamSettings >> 8 & 0xff;
*columns = packedParamSettings & 0xff;
return static_cast<store_address_t>(message->getParameter2());
return message->getParameter2();
}
void ParameterMessage::clear(CommandMessage* message) {

View File

@ -41,7 +41,7 @@ ReturnValue_t CService200ModeCommanding::getMessageQueueAndObject(uint8_t subser
ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t *messageQueueToSet, object_id_t *objectId) {
auto *destination = ObjectManager::instance()->get<HasModesIF>(*objectId);
HasModesIF *destination = ObjectManager::instance()->get<HasModesIF>(*objectId);
if (destination == nullptr) {
return CommandingServiceBase::INVALID_OBJECT;
}
@ -96,13 +96,13 @@ ReturnValue_t CService200ModeCommanding::handleReply(const CommandMessage *reply
ReturnValue_t CService200ModeCommanding::prepareModeReply(const CommandMessage *reply,
object_id_t objectId) {
ModePacket modeReplyPacket(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply));
return sendTmPacket(Subservice::REPLY_MODE_REPLY, modeReplyPacket);
return sendTmPacket(Subservice::REPLY_MODE_REPLY, &modeReplyPacket);
}
ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMessage *reply,
object_id_t objectId) {
ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply), ModeMessage::getSubmode(reply));
ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, wrongModeReply);
ReturnValue_t result = sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, &wrongModeReply);
if (result == returnvalue::OK) {
// We want to produce an error here in any case because the mode was not correct
return returnvalue::FAILED;
@ -113,7 +113,7 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess
ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const CommandMessage *reply,
object_id_t objectId) {
CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply));
ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket);
ReturnValue_t result = sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, &cantReachModePacket);
if (result == returnvalue::OK) {
// We want to produce an error here in any case because the mode was not reached
return returnvalue::FAILED;

View File

@ -102,5 +102,5 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep
auto health = static_cast<uint8_t>(HealthMessage::getHealth(reply));
auto oldHealth = static_cast<uint8_t>(HealthMessage::getOldHealth(reply));
HealthSetReply healthSetReply(health, oldHealth);
return sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply);
return sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply);
}

View File

@ -38,9 +38,8 @@ class Service11TelecommandScheduling final : public PusServiceBase {
static constexpr uint8_t CLASS_ID = CLASS_ID::PUS_SERVICE_11;
static constexpr ReturnValue_t INVALID_TYPE_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 1);
static constexpr ReturnValue_t INVALID_TIME_WINDOW = returnvalue::makeCode(CLASS_ID, 2);
static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 3);
static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 4);
static constexpr ReturnValue_t TIMESHIFTING_NOT_POSSIBLE = returnvalue::makeCode(CLASS_ID, 2);
static constexpr ReturnValue_t INVALID_RELATIVE_TIME = returnvalue::makeCode(CLASS_ID, 3);
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11;
@ -72,7 +71,8 @@ class Service11TelecommandScheduling final : public PusServiceBase {
TO_TIMETAG = 3
};
Service11TelecommandScheduling(PsbParams params, AcceptsTelecommandsIF* tcRecipient,
Service11TelecommandScheduling(object_id_t objectId, uint16_t apid, uint8_t serviceId,
AcceptsTelecommandsIF* tcRecipient,
uint16_t releaseTimeMarginSeconds = DEFAULT_RELEASE_TIME_MARGIN,
bool debugMode = false);
@ -156,7 +156,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
* @param data The Application data of the TC (get via getApplicationData()).
* @return requestId
*/
[[nodiscard]] uint64_t getRequestIdFromTc() const;
uint64_t getRequestIdFromDataTC(const uint8_t* data) const;
/**
* @brief Extracts the Request ID from the Application Data directly, assuming it is packed

View File

@ -11,9 +11,9 @@ static constexpr auto DEF_END = SerializeIF::Endianness::BIG;
template <size_t MAX_NUM_TCS>
inline Service11TelecommandScheduling<MAX_NUM_TCS>::Service11TelecommandScheduling(
PsbParams params, AcceptsTelecommandsIF *tcRecipient, uint16_t releaseTimeMarginSeconds,
bool debugMode)
: PusServiceBase(params),
object_id_t objectId, uint16_t apid, uint8_t serviceId, AcceptsTelecommandsIF *tcRecipient,
uint16_t releaseTimeMarginSeconds, bool debugMode)
: PusServiceBase(objectId, apid, serviceId),
RELEASE_TIME_MARGIN_SECONDS(releaseTimeMarginSeconds),
debugMode(debugMode),
tcRecipient(tcRecipient) {}
@ -32,8 +32,11 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleRequest(
#endif
}
// Get de-serialized Timestamp
const uint8_t *data = currentPacket.getUserData();
size_t size = currentPacket.getUserDataLen();
const uint8_t *data = currentPacket.getApplicationData();
size_t size = currentPacket.getApplicationDataSize();
if (data == nullptr) {
return handleInvalidData("handleRequest");
}
switch (subservice) {
case Subservice::ENABLE_SCHEDULING: {
schedulingEnabled = true;
@ -79,7 +82,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService
if (schedulingEnabled) {
// release tc
TmTcMessage releaseMsg(it->second.storeAddr);
auto sendRet = psbParams.reqQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false);
auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false);
if (sendRet != returnvalue::OK) {
return sendRet;
@ -172,7 +175,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivi
// store currentPacket and receive the store address
store_address_t addr{};
if (tcStore->addData(&addr, data, size) != returnvalue::OK ||
addr.raw == store_address_t::INVALID_RAW) {
addr.raw == storeId::INVALID_STORE_ADDRESS) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service11TelecommandScheduling::doInsertActivity: Adding data to TC Store failed"
<< std::endl;
@ -187,7 +190,8 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivi
TelecommandStruct tc;
tc.seconds = timestamp;
tc.storeAddr = addr;
tc.requestId = getRequestIdFromTc(); // TODO: Missing sanity check of the returned request id
tc.requestId =
getRequestIdFromDataTC(data); // TODO: Missing sanity check of the returned request id
auto it = telecommandMap.insert(std::pair<uint32_t, TelecommandStruct>(timestamp, tc));
if (it == telecommandMap.end()) {
@ -451,10 +455,13 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doFilterTimesh
}
template <size_t MAX_NUM_TCS>
inline uint64_t Service11TelecommandScheduling<MAX_NUM_TCS>::getRequestIdFromTc() const {
uint32_t sourceId = currentPacket.getSourceId();
uint16_t apid = currentPacket.getApid();
uint16_t sequenceCount = currentPacket.getSequenceCount();
inline uint64_t Service11TelecommandScheduling<MAX_NUM_TCS>::getRequestIdFromDataTC(
const uint8_t *data) const {
TcPacketPus mask(data);
uint32_t sourceId = mask.getSourceId();
uint16_t apid = mask.getAPID();
uint16_t sequenceCount = mask.getPacketSequenceCount();
return buildRequestId(sourceId, apid, sequenceCount);
}
@ -564,17 +571,12 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFr
if (result != returnvalue::OK) {
return result;
}
if (fromTimestamp > toTimestamp) {
return INVALID_TIME_WINDOW;
}
itBegin = telecommandMap.begin();
itEnd = telecommandMap.begin();
while (itBegin->first < fromTimestamp && itBegin != telecommandMap.end()) {
itBegin++;
}
// start looking for end beginning at begin
itEnd = itBegin;
while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) {
itEnd++;
}
@ -584,6 +586,17 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::getMapFilterFr
default:
return returnvalue::FAILED;
}
// additional security check, this should never be true
if (itBegin > itEnd) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "11::getMapFilterFromData: itBegin > itEnd\n" << std::endl;
#else
sif::printError("11::getMapFilterFromData: itBegin > itEnd\n");
#endif
return returnvalue::FAILED;
}
// the map range should now be set according to the sent filter.
return returnvalue::OK;
}

View File

@ -1,33 +1,39 @@
#include "fsfw/pus/Service17Test.h"
#include "fsfw/FSFW.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tmtcservices/tmHelpers.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
Service17Test::Service17Test(PsbParams params)
: PusServiceBase(params),
storeHelper(params.apid),
tmHelper(params.serviceId, storeHelper, sendHelper) {}
Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId)
: PusServiceBase(objectId, apid, serviceId), packetSubCounter(0) {}
Service17Test::~Service17Test() = default;
Service17Test::~Service17Test() {}
ReturnValue_t Service17Test::handleRequest(uint8_t subservice) {
switch (subservice) {
case Subservice::CONNECTION_TEST: {
ReturnValue_t result = tmHelper.prepareTmPacket(Subservice::CONNECTION_TEST_REPORT);
if (result != returnvalue::OK) {
return result;
}
return tmHelper.storeAndSendTmPacket();
#if FSFW_USE_PUS_C_TELEMETRY == 0
TmPacketStoredPusA connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT,
packetSubCounter++);
#else
TmPacketStoredPusC connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT,
packetSubCounter++);
#endif
connectionPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId());
return returnvalue::OK;
}
case Subservice::EVENT_TRIGGER_TEST: {
#if FSFW_USE_PUS_C_TELEMETRY == 0
TmPacketStoredPusA connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT,
packetSubCounter++);
#else
TmPacketStoredPusC connectionPacket(apid, serviceId, Subservice::CONNECTION_TEST_REPORT,
packetSubCounter++);
#endif
connectionPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId());
triggerEvent(TEST, 1234, 5678);
ReturnValue_t result = tmHelper.prepareTmPacket(Subservice::EVENT_TRIGGER_TEST);
if (result != returnvalue::OK) {
return result;
}
return tmHelper.storeAndSendTmPacket();
return returnvalue::OK;
}
default:
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
@ -35,23 +41,3 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) {
}
ReturnValue_t Service17Test::performService() { return returnvalue::OK; }
ReturnValue_t Service17Test::initialize() {
ReturnValue_t result = PusServiceBase::initialize();
if (result != returnvalue::OK) {
return result;
}
initializeTmHelpers(sendHelper, storeHelper);
if (storeHelper.getTmStore() == nullptr) {
auto* tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmStore == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
storeHelper.setTmStore(*tmStore);
}
return result;
}
void Service17Test::setCustomTmStore(StorageManagerIF& tmStore_) {
storeHelper.setTmStore(tmStore_);
}

View File

@ -3,8 +3,6 @@
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tmtcservices/PusServiceBase.h"
#include "fsfw/tmtcservices/TmStoreAndSendHelper.h"
#include "fsfw/tmtcservices/TmStoreHelper.h"
/**
* @brief Test Service
@ -34,19 +32,13 @@ class Service17Test : public PusServiceBase {
EVENT_TRIGGER_TEST = 128,
};
explicit Service17Test(PsbParams params);
void setCustomTmStore(StorageManagerIF& tmStore);
~Service17Test() override;
ReturnValue_t handleRequest(uint8_t subservice) override;
ReturnValue_t performService() override;
ReturnValue_t initialize() override;
Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId);
virtual ~Service17Test();
virtual ReturnValue_t handleRequest(uint8_t subservice) override;
virtual ReturnValue_t performService() override;
protected:
TmStoreHelper storeHelper;
TmSendHelper sendHelper;
TmStoreAndSendWrapper tmHelper;
uint16_t packetSubCounter = 0;
};
#endif /* FSFW_PUS_SERVICE17TEST_H_ */

View File

@ -3,21 +3,19 @@
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/pus/servicepackets/Service1Packets.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/PusVerificationReport.h"
#include "fsfw/tmtcservices/tmHelpers.h"
Service1TelecommandVerification::Service1TelecommandVerification(object_id_t objectId,
uint16_t apid, uint8_t serviceId,
object_id_t targetDestination,
uint16_t messageQueueDepth,
TimeWriterIF* timeStamper)
uint16_t messageQueueDepth)
: SystemObject(objectId),
apid(apid),
serviceId(serviceId),
targetDestination(targetDestination),
storeHelper(apid),
tmHelper(serviceId, storeHelper, sendHelper) {
targetDestination(targetDestination) {
tmQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
}
@ -49,19 +47,6 @@ ReturnValue_t Service1TelecommandVerification::performOperation(uint8_t operatio
ReturnValue_t Service1TelecommandVerification::sendVerificationReport(
PusVerificationMessage* message) {
ReturnValue_t result;
uint8_t reportId = message->getReportId();
if (reportId == 0 or reportId > 8) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service1TelecommandVerification::sendVerificationReport: Invalid report ID "
<< static_cast<int>(reportId) << " detected" << std::endl;
#else
sif::printError(
"Service1TelecommandVerification::sendVerificationReport: Invalid report ID "
"%d detected\n",
reportId);
#endif
return returnvalue::FAILED;
}
if (message->getReportId() % 2 == 0) {
result = generateFailureReport(message);
} else {
@ -82,37 +67,32 @@ ReturnValue_t Service1TelecommandVerification::generateFailureReport(
FailureReport report(message->getReportId(), message->getTcPacketId(),
message->getTcSequenceControl(), message->getStep(), message->getErrorCode(),
message->getParameter1(), message->getParameter2());
ReturnValue_t result =
storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++);
if (result != returnvalue::OK) {
#if FSFW_USE_PUS_C_TELEMETRY == 0
TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
#else
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
#endif
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(), tmQueue->getId());
return result;
}
result = storeHelper.setSourceDataSerializable(report);
if (result != returnvalue::OK) {
return result;
}
return tmHelper.storeAndSendTmPacket();
}
ReturnValue_t Service1TelecommandVerification::generateSuccessReport(
PusVerificationMessage* message) {
SuccessReport report(message->getReportId(), message->getTcPacketId(),
message->getTcSequenceControl(), message->getStep());
ReturnValue_t result =
storeHelper.preparePacket(serviceId, message->getReportId(), packetSubCounter++);
if (result != returnvalue::OK) {
#if FSFW_USE_PUS_C_TELEMETRY == 0
TmPacketStoredPusA tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
#else
TmPacketStoredPusC tmPacket(apid, serviceId, message->getReportId(), packetSubCounter++, &report);
#endif
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(), tmQueue->getId());
return result;
}
result = storeHelper.setSourceDataSerializable(report);
if (result != returnvalue::OK) {
return result;
}
return tmHelper.storeAndSendTmPacket();
}
ReturnValue_t Service1TelecommandVerification::initialize() {
// Get target object for TC verification messages
auto* funnel = ObjectManager::instance()->get<AcceptsTelemetryIF>(targetDestination);
AcceptsTelemetryIF* funnel =
ObjectManager::instance()->get<AcceptsTelemetryIF>(targetDestination);
if (funnel == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service1TelecommandVerification::initialize: Specified"
@ -122,33 +102,6 @@ ReturnValue_t Service1TelecommandVerification::initialize() {
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
if (tmQueue == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmQueue->setDefaultDestination(funnel->getReportReceptionQueue());
if (tmStore == nullptr) {
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmStore == nullptr) {
return ObjectManager::CHILD_INIT_FAILED;
}
storeHelper.setTmStore(*tmStore);
}
if (timeStamper == nullptr) {
timeStamper = ObjectManager::instance()->get<TimeWriterIF>(objects::TIME_STAMPER);
if (timeStamper == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
} else {
}
storeHelper.setTimeStamper(*timeStamper);
sendHelper.setMsgQueue(*tmQueue);
if (errReporter == nullptr) {
errReporter =
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
if (errReporter != nullptr) {
sendHelper.setInternalErrorReporter(*errReporter);
}
}
return SystemObject::initialize();
}

View File

@ -7,9 +7,6 @@
#include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h"
#include "fsfw/tmtcservices/PusVerificationReport.h"
#include "fsfw/tmtcservices/TmSendHelper.h"
#include "fsfw/tmtcservices/TmStoreAndSendHelper.h"
#include "fsfw/tmtcservices/TmStoreHelper.h"
/**
* @brief Verify TC acceptance, start, progress and execution.
@ -46,15 +43,14 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_1;
Service1TelecommandVerification(object_id_t objectId, uint16_t apid, uint8_t serviceId,
object_id_t targetDestination, uint16_t messageQueueDepth,
TimeWriterIF* timeStamper = nullptr);
~Service1TelecommandVerification() override;
object_id_t targetDestination, uint16_t messageQueueDepth);
virtual ~Service1TelecommandVerification();
/**
*
* @return ID of Verification Queue
*/
MessageQueueId_t getVerificationQueue() override;
virtual MessageQueueId_t getVerificationQueue() override;
/**
* Performs the service periodically as specified in init_mission().
@ -62,7 +58,7 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
* @param operationCode
* @return
*/
ReturnValue_t performOperation(uint8_t operationCode) override;
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
/**
* Initializes the destination for TC verification messages and initializes
@ -83,12 +79,6 @@ class Service1TelecommandVerification : public AcceptsVerifyMessageIF,
uint16_t packetSubCounter = 0;
TmSendHelper sendHelper;
TmStoreHelper storeHelper;
TmStoreAndSendWrapper tmHelper;
InternalErrorReporterIF* errReporter = nullptr;
TimeWriterIF* timeStamper = nullptr;
StorageManagerIF* tmStore = nullptr;
MessageQueueIF* tmQueue = nullptr;
enum class Subservice : uint8_t {

View File

@ -14,7 +14,7 @@ Service20ParameterManagement::Service20ParameterManagement(object_id_t objectId,
: CommandingServiceBase(objectId, apid, serviceId, numberOfParallelCommands,
commandTimeoutSeconds) {}
Service20ParameterManagement::~Service20ParameterManagement() = default;
Service20ParameterManagement::~Service20ParameterManagement() {}
ReturnValue_t Service20ParameterManagement::isValidSubservice(uint8_t subservice) {
switch (static_cast<Subservice>(subservice)) {
@ -64,7 +64,8 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t*
ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
// check ReceivesParameterMessagesIF property of target
auto* possibleTarget = ObjectManager::instance()->get<ReceivesParameterMessagesIF>(*objectId);
ReceivesParameterMessagesIF* possibleTarget =
ObjectManager::instance()->get<ReceivesParameterMessagesIF>(*objectId);
if (possibleTarget == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service20ParameterManagement::checkInterfaceAndAcquire"
@ -136,7 +137,7 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(CommandMessage* m
if (parameterDataLen == 0) {
return CommandingServiceBase::INVALID_TC;
}
ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer);
ReturnValue_t result = IPCStore->getFreeElement(&storeAddress, parameterDataLen, &storePointer);
if (result != returnvalue::OK) {
return result;
}
@ -168,7 +169,7 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re
switch (replyId) {
case ParameterMessage::REPLY_PARAMETER_DUMP: {
ConstAccessorPair parameterData = ipcStore->getData(ParameterMessage::getStoreId(reply));
ConstAccessorPair parameterData = IPCStore->getData(ParameterMessage::getStoreId(reply));
if (parameterData.first != returnvalue::OK) {
return returnvalue::FAILED;
}
@ -176,7 +177,8 @@ ReturnValue_t Service20ParameterManagement::handleReply(const CommandMessage* re
ParameterId_t parameterId = ParameterMessage::getParameterId(reply);
ParameterDumpReply parameterReply(objectId, parameterId, parameterData.second.data(),
parameterData.second.size());
return sendTmPacket(static_cast<uint8_t>(Subservice::PARAMETER_DUMP_REPLY), parameterReply);
sendTmPacket(static_cast<uint8_t>(Subservice::PARAMETER_DUMP_REPLY), &parameterReply);
return returnvalue::OK;
}
default:
return CommandingServiceBase::INVALID_REPLY;

View File

@ -75,7 +75,7 @@ ReturnValue_t Service2DeviceAccess::prepareRawCommand(CommandMessage* messageToS
// store command into the Inter Process Communication Store
store_address_t storeAddress;
ReturnValue_t result =
ipcStore->addData(&storeAddress, RawCommand.getCommand(), RawCommand.getCommandSize());
IPCStore->addData(&storeAddress, RawCommand.getCommand(), RawCommand.getCommandSize());
DeviceHandlerMessage::setDeviceHandlerRawCommandMessage(messageToSet, storeAddress);
return result;
}
@ -135,7 +135,7 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs
store_address_t storeAddress = DeviceHandlerMessage::getStoreAddress(reply);
const uint8_t* data = nullptr;
size_t size = 0;
ReturnValue_t result = ipcStore->getData(storeAddress, &data, &size);
ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size);
if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in "
@ -147,12 +147,10 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage* reply, uint8_t subs
// Init our dummy packet and correct endianness of object ID before
// sending it back.
WiretappingPacket tmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data);
result = sendTmPacket(subservice, tmPacket.objectId, tmPacket.data, size);
if (result != returnvalue::OK) {
// TODO: Warning
return;
}
WiretappingPacket TmPacket(DeviceHandlerMessage::getDeviceObjectId(reply), data);
TmPacket.objectId = EndianConverter::convertBigEndian(TmPacket.objectId);
sendTmPacket(subservice, TmPacket.data, size, reinterpret_cast<uint8_t*>(&TmPacket.objectId),
sizeof(TmPacket.objectId));
}
MessageQueueId_t Service2DeviceAccess::getDeviceQueue() { return commandQueue->getId(); }

View File

@ -284,13 +284,14 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess
store_address_t storeId;
sid_t sid = HousekeepingMessage::getHkDataReply(hkMessage, &storeId);
auto resultPair = ipcStore->getData(storeId);
auto resultPair = IPCStore->getData(storeId);
if (resultPair.first != returnvalue::OK) {
return resultPair.first;
}
HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size());
return sendTmPacket(static_cast<uint8_t>(subserviceId), hkPacket.hkData, hkPacket.hkSize);
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,

View File

@ -5,13 +5,12 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/pus/servicepackets/Service5Packets.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcservices/tmHelpers.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
Service5EventReporting::Service5EventReporting(PsbParams params, size_t maxNumberReportsPerCycle,
Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid,
uint8_t serviceId, size_t maxNumberReportsPerCycle,
uint32_t messageQueueDepth)
: PusServiceBase(params),
storeHelper(params.apid),
tmHelper(params.serviceId, storeHelper, sendHelper),
: PusServiceBase(objectId, apid, serviceId),
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
}
@ -46,9 +45,15 @@ ReturnValue_t Service5EventReporting::performService() {
ReturnValue_t Service5EventReporting::generateEventReport(EventMessage message) {
EventReport report(message.getEventId(), message.getReporter(), message.getParameter1(),
message.getParameter2());
storeHelper.preparePacket(psbParams.serviceId, message.getSeverity(), tmHelper.sendCounter);
storeHelper.setSourceDataSerializable(report);
ReturnValue_t result = tmHelper.storeAndSendTmPacket();
#if FSFW_USE_PUS_C_TELEMETRY == 0
TmPacketStoredPusA tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
message.getSeverity(), packetSubCounter++, &report);
#else
TmPacketStoredPusC tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
message.getSeverity(), packetSubCounter++, &report);
#endif
ReturnValue_t result =
tmPacket.sendPacket(requestQueue->getDefaultDestination(), requestQueue->getId());
if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Service5EventReporting::generateEventReport: "
@ -81,19 +86,14 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) {
// In addition to the default PUSServiceBase initialization, this service needs
// to be registered to the event manager to listen for events.
ReturnValue_t Service5EventReporting::initialize() {
ReturnValue_t result = PusServiceBase::initialize();
if (result != returnvalue::OK) {
return result;
}
auto* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
if (manager == nullptr) {
return returnvalue::FAILED;
}
// register Service 5 as listener for events
result = manager->registerListener(eventQueue->getId(), true);
ReturnValue_t result = manager->registerListener(eventQueue->getId(), true);
if (result != returnvalue::OK) {
return result;
}
initializeTmHelpers(sendHelper, storeHelper);
return result;
return PusServiceBase::initialize();
}

View File

@ -3,7 +3,6 @@
#include "fsfw/events/EventMessage.h"
#include "fsfw/tmtcservices/PusServiceBase.h"
#include "fsfw/tmtcservices/TmStoreAndSendHelper.h"
/**
* @brief Report on-board events like information or errors
@ -41,9 +40,9 @@
*/
class Service5EventReporting : public PusServiceBase {
public:
Service5EventReporting(PsbParams params, size_t maxNumberReportsPerCycle = 10,
uint32_t messageQueueDepth = 10);
~Service5EventReporting() override;
Service5EventReporting(object_id_t objectId, uint16_t apid, uint8_t serviceId,
size_t maxNumberReportsPerCycle = 10, uint32_t messageQueueDepth = 10);
virtual ~Service5EventReporting();
/***
* Check for events and generate event reports if required.
@ -75,11 +74,9 @@ class Service5EventReporting : public PusServiceBase {
};
private:
uint16_t packetSubCounter = 0;
MessageQueueIF* eventQueue = nullptr;
bool enableEventReport = true;
TmSendHelper sendHelper;
TmStoreHelper storeHelper;
TmStoreAndSendWrapper tmHelper;
const uint8_t maxNumberReportsPerCycle;
ReturnValue_t generateEventReport(EventMessage message);

View File

@ -78,7 +78,7 @@ ReturnValue_t Service8FunctionManagement::prepareDirectCommand(CommandMessage* m
// store additional parameters into the IPC Store
store_address_t parameterAddress;
ReturnValue_t result =
ipcStore->addData(&parameterAddress, command.getParameters(), command.getParametersSize());
IPCStore->addData(&parameterAddress, command.getParameters(), command.getParametersSize());
// setCommand expects a Command Message, an Action ID and a store adress
// pointing to additional parameters
@ -130,7 +130,7 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage*
store_address_t storeId = ActionMessage::getStoreId(reply);
size_t size = 0;
const uint8_t* buffer = nullptr;
ReturnValue_t result = ipcStore->getData(storeId, &buffer, &size);
ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size);
if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service 8: Could not retrieve data for data reply" << std::endl;
@ -138,9 +138,9 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage*
return result;
}
DataReply dataReply(objectId, actionId, buffer, size);
result = sendTmPacket(static_cast<uint8_t>(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply);
result = sendTmPacket(static_cast<uint8_t>(Subservice::REPLY_DIRECT_COMMANDING_DATA), &dataReply);
auto deletionResult = ipcStore->deleteData(storeId);
auto deletionResult = IPCStore->deleteData(storeId);
if (deletionResult != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Service8FunctionManagement::handleReply: Deletion"

View File

@ -32,7 +32,7 @@ class Service8FunctionManagement : public CommandingServiceBase {
public:
Service8FunctionManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId,
uint8_t numParallelCommands = 4, uint16_t commandTimeoutSeconds = 60);
~Service8FunctionManagement() override;
virtual ~Service8FunctionManagement();
protected:
/* CSB abstract functions implementation . See CSB documentation. */

View File

@ -5,9 +5,11 @@
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/timemanager/CCSDSTime.h"
Service9TimeManagement::Service9TimeManagement(PsbParams params) : PusServiceBase(params) {}
Service9TimeManagement::Service9TimeManagement(object_id_t objectId, uint16_t apid,
uint8_t serviceId)
: PusServiceBase(objectId, apid, serviceId) {}
Service9TimeManagement::~Service9TimeManagement() = default;
Service9TimeManagement::~Service9TimeManagement() {}
ReturnValue_t Service9TimeManagement::performService() { return returnvalue::OK; }
@ -23,7 +25,7 @@ ReturnValue_t Service9TimeManagement::handleRequest(uint8_t subservice) {
ReturnValue_t Service9TimeManagement::setTime() {
Clock::TimeOfDay_t timeToSet;
TimePacket timePacket(currentPacket.getUserData(), currentPacket.getUserDataLen());
TimePacket timePacket(currentPacket.getApplicationData(), currentPacket.getApplicationDataSize());
ReturnValue_t result =
CCSDSTime::convertFromCcsds(&timeToSet, timePacket.getTime(), timePacket.getTimeSize());
if (result != returnvalue::OK) {

View File

@ -16,16 +16,16 @@ class Service9TimeManagement : public PusServiceBase {
/**
* @brief This service provides the capability to set the on-board time.
*/
explicit Service9TimeManagement(PsbParams params);
Service9TimeManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId);
~Service9TimeManagement() override;
virtual ~Service9TimeManagement();
ReturnValue_t performService() override;
virtual ReturnValue_t performService() override;
/**
* @brief Sets the onboard-time by retrieving the time to set from TC[9,128].
*/
ReturnValue_t handleRequest(uint8_t subservice) override;
virtual ReturnValue_t handleRequest(uint8_t subservice) override;
virtual ReturnValue_t setTime();

View File

@ -50,7 +50,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6
if (result != returnvalue::OK) {
return result;
}
if (failureSubtype == tcverif::PROGRESS_FAILURE) {
if (failureSubtype == tc_verification::PROGRESS_FAILURE) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) {
return result;
@ -73,7 +73,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6
size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl);
if (failureSubtype == tcverif::PROGRESS_FAILURE) {
if (failureSubtype == tc_verification::PROGRESS_FAILURE) {
size += SerializeAdapter::getSerializedSize(&stepNumber);
}
size += SerializeAdapter::getSerializedSize(&errorCode);
@ -130,7 +130,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5
if (result != returnvalue::OK) {
return result;
}
if (subtype == tcverif::PROGRESS_SUCCESS) {
if (subtype == tc_verification::PROGRESS_SUCCESS) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness);
if (result != returnvalue::OK) {
return result;
@ -143,7 +143,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5
size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl);
if (subtype == tcverif::PROGRESS_SUCCESS) {
if (subtype == tc_verification::PROGRESS_SUCCESS) {
size += SerializeAdapter::getSerializedSize(&stepNumber);
}
return size;

View File

@ -1,7 +1,7 @@
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_
#define FSFW_PUS_SERVICEPACKETS_SERVICE9PACKETS_H_
#include "fsfw/serialize/SerialLinkedListAdapter.h"
#include "../../serialize/SerialLinkedListAdapter.h"
/**
* @brief Subservice 128
@ -11,16 +11,16 @@
*/
class TimePacket : SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 128
public:
TimePacket(const TimePacket& command) = delete;
TimePacket(const uint8_t* timeBuffer_, uint32_t timeSize_) {
timeBuffer = timeBuffer_;
timeSize = timeSize_;
}
const uint8_t* getTime() { return timeBuffer; }
[[nodiscard]] uint32_t getTimeSize() const { return timeSize; }
uint32_t getTimeSize() const { return timeSize; }
private:
TimePacket(const TimePacket& command);
const uint8_t* timeBuffer;
uint32_t timeSize; //!< [EXPORT] : [IGNORE]
};

View File

@ -34,10 +34,9 @@ enum : uint8_t {
FIFO_CLASS, // FF
MESSAGE_PROXY, // MQP
TRIPLE_REDUNDACY_CHECK, // TRC
PACKET_CHECK, // TCC
TC_PACKET_CHECK, // TCC
PACKET_DISTRIBUTION, // TCD
ACCEPTS_TELECOMMANDS_IF, // ATC
PUS_IF, // PUS
ACCEPTS_TELECOMMANDS_IF, // PUS
DEVICE_SERVICE_BASE, // DSB
COMMAND_SERVICE_BASE, // CSB
TM_STORE_BACKEND_IF, // TMB

View File

@ -1,8 +0,0 @@
#ifndef FSFW_RETURNVALUES_HASRETURNVALUES_IF_H_
#define FSFW_RETURNVALUES_HASRETURNVALUES_IF_H_
#warning "This header is deprecated, please include returnvalue.h"
#include "returnvalue.h"
#endif /* FSFW_RETURNVALUES_HASRETURNVALUES_IF_H_ */

View File

@ -1,6 +1,8 @@
#ifndef FSFW_RETURNVALUES_RETURNVALUE_H_
#define FSFW_RETURNVALUES_RETURNVALUE_H_
#include <returnvalues/classIds.h>
#include <cstdint>
#include "FwClassIds.h"

View File

@ -1,6 +0,0 @@
#ifndef FSFW_RETVAL_H
#define FSFW_RETVAL_H
#include "fsfw/returnvalues/returnvalue.h"
#endif // FSFW_RETVAL_H

View File

@ -1,10 +1,10 @@
#ifndef FSFW_SERIALIZE_H_
#define FSFW_SERIALIZE_H_
#ifndef FSFW_INC_FSFW_SERIALIZE_H_
#define FSFW_INC_FSFW_SERIALIZE_H_
#include "serialize/EndianConverter.h"
#include "serialize/SerialArrayListAdapter.h"
#include "serialize/SerialBufferAdapter.h"
#include "serialize/SerialLinkedListAdapter.h"
#include "serialize/SerializeElement.h"
#include "fsfw/serialize/EndianConverter.h"
#include "fsfw/serialize/SerialArrayListAdapter.h"
#include "fsfw/serialize/SerialBufferAdapter.h"
#include "fsfw/serialize/SerialLinkedListAdapter.h"
#include "fsfw/serialize/SerializeElement.h"
#endif /* FSFW_SERIALIZE_H_ */
#endif /* FSFW_INC_FSFW_SERIALIZE_H_ */

View File

@ -21,7 +21,7 @@ SerialBufferAdapter<count_t>::SerialBufferAdapter(uint8_t* buffer, count_t buffe
bufferLength(bufferLength) {}
template <typename count_t>
SerialBufferAdapter<count_t>::~SerialBufferAdapter() = default;
SerialBufferAdapter<count_t>::~SerialBufferAdapter() {}
template <typename count_t>
ReturnValue_t SerialBufferAdapter<count_t>::serialize(uint8_t** buffer, size_t* size,
@ -119,10 +119,10 @@ const uint8_t* SerialBufferAdapter<count_t>::getConstBuffer() const {
}
template <typename count_t>
void SerialBufferAdapter<count_t>::setConstBuffer(const uint8_t* buf, count_t bufLen) {
this->buffer = nullptr;
this->bufferLength = bufLen;
this->constBuffer = buf;
void SerialBufferAdapter<count_t>::setBuffer(uint8_t* buffer, count_t bufferLength) {
this->buffer = buffer;
this->constBuffer = buffer;
this->bufferLength = bufferLength;
}
// forward Template declaration for linker

View File

@ -21,7 +21,6 @@
template <typename count_t>
class SerialBufferAdapter : public SerializeIF {
public:
SerialBufferAdapter() = default;
/**
* Constructor for constant uint8_t buffer. Length field can be serialized optionally.
* Type of length can be supplied as template type.
@ -41,12 +40,12 @@ class SerialBufferAdapter : public SerializeIF {
*/
SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false);
~SerialBufferAdapter() override;
virtual ~SerialBufferAdapter();
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
[[nodiscard]] size_t getSerializedSize() const override;
virtual size_t getSerializedSize() const override;
/**
* @brief This function deserializes a buffer into the member buffer.
@ -60,12 +59,12 @@ class SerialBufferAdapter : public SerializeIF {
* @param bigEndian
* @return
*/
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
uint8_t* getBuffer();
[[nodiscard]] const uint8_t* getConstBuffer() const;
void setConstBuffer(const uint8_t* buf, count_t bufLen);
const uint8_t* getConstBuffer() const;
void setBuffer(uint8_t* buffer, count_t bufferLength);
private:
bool serializeLength = false;

View File

@ -74,7 +74,7 @@ class SerializeAdapter {
return returnvalue::FAILED;
}
InternalSerializeAdapter<T, std::is_base_of<SerializeIF, T>::value> adapter;
auto **tempPtr = const_cast<uint8_t **>(&buffer);
uint8_t **tempPtr = const_cast<uint8_t **>(&buffer);
size_t tmpSize = 0;
ReturnValue_t result = adapter.serialize(object, tempPtr, &tmpSize, maxSize, streamEndianness);
if (serSize != nullptr) {
@ -232,7 +232,7 @@ class SerializeAdapter {
}
}
uint32_t getSerializedSize(const T *) { return sizeof(T); }
uint32_t getSerializedSize(const T *object) { return sizeof(T); }
};
/**

View File

@ -1,8 +1,8 @@
#include "ServiceInterfaceBuffer.h"
#include "fsfw/serviceinterface/ServiceInterfaceBuffer.h"
#if FSFW_CPP_OSTREAM_ENABLED == 1
#include <cinttypes>
#include <inttypes.h>
#include <cstring>
@ -16,6 +16,8 @@
// to be implemented by bsp
extern "C" void printChar(const char*, bool errStream);
#ifndef UT699
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addCrToPreamble,
bool buffered, bool errStream, uint16_t port)
: isActive(true),
@ -56,9 +58,6 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addC
}
void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
if (not isActive) {
return;
}
char array[BUF_SIZE];
uint32_t length = end - begin;
if (length > sizeof(array)) {
@ -75,6 +74,8 @@ void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
}
}
#endif
int ServiceInterfaceBuffer::overflow(int c) {
if (not buffered and this->isActive) {
if (c != Traits::eof()) {
@ -168,4 +169,89 @@ void ServiceInterfaceBuffer::setAsciiColorPrefix(std::string colorPrefix) {
}
#endif
#endif
#ifdef UT699
#include "../osal/rtems/Interrupt.h"
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) {
this->log_message = set_message;
this->isActive = true;
setp(buf, buf + BUF_SIZE);
}
void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
char array[BUF_SIZE];
uint32_t length = end - begin;
if (length > sizeof(array)) {
length = sizeof(array);
}
memcpy(array, begin, length);
if (!Interrupt::isInterruptInProgress()) {
std::cout << array;
} else {
// Uncomment the following line if you need ISR debug output.
// printk(array);
}
}
#endif // UT699
#ifdef ML505
#include <bsp_flp/network/networkconfig.h>
ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port)
: isActive(true),
log_message(set_message),
udpSocket(0),
remoteAddressLength(sizeof(remoteAddress)) {
setp(buf, buf + BUF_SIZE);
memset((uint8_t*)&remoteAddress, 0, sizeof(remoteAddress));
remoteAddress.sin_family = AF_INET;
remoteAddress.sin_port = htons(port);
remoteAddress.sin_addr.s_addr = htonl(inet_addr("192.168.250.100"));
}
void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) {
char array[BUF_SIZE];
uint32_t length = end - begin;
if (length > sizeof(array)) {
length = sizeof(array);
}
memcpy(array, begin, length);
if (udpSocket <= 0) {
initSocket();
}
if (udpSocket > 0) {
sendto(udpSocket, array, length, 0, (sockaddr*)&remoteAddress, sizeof(remoteAddress));
}
}
void ServiceInterfaceBuffer::initSocket() {
sockaddr_in address;
memset((uint8_t*)&address, 0, sizeof(address));
address.sin_family = AF_INET;
address.sin_port = htons(0);
address.sin_addr.s_addr = htonl(INADDR_ANY);
udpSocket = socket(PF_INET, SOCK_DGRAM, 0);
if (socket < 0) {
printf("Error opening socket!\n");
return;
}
timeval timeout = {0, 20};
if (setsockopt(udpSocket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) {
printf("Error setting SO_RCVTIMEO socket options!\n");
return;
}
if (setsockopt(udpSocket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) {
printf("Error setting SO_SNDTIMEO socket options!\n");
return;
}
if (bind(udpSocket, (sockaddr*)&address, sizeof(address)) < 0) {
printf("Error binding socket!\n");
}
}
#endif // ML505
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */

View File

@ -1,8 +1,9 @@
#ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_
#define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_
#include "fsfw/FSFW.h"
#include "fsfw/returnvalues/returnvalue.h"
#include <FSFWConfig.h>
#include "../returnvalues/returnvalue.h"
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -10,6 +11,8 @@
#include <iostream>
#include <sstream>
#ifndef UT699
/**
* @brief This is the underlying stream buffer which implements the
* streambuf class and overloads the overflow() and sync() methods
@ -74,6 +77,85 @@ class ServiceInterfaceBuffer : public std::streambuf {
bool crAdditionEnabled() const;
};
#endif
#ifdef UT699
class ServiceInterfaceBuffer : public std::basic_streambuf<char, std::char_traits<char> > {
friend class ServiceInterfaceStream;
public:
ServiceInterfaceBuffer(std::string set_message, uint16_t port);
protected:
bool isActive;
// This is called when buffer becomes full. If
// buffer is not used, then this is called every
// time when characters are put to stream.
virtual int overflow(int c = Traits::eof());
// This function is called when stream is flushed,
// for example when std::endl is put to stream.
virtual int sync(void);
private:
// For additional message information
std::string log_message;
// For EOF detection
typedef std::char_traits<char> Traits;
// Work in buffer mode. It is also possible to work without buffer.
static size_t const BUF_SIZE = 128;
char buf[BUF_SIZE];
// In this function, the characters are parsed.
void putChars(char const* begin, char const* end);
};
#endif // UT699
#ifdef ML505
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/udp.h>
#include <sys/socket.h>
#include <sys/types.h>
class ServiceInterfaceBuffer : public std::basic_streambuf<char, std::char_traits<char> > {
friend class ServiceInterfaceStream;
public:
ServiceInterfaceBuffer(std::string set_message, uint16_t port);
protected:
bool isActive;
// This is called when buffer becomes full. If
// buffer is not used, then this is called every
// time when characters are put to stream.
virtual int overflow(int c = Traits::eof());
// This function is called when stream is flushed,
// for example when std::endl is put to stream.
virtual int sync(void);
private:
// For additional message information
std::string log_message;
// For EOF detection
typedef std::char_traits<char> Traits;
// Work in buffer mode. It is also possible to work without buffer.
static size_t const BUF_SIZE = 128;
char buf[BUF_SIZE];
// In this function, the characters are parsed.
void putChars(char const* begin, char const* end);
int udpSocket;
sockaddr_in remoteAddress;
socklen_t remoteAddressLength;
void initSocket();
};
#endif // ML505
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ */

View File

@ -1,8 +1,9 @@
#ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_
#define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACESTREAM_H_
#include <FSFWConfig.h>
#include "ServiceInterfaceBuffer.h"
#include "fsfw/FSFW.h"
#if FSFW_CPP_OSTREAM_ENABLED == 1

View File

@ -194,6 +194,8 @@ void LocalPool::clearStore() {
for (auto& size : sizeList) {
size = STORAGE_FREE;
}
// std::memset(sizeList[index], 0xff,
// numberOfElements[index] * sizeof(size_type));
}
}
@ -336,16 +338,3 @@ void LocalPool::clearSubPool(max_subpools_t subpoolIndex) {
}
LocalPool::max_subpools_t LocalPool::getNumberOfSubPools() const { return NUMBER_OF_SUBPOOLS; }
bool LocalPool::hasDataAtId(store_address_t storeId) const {
if (storeId.poolIndex >= NUMBER_OF_SUBPOOLS) {
return false;
}
if ((storeId.packetIndex >= numberOfElements[storeId.poolIndex])) {
return false;
}
if (sizeLists[storeId.poolIndex][storeId.packetIndex] != STORAGE_FREE) {
return true;
}
return false;
}

View File

@ -81,7 +81,7 @@ class LocalPool : public SystemObject, public StorageManagerIF {
/**
* @brief In the LocalPool's destructor all allocated memory is freed.
*/
~LocalPool() override;
virtual ~LocalPool(void);
/**
* Documentation: See StorageManagerIF.h
@ -132,7 +132,6 @@ class LocalPool : public SystemObject, public StorageManagerIF {
* @return
*/
max_subpools_t getNumberOfSubPools() const override;
bool hasDataAtId(store_address_t storeId) const override;
protected:
/**

View File

@ -7,7 +7,7 @@ PoolManager::PoolManager(object_id_t setObjectId, const LocalPoolConfig& localPo
mutex = MutexFactory::instance()->createMutex();
}
PoolManager::~PoolManager() { MutexFactory::instance()->deleteMutex(mutex); }
PoolManager::~PoolManager(void) { MutexFactory::instance()->deleteMutex(mutex); }
ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* address,
bool ignoreFault) {
@ -17,7 +17,7 @@ ReturnValue_t PoolManager::reserveSpace(const size_t size, store_address_t* addr
}
ReturnValue_t PoolManager::deleteData(store_address_t storeId) {
#if FSFW_VERBOSE_LEVEL >= 2 && FSFW_OBJ_EVENT_TRANSLATION == 1
#if FSFW_VERBOSE_LEVEL >= 2
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PoolManager( " << translateObject(getObjectId()) << " )::deleteData from store "
<< storeId.poolIndex << ". id is " << storeId.packetIndex << std::endl;

View File

@ -55,7 +55,7 @@ class StorageManagerIF {
/**
* @brief This is the empty virtual destructor as required for C++ interfaces.
*/
~StorageManagerIF() = default;
virtual ~StorageManagerIF(){};
/**
* @brief With addData, a free storage position is allocated and data
* stored there.
@ -63,8 +63,9 @@ class StorageManagerIF {
* @param storageId A pointer to the storageId to retrieve.
* @param data The data to be stored in the StorageManager.
* @param size The amount of data to be stored.
* @return Returns @returnvalue::OK if data was added.
* @returnvalue::FAILED if data could not be added, storageId is unchanged then.
* @return Returns @li returnvalue::OK if data was added.
* @li returnvalue::FAILED if data could not be added.
* storageId is unchanged then.
*/
virtual ReturnValue_t addData(store_address_t* storageId, const uint8_t* data, size_t size,
bool ignoreFault = false) = 0;
@ -115,8 +116,8 @@ class StorageManagerIF {
* @param packet_ptr The passed pointer address is set to the the memory
* position
* @param size The exact size of the stored data is returned here.
* @return @returnvalue::OK on success.
* @returnvalue::FAILED if fetching data did not work
* @return @li returnvalue::OK on success.
* @li returnvalue::FAILED if fetching data did not work
* (e.g. an illegal packet_id was passed).
*/
virtual ReturnValue_t getData(store_address_t packet_id, const uint8_t** packet_ptr,
@ -156,12 +157,11 @@ class StorageManagerIF {
* @param size The size of the space to be reserved.
* @param p_data A pointer to the element data is returned here.
* @return Returns @li returnvalue::OK if data was added.
* @returnvalue::FAILED if data could not be added, storageId is unchanged then.
* @li returnvalue::FAILED if data could not be added.
* storageId is unchanged then.
*/
virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** p_data,
bool ignoreFault = false) = 0;
[[nodiscard]] virtual bool hasDataAtId(store_address_t storeId) const = 0;
virtual ReturnValue_t getFreeElement(store_address_t* storageId, const size_t size,
uint8_t** p_data, bool ignoreFault = false) = 0;
/**
* Clears the whole store.
@ -192,7 +192,7 @@ class StorageManagerIF {
* Get number of pools.
* @return
*/
[[nodiscard]] virtual max_subpools_t getNumberOfSubPools() const = 0;
virtual max_subpools_t getNumberOfSubPools() const = 0;
};
#endif /* FSFW_STORAGEMANAGER_STORAGEMANAGERIF_H_ */

View File

@ -3,26 +3,26 @@
#include <cstdint>
namespace storeId {
static constexpr uint32_t INVALID_STORE_ADDRESS = 0xffffffff;
}
/**
* This union defines the type that identifies where a data packet is
* stored in the store. It comprises of a raw part to read it as raw value and
* a structured part to use it in pool-like stores.
*/
union store_address_t {
public:
static constexpr uint32_t INVALID_RAW = 0xffffffff;
/**
* Default Constructor, initializing to INVALID_ADDRESS
*/
store_address_t() : raw(INVALID_RAW) {}
store_address_t() : raw(storeId::INVALID_STORE_ADDRESS) {}
/**
* Constructor to create an address object using the raw address
*
* @param rawAddress
*/
explicit store_address_t(uint32_t rawAddress) : raw(rawAddress) {}
static store_address_t invalid() { return {}; };
store_address_t(uint32_t rawAddress) : raw(rawAddress) {}
/**
* Constructor to create an address object using pool
@ -52,12 +52,6 @@ union store_address_t {
uint32_t raw;
bool operator==(const store_address_t& other) const { return raw == other.raw; }
bool operator!=(const store_address_t& other) const { return raw != other.raw; }
store_address_t& operator=(const uint32_t rawAddr) {
raw = rawAddr;
return *this;
}
};
#endif /* FSFW_STORAGEMANAGER_STOREADDRESS_H_ */

View File

@ -2,13 +2,12 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
#include "fsfw/tmtcpacket/SpacePacketBase.h"
#define CCSDS_DISTRIBUTOR_DEBUGGING 0
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId,
CcsdsPacketCheckIF* packetChecker)
: TcDistributor(setObjectId), defaultApid(setDefaultApid), packetChecker(packetChecker) {}
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId)
: TcDistributor(setObjectId), defaultApid(setDefaultApid) {}
CCSDSDistributor::~CCSDSDistributor() = default;
@ -26,7 +25,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
#endif
const uint8_t* packet = nullptr;
size_t size = 0;
ReturnValue_t result = tcStore->getData(currentMessage.getStorageId(), &packet, &size);
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size);
if (result != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -41,21 +40,19 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
#endif
return queueMap.end();
}
SpacePacketReader currentPacket(packet, size);
result = packetChecker->checkPacket(currentPacket, size);
if (result != returnvalue::OK) {
}
SpacePacketBase currentPacket(packet);
#if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1
sif::info << "CCSDSDistributor::selectDestination has packet with APID 0x" << std::hex
<< currentPacket.getApid() << std::dec << std::endl;
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex
<< currentPacket.getAPID() << std::dec << std::endl;
#endif
auto position = this->queueMap.find(currentPacket.getApid());
auto position = this->queueMap.find(currentPacket.getAPID());
if (position != this->queueMap.end()) {
return position;
} else {
// The APID was not found. Forward packet to main SW-APID anyway to
// create acceptance failure report.
return queueMap.find(this->defaultApid);
return this->queueMap.find(this->defaultApid);
}
}
@ -83,9 +80,6 @@ ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid, MessageQueueI
uint16_t CCSDSDistributor::getIdentifier() { return 0; }
ReturnValue_t CCSDSDistributor::initialize() {
if (packetChecker == nullptr) {
packetChecker = new CcsdsPacketChecker(ccsds::PacketType::TC);
}
ReturnValue_t status = this->TcDistributor::initialize();
this->tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (this->tcStore == nullptr) {

View File

@ -1,12 +1,11 @@
#ifndef FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_
#define FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
#include "fsfw/tcdistribution/CcsdsPacketChecker.h"
#include "fsfw/tcdistribution/TcDistributor.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "../objectmanager/ObjectManagerIF.h"
#include "../storagemanager/StorageManagerIF.h"
#include "../tcdistribution/CCSDSDistributorIF.h"
#include "../tcdistribution/TcDistributor.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h"
/**
* @brief An instantiation of the CCSDSDistributorIF.
@ -25,15 +24,14 @@ class CCSDSDistributor : public TcDistributor,
* TcDistributor ctor with a certain object id.
* @details
* @c tcStore is set in the @c initialize method.
* @param unknownApid The default APID, where packets with unknown
* @param setDefaultApid The default APID, where packets with unknown
* destination are sent to.
*/
CCSDSDistributor(uint16_t unknownApid, object_id_t setObjectId,
CcsdsPacketCheckIF* packetChecker = nullptr);
CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId);
/**
* The destructor is empty.
*/
~CCSDSDistributor() override;
virtual ~CCSDSDistributor();
MessageQueueId_t getRequestQueue() override;
ReturnValue_t registerApplication(uint16_t apid, MessageQueueId_t id) override;
@ -65,8 +63,6 @@ class CCSDSDistributor : public TcDistributor,
* pure Space Packets and there exists no SpacePacketStored class.
*/
StorageManagerIF* tcStore = nullptr;
CcsdsPacketCheckIF* packetChecker = nullptr;
};
#endif /* FRAMEWORK_TCDISTRIBUTION_CCSDSDISTRIBUTOR_H_ */

View File

@ -34,7 +34,7 @@ class CCSDSDistributorIF {
/**
* The empty virtual destructor.
*/
virtual ~CCSDSDistributorIF() = default;
virtual ~CCSDSDistributorIF() {}
};
#endif /* FSFW_TCDISTRIBUTION_CCSDSDISTRIBUTORIF_H_ */

View File

@ -2,7 +2,7 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
#include "fsfw/tmtcpacket/cfdp/CfdpPacketStored.h"
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
#ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING
#define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1
@ -16,7 +16,7 @@ CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
tcStatus(returnvalue::FAILED),
packetSource(setPacketSource) {}
CFDPDistributor::~CFDPDistributor() = default;
CFDPDistributor::~CFDPDistributor() {}
CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
@ -29,13 +29,13 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
storeId.packetIndex);
#endif
#endif
auto queueMapIt = this->queueMap.end();
TcMqMapIter queueMapIt = this->queueMap.end();
if (this->currentPacket == nullptr) {
return queueMapIt;
}
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
if (currentPacket->getFullData() != nullptr) {
tcStatus = checker.checkPacket(*currentPacket, currentPacket->getFullPacketLen());
if (currentPacket->getWholeData() != nullptr) {
tcStatus = checker.checkPacket(currentPacket);
if (tcStatus != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
@ -72,7 +72,7 @@ CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) {
uint16_t handlerId =
handler->getIdentifier(); // should be 0, because CfdpHandler does not set a set a service-ID
handler->getIdentifier(); // should be 0, because CFDPHandler does not set a set a service-ID
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast<int>(handlerId)
@ -121,13 +121,14 @@ MessageQueueId_t CFDPDistributor::getRequestQueue() { return tcQueue->getId(); }
uint16_t CFDPDistributor::getIdentifier() { return this->apid; }
ReturnValue_t CFDPDistributor::initialize() {
currentPacket = new CfdpPacketStored();
currentPacket = new CFDPPacketStored();
if (currentPacket == nullptr) {
// Should not happen, memory allocation failed!
return ObjectManagerIF::CHILD_INIT_FAILED;
}
auto* ccsdsDistributor = ObjectManager::instance()->get<CCSDSDistributorIF>(packetSource);
CCSDSDistributorIF* ccsdsDistributor =
ObjectManager::instance()->get<CCSDSDistributorIF>(packetSource);
if (ccsdsDistributor == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl;

View File

@ -1,10 +1,10 @@
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
#include <fsfw/tcdistribution/CfdpPacketChecker.h>
#include <fsfw/tcdistribution/TcPacketCheckCFDP.h>
#include "../returnvalues/returnvalue.h"
#include "../tmtcpacket/cfdp/CfdpPacketStored.h"
#include "../tmtcpacket/cfdp/CFDPPacketStored.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h"
#include "../tmtcservices/VerificationReporter.h"
#include "CFDPDistributorIF.h"
@ -31,7 +31,7 @@ class CFDPDistributor : public TcDistributor,
/**
* The destructor is empty.
*/
~CFDPDistributor() override;
virtual ~CFDPDistributor();
ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override;
MessageQueueId_t getRequestQueue() override;
ReturnValue_t initialize() override;
@ -42,8 +42,8 @@ class CFDPDistributor : public TcDistributor,
/**
* The currently handled packet is stored here.
*/
CfdpPacketStored* currentPacket = nullptr;
CfdpPacketChecker checker;
CFDPPacketStored* currentPacket = nullptr;
TcPacketCheckCFDP checker;
/**
* With this variable, the current check status is stored to generate
* acceptance messages later.

View File

@ -13,7 +13,7 @@ class CFDPDistributorIF {
/**
* The empty virtual destructor.
*/
virtual ~CFDPDistributorIF() = default;
virtual ~CFDPDistributorIF() {}
/**
* With this method, Handlers can register themselves at the CFDP Distributor.
* @param handler A pointer to the registering Handler.

View File

@ -1,9 +1,4 @@
target_sources(
${LIB_FSFW_NAME}
PRIVATE CCSDSDistributor.cpp
PusDistributor.cpp
TcDistributor.cpp
PusPacketChecker.cpp
TcPacketCheckCFDP.cpp
CFDPDistributor.cpp
CcsdsPacketChecker.cpp)
PRIVATE CCSDSDistributor.cpp PUSDistributor.cpp TcDistributor.cpp
TcPacketCheckPUS.cpp TcPacketCheckCFDP.cpp CFDPDistributor.cpp)

View File

@ -1,33 +0,0 @@
#include "CcsdsPacketChecker.h"
#include "fsfw/tcdistribution/definitions.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
CcsdsPacketChecker::CcsdsPacketChecker(ccsds::PacketType packetType_, uint8_t ccsdsVersion_)
: packetType(packetType_), ccsdsVersion(ccsdsVersion_) {}
ReturnValue_t CcsdsPacketChecker::checkPacket(const SpacePacketReader& currentPacket,
size_t packetLen) {
if (checkApid) {
if (currentPacket.getApid() != apid) {
return tcdistrib::INVALID_APID;
}
}
if (currentPacket.getVersion() != ccsdsVersion) {
return tcdistrib::INVALID_CCSDS_VERSION;
}
if (currentPacket.getPacketType() != packetType) {
return tcdistrib::INVALID_PACKET_TYPE;
}
// This assumes that the getFullPacketLen version uses the space packet data length field
if (currentPacket.getFullPacketLen() != packetLen) {
return tcdistrib::INCOMPLETE_PACKET;
}
return returnvalue::OK;
}
void CcsdsPacketChecker::setApidToCheck(uint16_t apid_) {
apid = apid_;
checkApid = true;
}

View File

@ -1,20 +0,0 @@
#ifndef FSFW_TESTS_CCSDSPACKETCHECKERBASE_H
#define FSFW_TESTS_CCSDSPACKETCHECKERBASE_H
#include "CcsdsPacketCheckIF.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketIF.h"
class CcsdsPacketChecker : public CcsdsPacketCheckIF {
public:
CcsdsPacketChecker(ccsds::PacketType packetType, uint8_t ccsdsVersion = 0b000);
void setApidToCheck(uint16_t apid);
ReturnValue_t checkPacket(const SpacePacketReader& currentPacket, size_t packetLen) override;
protected:
bool checkApid = false;
uint16_t apid = 0;
ccsds::PacketType packetType;
uint8_t ccsdsVersion;
};
#endif // FSFW_TESTS_CCSDSPACKETCHECKERBASE_H

View File

@ -0,0 +1,146 @@
#include "fsfw/tcdistribution/PUSDistributor.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
#include "fsfw/tmtcservices/PusVerificationReport.h"
#define PUS_DISTRIBUTOR_DEBUGGING 0
PUSDistributor::PUSDistributor(uint16_t setApid, object_id_t setObjectId,
object_id_t setPacketSource)
: TcDistributor(setObjectId),
checker(setApid),
verifyChannel(),
tcStatus(returnvalue::FAILED),
packetSource(setPacketSource) {}
PUSDistributor::~PUSDistributor() = default;
PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
#if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1
store_address_t storeId = this->currentMessage.getStorageId());
sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", "
<< storeId.packetIndex << std::endl;
#endif
auto queueMapIt = this->queueMap.end();
if (this->currentPacket == nullptr) {
return queueMapIt;
}
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket);
if (currentPacket->getWholeData() != nullptr) {
tcStatus = checker.checkPacket(currentPacket);
if (tcStatus != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1
const char* keyword = "unnamed error";
if (tcStatus == TcPacketCheckPUS::INCORRECT_CHECKSUM) {
keyword = "checksum";
} else if (tcStatus == TcPacketCheckPUS::INCORRECT_PRIMARY_HEADER) {
keyword = "incorrect primary header";
} else if (tcStatus == TcPacketCheckPUS::ILLEGAL_APID) {
keyword = "illegal APID";
} else if (tcStatus == TcPacketCheckPUS::INCORRECT_SECONDARY_HEADER) {
keyword = "incorrect secondary header";
} else if (tcStatus == TcPacketCheckPUS::INCOMPLETE_PACKET) {
keyword = "incomplete packet";
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword
<< " error" << std::endl;
#else
sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n",
keyword);
#endif
#endif
}
uint32_t queue_id = currentPacket->getService();
queueMapIt = this->queueMap.find(queue_id);
} else {
tcStatus = PACKET_LOST;
}
if (queueMapIt == this->queueMap.end()) {
tcStatus = DESTINATION_NOT_FOUND;
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl;
#else
sif::printDebug("PUSDistributor::handlePacket: Destination not found\n");
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif
}
if (tcStatus != returnvalue::OK) {
return this->queueMap.end();
} else {
return queueMapIt;
}
}
ReturnValue_t PUSDistributor::registerService(AcceptsTelecommandsIF* service) {
uint16_t serviceId = service->getIdentifier();
#if PUS_DISTRIBUTOR_DEBUGGING == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Service ID: " << static_cast<int>(serviceId) << std::endl;
#else
sif::printInfo("Service ID: %d\n", static_cast<int>(serviceId));
#endif
#endif
MessageQueueId_t queue = service->getRequestQueue();
auto returnPair = queueMap.emplace(serviceId, queue);
if (not returnPair.second) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PUSDistributor::registerService: Service ID already"
" exists in map"
<< std::endl;
#else
sif::printError("PUSDistributor::registerService: Service ID already exists in map\n");
#endif
#endif
return SERVICE_ID_ALREADY_EXISTS;
}
return returnvalue::OK;
}
MessageQueueId_t PUSDistributor::getRequestQueue() { return tcQueue->getId(); }
ReturnValue_t PUSDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
if (queueStatus != returnvalue::OK) {
tcStatus = queueStatus;
}
if (tcStatus != returnvalue::OK) {
this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, currentPacket,
tcStatus);
// A failed packet is deleted immediately after reporting,
// otherwise it will block memory.
currentPacket->deletePacket();
return returnvalue::FAILED;
} else {
this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, currentPacket);
return returnvalue::OK;
}
}
uint16_t PUSDistributor::getIdentifier() { return checker.getApid(); }
ReturnValue_t PUSDistributor::initialize() {
currentPacket = new TcPacketStoredPus();
if (currentPacket == nullptr) {
// Should not happen, memory allocation failed!
return ObjectManagerIF::CHILD_INIT_FAILED;
}
auto* ccsdsDistributor = ObjectManager::instance()->get<CCSDSDistributorIF>(packetSource);
if (ccsdsDistributor == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl;
sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl;
#else
sif::printError("PUSDistributor::initialize: Packet source invalid\n");
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
#endif
return returnvalue::FAILED;
}
return ccsdsDistributor->registerApplication(this);
}

View File

@ -2,22 +2,20 @@
#define FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_
#include "PUSDistributorIF.h"
#include "PusPacketChecker.h"
#include "TcDistributor.h"
#include "TcPacketCheckPUS.h"
#include "fsfw/returnvalues/returnvalue.h"
#include "fsfw/tmtcpacket/pus/tc.h"
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
#include "fsfw/tmtcservices/VerificationReporter.h"
class CCSDSDistributorIF;
/**
* This class accepts PUS Telecommands and forwards them to Application
* services. In addition, the class performs a formal packet check and
* sends acceptance success or failure messages.
* @ingroup tc_distribution
*/
class PusDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF {
class PUSDistributor : public TcDistributor, public PUSDistributorIF, public AcceptsTelecommandsIF {
public:
/**
* The ctor passes @c set_apid to the checker class and calls the
@ -27,31 +25,30 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
* @param setPacketSource Object ID of the source of TC packets.
* Must implement CCSDSDistributorIF.
*/
PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* packetSource,
StorageManagerIF* store = nullptr);
PUSDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource);
/**
* The destructor is empty.
*/
~PusDistributor() override;
virtual ~PUSDistributor();
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
MessageQueueId_t getRequestQueue() override;
ReturnValue_t initialize() override;
uint16_t getIdentifier() override;
protected:
StorageManagerIF* store;
/**
* This attribute contains the class, that performs a formal packet check.
*/
PusPacketChecker checker;
TcPacketCheckPUS checker;
/**
* With this class, verification messages are sent to the
* TC Verification service.
*/
VerificationReporterIF* verifyChannel = nullptr;
//! Cached for initialization
CCSDSDistributorIF* ccsdsDistributor = nullptr;
PusTcReader reader;
VerificationReporter verifyChannel;
/**
* The currently handled packet is stored here.
*/
TcPacketStoredPus* currentPacket = nullptr;
/**
* With this variable, the current check status is stored to generate
@ -59,6 +56,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
*/
ReturnValue_t tcStatus;
const object_id_t packetSource;
/**
* This method reads the packet service, checks if such a service is
* registered and forwards the packet to the destination.
@ -73,8 +72,6 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc
* success/failure messages.
*/
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
void checkerFailurePrinter() const;
};
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */

View File

@ -1,168 +0,0 @@
#include "fsfw/tcdistribution/PusDistributor.h"
#include "definitions.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
#include "fsfw/tmtcservices/PusVerificationReport.h"
#define PUS_DISTRIBUTOR_DEBUGGING 0
PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId,
CCSDSDistributorIF* distributor, StorageManagerIF* store_)
: TcDistributor(setObjectId),
store(store_),
checker(setApid, ccsds::PacketType::TC),
ccsdsDistributor(distributor),
tcStatus(returnvalue::FAILED) {}
PusDistributor::~PusDistributor() = default;
PusDistributor::TcMqMapIter PusDistributor::selectDestination() {
#if FSFW_CPP_OSTREAM_ENABLED == 1 && PUS_DISTRIBUTOR_DEBUGGING == 1
store_address_t storeId = currentMessage.getStorageId();
sif::debug << "PUSDistributor::handlePacket received: " << storeId.poolIndex << ", "
<< storeId.packetIndex << std::endl;
#endif
auto queueMapIt = queueMap.end();
// TODO: Need to set the data
const uint8_t* packetPtr = nullptr;
size_t packetLen = 0;
if (store->getData(currentMessage.getStorageId(), &packetPtr, &packetLen) != returnvalue::OK) {
return queueMapIt;
}
ReturnValue_t result = reader.setReadOnlyData(packetPtr, packetLen);
if (result != returnvalue::OK) {
tcStatus = PACKET_LOST;
return queueMapIt;
}
// CRC check done by checker
result = reader.parseDataWithoutCrcCheck();
if (result != returnvalue::OK) {
tcStatus = PACKET_LOST;
return queueMapIt;
}
if (reader.getFullData() != nullptr) {
tcStatus = checker.checkPacket(reader, reader.getFullPacketLen());
if (tcStatus != returnvalue::OK) {
checkerFailurePrinter();
}
uint32_t queue_id = reader.getService();
queueMapIt = queueMap.find(queue_id);
} else {
tcStatus = PACKET_LOST;
}
if (queueMapIt == this->queueMap.end()) {
tcStatus = DESTINATION_NOT_FOUND;
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PUSDistributor::handlePacket: Destination not found" << std::endl;
#else
sif::printDebug("PUSDistributor::handlePacket: Destination not found\n");
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif
}
if (tcStatus != returnvalue::OK) {
return this->queueMap.end();
} else {
return queueMapIt;
}
}
ReturnValue_t PusDistributor::registerService(AcceptsTelecommandsIF* service) {
uint16_t serviceId = service->getIdentifier();
#if PUS_DISTRIBUTOR_DEBUGGING == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Service ID: " << static_cast<int>(serviceId) << std::endl;
#else
sif::printInfo("Service ID: %d\n", static_cast<int>(serviceId));
#endif
#endif
MessageQueueId_t queue = service->getRequestQueue();
auto returnPair = queueMap.emplace(serviceId, queue);
if (not returnPair.second) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PUSDistributor::registerService: Service ID already"
" exists in map"
<< std::endl;
#else
sif::printError("PUSDistributor::registerService: Service ID already exists in map\n");
#endif
#endif
return SERVICE_ID_ALREADY_EXISTS;
}
return returnvalue::OK;
}
MessageQueueId_t PusDistributor::getRequestQueue() { return tcQueue->getId(); }
ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
if (queueStatus != returnvalue::OK) {
tcStatus = queueStatus;
}
if (tcStatus != returnvalue::OK) {
verifyChannel->sendFailureReport({tcverif::ACCEPTANCE_FAILURE, reader, tcStatus});
// A failed packet is deleted immediately after reporting,
// otherwise it will block memory.
store->deleteData(currentMessage.getStorageId());
return returnvalue::FAILED;
} else {
verifyChannel->sendSuccessReport({tcverif::ACCEPTANCE_SUCCESS, reader});
return returnvalue::OK;
}
}
uint16_t PusDistributor::getIdentifier() { return checker.getApid(); }
ReturnValue_t PusDistributor::initialize() {
if (store == nullptr) {
store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (store == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
if (ccsdsDistributor == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl;
sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl;
#else
sif::printError("PusDistributor::initialize: Packet source invalid\n");
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
if (verifyChannel == nullptr) {
verifyChannel =
ObjectManager::instance()->get<VerificationReporterIF>(objects::VERIFICATION_REPORTER);
if (verifyChannel == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
return ccsdsDistributor->registerApplication(this);
}
void PusDistributor::checkerFailurePrinter() const {
#if FSFW_VERBOSE_LEVEL >= 1
const char* keyword = "unnamed error";
if (tcStatus == tcdistrib::INCORRECT_CHECKSUM) {
keyword = "checksum";
} else if (tcStatus == tcdistrib::INCORRECT_PRIMARY_HEADER) {
keyword = "incorrect primary header";
} else if (tcStatus == tcdistrib::INVALID_APID) {
keyword = "illegal APID";
} else if (tcStatus == tcdistrib::INCORRECT_SECONDARY_HEADER) {
keyword = "incorrect secondary header";
} else if (tcStatus == tcdistrib::INCOMPLETE_PACKET) {
keyword = "incomplete packet";
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword << " error"
<< std::endl;
#else
sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n", keyword);
#endif
#endif
}

Some files were not shown because too many files have changed in this diff Show More