diff --git a/CHANGELOG b/CHANGELOG
index add8e1a5..09b8db6a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,16 @@
+## Changes from ASTP 1.0.0 to 1.1.0
+
+### PUS
+
+- Added PUS C support
+
+### Configuration
+
+- Additional configuration option fsfwconfig::FSFW_MAX_TM_PACKET_SIZE which
+ need to be specified in FSFWConfig.h
+
+
+
## Changes from ASTP 0.0.1 to 1.0.0
### Host OSAL
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8ba6a187..9ba73a3f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,13 @@ add_library(${LIB_FSFW_NAME})
set_property(CACHE OS_FSFW PROPERTY STRINGS host linux rtems freertos)
+if(NOT CMAKE_CXX_STANDARD)
+ set(CMAKE_CXX_STANDARD 11)
+ set(CMAKE_CXX_STANDARD_REQUIRED True)
+elseif(${CMAKE_CXX_STANDARD} LESS 11)
+ message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++11 support")
+endif()
+
if(NOT OS_FSFW)
message(STATUS "No OS for FSFW via OS_FSFW set. Assuming host OS")
# Assume host OS and autodetermine from OS_FSFW
@@ -131,9 +138,9 @@ else()
)
endif()
-foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATH})
+foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS})
if(IS_ABSOLUTE ${INCLUDE_PATH})
- set(CURR_ABS_INC_PATH "${FREERTOS_PATH}")
+ set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
else()
get_filename_component(CURR_ABS_INC_PATH
${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
diff --git a/FSFW.h b/FSFW.h
new file mode 100644
index 00000000..df06ff3d
--- /dev/null
+++ b/FSFW.h
@@ -0,0 +1,7 @@
+#ifndef FSFW_FSFW_H_
+#define FSFW_FSFW_H_
+
+#include "FSFWConfig.h"
+
+
+#endif /* FSFW_FSFW_H_ */
diff --git a/README.md b/README.md
index fb3be429..484d65c0 100644
--- a/README.md
+++ b/README.md
@@ -38,11 +38,12 @@ a starting point. The [configuration section](doc/README-config.md#top) provides
[1. High-level overview](doc/README-highlevel.md#top)
[2. Core components](doc/README-core.md#top)
-[3. OSAL overview](doc/README-osal.md#top)
-[4. PUS services](doc/README-pus.md#top)
-[5. Device Handler overview](doc/README-devicehandlers.md#top)
-[6. Controller overview](doc/README-controllers.md#top)
-[7. Local Data Pools](doc/README-localpools.md#top)
+[3. Configuration](doc/README-config.md#top)
+[4. OSAL overview](doc/README-osal.md#top)
+[5. PUS services](doc/README-pus.md#top)
+[6. Device Handler overview](doc/README-devicehandlers.md#top)
+[7. Controller overview](doc/README-controllers.md#top)
+[8. Local Data Pools](doc/README-localpools.md#top)
diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp
index b2374ed6..73007ea3 100644
--- a/action/ActionHelper.cpp
+++ b/action/ActionHelper.cpp
@@ -2,7 +2,7 @@
#include "HasActionsIF.h"
#include "../ipc/MessageQueueSenderIF.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
#include "../serviceinterface/ServiceInterface.h"
ActionHelper::ActionHelper(HasActionsIF* setOwner,
@@ -25,7 +25,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) {
}
ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
- ipcStore = objectManager->get(objects::IPC_STORE);
+ ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
if (ipcStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
diff --git a/action/ActionMessage.cpp b/action/ActionMessage.cpp
index 66c7f058..f25858af 100644
--- a/action/ActionMessage.cpp
+++ b/action/ActionMessage.cpp
@@ -1,7 +1,7 @@
#include "ActionMessage.h"
#include "HasActionsIF.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
#include "../storagemanager/StorageManagerIF.h"
ActionMessage::ActionMessage() {
@@ -69,7 +69,7 @@ void ActionMessage::clear(CommandMessage* message) {
switch(message->getCommand()) {
case EXECUTE_ACTION:
case DATA_REPLY: {
- StorageManagerIF *ipcStore = objectManager->get(
+ StorageManagerIF *ipcStore = ObjectManager::instance()->get(
objects::IPC_STORE);
if (ipcStore != NULL) {
ipcStore->deleteData(getStoreId(message));
diff --git a/action/CommandActionHelper.cpp b/action/CommandActionHelper.cpp
index 148b3657..31650cae 100644
--- a/action/CommandActionHelper.cpp
+++ b/action/CommandActionHelper.cpp
@@ -2,7 +2,8 @@
#include "CommandActionHelper.h"
#include "CommandsActionsIF.h"
#include "HasActionsIF.h"
-#include "../objectmanager/ObjectManagerIF.h"
+
+#include "../objectmanager/ObjectManager.h"
CommandActionHelper::CommandActionHelper(CommandsActionsIF *setOwner) :
owner(setOwner), queueToUse(NULL), ipcStore(
@@ -14,7 +15,7 @@ CommandActionHelper::~CommandActionHelper() {
ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo,
ActionId_t actionId, SerializeIF *data) {
- HasActionsIF *receiver = objectManager->get(commandTo);
+ HasActionsIF *receiver = ObjectManager::instance()->get(commandTo);
if (receiver == NULL) {
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
}
@@ -40,7 +41,7 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo,
// if (commandCount != 0) {
// return CommandsFunctionsIF::ALREADY_COMMANDING;
// }
- HasActionsIF *receiver = objectManager->get(commandTo);
+ HasActionsIF *receiver = ObjectManager::instance()->get(commandTo);
if (receiver == NULL) {
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
}
@@ -66,7 +67,7 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId,
}
ReturnValue_t CommandActionHelper::initialize() {
- ipcStore = objectManager->get(objects::IPC_STORE);
+ ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
if (ipcStore == NULL) {
return HasReturnvaluesIF::RETURN_FAILED;
}
diff --git a/controller/ControllerBase.cpp b/controller/ControllerBase.cpp
index 89f0ff68..5a94c082 100644
--- a/controller/ControllerBase.cpp
+++ b/controller/ControllerBase.cpp
@@ -3,6 +3,7 @@
#include "../subsystem/SubsystemBase.h"
#include "../ipc/QueueFactory.h"
#include "../action/HasActionsIF.h"
+#include "../objectmanager/ObjectManager.h"
ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId,
size_t commandQueueDepth) :
@@ -25,7 +26,7 @@ ReturnValue_t ControllerBase::initialize() {
MessageQueueId_t parentQueue = 0;
if (parentId != objects::NO_OBJECT) {
- SubsystemBase *parent = objectManager->get(parentId);
+ SubsystemBase *parent = ObjectManager::instance()->get(parentId);
if (parent == nullptr) {
return RETURN_FAILED;
}
diff --git a/controller/ExtendedControllerBase.h b/controller/ExtendedControllerBase.h
index d5d43933..63c350e2 100644
--- a/controller/ExtendedControllerBase.h
+++ b/controller/ExtendedControllerBase.h
@@ -66,6 +66,10 @@ protected:
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
LocalDataPoolManager& poolManager) override = 0;
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0;
+
+ // Mode abstract functions
+ virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
+ uint32_t *msToReachTheMode) override = 0;
};
diff --git a/datalinklayer/DataLinkLayer.h b/datalinklayer/DataLinkLayer.h
index 17a57d61..27e69006 100644
--- a/datalinklayer/DataLinkLayer.h
+++ b/datalinklayer/DataLinkLayer.h
@@ -19,7 +19,8 @@ class VirtualChannelReception;
class DataLinkLayer : public CCSDSReturnValuesIF {
public:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_1;
- static const Event RF_AVAILABLE = MAKE_EVENT(0, severity::INFO); //!< A RF available signal was detected. P1: raw RFA state, P2: 0
+ //! [EXPORT] : [COMMENT] A RF available signal was detected. P1: raw RFA state, P2: 0
+ static const Event RF_AVAILABLE = MAKE_EVENT(0, severity::INFO);
static const Event RF_LOST = MAKE_EVENT(1, severity::INFO); //!< A previously found RF available signal was lost. P1: raw RFA state, P2: 0
static const Event BIT_LOCK = MAKE_EVENT(2, severity::INFO); //!< A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0
static const Event BIT_LOCK_LOST = MAKE_EVENT(3, severity::INFO); //!< A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0
diff --git a/datalinklayer/MapPacketExtraction.cpp b/datalinklayer/MapPacketExtraction.cpp
index cdc9ae27..d377ca34 100644
--- a/datalinklayer/MapPacketExtraction.cpp
+++ b/datalinklayer/MapPacketExtraction.cpp
@@ -1,10 +1,13 @@
#include "MapPacketExtraction.h"
+
#include "../ipc/QueueFactory.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../storagemanager/StorageManagerIF.h"
#include "../tmtcpacket/SpacePacketBase.h"
#include "../tmtcservices/AcceptsTelecommandsIF.h"
#include "../tmtcservices/TmTcMessage.h"
+#include "../objectmanager/ObjectManager.h"
+
#include
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
@@ -131,9 +134,9 @@ void MapPacketExtraction::clearBuffers() {
}
ReturnValue_t MapPacketExtraction::initialize() {
- packetStore = objectManager->get(objects::TC_STORE);
- AcceptsTelecommandsIF* distributor = objectManager->get<
- AcceptsTelecommandsIF>(packetDestination);
+ packetStore = ObjectManager::instance()->get(objects::TC_STORE);
+ AcceptsTelecommandsIF* distributor = ObjectManager::instance()->
+ get(packetDestination);
if ((packetStore != NULL) && (distributor != NULL)) {
tcQueueId = distributor->getRequestQueue();
return RETURN_OK;
diff --git a/datapoollocal/HasLocalDataPoolIF.h b/datapoollocal/HasLocalDataPoolIF.h
index 74e372c9..6051f068 100644
--- a/datapoollocal/HasLocalDataPoolIF.h
+++ b/datapoollocal/HasLocalDataPoolIF.h
@@ -34,7 +34,8 @@ class LocalPoolObjectBase;
* can be retrieved using the object manager, provided the target object is a SystemObject.
* For example, the following line of code can be used to retrieve the interface
*
- * HasLocalDataPoolIF* poolIF = objectManager->get(objects::SOME_OBJECT);
+ * HasLocalDataPoolIF* poolIF = ObjectManager::instance()->
+ * get(objects::SOME_OBJECT);
* if(poolIF != nullptr) {
* doSomething()
* }
diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp
index dbe68ff1..71997b9b 100644
--- a/datapoollocal/LocalDataPoolManager.cpp
+++ b/datapoollocal/LocalDataPoolManager.cpp
@@ -6,6 +6,7 @@
#include "internal/HasLocalDpIFManagerAttorney.h"
#include "../housekeeping/HousekeepingSetPacket.h"
+#include "../objectmanager/ObjectManager.h"
#include "../housekeeping/HousekeepingSnapshot.h"
#include "../housekeeping/AcceptsHkPacketsIF.h"
#include "../timemanager/CCSDSTime.h"
@@ -19,23 +20,23 @@
object_id_t LocalDataPoolManager::defaultHkDestination = objects::PUS_SERVICE_3_HOUSEKEEPING;
LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse,
- bool appendValidityBuffer):
- appendValidityBuffer(appendValidityBuffer) {
- if(owner == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "LocalDataPoolManager", HasReturnvaluesIF::RETURN_FAILED,
- "Invalid supplied owner");
- return;
- }
- this->owner = owner;
- mutex = MutexFactory::instance()->createMutex();
- if(mutex == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_ERROR,
- "LocalDataPoolManager", HasReturnvaluesIF::RETURN_FAILED,
- "Could not create mutex");
- }
+ bool appendValidityBuffer):
+ appendValidityBuffer(appendValidityBuffer) {
+ if(owner == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "LocalDataPoolManager", HasReturnvaluesIF::RETURN_FAILED,
+ "Invalid supplied owner");
+ return;
+ }
+ this->owner = owner;
+ mutex = MutexFactory::instance()->createMutex();
+ if(mutex == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_ERROR,
+ "LocalDataPoolManager", HasReturnvaluesIF::RETURN_FAILED,
+ "Could not create mutex");
+ }
- hkQueue = queueToUse;
+ hkQueue = queueToUse;
}
LocalDataPoolManager::~LocalDataPoolManager() {
@@ -45,898 +46,903 @@ LocalDataPoolManager::~LocalDataPoolManager() {
}
ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
- if(queueToUse == nullptr) {
- /* Error, all destinations invalid */
- printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
- QUEUE_OR_DESTINATION_INVALID);
- }
- hkQueue = queueToUse;
+ if(queueToUse == nullptr) {
+ /* Error, all destinations invalid */
+ printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
+ QUEUE_OR_DESTINATION_INVALID);
+ }
+ hkQueue = queueToUse;
- ipcStore = objectManager->get(objects::IPC_STORE);
- if(ipcStore == nullptr) {
- /* Error, all destinations invalid */
- printWarningOrError(sif::OutputTypes::OUT_ERROR,
- "initialize", HasReturnvaluesIF::RETURN_FAILED,
- "Could not set IPC store.");
- return HasReturnvaluesIF::RETURN_FAILED;
- }
+ ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
+ if(ipcStore == nullptr) {
+ /* Error, all destinations invalid */
+ printWarningOrError(sif::OutputTypes::OUT_ERROR,
+ "initialize", HasReturnvaluesIF::RETURN_FAILED,
+ "Could not set IPC store.");
+ return HasReturnvaluesIF::RETURN_FAILED;
+ }
- if(defaultHkDestination != objects::NO_OBJECT) {
- AcceptsHkPacketsIF* hkPacketReceiver =
- objectManager->get(defaultHkDestination);
- if(hkPacketReceiver != nullptr) {
- hkDestinationId = hkPacketReceiver->getHkQueue();
- }
- else {
- printWarningOrError(sif::OutputTypes::OUT_ERROR,
- "initialize", QUEUE_OR_DESTINATION_INVALID);
- return QUEUE_OR_DESTINATION_INVALID;
- }
- }
+ if(defaultHkDestination != objects::NO_OBJECT) {
+ AcceptsHkPacketsIF* hkPacketReceiver = ObjectManager::instance()->
+ get(defaultHkDestination);
+ if(hkPacketReceiver != nullptr) {
+ hkDestinationId = hkPacketReceiver->getHkQueue();
+ }
+ else {
+ printWarningOrError(sif::OutputTypes::OUT_ERROR,
+ "initialize", QUEUE_OR_DESTINATION_INVALID);
+ return QUEUE_OR_DESTINATION_INVALID;
+ }
+ }
- return HasReturnvaluesIF::RETURN_OK;
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation(
- uint8_t nonDiagInvlFactor) {
- setNonDiagnosticIntervalFactor(nonDiagInvlFactor);
- return initializeHousekeepingPoolEntriesOnce();
+ uint8_t nonDiagInvlFactor) {
+ setNonDiagnosticIntervalFactor(nonDiagInvlFactor);
+ return initializeHousekeepingPoolEntriesOnce();
}
ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
- if(not mapInitialized) {
- ReturnValue_t result = owner->initializeLocalDataPool(localPoolMap,
- *this);
- if(result == HasReturnvaluesIF::RETURN_OK) {
- mapInitialized = true;
- }
- return result;
- }
+ if(not mapInitialized) {
+ ReturnValue_t result = owner->initializeLocalDataPool(localPoolMap,
+ *this);
+ if(result == HasReturnvaluesIF::RETURN_OK) {
+ mapInitialized = true;
+ }
+ return result;
+ }
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "initialize", HasReturnvaluesIF::RETURN_FAILED,
- "The map should only be initialized once");
- return HasReturnvaluesIF::RETURN_OK;
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "initialize", HasReturnvaluesIF::RETURN_FAILED,
+ "The map should only be initialized once");
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::performHkOperation() {
- ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
- for(auto& receiver: hkReceivers) {
- switch(receiver.reportingType) {
- case(ReportingType::PERIODIC): {
- if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
- /* Periodic packets shall only be generated from datasets */
- continue;
- }
- performPeriodicHkGeneration(receiver);
- break;
- }
- case(ReportingType::UPDATE_HK): {
- handleHkUpdate(receiver, status);
- break;
- }
- case(ReportingType::UPDATE_NOTIFICATION): {
- handleNotificationUpdate(receiver, status);
- break;
- }
- case(ReportingType::UPDATE_SNAPSHOT): {
- handleNotificationSnapshot(receiver, status);
- break;
- }
- default:
- // This should never happen.
- return HasReturnvaluesIF::RETURN_FAILED;
- }
- }
- resetHkUpdateResetHelper();
- return status;
+ ReturnValue_t status = HasReturnvaluesIF::RETURN_OK;
+ for(auto& receiver: hkReceivers) {
+ switch(receiver.reportingType) {
+ case(ReportingType::PERIODIC): {
+ if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
+ /* Periodic packets shall only be generated from datasets */
+ continue;
+ }
+ performPeriodicHkGeneration(receiver);
+ break;
+ }
+ case(ReportingType::UPDATE_HK): {
+ handleHkUpdate(receiver, status);
+ break;
+ }
+ case(ReportingType::UPDATE_NOTIFICATION): {
+ handleNotificationUpdate(receiver, status);
+ break;
+ }
+ case(ReportingType::UPDATE_SNAPSHOT): {
+ handleNotificationSnapshot(receiver, status);
+ break;
+ }
+ default:
+ // This should never happen.
+ return HasReturnvaluesIF::RETURN_FAILED;
+ }
+ }
+ resetHkUpdateResetHelper();
+ return status;
}
ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver,
- ReturnValue_t& status) {
- if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
- /* Update packets shall only be generated from datasets. */
- return HasReturnvaluesIF::RETURN_FAILED;
- }
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
- receiver.dataId.sid);
- if(dataSet == nullptr) {
+ ReturnValue_t& status) {
+ if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
+ /* Update packets shall only be generated from datasets. */
+ return HasReturnvaluesIF::RETURN_FAILED;
+ }
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
+ receiver.dataId.sid);
+ if(dataSet == nullptr) {
return DATASET_NOT_FOUND;
- }
- if(dataSet->hasChanged()) {
- /* Prepare and send update notification */
- ReturnValue_t result = generateHousekeepingPacket(
- receiver.dataId.sid, dataSet, true);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- status = result;
- }
- }
- handleChangeResetLogic(receiver.dataType, receiver.dataId,
- dataSet);
- return HasReturnvaluesIF::RETURN_OK;
+ }
+ if(dataSet->hasChanged()) {
+ /* Prepare and send update notification */
+ ReturnValue_t result = generateHousekeepingPacket(
+ receiver.dataId.sid, dataSet, true);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ status = result;
+ }
+ }
+ handleChangeResetLogic(receiver.dataType, receiver.dataId,
+ dataSet);
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(HkReceiver& receiver,
- ReturnValue_t& status) {
- MarkChangedIF* toReset = nullptr;
- if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
- LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
- receiver.dataId.localPoolId);
- if(poolObj == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "handleNotificationUpdate", POOLOBJECT_NOT_FOUND);
- return POOLOBJECT_NOT_FOUND;
- }
- if(poolObj->hasChanged()) {
- /* Prepare and send update notification. */
- CommandMessage notification;
- HousekeepingMessage::setUpdateNotificationVariableCommand(¬ification,
- gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId));
- ReturnValue_t result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- status = result;
- }
- toReset = poolObj;
- }
+ ReturnValue_t& status) {
+ MarkChangedIF* toReset = nullptr;
+ if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
+ LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
+ receiver.dataId.localPoolId);
+ if(poolObj == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "handleNotificationUpdate", POOLOBJECT_NOT_FOUND);
+ return POOLOBJECT_NOT_FOUND;
+ }
+ if(poolObj->hasChanged()) {
+ /* Prepare and send update notification. */
+ CommandMessage notification;
+ HousekeepingMessage::setUpdateNotificationVariableCommand(¬ification,
+ gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId));
+ ReturnValue_t result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ status = result;
+ }
+ toReset = poolObj;
+ }
- }
- else {
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
- receiver.dataId.sid);
- if(dataSet == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "handleNotificationUpdate", DATASET_NOT_FOUND);
- return DATASET_NOT_FOUND;
- }
- if(dataSet->hasChanged()) {
- /* Prepare and send update notification */
- CommandMessage notification;
- HousekeepingMessage::setUpdateNotificationSetCommand(¬ification,
- receiver.dataId.sid);
- ReturnValue_t result = hkQueue->sendMessage(
- receiver.destinationQueue, ¬ification);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- status = result;
- }
- toReset = dataSet;
- }
- }
- if(toReset != nullptr) {
- handleChangeResetLogic(receiver.dataType, receiver.dataId, toReset);
- }
- return HasReturnvaluesIF::RETURN_OK;
+ }
+ else {
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
+ receiver.dataId.sid);
+ if(dataSet == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "handleNotificationUpdate", DATASET_NOT_FOUND);
+ return DATASET_NOT_FOUND;
+ }
+ if(dataSet->hasChanged()) {
+ /* Prepare and send update notification */
+ CommandMessage notification;
+ HousekeepingMessage::setUpdateNotificationSetCommand(¬ification,
+ receiver.dataId.sid);
+ ReturnValue_t result = hkQueue->sendMessage(
+ receiver.destinationQueue, ¬ification);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ status = result;
+ }
+ toReset = dataSet;
+ }
+ }
+ if(toReset != nullptr) {
+ handleChangeResetLogic(receiver.dataType, receiver.dataId, toReset);
+ }
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
- HkReceiver& receiver, ReturnValue_t& status) {
- MarkChangedIF* toReset = nullptr;
- /* Check whether data has changed and send messages in case it has */
- if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
- LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
- receiver.dataId.localPoolId);
- if(poolObj == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "handleNotificationSnapshot", POOLOBJECT_NOT_FOUND);
- return POOLOBJECT_NOT_FOUND;
- }
+ HkReceiver& receiver, ReturnValue_t& status) {
+ MarkChangedIF* toReset = nullptr;
+ /* Check whether data has changed and send messages in case it has */
+ if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
+ LocalPoolObjectBase* poolObj = HasLocalDpIFManagerAttorney::getPoolObjectHandle(owner,
+ receiver.dataId.localPoolId);
+ if(poolObj == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "handleNotificationSnapshot", POOLOBJECT_NOT_FOUND);
+ return POOLOBJECT_NOT_FOUND;
+ }
- if (not poolObj->hasChanged()) {
- return HasReturnvaluesIF::RETURN_OK;
- }
+ if (not poolObj->hasChanged()) {
+ return HasReturnvaluesIF::RETURN_OK;
+ }
- /* Prepare and send update snapshot */
- timeval now;
- Clock::getClock_timeval(&now);
- CCSDSTime::CDS_short cds;
- CCSDSTime::convertToCcsds(&cds, &now);
- HousekeepingSnapshot updatePacket(reinterpret_cast(&cds), sizeof(cds),
- HasLocalDpIFManagerAttorney::getPoolObjectHandle(
- owner,receiver.dataId.localPoolId));
+ /* Prepare and send update snapshot */
+ timeval now;
+ Clock::getClock_timeval(&now);
+ CCSDSTime::CDS_short cds;
+ CCSDSTime::convertToCcsds(&cds, &now);
+ HousekeepingSnapshot updatePacket(reinterpret_cast(&cds), sizeof(cds),
+ HasLocalDpIFManagerAttorney::getPoolObjectHandle(
+ owner,receiver.dataId.localPoolId));
- store_address_t storeId;
- ReturnValue_t result = addUpdateToStore(updatePacket, storeId);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
+ store_address_t storeId;
+ ReturnValue_t result = addUpdateToStore(updatePacket, storeId);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ return result;
+ }
- CommandMessage notification;
- HousekeepingMessage::setUpdateSnapshotVariableCommand(¬ification,
- gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId), storeId);
- result = hkQueue->sendMessage(receiver.destinationQueue,
- ¬ification);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- status = result;
- }
- toReset = poolObj;
- }
- else {
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
- receiver.dataId.sid);
- if(dataSet == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "handleNotificationSnapshot", DATASET_NOT_FOUND);
- return DATASET_NOT_FOUND;
- }
+ CommandMessage notification;
+ HousekeepingMessage::setUpdateSnapshotVariableCommand(¬ification,
+ gp_id_t(owner->getObjectId(), receiver.dataId.localPoolId), storeId);
+ result = hkQueue->sendMessage(receiver.destinationQueue,
+ ¬ification);
+ if (result != HasReturnvaluesIF::RETURN_OK) {
+ status = result;
+ }
+ toReset = poolObj;
+ }
+ else {
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
+ receiver.dataId.sid);
+ if(dataSet == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "handleNotificationSnapshot", DATASET_NOT_FOUND);
+ return DATASET_NOT_FOUND;
+ }
- if(not dataSet->hasChanged()) {
- return HasReturnvaluesIF::RETURN_OK;
- }
+ if(not dataSet->hasChanged()) {
+ return HasReturnvaluesIF::RETURN_OK;
+ }
- /* Prepare and send update snapshot */
- timeval now;
- Clock::getClock_timeval(&now);
- CCSDSTime::CDS_short cds;
- CCSDSTime::convertToCcsds(&cds, &now);
- HousekeepingSnapshot updatePacket(reinterpret_cast(&cds),
- sizeof(cds), HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
- receiver.dataId.sid));
+ /* Prepare and send update snapshot */
+ timeval now;
+ Clock::getClock_timeval(&now);
+ CCSDSTime::CDS_short cds;
+ CCSDSTime::convertToCcsds(&cds, &now);
+ HousekeepingSnapshot updatePacket(reinterpret_cast(&cds),
+ sizeof(cds), HasLocalDpIFManagerAttorney::getDataSetHandle(owner,
+ receiver.dataId.sid));
- store_address_t storeId;
- ReturnValue_t result = addUpdateToStore(updatePacket, storeId);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
+ store_address_t storeId;
+ ReturnValue_t result = addUpdateToStore(updatePacket, storeId);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ return result;
+ }
- CommandMessage notification;
- HousekeepingMessage::setUpdateSnapshotSetCommand(
- ¬ification, receiver.dataId.sid, storeId);
- result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- status = result;
- }
- toReset = dataSet;
+ CommandMessage notification;
+ HousekeepingMessage::setUpdateSnapshotSetCommand(
+ ¬ification, receiver.dataId.sid, storeId);
+ result = hkQueue->sendMessage(receiver.destinationQueue, ¬ification);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ status = result;
+ }
+ toReset = dataSet;
- }
- if(toReset != nullptr) {
- handleChangeResetLogic(receiver.dataType,
- receiver.dataId, toReset);
- }
- return HasReturnvaluesIF::RETURN_OK;
+ }
+ if(toReset != nullptr) {
+ handleChangeResetLogic(receiver.dataType,
+ receiver.dataId, toReset);
+ }
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::addUpdateToStore(
- HousekeepingSnapshot& updatePacket, store_address_t& storeId) {
- size_t updatePacketSize = updatePacket.getSerializedSize();
- uint8_t *storePtr = nullptr;
- ReturnValue_t result = ipcStore->getFreeElement(&storeId,
- updatePacket.getSerializedSize(), &storePtr);
- if (result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- size_t serializedSize = 0;
- result = updatePacket.serialize(&storePtr, &serializedSize,
- updatePacketSize, SerializeIF::Endianness::MACHINE);
- return result;;
+ HousekeepingSnapshot& updatePacket, store_address_t& storeId) {
+ size_t updatePacketSize = updatePacket.getSerializedSize();
+ uint8_t *storePtr = nullptr;
+ ReturnValue_t result = ipcStore->getFreeElement(&storeId,
+ updatePacket.getSerializedSize(), &storePtr);
+ if (result != HasReturnvaluesIF::RETURN_OK) {
+ return result;
+ }
+ size_t serializedSize = 0;
+ result = updatePacket.serialize(&storePtr, &serializedSize,
+ updatePacketSize, SerializeIF::Endianness::MACHINE);
+ return result;;
}
void LocalDataPoolManager::handleChangeResetLogic(
- DataType type, DataId dataId, MarkChangedIF* toReset) {
- if(hkUpdateResetList == nullptr) {
- /* Config error */
- return;
- }
- HkUpdateResetList& listRef = *hkUpdateResetList;
- for(auto& changeInfo: listRef) {
- if(changeInfo.dataType != type) {
- continue;
- }
- if((changeInfo.dataType == DataType::DATA_SET) and
- (changeInfo.dataId.sid != dataId.sid)) {
- continue;
- }
- if((changeInfo.dataType == DataType::LOCAL_POOL_VARIABLE) and
- (changeInfo.dataId.localPoolId != dataId.localPoolId)) {
- continue;
- }
+ DataType type, DataId dataId, MarkChangedIF* toReset) {
+ if(hkUpdateResetList == nullptr) {
+ /* Config error */
+ return;
+ }
+ HkUpdateResetList& listRef = *hkUpdateResetList;
+ for(auto& changeInfo: listRef) {
+ if(changeInfo.dataType != type) {
+ continue;
+ }
+ if((changeInfo.dataType == DataType::DATA_SET) and
+ (changeInfo.dataId.sid != dataId.sid)) {
+ continue;
+ }
+ if((changeInfo.dataType == DataType::LOCAL_POOL_VARIABLE) and
+ (changeInfo.dataId.localPoolId != dataId.localPoolId)) {
+ continue;
+ }
- /* Only one update recipient, we can reset changes status immediately */
- if(changeInfo.updateCounter <= 1) {
- toReset->setChanged(false);
- }
- /* All recipients have been notified, reset the changed flag */
- else if(changeInfo.currentUpdateCounter <= 1) {
- toReset->setChanged(false);
- changeInfo.currentUpdateCounter = 0;
- }
- /* Not all recipiens have been notified yet, decrement */
- else {
- changeInfo.currentUpdateCounter--;
- }
- return;
- }
+ /* Only one update recipient, we can reset changes status immediately */
+ if(changeInfo.updateCounter <= 1) {
+ toReset->setChanged(false);
+ }
+ /* All recipients have been notified, reset the changed flag */
+ else if(changeInfo.currentUpdateCounter <= 1) {
+ toReset->setChanged(false);
+ changeInfo.currentUpdateCounter = 0;
+ }
+ /* Not all recipiens have been notified yet, decrement */
+ else {
+ changeInfo.currentUpdateCounter--;
+ }
+ return;
+ }
}
void LocalDataPoolManager::resetHkUpdateResetHelper() {
- if(hkUpdateResetList == nullptr) {
- return;
- }
+ if(hkUpdateResetList == nullptr) {
+ return;
+ }
- for(auto& changeInfo: *hkUpdateResetList) {
- changeInfo.currentUpdateCounter = changeInfo.updateCounter;
- }
+ for(auto& changeInfo: *hkUpdateResetList) {
+ changeInfo.currentUpdateCounter = changeInfo.updateCounter;
+ }
}
ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
- bool enableReporting, float collectionInterval, bool isDiagnostics,
- object_id_t packetDestination) {
- AcceptsHkPacketsIF* hkReceiverObject =
- objectManager->get(packetDestination);
- if(hkReceiverObject == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
- return QUEUE_OR_DESTINATION_INVALID;
- }
+ bool enableReporting, float collectionInterval, bool isDiagnostics,
+ object_id_t packetDestination) {
+ AcceptsHkPacketsIF* hkReceiverObject = ObjectManager::instance()->
+ get(packetDestination);
+ if(hkReceiverObject == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
+ return QUEUE_OR_DESTINATION_INVALID;
+ }
- struct HkReceiver hkReceiver;
- hkReceiver.dataId.sid = sid;
- hkReceiver.reportingType = ReportingType::PERIODIC;
- hkReceiver.dataType = DataType::DATA_SET;
- hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
+ struct HkReceiver hkReceiver;
+ hkReceiver.dataId.sid = sid;
+ hkReceiver.reportingType = ReportingType::PERIODIC;
+ hkReceiver.dataType = DataType::DATA_SET;
+ hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
- if(dataSet != nullptr) {
- LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting);
- LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
- LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval,
- owner->getPeriodicOperationFrequency());
- }
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
+ if(dataSet != nullptr) {
+ LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enableReporting);
+ LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
+ LocalPoolDataSetAttorney::initializePeriodicHelper(*dataSet, collectionInterval,
+ owner->getPeriodicOperationFrequency());
+ }
- hkReceivers.push_back(hkReceiver);
- return HasReturnvaluesIF::RETURN_OK;
+ hkReceivers.push_back(hkReceiver);
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid,
- bool isDiagnostics, bool reportingEnabled,
- object_id_t packetDestination) {
- AcceptsHkPacketsIF* hkReceiverObject =
- objectManager->get(packetDestination);
- if(hkReceiverObject == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
- return QUEUE_OR_DESTINATION_INVALID;
- }
+ bool isDiagnostics, bool reportingEnabled,
+ object_id_t packetDestination) {
+ AcceptsHkPacketsIF* hkReceiverObject =
+ ObjectManager::instance()->get(packetDestination);
+ if(hkReceiverObject == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
+ return QUEUE_OR_DESTINATION_INVALID;
+ }
- struct HkReceiver hkReceiver;
- hkReceiver.dataId.sid = sid;
- hkReceiver.reportingType = ReportingType::UPDATE_HK;
- hkReceiver.dataType = DataType::DATA_SET;
- hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
+ struct HkReceiver hkReceiver;
+ hkReceiver.dataId.sid = sid;
+ hkReceiver.reportingType = ReportingType::UPDATE_HK;
+ hkReceiver.dataType = DataType::DATA_SET;
+ hkReceiver.destinationQueue = hkReceiverObject->getHkQueue();
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
- if(dataSet != nullptr) {
- LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
- LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
- }
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
+ if(dataSet != nullptr) {
+ LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, true);
+ LocalPoolDataSetAttorney::setDiagnostic(*dataSet, isDiagnostics);
+ }
- hkReceivers.push_back(hkReceiver);
+ hkReceivers.push_back(hkReceiver);
- handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
- return HasReturnvaluesIF::RETURN_OK;
+ handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::subscribeForSetUpdateMessage(
- const uint32_t setId, object_id_t destinationObject,
- MessageQueueId_t targetQueueId, bool generateSnapshot) {
- struct HkReceiver hkReceiver;
- hkReceiver.dataType = DataType::DATA_SET;
- hkReceiver.dataId.sid = sid_t(owner->getObjectId(), setId);
- hkReceiver.destinationQueue = targetQueueId;
- hkReceiver.objectId = destinationObject;
- if(generateSnapshot) {
- hkReceiver.reportingType = ReportingType::UPDATE_SNAPSHOT;
- }
- else {
- hkReceiver.reportingType = ReportingType::UPDATE_NOTIFICATION;
- }
+ const uint32_t setId, object_id_t destinationObject,
+ MessageQueueId_t targetQueueId, bool generateSnapshot) {
+ struct HkReceiver hkReceiver;
+ hkReceiver.dataType = DataType::DATA_SET;
+ hkReceiver.dataId.sid = sid_t(owner->getObjectId(), setId);
+ hkReceiver.destinationQueue = targetQueueId;
+ hkReceiver.objectId = destinationObject;
+ if(generateSnapshot) {
+ hkReceiver.reportingType = ReportingType::UPDATE_SNAPSHOT;
+ }
+ else {
+ hkReceiver.reportingType = ReportingType::UPDATE_NOTIFICATION;
+ }
- hkReceivers.push_back(hkReceiver);
+ hkReceivers.push_back(hkReceiver);
- handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
- return HasReturnvaluesIF::RETURN_OK;
+ handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::subscribeForVariableUpdateMessage(
- const lp_id_t localPoolId, object_id_t destinationObject,
- MessageQueueId_t targetQueueId, bool generateSnapshot) {
- struct HkReceiver hkReceiver;
- hkReceiver.dataType = DataType::LOCAL_POOL_VARIABLE;
- hkReceiver.dataId.localPoolId = localPoolId;
- hkReceiver.destinationQueue = targetQueueId;
- hkReceiver.objectId = destinationObject;
- if(generateSnapshot) {
- hkReceiver.reportingType = ReportingType::UPDATE_SNAPSHOT;
- }
- else {
- hkReceiver.reportingType = ReportingType::UPDATE_NOTIFICATION;
- }
+ const lp_id_t localPoolId, object_id_t destinationObject,
+ MessageQueueId_t targetQueueId, bool generateSnapshot) {
+ struct HkReceiver hkReceiver;
+ hkReceiver.dataType = DataType::LOCAL_POOL_VARIABLE;
+ hkReceiver.dataId.localPoolId = localPoolId;
+ hkReceiver.destinationQueue = targetQueueId;
+ hkReceiver.objectId = destinationObject;
+ if(generateSnapshot) {
+ hkReceiver.reportingType = ReportingType::UPDATE_SNAPSHOT;
+ }
+ else {
+ hkReceiver.reportingType = ReportingType::UPDATE_NOTIFICATION;
+ }
- hkReceivers.push_back(hkReceiver);
+ hkReceivers.push_back(hkReceiver);
- handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
- return HasReturnvaluesIF::RETURN_OK;
+ handleHkUpdateResetListInsertion(hkReceiver.dataType, hkReceiver.dataId);
+ return HasReturnvaluesIF::RETURN_OK;
}
void LocalDataPoolManager::handleHkUpdateResetListInsertion(DataType dataType,
- DataId dataId) {
- if(hkUpdateResetList == nullptr) {
- hkUpdateResetList = new std::vector();
- }
+ DataId dataId) {
+ if(hkUpdateResetList == nullptr) {
+ hkUpdateResetList = new std::vector();
+ }
- for(auto& updateResetStruct: *hkUpdateResetList) {
- if(dataType == DataType::DATA_SET) {
- if(updateResetStruct.dataId.sid == dataId.sid) {
- updateResetStruct.updateCounter++;
- updateResetStruct.currentUpdateCounter++;
- return;
- }
- }
- else {
- if(updateResetStruct.dataId.localPoolId == dataId.localPoolId) {
- updateResetStruct.updateCounter++;
- updateResetStruct.currentUpdateCounter++;
- return;
- }
- }
+ for(auto& updateResetStruct: *hkUpdateResetList) {
+ if(dataType == DataType::DATA_SET) {
+ if(updateResetStruct.dataId.sid == dataId.sid) {
+ updateResetStruct.updateCounter++;
+ updateResetStruct.currentUpdateCounter++;
+ return;
+ }
+ }
+ else {
+ if(updateResetStruct.dataId.localPoolId == dataId.localPoolId) {
+ updateResetStruct.updateCounter++;
+ updateResetStruct.currentUpdateCounter++;
+ return;
+ }
+ }
- }
- HkUpdateResetHelper hkUpdateResetHelper;
- hkUpdateResetHelper.currentUpdateCounter = 1;
- hkUpdateResetHelper.updateCounter = 1;
- hkUpdateResetHelper.dataType = dataType;
- if(dataType == DataType::DATA_SET) {
- hkUpdateResetHelper.dataId.sid = dataId.sid;
- }
- else {
- hkUpdateResetHelper.dataId.localPoolId = dataId.localPoolId;
- }
- hkUpdateResetList->push_back(hkUpdateResetHelper);
+ }
+ HkUpdateResetHelper hkUpdateResetHelper;
+ hkUpdateResetHelper.currentUpdateCounter = 1;
+ hkUpdateResetHelper.updateCounter = 1;
+ hkUpdateResetHelper.dataType = dataType;
+ if(dataType == DataType::DATA_SET) {
+ hkUpdateResetHelper.dataId.sid = dataId.sid;
+ }
+ else {
+ hkUpdateResetHelper.dataId.localPoolId = dataId.localPoolId;
+ }
+ hkUpdateResetList->push_back(hkUpdateResetHelper);
}
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
- CommandMessage* message) {
- Command_t command = message->getCommand();
- sid_t sid = HousekeepingMessage::getSid(message);
- ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
- switch(command) {
- // Houskeeping interface handling.
- case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): {
- result = togglePeriodicGeneration(sid, true, true);
- break;
- }
+ CommandMessage* message) {
+ Command_t command = message->getCommand();
+ sid_t sid = HousekeepingMessage::getSid(message);
+ ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
+ switch(command) {
+ // Houskeeping interface handling.
+ case(HousekeepingMessage::ENABLE_PERIODIC_DIAGNOSTICS_GENERATION): {
+ result = togglePeriodicGeneration(sid, true, true);
+ break;
+ }
- case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION): {
- result = togglePeriodicGeneration(sid, false, true);
- break;
- }
+ case(HousekeepingMessage::DISABLE_PERIODIC_DIAGNOSTICS_GENERATION): {
+ result = togglePeriodicGeneration(sid, false, true);
+ break;
+ }
- case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION): {
- result = togglePeriodicGeneration(sid, true, false);
- break;
- }
+ case(HousekeepingMessage::ENABLE_PERIODIC_HK_REPORT_GENERATION): {
+ result = togglePeriodicGeneration(sid, true, false);
+ break;
+ }
- case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION): {
- result = togglePeriodicGeneration(sid, false, false);
- break;
- }
+ case(HousekeepingMessage::DISABLE_PERIODIC_HK_REPORT_GENERATION): {
+ result = togglePeriodicGeneration(sid, false, false);
+ break;
+ }
- case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): {
- result = generateSetStructurePacket(sid, true);
- if(result == HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
- break;
- }
-
- case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): {
- result = generateSetStructurePacket(sid, false);
+ case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES): {
+ result = generateSetStructurePacket(sid, true);
if(result == HasReturnvaluesIF::RETURN_OK) {
return result;
}
break;
- }
- case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL):
- case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): {
- float newCollIntvl = 0;
- HousekeepingMessage::getCollectionIntervalModificationCommand(message,
- &newCollIntvl);
- if(command == HousekeepingMessage::
- MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL) {
- result = changeCollectionInterval(sid, newCollIntvl, true);
- }
- else {
- result = changeCollectionInterval(sid, newCollIntvl, false);
- }
- break;
- }
+ }
- case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
- case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): {
- LocalPoolDataSetBase* dataSet =HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
- if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT
- and LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
- result = WRONG_HK_PACKET_TYPE;
- break;
- }
- else if(command == HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT
- and not LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
+ case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES): {
+ result = generateSetStructurePacket(sid, false);
+ if(result == HasReturnvaluesIF::RETURN_OK) {
+ return result;
+ }
+ break;
+ }
+ case(HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL):
+ case(HousekeepingMessage::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL): {
+ float newCollIntvl = 0;
+ HousekeepingMessage::getCollectionIntervalModificationCommand(message,
+ &newCollIntvl);
+ if(command == HousekeepingMessage::
+ MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL) {
+ result = changeCollectionInterval(sid, newCollIntvl, true);
+ }
+ else {
+ result = changeCollectionInterval(sid, newCollIntvl, false);
+ }
+ break;
+ }
+
+ case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
+ case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): {
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
+ if(dataSet == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleHousekeepingMessage",
+ DATASET_NOT_FOUND);
+ return DATASET_NOT_FOUND;
+ }
+ if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT
+ and LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
result = WRONG_HK_PACKET_TYPE;
break;
- }
- return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
- dataSet, true);
- }
+ }
+ else if(command == HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT
+ and not LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
+ result = WRONG_HK_PACKET_TYPE;
+ break;
+ }
+ return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
+ dataSet, true);
+ }
- /* Notification handling */
- case(HousekeepingMessage::UPDATE_NOTIFICATION_SET): {
- owner->handleChangedDataset(sid);
- return HasReturnvaluesIF::RETURN_OK;
- }
- case(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE): {
- gp_id_t globPoolId = HousekeepingMessage::getUpdateNotificationVariableCommand(message);
- owner->handleChangedPoolVariable(globPoolId);
- return HasReturnvaluesIF::RETURN_OK;
- }
- case(HousekeepingMessage::UPDATE_SNAPSHOT_SET): {
- store_address_t storeId;
- HousekeepingMessage::getUpdateSnapshotSetCommand(message, &storeId);
- bool clearMessage = true;
- owner->handleChangedDataset(sid, storeId, &clearMessage);
- if(clearMessage) {
- message->clear();
- }
- return HasReturnvaluesIF::RETURN_OK;
- }
- case(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE): {
- store_address_t storeId;
- gp_id_t globPoolId = HousekeepingMessage::getUpdateSnapshotVariableCommand(message,
- &storeId);
- bool clearMessage = true;
- owner->handleChangedPoolVariable(globPoolId, storeId, &clearMessage);
- if(clearMessage) {
- message->clear();
- }
- return HasReturnvaluesIF::RETURN_OK;
- }
+ /* Notification handling */
+ case(HousekeepingMessage::UPDATE_NOTIFICATION_SET): {
+ owner->handleChangedDataset(sid);
+ return HasReturnvaluesIF::RETURN_OK;
+ }
+ case(HousekeepingMessage::UPDATE_NOTIFICATION_VARIABLE): {
+ gp_id_t globPoolId = HousekeepingMessage::getUpdateNotificationVariableCommand(message);
+ owner->handleChangedPoolVariable(globPoolId);
+ return HasReturnvaluesIF::RETURN_OK;
+ }
+ case(HousekeepingMessage::UPDATE_SNAPSHOT_SET): {
+ store_address_t storeId;
+ HousekeepingMessage::getUpdateSnapshotSetCommand(message, &storeId);
+ bool clearMessage = true;
+ owner->handleChangedDataset(sid, storeId, &clearMessage);
+ if(clearMessage) {
+ message->clear();
+ }
+ return HasReturnvaluesIF::RETURN_OK;
+ }
+ case(HousekeepingMessage::UPDATE_SNAPSHOT_VARIABLE): {
+ store_address_t storeId;
+ gp_id_t globPoolId = HousekeepingMessage::getUpdateSnapshotVariableCommand(message,
+ &storeId);
+ bool clearMessage = true;
+ owner->handleChangedPoolVariable(globPoolId, storeId, &clearMessage);
+ if(clearMessage) {
+ message->clear();
+ }
+ return HasReturnvaluesIF::RETURN_OK;
+ }
- default:
- return CommandMessageIF::UNKNOWN_COMMAND;
- }
+ default:
+ return CommandMessageIF::UNKNOWN_COMMAND;
+ }
- CommandMessage reply;
- if(result != HasReturnvaluesIF::RETURN_OK) {
- HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result);
- }
- else {
- HousekeepingMessage::setHkRequestSuccessReply(&reply, sid);
- }
- hkQueue->sendMessage(hkDestinationId, &reply);
- return result;
+ CommandMessage reply;
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result);
+ }
+ else {
+ HousekeepingMessage::setHkRequestSuccessReply(&reply, sid);
+ }
+ hkQueue->sendMessage(hkDestinationId, &reply);
+ return result;
}
ReturnValue_t LocalDataPoolManager::printPoolEntry(
- lp_id_t localPoolId) {
- auto poolIter = localPoolMap.find(localPoolId);
- if (poolIter == localPoolMap.end()) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING, "printPoolEntry",
- localpool::POOL_ENTRY_NOT_FOUND);
- return localpool::POOL_ENTRY_NOT_FOUND;
- }
- poolIter->second->print();
- return HasReturnvaluesIF::RETURN_OK;
+ lp_id_t localPoolId) {
+ auto poolIter = localPoolMap.find(localPoolId);
+ if (poolIter == localPoolMap.end()) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING, "printPoolEntry",
+ localpool::POOL_ENTRY_NOT_FOUND);
+ return localpool::POOL_ENTRY_NOT_FOUND;
+ }
+ poolIter->second->print();
+ return HasReturnvaluesIF::RETURN_OK;
}
MutexIF* LocalDataPoolManager::getMutexHandle() {
- return mutex;
+ return mutex;
}
HasLocalDataPoolIF* LocalDataPoolManager::getOwner() {
- return owner;
+ return owner;
}
ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
- LocalPoolDataSetBase* dataSet, bool forDownlink,
- MessageQueueId_t destination) {
- if(dataSet == nullptr) {
- /* Configuration error. */
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "generateHousekeepingPacket",
- DATASET_NOT_FOUND);
- return DATASET_NOT_FOUND;
- }
+ LocalPoolDataSetBase* dataSet, bool forDownlink,
+ MessageQueueId_t destination) {
+ if(dataSet == nullptr) {
+ /* Configuration error. */
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "generateHousekeepingPacket",
+ DATASET_NOT_FOUND);
+ return DATASET_NOT_FOUND;
+ }
- store_address_t storeId;
- HousekeepingPacketDownlink hkPacket(sid, dataSet);
- size_t serializedSize = 0;
- ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId,
- forDownlink, &serializedSize);
- if(result != HasReturnvaluesIF::RETURN_OK or serializedSize == 0) {
- return result;
- }
+ store_address_t storeId;
+ HousekeepingPacketDownlink hkPacket(sid, dataSet);
+ size_t serializedSize = 0;
+ ReturnValue_t result = serializeHkPacketIntoStore(hkPacket, storeId,
+ forDownlink, &serializedSize);
+ if(result != HasReturnvaluesIF::RETURN_OK or serializedSize == 0) {
+ return result;
+ }
- /* Now we set a HK message and send it the HK packet destination. */
- CommandMessage hkMessage;
- if(LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
- HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId);
- }
- else {
- HousekeepingMessage::setHkReportReply(&hkMessage, sid, storeId);
- }
+ /* Now we set a HK message and send it the HK packet destination. */
+ CommandMessage hkMessage;
+ if(LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
+ HousekeepingMessage::setHkDiagnosticsReply(&hkMessage, sid, storeId);
+ }
+ else {
+ HousekeepingMessage::setHkReportReply(&hkMessage, sid, storeId);
+ }
- if(hkQueue == nullptr) {
- /* Error, no queue available to send packet with. */
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "generateHousekeepingPacket",
- QUEUE_OR_DESTINATION_INVALID);
- return QUEUE_OR_DESTINATION_INVALID;
- }
- if(destination == MessageQueueIF::NO_QUEUE) {
- if(hkDestinationId == MessageQueueIF::NO_QUEUE) {
- /* Error, all destinations invalid */
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "generateHousekeepingPacket",
- QUEUE_OR_DESTINATION_INVALID);
- }
- destination = hkDestinationId;
- }
+ if(hkQueue == nullptr) {
+ /* Error, no queue available to send packet with. */
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "generateHousekeepingPacket",
+ QUEUE_OR_DESTINATION_INVALID);
+ return QUEUE_OR_DESTINATION_INVALID;
+ }
+ if(destination == MessageQueueIF::NO_QUEUE) {
+ if(hkDestinationId == MessageQueueIF::NO_QUEUE) {
+ /* Error, all destinations invalid */
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "generateHousekeepingPacket",
+ QUEUE_OR_DESTINATION_INVALID);
+ }
+ destination = hkDestinationId;
+ }
- return hkQueue->sendMessage(destination, &hkMessage);
+ return hkQueue->sendMessage(destination, &hkMessage);
}
ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(
- HousekeepingPacketDownlink& hkPacket,
- store_address_t& storeId, bool forDownlink,
- size_t* serializedSize) {
- uint8_t* dataPtr = nullptr;
- const size_t maxSize = hkPacket.getSerializedSize();
- ReturnValue_t result = ipcStore->getFreeElement(&storeId,
- maxSize, &dataPtr);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- return result;
- }
+ HousekeepingPacketDownlink& hkPacket,
+ store_address_t& storeId, bool forDownlink,
+ size_t* serializedSize) {
+ uint8_t* dataPtr = nullptr;
+ const size_t maxSize = hkPacket.getSerializedSize();
+ ReturnValue_t result = ipcStore->getFreeElement(&storeId,
+ maxSize, &dataPtr);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ return result;
+ }
- if(forDownlink) {
- return hkPacket.serialize(&dataPtr, serializedSize, maxSize,
- SerializeIF::Endianness::BIG);
- }
- return hkPacket.serialize(&dataPtr, serializedSize, maxSize,
- SerializeIF::Endianness::MACHINE);
+ if(forDownlink) {
+ return hkPacket.serialize(&dataPtr, serializedSize, maxSize,
+ SerializeIF::Endianness::BIG);
+ }
+ return hkPacket.serialize(&dataPtr, serializedSize, maxSize,
+ SerializeIF::Endianness::MACHINE);
}
void LocalDataPoolManager::setNonDiagnosticIntervalFactor(
- uint8_t nonDiagInvlFactor) {
- this->nonDiagnosticIntervalFactor = nonDiagInvlFactor;
+ uint8_t nonDiagInvlFactor) {
+ this->nonDiagnosticIntervalFactor = nonDiagInvlFactor;
}
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
- sid_t sid = receiver.dataId.sid;
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
- if(dataSet == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "performPeriodicHkGeneration",
- DATASET_NOT_FOUND);
- return;
- }
+ sid_t sid = receiver.dataId.sid;
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
+ if(dataSet == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "performPeriodicHkGeneration",
+ DATASET_NOT_FOUND);
+ return;
+ }
- if(not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet)) {
- return;
- }
+ if(not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet)) {
+ return;
+ }
- PeriodicHousekeepingHelper* periodicHelper =
- LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
+ PeriodicHousekeepingHelper* periodicHelper =
+ LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
- if(periodicHelper == nullptr) {
- /* Configuration error */
- return;
- }
+ if(periodicHelper == nullptr) {
+ /* Configuration error */
+ return;
+ }
- if(not periodicHelper->checkOpNecessary()) {
- return;
- }
+ if(not periodicHelper->checkOpNecessary()) {
+ return;
+ }
- ReturnValue_t result = generateHousekeepingPacket(
- sid, dataSet, true);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- /* Configuration error */
+ ReturnValue_t result = generateHousekeepingPacket(
+ sid, dataSet, true);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ /* Configuration error */
#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::warning << "LocalDataPoolManager::performHkOperation: HK generation failed." <<
- std::endl;
+ sif::warning << "LocalDataPoolManager::performHkOperation: HK generation failed." <<
+ std::endl;
#else
- sif::printWarning("LocalDataPoolManager::performHkOperation: HK generation failed.\n");
+ sif::printWarning("LocalDataPoolManager::performHkOperation: HK generation failed.\n");
#endif
- }
+ }
}
ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid,
- bool enable, bool isDiagnostics) {
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
+ bool enable, bool isDiagnostics) {
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
if(dataSet == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "togglePeriodicGeneration",
DATASET_NOT_FOUND);
return DATASET_NOT_FOUND;
}
- if((LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and not isDiagnostics) or
- (not LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and isDiagnostics)) {
- return WRONG_HK_PACKET_TYPE;
- }
+ if((LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and not isDiagnostics) or
+ (not LocalPoolDataSetAttorney::isDiagnostics(*dataSet) and isDiagnostics)) {
+ return WRONG_HK_PACKET_TYPE;
+ }
- if((LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and enable) or
- (not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and not enable)) {
- return REPORTING_STATUS_UNCHANGED;
- }
+ if((LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and enable) or
+ (not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and not enable)) {
+ return REPORTING_STATUS_UNCHANGED;
+ }
- LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable);
- return HasReturnvaluesIF::RETURN_OK;
+ LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable);
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
- float newCollectionInterval, bool isDiagnostics) {
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
- if(dataSet == nullptr) {
+ float newCollectionInterval, bool isDiagnostics) {
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
+ if(dataSet == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval",
DATASET_NOT_FOUND);
- return DATASET_NOT_FOUND;
- }
+ return DATASET_NOT_FOUND;
+ }
- bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
- if((targetIsDiagnostics and not isDiagnostics) or
- (not targetIsDiagnostics and isDiagnostics)) {
- return WRONG_HK_PACKET_TYPE;
- }
+ bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
+ if((targetIsDiagnostics and not isDiagnostics) or
+ (not targetIsDiagnostics and isDiagnostics)) {
+ return WRONG_HK_PACKET_TYPE;
+ }
- PeriodicHousekeepingHelper* periodicHelper =
- LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
+ PeriodicHousekeepingHelper* periodicHelper =
+ LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
- if(periodicHelper == nullptr) {
- /* Configuration error, set might not have a corresponding pool manager */
- return PERIODIC_HELPER_INVALID;
- }
+ if(periodicHelper == nullptr) {
+ /* Configuration error, set might not have a corresponding pool manager */
+ return PERIODIC_HELPER_INVALID;
+ }
- periodicHelper->changeCollectionInterval(newCollectionInterval);
- return HasReturnvaluesIF::RETURN_OK;
+ periodicHelper->changeCollectionInterval(newCollectionInterval);
+ return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
- bool isDiagnostics) {
- /* Get and check dataset first. */
- LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
- if(dataSet == nullptr) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "performPeriodicHkGeneration", DATASET_NOT_FOUND);
- return DATASET_NOT_FOUND;
- }
+ bool isDiagnostics) {
+ /* Get and check dataset first. */
+ LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
+ if(dataSet == nullptr) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "performPeriodicHkGeneration", DATASET_NOT_FOUND);
+ return DATASET_NOT_FOUND;
+ }
- bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
- if((targetIsDiagnostics and not isDiagnostics) or
- (not targetIsDiagnostics and isDiagnostics)) {
- return WRONG_HK_PACKET_TYPE;
- }
+ bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
+ if((targetIsDiagnostics and not isDiagnostics) or
+ (not targetIsDiagnostics and isDiagnostics)) {
+ return WRONG_HK_PACKET_TYPE;
+ }
- bool valid = dataSet->isValid();
- bool reportingEnabled = LocalPoolDataSetAttorney::getReportingEnabled(*dataSet);
- float collectionInterval = LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet)->
- getCollectionIntervalInSeconds();
+ bool valid = dataSet->isValid();
+ bool reportingEnabled = LocalPoolDataSetAttorney::getReportingEnabled(*dataSet);
+ float collectionInterval = LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet)->
+ getCollectionIntervalInSeconds();
- // Generate set packet which can be serialized.
- HousekeepingSetPacket setPacket(sid,
- reportingEnabled, valid, collectionInterval, dataSet);
- size_t expectedSize = setPacket.getSerializedSize();
- uint8_t* storePtr = nullptr;
- store_address_t storeId;
- ReturnValue_t result = ipcStore->getFreeElement(&storeId,
- expectedSize,&storePtr);
- if(result != HasReturnvaluesIF::RETURN_OK) {
- printWarningOrError(sif::OutputTypes::OUT_ERROR,
- "generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED,
- "Could not get free element from IPC store.");
- return result;
- }
+ // Generate set packet which can be serialized.
+ HousekeepingSetPacket setPacket(sid,
+ reportingEnabled, valid, collectionInterval, dataSet);
+ size_t expectedSize = setPacket.getSerializedSize();
+ uint8_t* storePtr = nullptr;
+ store_address_t storeId;
+ ReturnValue_t result = ipcStore->getFreeElement(&storeId,
+ expectedSize,&storePtr);
+ if(result != HasReturnvaluesIF::RETURN_OK) {
+ printWarningOrError(sif::OutputTypes::OUT_ERROR,
+ "generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED,
+ "Could not get free element from IPC store.");
+ return result;
+ }
- // Serialize set packet into store.
- size_t size = 0;
- result = setPacket.serialize(&storePtr, &size, expectedSize,
- SerializeIF::Endianness::BIG);
- if(expectedSize != size) {
- printWarningOrError(sif::OutputTypes::OUT_WARNING,
- "generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED,
- "Expected size is not equal to serialized size");
- }
+ // Serialize set packet into store.
+ size_t size = 0;
+ result = setPacket.serialize(&storePtr, &size, expectedSize,
+ SerializeIF::Endianness::BIG);
+ if(expectedSize != size) {
+ printWarningOrError(sif::OutputTypes::OUT_WARNING,
+ "generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED,
+ "Expected size is not equal to serialized size");
+ }
- // Send structure reporting reply.
- CommandMessage reply;
- if(isDiagnostics) {
- HousekeepingMessage::setDiagnosticsStuctureReportReply(&reply,
- sid, storeId);
- }
- else {
- HousekeepingMessage::setHkStuctureReportReply(&reply,
- sid, storeId);
- }
+ // Send structure reporting reply.
+ CommandMessage reply;
+ if(isDiagnostics) {
+ HousekeepingMessage::setDiagnosticsStuctureReportReply(&reply,
+ sid, storeId);
+ }
+ else {
+ HousekeepingMessage::setHkStuctureReportReply(&reply,
+ sid, storeId);
+ }
- hkQueue->reply(&reply);
- return result;
+ hkQueue->reply(&reply);
+ return result;
}
void LocalDataPoolManager::clearReceiversList() {
- /* Clear the vector completely and releases allocated memory. */
- HkReceivers().swap(hkReceivers);
- /* Also clear the reset helper if it exists */
- if(hkUpdateResetList != nullptr) {
- HkUpdateResetList().swap(*hkUpdateResetList);
- }
+ /* Clear the vector completely and releases allocated memory. */
+ HkReceivers().swap(hkReceivers);
+ /* Also clear the reset helper if it exists */
+ if(hkUpdateResetList != nullptr) {
+ HkUpdateResetList().swap(*hkUpdateResetList);
+ }
}
MutexIF* LocalDataPoolManager::getLocalPoolMutex() {
- return this->mutex;
+ return this->mutex;
}
object_id_t LocalDataPoolManager::getCreatorObjectId() const {
- return owner->getObjectId();
+ return owner->getObjectId();
}
void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
- const char* functionName, ReturnValue_t error, const char* errorPrint) {
+ const char* functionName, ReturnValue_t error, const char* errorPrint) {
#if FSFW_VERBOSE_LEVEL >= 1
- if(errorPrint == nullptr) {
- if(error == DATASET_NOT_FOUND) {
- errorPrint = "Dataset not found";
- }
- else if(error == POOLOBJECT_NOT_FOUND) {
- errorPrint = "Pool Object not found";
- }
- else if(error == HasReturnvaluesIF::RETURN_FAILED) {
- if(outputType == sif::OutputTypes::OUT_WARNING) {
- errorPrint = "Generic Warning";
- }
- else {
- errorPrint = "Generic error";
- }
- }
- else if(error == QUEUE_OR_DESTINATION_INVALID) {
- errorPrint = "Queue or destination not set";
- }
- else if(error == localpool::POOL_ENTRY_TYPE_CONFLICT) {
- errorPrint = "Pool entry type conflict";
- }
- else if(error == localpool::POOL_ENTRY_NOT_FOUND) {
- errorPrint = "Pool entry not found";
- }
- else {
- errorPrint = "Unknown error";
- }
- }
- object_id_t objectId = 0xffffffff;
- if(owner != nullptr) {
- objectId = owner->getObjectId();
- }
+ if(errorPrint == nullptr) {
+ if(error == DATASET_NOT_FOUND) {
+ errorPrint = "Dataset not found";
+ }
+ else if(error == POOLOBJECT_NOT_FOUND) {
+ errorPrint = "Pool Object not found";
+ }
+ else if(error == HasReturnvaluesIF::RETURN_FAILED) {
+ if(outputType == sif::OutputTypes::OUT_WARNING) {
+ errorPrint = "Generic Warning";
+ }
+ else {
+ errorPrint = "Generic error";
+ }
+ }
+ else if(error == QUEUE_OR_DESTINATION_INVALID) {
+ errorPrint = "Queue or destination not set";
+ }
+ else if(error == localpool::POOL_ENTRY_TYPE_CONFLICT) {
+ errorPrint = "Pool entry type conflict";
+ }
+ else if(error == localpool::POOL_ENTRY_NOT_FOUND) {
+ errorPrint = "Pool entry not found";
+ }
+ else {
+ errorPrint = "Unknown error";
+ }
+ }
+ object_id_t objectId = 0xffffffff;
+ if(owner != nullptr) {
+ objectId = owner->getObjectId();
+ }
- if(outputType == sif::OutputTypes::OUT_WARNING) {
+ if(outputType == sif::OutputTypes::OUT_WARNING) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::warning << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
- std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
- std::dec << std::setfill(' ') << std::endl;
+ sif::warning << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
+ std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
+ std::dec << std::setfill(' ') << std::endl;
#else
- sif::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
- functionName, objectId, errorPrint);
+ sif::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
+ functionName, objectId, errorPrint);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
- }
- else if(outputType == sif::OutputTypes::OUT_ERROR) {
+ }
+ else if(outputType == sif::OutputTypes::OUT_ERROR) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::error << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
- std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
- std::dec << std::setfill(' ') << std::endl;
+ sif::error << "LocalDataPoolManager::" << functionName << ": Object ID 0x" <<
+ std::setw(8) << std::setfill('0') << std::hex << objectId << " | " << errorPrint <<
+ std::dec << std::setfill(' ') << std::endl;
#else
- sif::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
- functionName, objectId, errorPrint);
+ sif::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
+ functionName, objectId, errorPrint);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
- }
+ }
#endif /* #if FSFW_VERBOSE_LEVEL >= 1 */
}
LocalDataPoolManager* LocalDataPoolManager::getPoolManagerHandle() {
- return this;
+ return this;
}
diff --git a/datapoollocal/LocalPoolDataSetBase.cpp b/datapoollocal/LocalPoolDataSetBase.cpp
index a72e9db1..a7a7e6c8 100644
--- a/datapoollocal/LocalPoolDataSetBase.cpp
+++ b/datapoollocal/LocalPoolDataSetBase.cpp
@@ -3,6 +3,7 @@
#include "internal/HasLocalDpIFUserAttorney.h"
#include "../serviceinterface/ServiceInterface.h"
+#include "../objectmanager/ObjectManager.h"
#include "../globalfunctions/bitutility.h"
#include "../datapoollocal/LocalDataPoolManager.h"
#include "../housekeeping/PeriodicHousekeepingHelper.h"
@@ -45,7 +46,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
const size_t maxNumberOfVariables):
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
- HasLocalDataPoolIF* hkOwner = objectManager->get(
+ HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get(
sid.objectId);
if(hkOwner != nullptr) {
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
diff --git a/datapoollocal/LocalPoolObjectBase.cpp b/datapoollocal/LocalPoolObjectBase.cpp
index b6db0608..6920749b 100644
--- a/datapoollocal/LocalPoolObjectBase.cpp
+++ b/datapoollocal/LocalPoolObjectBase.cpp
@@ -4,7 +4,7 @@
#include "HasLocalDataPoolIF.h"
#include "internal/HasLocalDpIFUserAttorney.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
@@ -43,7 +43,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
"which is the NO_PARAMETER value!\n");
#endif
}
- HasLocalDataPoolIF* hkOwner = objectManager->get(poolOwner);
+ HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get(poolOwner);
if(hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVariable: The supplied pool owner did not implement the correct "
diff --git a/defaultcfg/fsfwconfig/CMakeLists.txt b/defaultcfg/fsfwconfig/CMakeLists.txt
index cbd4ecde..178fc273 100644
--- a/defaultcfg/fsfwconfig/CMakeLists.txt
+++ b/defaultcfg/fsfwconfig/CMakeLists.txt
@@ -1,15 +1,23 @@
-target_sources(${LIB_FSFW_NAME} PRIVATE
- ipc/missionMessageTypes.cpp
- objects/FsfwFactory.cpp
- pollingsequence/PollingSequenceFactory.cpp
-)
-
-# Should be added to include path
target_include_directories(${TARGET_NAME} PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}
)
-if(NOT FSFW_CONFIG_PATH)
- set(FSFW_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+target_sources(${TARGET_NAME} PRIVATE
+ ipc/missionMessageTypes.cpp
+ pollingsequence/PollingSequenceFactory.cpp
+ objects/FsfwFactory.cpp
+)
+
+# If a special translation file for object IDs exists, compile it.
+if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
+ target_sources(${TARGET_NAME} PRIVATE
+ objects/translateObjects.cpp
+ )
endif()
+# If a special translation file for events exists, compile it.
+if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/objects/translateObjects.cpp")
+ target_sources(${TARGET_NAME} PRIVATE
+ events/translateEvents.cpp
+ )
+endif()
diff --git a/defaultcfg/fsfwconfig/FSFWConfig.h b/defaultcfg/fsfwconfig/FSFWConfig.h
index fe18a2f4..adf9912f 100644
--- a/defaultcfg/fsfwconfig/FSFWConfig.h
+++ b/defaultcfg/fsfwconfig/FSFWConfig.h
@@ -7,27 +7,30 @@
//! 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
-#define FSFW_CPP_OSTREAM_ENABLED 1
+#define FSFW_CPP_OSTREAM_ENABLED 1
//! More FSFW related printouts depending on level. Useful for development.
-#define FSFW_VERBOSE_LEVEL 1
+#define FSFW_VERBOSE_LEVEL 1
//! Can be used to completely disable printouts, even the C stdio ones.
#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_VERBOSE_LEVEL == 0
- #define FSFW_DISABLE_PRINTOUT 0
+ #define FSFW_DISABLE_PRINTOUT 0
#endif
+#define FSFW_USE_PUS_C_TELEMETRY 1
+#define FSFW_USE_PUS_C_TELECOMMANDS 1
+
//! Can be used to disable the ANSI color sequences for C stdio.
-#define FSFW_COLORED_OUTPUT 1
+#define FSFW_COLORED_OUTPUT 1
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
//! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiled source files)
-#define FSFW_OBJ_EVENT_TRANSLATION 0
+#define FSFW_OBJ_EVENT_TRANSLATION 0
#if FSFW_OBJ_EVENT_TRANSLATION == 1
//! Specify whether info events are printed too.
-#define FSFW_DEBUG_INFO 1
+#define FSFW_DEBUG_INFO 1
#include "objects/translateObjects.h"
#include "events/translateEvents.h"
#else
@@ -35,22 +38,22 @@
//! When using the newlib nano library, C99 support for stdio facilities
//! will not be provided. This define should be set to 1 if this is the case.
-#define FSFW_NO_C99_IO 1
+#define FSFW_NO_C99_IO 1
//! Specify whether a special mode store is used for Subsystem components.
-#define FSFW_USE_MODESTORE 0
+#define FSFW_USE_MODESTORE 0
//! Defines if the real time scheduler for linux should be used.
//! If set to 0, this will also disable priority settings for linux
//! as most systems will not allow to set nice values without privileges
//! For embedded linux system set this to 1.
//! If set to 1 the binary needs "cap_sys_nice=eip" privileges to run
-#define FSFW_USE_REALTIME_FOR_LINUX 1
+#define FSFW_USE_REALTIME_FOR_LINUX 1
namespace fsfwconfig {
-//! Default timestamp size. The default timestamp will be an eight byte CDC
-//! short timestamp.
-static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 8;
+
+//! Default timestamp size. The default timestamp will be an seven byte CDC short timestamp.
+static constexpr uint8_t FSFW_MISSION_TIMESTAMP_SIZE = 7;
//! Configure the allocated pool sizes for the event manager.
static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
@@ -65,6 +68,8 @@ static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
+static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
+
}
#endif /* CONFIG_FSFWCONFIG_H_ */
diff --git a/devicehandlers/ChildHandlerBase.cpp b/devicehandlers/ChildHandlerBase.cpp
index d4ef67ad..628ea3e0 100644
--- a/devicehandlers/ChildHandlerBase.cpp
+++ b/devicehandlers/ChildHandlerBase.cpp
@@ -1,6 +1,5 @@
#include "ChildHandlerBase.h"
#include "../subsystem/SubsystemBase.h"
-#include "../subsystem/SubsystemBase.h"
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId,
object_id_t deviceCommunication, CookieIF * cookie,
@@ -30,7 +29,7 @@ ReturnValue_t ChildHandlerBase::initialize() {
MessageQueueId_t parentQueue = 0;
if (parentId != objects::NO_OBJECT) {
- SubsystemBase *parent = objectManager->get(parentId);
+ SubsystemBase *parent = ObjectManager::instance()->get(parentId);
if (parent == NULL) {
return RETURN_FAILED;
}
diff --git a/devicehandlers/DeviceHandlerBase.cpp b/devicehandlers/DeviceHandlerBase.cpp
index 1623a1ac..5665b101 100644
--- a/devicehandlers/DeviceHandlerBase.cpp
+++ b/devicehandlers/DeviceHandlerBase.cpp
@@ -119,7 +119,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return result;
}
- communicationInterface = objectManager->get(
+ communicationInterface = ObjectManager::instance()->get(
deviceCommunicationId);
if (communicationInterface == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
@@ -136,7 +136,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return result;
}
- IPCStore = objectManager->get(objects::IPC_STORE);
+ IPCStore = ObjectManager::instance()->get(objects::IPC_STORE);
if (IPCStore == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
ObjectManagerIF::CHILD_INIT_FAILED, "IPC Store not set up");
@@ -144,8 +144,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
}
if(rawDataReceiverId != objects::NO_OBJECT) {
- AcceptsDeviceResponsesIF *rawReceiver = objectManager->get<
- AcceptsDeviceResponsesIF>(rawDataReceiverId);
+ AcceptsDeviceResponsesIF *rawReceiver = ObjectManager::instance()->
+ get(rawDataReceiverId);
if (rawReceiver == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_ERROR,
@@ -164,7 +164,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
}
if(powerSwitcherId != objects::NO_OBJECT) {
- powerSwitcher = objectManager->get(powerSwitcherId);
+ powerSwitcher = ObjectManager::instance()->get(powerSwitcherId);
if (powerSwitcher == nullptr) {
printWarningOrError(sif::OutputTypes::OUT_ERROR,
"initialize", ObjectManagerIF::CHILD_INIT_FAILED,
@@ -226,16 +226,15 @@ ReturnValue_t DeviceHandlerBase::initialize() {
}
void DeviceHandlerBase::decrementDeviceReplyMap() {
- for (std::map::iterator iter =
- deviceReplyMap.begin(); iter != deviceReplyMap.end(); iter++) {
- if (iter->second.delayCycles != 0) {
- iter->second.delayCycles--;
- if (iter->second.delayCycles == 0) {
- if (iter->second.periodic) {
- iter->second.delayCycles = iter->second.maxDelayCycles;
+ for (std::pair& replyPair: deviceReplyMap) {
+ if (replyPair.second.delayCycles != 0) {
+ replyPair.second.delayCycles--;
+ if (replyPair.second.delayCycles == 0) {
+ if (replyPair.second.periodic) {
+ replyPair.second.delayCycles = replyPair.second.maxDelayCycles;
}
- replyToReply(iter, TIMEOUT);
- missedReply(iter->first);
+ replyToReply(replyPair.first, replyPair.second, TIMEOUT);
+ missedReply(replyPair.first);
}
}
}
@@ -584,17 +583,28 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status,
}
}
-void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
+void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceReplyInfo& replyInfo,
ReturnValue_t status) {
// No need to check if iter exists, as this is checked by callers.
// If someone else uses the method, add check.
- if (iter->second.command == deviceCommandMap.end()) {
+ if (replyInfo.command == deviceCommandMap.end()) {
//Is most likely periodic reply. Silent return.
return;
}
+ DeviceCommandInfo* info = &replyInfo.command->second;
+ if (info == nullptr){
+ printWarningOrError(sif::OutputTypes::OUT_ERROR,
+ "replyToReply", HasReturnvaluesIF::RETURN_FAILED,
+ "Command pointer not found");
+ return;
+ }
+
+ if (info->expectedReplies > 0){
+ // Check before to avoid underflow
+ info->expectedReplies--;
+ }
// Check if more replies are expected. If so, do nothing.
- DeviceCommandInfo* info = &(iter->second.command->second);
- if (--info->expectedReplies == 0) {
+ if (info->expectedReplies == 0) {
// Check if it was transition or internal command.
// Don't send any replies in that case.
if (info->sendReplyTo != NO_COMMANDER) {
@@ -602,7 +612,7 @@ void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
if(status == HasReturnvaluesIF::RETURN_OK) {
success = true;
}
- actionHelper.finish(success, info->sendReplyTo, iter->first, status);
+ actionHelper.finish(success, info->sendReplyTo, command, status);
}
info->isExecuting = false;
}
@@ -801,7 +811,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
replyRawReplyIfnotWiretapped(receivedData, foundLen);
triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId);
}
- replyToReply(iter, result);
+ replyToReply(iter->first, iter->second, result);
}
else {
/* Other completion failure messages are created by timeout.
diff --git a/devicehandlers/DeviceHandlerBase.h b/devicehandlers/DeviceHandlerBase.h
index 496c08ff..53bd1e65 100644
--- a/devicehandlers/DeviceHandlerBase.h
+++ b/devicehandlers/DeviceHandlerBase.h
@@ -667,7 +667,7 @@ protected:
static const ReturnValue_t CHILD_TIMEOUT = MAKE_RETURN_CODE(0xE0);
static const ReturnValue_t SWITCH_FAILED = MAKE_RETURN_CODE(0xE1);
- static const MessageQueueId_t NO_COMMANDER = 0;
+ static const MessageQueueId_t NO_COMMANDER = MessageQueueIF::NO_QUEUE;
//! Pointer to the raw packet that will be sent.
uint8_t *rawPacket = nullptr;
@@ -1195,7 +1195,8 @@ private:
* @foundLen the length of the packet
*/
void handleReply(const uint8_t *data, DeviceCommandId_t id, uint32_t foundLen);
- void replyToReply(DeviceReplyMap::iterator iter, ReturnValue_t status);
+ void replyToReply(const DeviceCommandId_t command, DeviceReplyInfo& replyInfo,
+ ReturnValue_t status);
/**
* Build and send a command to the device.
diff --git a/devicehandlers/DeviceHandlerFailureIsolation.cpp b/devicehandlers/DeviceHandlerFailureIsolation.cpp
index ba118090..b0708a59 100644
--- a/devicehandlers/DeviceHandlerFailureIsolation.cpp
+++ b/devicehandlers/DeviceHandlerFailureIsolation.cpp
@@ -1,6 +1,7 @@
#include "DeviceHandlerFailureIsolation.h"
#include "../devicehandlers/DeviceHandlerIF.h"
+#include "../objectmanager/ObjectManager.h"
#include "../modes/HasModesIF.h"
#include "../health/HealthTableIF.h"
#include "../power/Fuse.h"
@@ -175,7 +176,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
#endif
return result;
}
- ConfirmsFailuresIF* power = objectManager->get(
+ ConfirmsFailuresIF* power = ObjectManager::instance()->get(
powerConfirmationId);
if (power != nullptr) {
powerConfirmation = power->getEventReceptionQueue();
diff --git a/devicehandlers/DeviceHandlerMessage.cpp b/devicehandlers/DeviceHandlerMessage.cpp
index cb9043db..69c9deb9 100644
--- a/devicehandlers/DeviceHandlerMessage.cpp
+++ b/devicehandlers/DeviceHandlerMessage.cpp
@@ -1,5 +1,5 @@
#include "DeviceHandlerMessage.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
store_address_t DeviceHandlerMessage::getStoreAddress(
const CommandMessage* message) {
@@ -70,7 +70,7 @@ void DeviceHandlerMessage::clear(CommandMessage* message) {
case REPLY_RAW_COMMAND:
case REPLY_RAW_REPLY:
case REPLY_DIRECT_COMMAND_DATA: {
- StorageManagerIF *ipcStore = objectManager->get(
+ StorageManagerIF *ipcStore = ObjectManager::instance()->get(
objects::IPC_STORE);
if (ipcStore != nullptr) {
ipcStore->deleteData(getStoreAddress(message));
diff --git a/doc/README-config.md b/doc/README-config.md
index 036a7d14..d71feb97 100644
--- a/doc/README-config.md
+++ b/doc/README-config.md
@@ -1,12 +1,30 @@
-
-## Configuring the FSFW
+Configuring the FSFW
+======
The FSFW can be configured via the `fsfwconfig` folder. A template folder has
been provided to have a starting point for this. The folder should be added
-to the include path.
+to the include path. The primary configuration file is the `FSFWConfig.h` folder. Some
+of the available options will be explained in more detail here.
+# Auto-Translation of Events
-### Configuring the Event Manager
+The FSFW allows the automatic translation of events, which allows developers to track triggered
+events directly via console output. Using this feature requires:
+
+1. `FSFW_OBJ_EVENT_TRANSLATION` set to 1 in the configuration file.
+2. Special auto-generated translation files which translate event IDs and object IDs into
+ human readable strings. These files can be generated using the
+ [modgen Python scripts](https://git.ksat-stuttgart.de/source/modgen.git).
+3. The generated translation files for the object IDs should be named `translatesObjects.cpp`
+ and `translateObjects.h` and should be copied to the `fsfwconfig/objects` folder
+4. The generated translation files for the event IDs should be named `translateEvents.cpp` and
+ `translateEvents.h` and should be copied to the `fsfwconfig/events` folder
+
+An example implementations of these translation file generators can be found as part
+of the [SOURCE project here](https://git.ksat-stuttgart.de/source/sourceobsw/-/tree/development/generators)
+or the [FSFW example](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/generators)
+
+## Configuring the Event Manager
The number of allowed subscriptions can be modified with the following
parameters:
@@ -18,4 +36,5 @@ static constexpr size_t FSFW_EVENTMGMR_MATCHTREE_NODES = 240;
static constexpr size_t FSFW_EVENTMGMT_EVENTIDMATCHERS = 120;
static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
}
-```
\ No newline at end of file
+```
+
diff --git a/doc/README-core.md b/doc/README-core.md
index 6431b831..e34890ae 100644
--- a/doc/README-core.md
+++ b/doc/README-core.md
@@ -19,8 +19,9 @@ A nullptr check of the returning Pointer must be done. This function is based on
```cpp
template T* ObjectManagerIF::get( object_id_t id )
```
-* A typical way to create all objects on startup is a handing a static produce function to the ObjectManager on creation.
-By calling objectManager->initialize() the produce function will be called and all SystemObjects will be initialized afterwards.
+* A typical way to create all objects on startup is a handing a static produce function to the
+ ObjectManager on creation. By calling objectManager->initialize() the produce function will be
+ called and all SystemObjects will be initialized afterwards.
### Event Manager
@@ -36,14 +37,19 @@ By calling objectManager->initialize() the produce function will be called and a
### Stores
-* The message based communication can only exchange a few bytes of information inside the message itself. Therefore, additional information can
- be exchanged with Stores. With this, only the store address must be exchanged in the message.
-* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC Store is used. For outgoing TM a TM store is used.
+* The message based communication can only exchange a few bytes of information inside the message
+ itself. Therefore, additional information can be exchanged with Stores. With this, only the
+ store address must be exchanged in the message.
+* Internally, the FSFW uses an IPC Store to exchange data between processes. For incoming TCs a TC
+ Store is used. For outgoing TM a TM store is used.
* All of them should use the Thread Safe Class storagemanager/PoolManager
### Tasks
There are two different types of tasks:
- * The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the insertion to the Tasks.
- * FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for DeviceHandlers, where polling should be in a defined order. An example can be found in defaultcfg/fsfwconfig/pollingSequence
+ * The PeriodicTask just executes objects that are of type ExecutableObjectIF in the order of the
+ insertion to the Tasks.
+ * FixedTimeslotTask executes a list of calls in the order of the given list. This is intended for
+ DeviceHandlers, where polling should be in a defined order. An example can be found in
+ `defaultcfg/fsfwconfig/pollingSequence` folder
diff --git a/doc/README-highlevel.md b/doc/README-highlevel.md
index fac89c53..262138a7 100644
--- a/doc/README-highlevel.md
+++ b/doc/README-highlevel.md
@@ -1,99 +1,135 @@
-# High-level overview
+High-level overview
+======
-## Structure
+# Structure
The general structure is driven by the usage of interfaces provided by objects.
-The FSFW uses C++11 as baseline. The intention behind this is that this C++ Standard should be widely available, even with older compilers.
+The 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.
+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
+# Failure Handling
-Functions should return a defined ReturnValue_t to signal to the caller that something has gone wrong.
-Returnvalues must be unique. For this the function HasReturnvaluesIF::makeReturnCode or the Macro MAKE_RETURN can be used.
-The CLASS_ID is a unique id for that type of object. See returnvalues/FwClassIds.
+Functions should return a defined `ReturnValue_t` to signal to the caller that something has
+gone wrong. Returnvalues must be unique. For this the function `HasReturnvaluesIF::makeReturnCode`
+or the macro `MAKE_RETURN` can be used. The `CLASS_ID` is a unique id for that type of object.
+See `returnvalues/FwClassIds` folder. The user can add custom `CLASS_ID`s via the
+`fsfwconfig` folder.
-### OSAL
+# OSAL
The FSFW provides operation system abstraction layers for Linux, FreeRTOS and RTEMS.
The OSAL provides periodic tasks, message queues, clocks and semaphores as well as mutexes.
-The [OSAL README](doc/README-osal.md#top) provides more detailed information on provided components and how to use them.
+The [OSAL README](doc/README-osal.md#top) provides more detailed information on provided components
+and how to use them.
-### Core Components
+# Core Components
The FSFW has following core components. More detailed informations can be found in the
[core component section](doc/README-core.md#top):
-1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks with fixed timeslots
-2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID to the object handles.
-3. Static Stores: Different stores are provided to store data of variable size (like telecommands or small telemetry) in a pool structure without
- using dynamic memory allocation. These pools are allocated up front.
+1. Tasks: Abstraction for different (periodic) task types like periodic tasks or tasks
+ with fixed timeslots
+2. ObjectManager: This module stores all `SystemObjects` by mapping a provided unique object ID
+ to the object handles.
+3. Static Stores: Different stores are provided to store data of variable size (like telecommands
+ or small telemetry) in a pool structure without using dynamic memory allocation.
+ These pools are allocated up front.
3. Clock: This module provided common time related functions
4. EventManager: This module allows routing of events generated by `SystemObjects`
5. HealthTable: A component which stores the health states of objects
-### Static IDs in the framework
+# Static IDs in the framework
Some parts of the framework use a static routing address for communication.
-An example setup of ids can be found in the example config in "defaultcft/fsfwconfig/objects/Factory::setStaticFrameworkObjectIds()".
+An example setup of ids can be found in the example config in `defaultcft/fsfwconfig/objects`
+ inside the function `Factory::setStaticFrameworkObjectIds()`.
-### Events
+# Events
-Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT. This works analog to the returnvalues.
-Every object that needs own EventIds has to get a unique SUBSYSTEM_ID.
-Every SystemObject can call triggerEvent from the parent class.
-Therefore, event messages contain the specific EventId and the objectId of the object that has triggered.
+Events are tied to objects. EventIds can be generated by calling the Macro MAKE_EVENT.
+This works analog to the returnvalues. Every object that needs own EventIds has to get a
+unique SUBSYSTEM_ID. Every SystemObject can call triggerEvent from the parent class.
+Therefore, event messages contain the specific EventId and the objectId of the object that
+has triggered.
-### Internal Communication
+# Internal Communication
-Components communicate mostly over Message through Queues.
-Those queues are created by calling the singleton QueueFactory::instance()->create().
+Components communicate mostly via Messages through Queues.
+Those queues are created by calling the singleton `QueueFactory::instance()->create()` which
+will create `MessageQueue` instances for the used OSAL.
-### External Communication
+# External Communication
The external communication with the mission control system is mostly up to the user implementation.
The FSFW provides PUS Services which can be used to but don't need to be used.
The services can be seen as a conversion from a TC to a message based communication and back.
-#### CCSDS Frames, CCSDS Space Packets and PUS
+## TMTC Communication
-If the communication is based on CCSDS Frames and Space Packets, several classes can be used to distributed the packets to the corresponding services. Those can be found in tcdistribution.
-If Space Packets are used, a timestamper must be created.
-An example can be found in the timemanager folder, this uses CCSDSTime::CDS_short.
+The FSFW provides some components to facilitate TMTC handling via the PUS commands.
+For example, a UDP or TCP PUS server socket can be opened on a specific port using the
+files located in `osal/common`. The FSFW example uses this functionality to allow sending telecommands
+and receiving telemetry using the [TMTC commander application](https://github.com/spacefisch/tmtccmd).
+Simple commands like the PUS Service 17 ping service can be tested by simply running the
+`tmtc_client_cli.py` or `tmtc_client_gui.py` utility in
+the [example tmtc folder](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_example_public/src/branch/master/tmtc)
+while the `fsfw_example` application is running.
-#### Device Handlers
+More generally, any class responsible for handling incoming telecommands and sending telemetry
+can implement the generic `TmTcBridge` class located in `tmtcservices`. Many applications
+also use a dedicated polling task for reading telecommands which passes telecommands
+to the `TmTcBridge` implementation.
+
+## CCSDS Frames, CCSDS Space Packets and PUS
+
+If the communication is based on CCSDS Frames and Space Packets, several classes can be used to
+distributed the packets to the corresponding services. Those can be found in `tcdistribution`.
+If Space Packets are used, a timestamper has to be provided by the user.
+An example can be found in the `timemanager` folder, which uses `CCSDSTime::CDS_short`.
+
+# Device Handlers
DeviceHandlers are another important component of the FSFW.
-The idea is, to have a software counterpart of every physical device to provide a simple mode, health and commanding interface.
-By separating the underlying Communication Interface with DeviceCommunicationIF, a device handler (DH) can be tested on different hardware.
-The DH has mechanisms to monitor the communication with the physical device which allow for FDIR reaction.
-Device Handlers can be created by overriding `DeviceHandlerBase`.
-A standard FDIR component for the DH will be created automatically but can be overwritten by the user.
-More information on DeviceHandlers can be found in the related [documentation section](doc/README-devicehandlers.md#top).
+The idea is, to have a software counterpart of every physical device to provide a simple mode,
+health and commanding interface. By separating the underlying Communication Interface with
+`DeviceCommunicationIF`, a device handler (DH) can be tested on different hardware.
+The DH has mechanisms to monitor the communication with the physical device which allow
+for FDIR reaction. Device Handlers can be created by implementing `DeviceHandlerBase`.
+A standard FDIR component for the DH will be created automatically but can
+be overwritten by the user. More information on DeviceHandlers can be found in the
+related [documentation section](doc/README-devicehandlers.md#top).
-#### Modes, Health
+# Modes and Health
-The two interfaces HasModesIF and HasHealthIF provide access for commanding and monitoring of components.
-On-board Mode Management is implement in hierarchy system.
+The two interfaces `HasModesIF` and `HasHealthIF` provide access for commanding and monitoring
+of components. On-board Mode Management is implement in hierarchy system.
DeviceHandlers and Controllers are the lowest part of the hierarchy.
-The next layer are Assemblies. Those assemblies act as a component which handle redundancies of handlers.
-Assemblies share a common core with the next level which are the Subsystems.
+The next layer are Assemblies. Those assemblies act as a component which handle
+redundancies of handlers. Assemblies share a common core with the next level which
+are the Subsystems.
-Those Assemblies are intended to act as auto-generated components from a database which describes the subsystem modes.
-The definitions contain transition and target tables which contain the DH, Assembly and Controller Modes to be commanded.
-Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a switch into any higher AOCS mode might first turn on the sensors, than the actuators and the controller as last component.
+Those Assemblies are intended to act as auto-generated components from a database which describes
+the subsystem modes. The definitions contain transition and target tables which contain the DH,
+Assembly and Controller Modes to be commanded.
+Transition tables contain as many steps as needed to reach the mode from any other mode, e.g. a
+switch into any higher AOCS mode might first turn on the sensors, than the actuators and the
+controller as last component.
The target table is used to describe the state that is checked continuously by the subsystem.
All of this allows System Modes to be generated as Subsystem object as well from the same database.
This System contains list of subsystem modes in the transition and target tables.
-Therefore, it allows a modular system to create system modes and easy commanding of those, because only the highest components must be commanded.
+Therefore, it allows a modular system to create system modes and easy commanding of those, because
+only the highest components must be commanded.
The health state represents if the component is able to perform its tasks.
This can be used to signal the system to avoid using this component instead of a redundant one.
The on-board FDIR uses the health state for isolation and recovery.
-## Unit Tests
+# Unit Tests
-Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include catch2 itself. More information on how to run these tests can be found in the separate
+Unit Tests are provided in the unittest folder. Those use the catch2 framework but do not include
+catch2 itself. More information on how to run these tests can be found in the separate
[`fsfw_tests` reposoitory](https://egit.irs.uni-stuttgart.de/fsfw/fsfw_tests)
diff --git a/events/EventManager.cpp b/events/EventManager.cpp
index 5b2b31b5..8e2a2a82 100644
--- a/events/EventManager.cpp
+++ b/events/EventManager.cpp
@@ -1,8 +1,6 @@
#include "EventManager.h"
#include "EventMessage.h"
-#include
-#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../ipc/QueueFactory.h"
#include "../ipc/MutexFactory.h"
@@ -115,53 +113,6 @@ ReturnValue_t EventManager::unsubscribeFromEventRange(MessageQueueId_t listener,
return result;
}
-#if FSFW_OBJ_EVENT_TRANSLATION == 1
-
-void EventManager::printEvent(EventMessage* message) {
- const char *string = 0;
- switch (message->getSeverity()) {
- case severity::INFO:
-#if DEBUG_INFO_EVENT == 1
- string = translateObject(message->getReporter());
-#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::info << "EVENT: ";
- if (string != 0) {
- sif::info << string;
- } else {
- sif::info << "0x" << std::hex << message->getReporter() << std::dec;
- }
- sif::info << " reported " << translateEvents(message->getEvent()) << " ("
- << std::dec << message->getEventId() << std::hex << ") P1: 0x"
- << message->getParameter1() << " P2: 0x"
- << message->getParameter2() << std::dec << std::endl;
-#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
-#endif /* DEBUG_INFO_EVENT == 1 */
- break;
- default:
- string = translateObject(message->getReporter());
-#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::debug << "EventManager: ";
- if (string != 0) {
- sif::debug << string;
- }
- else {
- sif::debug << "0x" << std::hex << message->getReporter() << std::dec;
- }
- sif::debug << " reported " << translateEvents(message->getEvent())
- << " (" << std::dec << message->getEventId() << ") "
- << std::endl;
- sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1()
- << ", P1 Dec: " << std::dec << message->getParameter1()
- << std::endl;
- sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2()
- << ", P2 Dec: " << std::dec << message->getParameter2()
- << std::endl;
-#endif
- break;
- }
-}
-#endif
-
void EventManager::lockMutex() {
mutex->lockMutex(timeoutType, timeoutMs);
}
@@ -175,3 +126,85 @@ void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType,
this->timeoutType = timeoutType;
this->timeoutMs = timeoutMs;
}
+
+#if FSFW_OBJ_EVENT_TRANSLATION == 1
+
+void EventManager::printEvent(EventMessage* message) {
+ switch (message->getSeverity()) {
+ case severity::INFO: {
+#if FSFW_DEBUG_INFO == 1
+ printUtility(sif::OutputTypes::OUT_INFO, message);
+#endif /* DEBUG_INFO_EVENT == 1 */
+ break;
+ }
+ default:
+ printUtility(sif::OutputTypes::OUT_DEBUG, message);
+ break;
+ }
+}
+
+void EventManager::printUtility(sif::OutputTypes printType, EventMessage *message) {
+ const char *string = 0;
+ if(printType == sif::OutputTypes::OUT_INFO) {
+ string = translateObject(message->getReporter());
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ sif::info << "EventManager: ";
+ if (string != 0) {
+ sif::info << string;
+ }
+ else {
+ sif::info << "0x" << std::hex << std::setw(8) << std::setfill('0') <<
+ message->getReporter() << std::setfill(' ') << std::dec;
+ }
+ sif::info << " reported event with ID " << message->getEventId() << std::endl;
+ sif::debug << translateEvents(message->getEvent()) << " | " <getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() <<
+ std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " <<
+ std::dec << message->getParameter2() << std::endl;
+#else
+ if (string != 0) {
+ sif::printInfo("Event Manager: %s reported event with ID %d\n", string,
+ message->getEventId());
+ }
+ else {
+ sif::printInfo("Event Manager: Reporter ID 0x%08x reported event with ID %d\n",
+ message->getReporter(), message->getEventId());
+ }
+ sif::printInfo("P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n",
+ message->getParameter1(), message->getParameter1(),
+ message->getParameter2(), message->getParameter2());
+#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
+ }
+ else {
+ string = translateObject(message->getReporter());
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ sif::debug << "EventManager: ";
+ if (string != 0) {
+ sif::debug << string;
+ }
+ else {
+ sif::debug << "0x" << std::hex << std::setw(8) << std::setfill('0') <<
+ message->getReporter() << std::setfill(' ') << std::dec;
+ }
+ sif::debug << " reported event with ID " << message->getEventId() << std::endl;
+ sif::debug << translateEvents(message->getEvent()) << " | " <getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() <<
+ std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " <<
+ std::dec << message->getParameter2() << std::endl;
+#else
+ if (string != 0) {
+ sif::printDebug("Event Manager: %s reported event with ID %d\n", string,
+ message->getEventId());
+ }
+ else {
+ sif::printDebug("Event Manager: Reporter ID 0x%08x reported event with ID %d\n",
+ message->getReporter(), message->getEventId());
+ }
+ sif::printDebug("P1 Hex: 0x%x | P1 Dec: %d | P2 Hex: 0x%x | P2 Dec: %d\n",
+ message->getParameter1(), message->getParameter1(),
+ message->getParameter2(), message->getParameter2());
+#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
+ }
+}
+
+#endif /* FSFW_OBJ_EVENT_TRANSLATION == 1 */
diff --git a/events/EventManager.h b/events/EventManager.h
index abce9b8b..012247db 100644
--- a/events/EventManager.h
+++ b/events/EventManager.h
@@ -3,9 +3,9 @@
#include "EventManagerIF.h"
#include "eventmatching/EventMatchTree.h"
+#include "FSFWConfig.h"
-#include
-
+#include "../serviceinterface/ServiceInterface.h"
#include "../objectmanager/SystemObject.h"
#include "../storagemanager/LocalPool.h"
#include "../tasks/ExecutableObjectIF.h"
@@ -67,6 +67,7 @@ protected:
#if FSFW_OBJ_EVENT_TRANSLATION == 1
void printEvent(EventMessage *message);
+ void printUtility(sif::OutputTypes printType, EventMessage* message);
#endif
void lockMutex();
diff --git a/events/EventManagerIF.h b/events/EventManagerIF.h
index ea22f8ae..0ba126a2 100644
--- a/events/EventManagerIF.h
+++ b/events/EventManagerIF.h
@@ -3,7 +3,7 @@
#include "EventMessage.h"
#include "eventmatching/eventmatching.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
#include "../ipc/MessageQueueSenderIF.h"
#include "../ipc/MessageQueueIF.h"
#include "../serviceinterface/ServiceInterface.h"
@@ -43,7 +43,7 @@ public:
static void triggerEvent(EventMessage* message,
MessageQueueId_t sentFrom = 0) {
if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) {
- EventManagerIF *eventmanager = objectManager->get(
+ EventManagerIF *eventmanager = ObjectManager::instance()->get(
objects::EVENT_MANAGER);
if (eventmanager == nullptr) {
#if FSFW_VERBOSE_LEVEL >= 1
diff --git a/events/fwSubsystemIdRanges.h b/events/fwSubsystemIdRanges.h
index 1b0b238e..88dee9b4 100644
--- a/events/fwSubsystemIdRanges.h
+++ b/events/fwSubsystemIdRanges.h
@@ -1,30 +1,37 @@
#ifndef FSFW_EVENTS_FWSUBSYSTEMIDRANGES_H_
#define FSFW_EVENTS_FWSUBSYSTEMIDRANGES_H_
+#include
+
namespace SUBSYSTEM_ID {
-enum {
- MEMORY = 22,
- OBSW = 26,
- CDH = 28,
- TCS_1 = 59,
- PCDU_1 = 42,
- PCDU_2 = 43,
- HEATER = 50,
- T_SENSORS = 52,
- FDIR = 70,
- FDIR_1 = 71,
- FDIR_2 = 72,
- HK = 73,
- SYSTEM_MANAGER = 74,
- SYSTEM_MANAGER_1 = 75,
- SYSTEM_1 = 79,
- PUS_SERVICE_1 = 80,
- PUS_SERVICE_9 = 89,
- PUS_SERVICE_17 = 97,
- FW_SUBSYSTEM_ID_RANGE
+enum: uint8_t {
+ MEMORY = 22,
+ OBSW = 26,
+ CDH = 28,
+ TCS_1 = 59,
+ PCDU_1 = 42,
+ PCDU_2 = 43,
+ HEATER = 50,
+ T_SENSORS = 52,
+ FDIR = 70,
+ FDIR_1 = 71,
+ FDIR_2 = 72,
+ HK = 73,
+ SYSTEM_MANAGER = 74,
+ SYSTEM_MANAGER_1 = 75,
+ SYSTEM_1 = 79,
+ PUS_SERVICE_1 = 80,
+ PUS_SERVICE_2 = 82,
+ PUS_SERVICE_3 = 83,
+ PUS_SERVICE_5 = 85,
+ PUS_SERVICE_6 = 86,
+ PUS_SERVICE_8 = 88,
+ PUS_SERVICE_9 = 89,
+ PUS_SERVICE_17 = 97,
+ PUS_SERVICE_23 = 103,
+
+ FW_SUBSYSTEM_ID_RANGE
};
}
-
-
#endif /* FSFW_EVENTS_FWSUBSYSTEMIDRANGES_H_ */
diff --git a/fdir/FailureIsolationBase.cpp b/fdir/FailureIsolationBase.cpp
index 69cb0f01..764fc918 100644
--- a/fdir/FailureIsolationBase.cpp
+++ b/fdir/FailureIsolationBase.cpp
@@ -3,7 +3,7 @@
#include "../health/HasHealthIF.h"
#include "../health/HealthMessage.h"
#include "../ipc/QueueFactory.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
FailureIsolationBase::FailureIsolationBase(object_id_t owner,
object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) :
@@ -18,7 +18,7 @@ FailureIsolationBase::~FailureIsolationBase() {
}
ReturnValue_t FailureIsolationBase::initialize() {
- EventManagerIF* manager = objectManager->get(
+ EventManagerIF* manager = ObjectManager::instance()->get(
objects::EVENT_MANAGER);
if (manager == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
@@ -36,7 +36,7 @@ ReturnValue_t FailureIsolationBase::initialize() {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
- owner = objectManager->get(ownerId);
+ owner = ObjectManager::instance()->get(ownerId);
if (owner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::intialize: Owner object "
@@ -46,7 +46,7 @@ ReturnValue_t FailureIsolationBase::initialize() {
}
}
if (faultTreeParent != objects::NO_OBJECT) {
- ConfirmsFailuresIF* parentIF = objectManager->get(
+ ConfirmsFailuresIF* parentIF = ObjectManager::instance()->get(
faultTreeParent);
if (parentIF == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
diff --git a/globalfunctions/arrayprinter.cpp b/globalfunctions/arrayprinter.cpp
index 0423360b..3c729c6b 100644
--- a/globalfunctions/arrayprinter.cpp
+++ b/globalfunctions/arrayprinter.cpp
@@ -5,6 +5,15 @@
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
bool printInfo, size_t maxCharPerLine) {
+ if(size == 0) {
+#if FSFW_CPP_OSTREAM_ENABLED == 1
+ sif::info << "Size is zero, nothing to print" << std::endl;
+#else
+ sif::printInfo("Size is zero, nothing to print\n");
+#endif
+ return;
+ }
+
#if FSFW_CPP_OSTREAM_ENABLED == 1
if(printInfo) {
sif::info << "Printing data with size " << size << ": " << std::endl;
diff --git a/health/HealthHelper.cpp b/health/HealthHelper.cpp
index 231d616e..28419108 100644
--- a/health/HealthHelper.cpp
+++ b/health/HealthHelper.cpp
@@ -1,5 +1,5 @@
#include "HealthHelper.h"
-#include "../serviceinterface/ServiceInterfaceStream.h"
+#include "../serviceinterface/ServiceInterface.h"
HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) :
objectId(objectId), owner(owner) {
@@ -37,8 +37,8 @@ void HealthHelper::setParentQueue(MessageQueueId_t parentQueue) {
}
ReturnValue_t HealthHelper::initialize() {
- healthTable = objectManager->get(objects::HEALTH_TABLE);
- eventSender = objectManager->get(objectId);
+ healthTable = ObjectManager::instance()->get(objects::HEALTH_TABLE);
+ eventSender = ObjectManager::instance()->get(objectId);
if (healthTable == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
diff --git a/housekeeping/HousekeepingMessage.cpp b/housekeeping/HousekeepingMessage.cpp
index 90ca73c8..71f7ff17 100644
--- a/housekeeping/HousekeepingMessage.cpp
+++ b/housekeeping/HousekeepingMessage.cpp
@@ -1,6 +1,6 @@
#include "HousekeepingMessage.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
#include
HousekeepingMessage::~HousekeepingMessage() {}
@@ -161,7 +161,7 @@ void HousekeepingMessage::clear(CommandMessage* message) {
case(UPDATE_SNAPSHOT_VARIABLE): {
store_address_t storeId;
getHkDataReply(message, &storeId);
- StorageManagerIF *ipcStore = objectManager->get(
+ StorageManagerIF *ipcStore = ObjectManager::instance()->get(
objects::IPC_STORE);
if (ipcStore != nullptr) {
ipcStore->deleteData(storeId);
diff --git a/ipc/CommandMessageCleaner.cpp b/ipc/CommandMessageCleaner.cpp
index 6a364069..29998124 100644
--- a/ipc/CommandMessageCleaner.cpp
+++ b/ipc/CommandMessageCleaner.cpp
@@ -1,5 +1,6 @@
#include "CommandMessageCleaner.h"
+#include "../memory/GenericFileSystemMessage.h"
#include "../devicehandlers/DeviceHandlerMessage.h"
#include "../health/HealthMessage.h"
#include "../memory/MemoryMessage.h"
@@ -42,6 +43,9 @@ void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) {
case messagetypes::HOUSEKEEPING:
HousekeepingMessage::clear(message);
break;
+ case messagetypes::FILE_SYSTEM_MESSAGE:
+ GenericFileSystemMessage::clear(message);
+ break;
default:
messagetypes::clearMissionMessage(message);
break;
diff --git a/ipc/MessageQueueIF.h b/ipc/MessageQueueIF.h
index 74ccb29a..217174f6 100644
--- a/ipc/MessageQueueIF.h
+++ b/ipc/MessageQueueIF.h
@@ -22,11 +22,11 @@ public:
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
//! No new messages on the queue
static const ReturnValue_t EMPTY = MAKE_RETURN_CODE(1);
- //! No space left for more messages
+ //! [EXPORT] : [COMMENT] No space left for more messages
static const ReturnValue_t FULL = MAKE_RETURN_CODE(2);
- //! Returned if a reply method was called without partner
+ //! [EXPORT] : [COMMENT] Returned if a reply method was called without partner
static const ReturnValue_t NO_REPLY_PARTNER = MAKE_RETURN_CODE(3);
- //! Returned if the target destination is invalid.
+ //! [EXPORT] : [COMMENT] Returned if the target destination is invalid.
static constexpr ReturnValue_t DESTINATION_INVALID = MAKE_RETURN_CODE(4);
virtual ~MessageQueueIF() {}
diff --git a/memory/CMakeLists.txt b/memory/CMakeLists.txt
index 9edb9031..c713cd42 100644
--- a/memory/CMakeLists.txt
+++ b/memory/CMakeLists.txt
@@ -1,5 +1,5 @@
-target_sources(${LIB_FSFW_NAME}
- PRIVATE
- MemoryHelper.cpp
- MemoryMessage.cpp
+target_sources(${LIB_FSFW_NAME} PRIVATE
+ MemoryHelper.cpp
+ MemoryMessage.cpp
+ GenericFileSystemMessage.cpp
)
\ No newline at end of file
diff --git a/memory/GenericFileSystemMessage.cpp b/memory/GenericFileSystemMessage.cpp
new file mode 100644
index 00000000..b0e1a9ec
--- /dev/null
+++ b/memory/GenericFileSystemMessage.cpp
@@ -0,0 +1,161 @@
+#include "GenericFileSystemMessage.h"
+
+#include "../objectmanager/ObjectManager.h"
+#include "../storagemanager/StorageManagerIF.h"
+
+void GenericFileSystemMessage::setCreateFileCommand(CommandMessage* message,
+ store_address_t storeId) {
+ message->setCommand(CMD_CREATE_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setDeleteFileCommand(
+ CommandMessage* message, store_address_t storeId) {
+ message->setCommand(CMD_DELETE_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setCreateDirectoryCommand(
+ CommandMessage* message, store_address_t storeId) {
+ message->setCommand(CMD_CREATE_DIRECTORY);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setReportFileAttributesCommand(CommandMessage *message,
+ store_address_t storeId) {
+ message->setCommand(CMD_REPORT_FILE_ATTRIBUTES);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setReportFileAttributesReply(CommandMessage *message,
+ store_address_t storeId) {
+ message->setCommand(REPLY_REPORT_FILE_ATTRIBUTES);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setDeleteDirectoryCommand(CommandMessage* message,
+ store_address_t storeId) {
+ message->setCommand(CMD_DELETE_DIRECTORY);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setLockFileCommand(CommandMessage *message,
+ store_address_t storeId) {
+ message->setCommand(CMD_LOCK_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setUnlockFileCommand(CommandMessage *message,
+ store_address_t storeId) {
+ message->setCommand(CMD_UNLOCK_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setSuccessReply(CommandMessage *message) {
+ message->setCommand(COMPLETION_SUCCESS);
+}
+
+void GenericFileSystemMessage::setFailureReply(CommandMessage *message,
+ ReturnValue_t errorCode, uint32_t errorParam) {
+ message->setCommand(COMPLETION_FAILED);
+ message->setParameter(errorCode);
+ message->setParameter2(errorParam);
+}
+
+store_address_t GenericFileSystemMessage::getStoreId(const CommandMessage* message) {
+ store_address_t temp;
+ temp.raw = message->getParameter2();
+ return temp;
+}
+
+ReturnValue_t GenericFileSystemMessage::getFailureReply(
+ const CommandMessage *message, uint32_t* errorParam) {
+ if(errorParam != nullptr) {
+ *errorParam = message->getParameter2();
+ }
+ return message->getParameter();
+}
+
+void GenericFileSystemMessage::setFinishStopWriteCommand(CommandMessage *message,
+ store_address_t storeId) {
+ message->setCommand(CMD_FINISH_APPEND_TO_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setFinishStopWriteReply(CommandMessage *message,
+ store_address_t storeId) {
+ message->setCommand(REPLY_FINISH_APPEND);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setCopyCommand(CommandMessage* message,
+ store_address_t storeId) {
+ message->setCommand(CMD_COPY_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setWriteCommand(CommandMessage* message,
+ store_address_t storeId) {
+ message->setCommand(CMD_APPEND_TO_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setReadCommand(CommandMessage* message,
+ store_address_t storeId) {
+ message->setCommand(CMD_READ_FROM_FILE);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setFinishAppendReply(CommandMessage* message,
+ store_address_t storageID) {
+ message->setCommand(REPLY_FINISH_APPEND);
+ message->setParameter2(storageID.raw);
+}
+
+void GenericFileSystemMessage::setReadReply(CommandMessage* message,
+ bool readFinished, store_address_t storeId) {
+ message->setCommand(REPLY_READ_FROM_FILE);
+ message->setParameter(readFinished);
+ message->setParameter2(storeId.raw);
+}
+
+void GenericFileSystemMessage::setReadFinishedReply(CommandMessage *message,
+ store_address_t storeId) {
+ message->setCommand(REPLY_READ_FINISHED_STOP);
+ message->setParameter2(storeId.raw);
+}
+
+bool GenericFileSystemMessage::getReadReply(const CommandMessage *message,
+ store_address_t *storeId) {
+ if(storeId != nullptr) {
+ (*storeId).raw = message->getParameter2();
+ }
+ return message->getParameter();
+}
+
+ReturnValue_t GenericFileSystemMessage::clear(CommandMessage* message) {
+ switch(message->getCommand()) {
+ case(CMD_CREATE_FILE):
+ case(CMD_DELETE_FILE):
+ case(CMD_CREATE_DIRECTORY):
+ case(CMD_REPORT_FILE_ATTRIBUTES):
+ case(REPLY_REPORT_FILE_ATTRIBUTES):
+ case(CMD_LOCK_FILE):
+ case(CMD_UNLOCK_FILE):
+ case(CMD_COPY_FILE):
+ case(REPLY_READ_FROM_FILE):
+ case(CMD_READ_FROM_FILE):
+ case(CMD_APPEND_TO_FILE):
+ case(CMD_FINISH_APPEND_TO_FILE):
+ case(REPLY_READ_FINISHED_STOP):
+ case(REPLY_FINISH_APPEND): {
+ store_address_t storeId = GenericFileSystemMessage::getStoreId(message);
+ auto ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
+ if(ipcStore == nullptr) {
+ return HasReturnvaluesIF::RETURN_FAILED;
+ }
+ return ipcStore->deleteData(storeId);
+ }
+ }
+ return HasReturnvaluesIF::RETURN_OK;
+}
diff --git a/memory/GenericFileSystemMessage.h b/memory/GenericFileSystemMessage.h
new file mode 100644
index 00000000..6351dab9
--- /dev/null
+++ b/memory/GenericFileSystemMessage.h
@@ -0,0 +1,115 @@
+#ifndef MISSION_MEMORY_GENERICFILESYSTEMMESSAGE_H_
+#define MISSION_MEMORY_GENERICFILESYSTEMMESSAGE_H_
+
+#include
+
+#include
+#include
+#include
+#include
+
+/**
+ * @brief These messages are sent to an object implementing HasFilesystemIF.
+ * @details
+ * Enables a message-based file management. The user can add custo commands be implementing
+ * this generic class.
+ * @author Jakob Meier, R. Mueller
+ */
+class GenericFileSystemMessage {
+public:
+ /* Instantiation forbidden */
+ GenericFileSystemMessage() = delete;
+
+ static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE;
+ /* PUS standard (ECSS-E-ST-70-41C15 2016 p.654) */
+ static const Command_t CMD_CREATE_FILE = MAKE_COMMAND_ID(1);
+ static const Command_t CMD_DELETE_FILE = MAKE_COMMAND_ID(2);
+ /** Report file attributes */
+ static const Command_t CMD_REPORT_FILE_ATTRIBUTES = MAKE_COMMAND_ID(3);
+ static const Command_t REPLY_REPORT_FILE_ATTRIBUTES = MAKE_COMMAND_ID(4);
+ /** Command to lock a file, setting it read-only */
+ static const Command_t CMD_LOCK_FILE = MAKE_COMMAND_ID(5);
+ /** Command to unlock a file, enabling further operations on it */
+ static const Command_t CMD_UNLOCK_FILE = MAKE_COMMAND_ID(6);
+ /**
+ * Find file in repository, using a search pattern.
+ * Please note that * is the wildcard character.
+ * For example, when looking for all files which start with have the
+ * structure tm.bin, tm*.bin can be used.
+ */
+ static const Command_t CMD_FIND_FILE = MAKE_COMMAND_ID(7);
+ static const Command_t CMD_CREATE_DIRECTORY = MAKE_COMMAND_ID(9);
+ static const Command_t CMD_DELETE_DIRECTORY = MAKE_COMMAND_ID(10);
+ static const Command_t CMD_RENAME_DIRECTORY = MAKE_COMMAND_ID(11);
+
+ /** Dump contents of a repository */
+ static const Command_t CMD_DUMP_REPOSITORY = MAKE_COMMAND_ID(12);
+ /** Repository dump reply */
+ static const Command_t REPLY_DUMY_REPOSITORY = MAKE_COMMAND_ID(13);
+ static constexpr Command_t CMD_COPY_FILE = MAKE_COMMAND_ID(14);
+ static constexpr Command_t CMD_MOVE_FILE = MAKE_COMMAND_ID(15);
+
+ static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(128);
+ static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(129);
+
+ // These command IDs will remain until CFDP has been introduced and consolidated.
+ /** Append operation commands */
+ static const Command_t CMD_APPEND_TO_FILE = MAKE_COMMAND_ID(130);
+ static const Command_t CMD_FINISH_APPEND_TO_FILE = MAKE_COMMAND_ID(131);
+ static const Command_t REPLY_FINISH_APPEND = MAKE_COMMAND_ID(132);
+
+ static const Command_t CMD_READ_FROM_FILE = MAKE_COMMAND_ID(140);
+ static const Command_t REPLY_READ_FROM_FILE = MAKE_COMMAND_ID(141);
+ static const Command_t CMD_STOP_READ = MAKE_COMMAND_ID(142);
+ static const Command_t REPLY_READ_FINISHED_STOP = MAKE_COMMAND_ID(143);
+
+ static void setLockFileCommand(CommandMessage* message, store_address_t storeId);
+ static void setUnlockFileCommand(CommandMessage* message, store_address_t storeId);
+
+ static void setCreateFileCommand(CommandMessage* message,
+ store_address_t storeId);
+ static void setDeleteFileCommand(CommandMessage* message,
+ store_address_t storeId);
+
+ static void setReportFileAttributesCommand(CommandMessage* message,
+ store_address_t storeId);
+ static void setReportFileAttributesReply(CommandMessage* message,
+ store_address_t storeId);
+
+ static void setCreateDirectoryCommand(CommandMessage* message,
+ store_address_t storeId);
+ static void setDeleteDirectoryCommand(CommandMessage* message,
+ store_address_t storeId);
+
+ static void setSuccessReply(CommandMessage* message);
+ static void setFailureReply(CommandMessage* message,
+ ReturnValue_t errorCode, uint32_t errorParam = 0);
+ static void setCopyCommand(CommandMessage* message, store_address_t storeId);
+
+ static void setWriteCommand(CommandMessage* message,
+ store_address_t storeId);
+ static void setFinishStopWriteCommand(CommandMessage* message,
+ store_address_t storeId);
+ static void setFinishStopWriteReply(CommandMessage* message,
+ store_address_t storeId);
+ static void setFinishAppendReply(CommandMessage* message,
+ store_address_t storeId);
+
+ static void setReadCommand(CommandMessage* message,
+ store_address_t storeId);
+ static void setReadFinishedReply(CommandMessage* message,
+ store_address_t storeId);
+ static void setReadReply(CommandMessage* message, bool readFinished,
+ store_address_t storeId);
+ static bool getReadReply(const CommandMessage* message,
+ store_address_t* storeId);
+
+ static store_address_t getStoreId(const CommandMessage* message);
+ static ReturnValue_t getFailureReply(const CommandMessage* message,
+ uint32_t* errorParam = nullptr);
+
+ static ReturnValue_t clear(CommandMessage* message);
+
+};
+
+#endif /* MISSION_MEMORY_GENERICFILESYSTEMMESSAGE_H_ */
diff --git a/memory/MemoryHelper.cpp b/memory/MemoryHelper.cpp
index 42ac2654..d83a9fab 100644
--- a/memory/MemoryHelper.cpp
+++ b/memory/MemoryHelper.cpp
@@ -2,9 +2,9 @@
#include "MemoryMessage.h"
#include "../globalfunctions/CRC.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
#include "../serialize/EndianConverter.h"
-#include "../serviceinterface/ServiceInterfaceStream.h"
+#include "../serviceinterface/ServiceInterface.h"
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis,
MessageQueueIF* useThisQueue):
@@ -187,7 +187,7 @@ ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) {
}
ReturnValue_t MemoryHelper::initialize() {
- ipcStore = objectManager->get(objects::IPC_STORE);
+ ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
if (ipcStore != nullptr) {
return RETURN_OK;
} else {
diff --git a/memory/MemoryMessage.cpp b/memory/MemoryMessage.cpp
index 94fa4691..1f050ef8 100644
--- a/memory/MemoryMessage.cpp
+++ b/memory/MemoryMessage.cpp
@@ -1,6 +1,6 @@
#include "MemoryMessage.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
uint32_t MemoryMessage::getAddress(const CommandMessage* message) {
return message->getParameter();
@@ -44,7 +44,7 @@ void MemoryMessage::clear(CommandMessage* message) {
switch (message->getCommand()) {
case CMD_MEMORY_LOAD:
case REPLY_MEMORY_DUMP: {
- StorageManagerIF *ipcStore = objectManager->get(
+ StorageManagerIF *ipcStore = ObjectManager::instance()->get(
objects::IPC_STORE);
if (ipcStore != NULL) {
ipcStore->deleteData(getStoreID(message));
diff --git a/monitoring/LimitViolationReporter.cpp b/monitoring/LimitViolationReporter.cpp
index c531a6e6..2de1e008 100644
--- a/monitoring/LimitViolationReporter.cpp
+++ b/monitoring/LimitViolationReporter.cpp
@@ -1,13 +1,8 @@
-/**
- * @file LimitViolationReporter.cpp
- * @brief This file defines the LimitViolationReporter class.
- * @date 17.07.2014
- * @author baetz
- */
#include "LimitViolationReporter.h"
#include "MonitoringIF.h"
#include "ReceivesMonitoringReportsIF.h"
-#include "../objectmanager/ObjectManagerIF.h"
+
+#include "../objectmanager/ObjectManager.h"
#include "../serialize/SerializeAdapter.h"
ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF* data) {
@@ -16,7 +11,7 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF
return result;
}
store_address_t storeId;
- uint8_t* dataTarget = NULL;
+ uint8_t* dataTarget = nullptr;
size_t maxSize = data->getSerializedSize();
if (maxSize > MonitoringIF::VIOLATION_REPORT_MAX_SIZE) {
return MonitoringIF::INVALID_SIZE;
@@ -38,16 +33,16 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF
ReturnValue_t LimitViolationReporter::checkClassLoaded() {
if (reportQueue == 0) {
- ReceivesMonitoringReportsIF* receiver = objectManager->get<
+ ReceivesMonitoringReportsIF* receiver = ObjectManager::instance()->get<
ReceivesMonitoringReportsIF>(reportingTarget);
- if (receiver == NULL) {
+ if (receiver == nullptr) {
return ObjectManagerIF::NOT_FOUND;
}
reportQueue = receiver->getCommandQueue();
}
- if (ipcStore == NULL) {
- ipcStore = objectManager->get(objects::IPC_STORE);
- if (ipcStore == NULL) {
+ if (ipcStore == nullptr) {
+ ipcStore = ObjectManager::instance()->get(objects::IPC_STORE);
+ if (ipcStore == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
}
@@ -56,5 +51,5 @@ ReturnValue_t LimitViolationReporter::checkClassLoaded() {
//Lazy initialization.
MessageQueueId_t LimitViolationReporter::reportQueue = 0;
-StorageManagerIF* LimitViolationReporter::ipcStore = NULL;
+StorageManagerIF* LimitViolationReporter::ipcStore = nullptr;
object_id_t LimitViolationReporter::reportingTarget = 0;
diff --git a/monitoring/MonitoringMessage.cpp b/monitoring/MonitoringMessage.cpp
index 8caa27ae..6e5f49cc 100644
--- a/monitoring/MonitoringMessage.cpp
+++ b/monitoring/MonitoringMessage.cpp
@@ -1,5 +1,5 @@
#include "MonitoringMessage.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
MonitoringMessage::~MonitoringMessage() {
}
@@ -25,7 +25,7 @@ void MonitoringMessage::clear(CommandMessage* message) {
message->setCommand(CommandMessage::CMD_NONE);
switch (message->getCommand()) {
case MonitoringMessage::LIMIT_VIOLATION_REPORT: {
- StorageManagerIF *ipcStore = objectManager->get(
+ StorageManagerIF *ipcStore = ObjectManager::instance()->get(
objects::IPC_STORE);
if (ipcStore != NULL) {
ipcStore->deleteData(getStoreId(message));
diff --git a/monitoring/MonitoringMessageContent.h b/monitoring/MonitoringMessageContent.h
index 0314d7ed..1d5f9c92 100644
--- a/monitoring/MonitoringMessageContent.h
+++ b/monitoring/MonitoringMessageContent.h
@@ -5,7 +5,7 @@
#include "MonitoringIF.h"
#include "../datapoollocal/localPoolDefinitions.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
#include "../serialize/SerialBufferAdapter.h"
#include "../serialize/SerialFixedArrayListAdapter.h"
#include "../serialize/SerializeElement.h"
@@ -71,7 +71,7 @@ private:
}
bool checkAndSetStamper() {
if (timeStamper == nullptr) {
- timeStamper = objectManager->get( timeStamperId );
+ timeStamper = ObjectManager::instance()->get( timeStamperId );
if ( timeStamper == nullptr ) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MonitoringReportContent::checkAndSetStamper: "
diff --git a/monitoring/TriplexMonitor.h b/monitoring/TriplexMonitor.h
index d9ee8305..295a6174 100644
--- a/monitoring/TriplexMonitor.h
+++ b/monitoring/TriplexMonitor.h
@@ -5,7 +5,7 @@
#include "../datapool/PIDReaderList.h"
#include "../health/HealthTableIF.h"
#include "../parameters/HasParametersIF.h"
-#include "../objectmanager/ObjectManagerIF.h"
+#include "../objectmanager/ObjectManager.h"
//SHOULDDO: This is by far not perfect. Could be merged with new Monitor classes. But still, it's over-engineering.
@@ -64,7 +64,7 @@ public:
return result;
}
ReturnValue_t initialize() {
- healthTable = objectManager->get(objects::HEALTH_TABLE);
+ healthTable = ObjectManager::instance()->get(objects::HEALTH_TABLE);
if (healthTable == NULL) {
return HasReturnvaluesIF::RETURN_FAILED;
}
diff --git a/objectmanager/ObjectManager.cpp b/objectmanager/ObjectManager.cpp
index 3c2be532..3e6820a7 100644
--- a/objectmanager/ObjectManager.cpp
+++ b/objectmanager/ObjectManager.cpp
@@ -6,11 +6,23 @@
#endif
#include
-ObjectManager::ObjectManager( void (*setProducer)() ):
- produceObjects(setProducer) {
- //There's nothing special to do in the constructor.
+ObjectManager* ObjectManager::objManagerInstance = nullptr;
+
+ObjectManager* ObjectManager::instance() {
+ if(objManagerInstance == nullptr) {
+ objManagerInstance = new ObjectManager();
+ }
+ return objManagerInstance;
}
+void ObjectManager::setObjectFactoryFunction(produce_function_t objFactoryFunc, void *factoryArgs) {
+ this->objectFactoryFunction = objFactoryFunc;
+ this->factoryArgs = factoryArgs;
+}
+
+
+ObjectManager::ObjectManager() {}
+
ObjectManager::~ObjectManager() {
for (auto const& iter : objectList) {
@@ -28,10 +40,13 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
return this->RETURN_OK;
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::error << "ObjectManager::insert: Object id " << std::hex
- << static_cast(id) << std::dec
- << " is already in use!" << std::endl;
- sif::error << "Terminating program." << std::endl;
+ sif::error << "ObjectManager::insert: Object ID " << std::hex <<
+ static_cast(id) << std::dec << " is already in use!" << std::endl;
+ sif::error << "Terminating program" << std::endl;
+#else
+ sif::printError("ObjectManager::insert: Object ID 0x%08x is already in use!\n",
+ static_cast(id));
+ sif::printError("Terminating program");
#endif
//This is very severe and difficult to handle in other places.
std::exit(INSERTION_FAILED);
@@ -66,12 +81,8 @@ SystemObjectIF* ObjectManager::getSystemObject( object_id_t id ) {
}
}
-ObjectManager::ObjectManager() : produceObjects(nullptr) {
-
-}
-
void ObjectManager::initialize() {
- if(produceObjects == nullptr) {
+ if(objectFactoryFunction == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::initialize: Passed produceObjects "
"functions is nullptr!" << std::endl;
@@ -80,7 +91,7 @@ void ObjectManager::initialize() {
#endif
return;
}
- this->produceObjects();
+ objectFactoryFunction(factoryArgs);
ReturnValue_t result = RETURN_FAILED;
uint32_t errorCount = 0;
for (auto const& it : objectList) {
@@ -108,9 +119,9 @@ void ObjectManager::initialize() {
result = it.second->checkObjectConnections();
if ( result != RETURN_OK ) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
- sif::error << "ObjectManager::ObjectManager: Object " << std::hex <<
- (int) it.first << " connection check failed with code 0x"
- << result << std::dec << std::endl;
+ sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex <<
+ (int) it.first << " connection check failed with code 0x" << result <<
+ std::dec << std::endl;
#endif
errorCount++;
}
diff --git a/objectmanager/ObjectManager.h b/objectmanager/ObjectManager.h
index 69a74f73..9f5f0c37 100644
--- a/objectmanager/ObjectManager.h
+++ b/objectmanager/ObjectManager.h
@@ -5,6 +5,7 @@
#include "SystemObjectIF.h"
#include