Merge branch 'mueller/master' of https://egit.irs.uni-stuttgart.de/fsfw/fsfw into mueller/master
This commit is contained in:
commit
36bc7609c5
@ -1,32 +1,24 @@
|
|||||||
#include "PoolEntry.h"
|
#include "PoolEntry.h"
|
||||||
|
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../globalfunctions/arrayprinter.h"
|
#include "../globalfunctions/arrayprinter.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, uint8_t setLength,
|
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, bool setValid ):
|
||||||
bool setValid ) : length(setLength), valid(setValid) {
|
length(initValue.size()), valid(setValid) {
|
||||||
this->address = new T[this->length];
|
this->address = new T[this->length];
|
||||||
if(initValue.size() == 0) {
|
if(initValue.size() == 0) {
|
||||||
std::memset(this->address, 0, this->getByteSize());
|
std::memset(this->address, 0, this->getByteSize());
|
||||||
}
|
}
|
||||||
else if (initValue.size() != setLength){
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "PoolEntry: setLength is not equal to initializer list"
|
|
||||||
"length! Performing zero initialization with given setLength"
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
std::memset(this->address, 0, this->getByteSize());
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
std::copy(initValue.begin(), initValue.end(), this->address);
|
std::copy(initValue.begin(), initValue.end(), this->address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
PoolEntry<T>::PoolEntry( T* initValue, uint8_t setLength, bool setValid ) :
|
PoolEntry<T>::PoolEntry(T* initValue, uint8_t setLength, bool setValid):
|
||||||
length(setLength), valid(setValid) {
|
length(setLength), valid(setValid) {
|
||||||
this->address = new T[this->length];
|
this->address = new T[this->length];
|
||||||
if (initValue != nullptr) {
|
if (initValue != nullptr) {
|
||||||
@ -70,14 +62,26 @@ bool PoolEntry<T>::getValid() {
|
|||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void PoolEntry<T>::print() {
|
void PoolEntry<T>::print() {
|
||||||
|
const char* validString = nullptr;
|
||||||
|
if(valid) {
|
||||||
|
validString = "Valid";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
validString = "Invalid";
|
||||||
|
}
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::debug << "Pool Entry Validity: " <<
|
sif::info << "PoolEntry information." << std::endl;
|
||||||
(this->valid? " (valid) " : " (invalid) ") << std::endl;
|
sif::info << "PoolEntry validity: " << validString << std::endl;
|
||||||
#endif
|
#else
|
||||||
arrayprinter::print(reinterpret_cast<uint8_t*>(address), length);
|
fsfw::printInfo("PoolEntry information.\n");
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
fsfw::printInfo("PoolEntry validity: %s\n", validString);
|
||||||
sif::debug << std::dec << std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
|
arrayprinter::print(reinterpret_cast<uint8_t*>(address), getByteSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
inline T* PoolEntry<T>::getDataPtr() {
|
||||||
|
return this->address;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -35,24 +35,22 @@ public:
|
|||||||
"uint8_t");
|
"uint8_t");
|
||||||
/**
|
/**
|
||||||
* @brief In the classe's constructor, space is allocated on the heap and
|
* @brief In the classe's constructor, space is allocated on the heap and
|
||||||
* potential init values are copied to that space.
|
* potential initialization values are copied to that space.
|
||||||
* @details
|
* @details
|
||||||
* Not passing any arguments will initialize an non-array pool entry
|
* Not passing any arguments will initialize an non-array pool entry
|
||||||
* (setLength = 1) with an initial invalid state.
|
* with an initial invalid state and the value 0.
|
||||||
* Please note that if an initializer list is passed, the correct
|
* Please note that if an initializer list is passed, the length of the
|
||||||
* corresponding length should be passed too, otherwise a zero
|
* initializer list needs to be correct for vector entries because
|
||||||
* initialization will be performed with the given setLength.
|
* required allocated space will be deduced from the initializer list length
|
||||||
|
* and the pool entry type.
|
||||||
* @param initValue
|
* @param initValue
|
||||||
* Initializer list with values to initialize with, for example {0,0} to
|
* Initializer list with values to initialize with, for example {0, 0} to
|
||||||
* initialize the two entries to zero.
|
* initialize the a pool entry of a vector with two entries to 0.
|
||||||
* @param setLength
|
|
||||||
* Defines the array length of this entry. Should be equal to the
|
|
||||||
* intializer list length.
|
|
||||||
* @param setValid
|
* @param setValid
|
||||||
* Sets the initialization flag. It is invalid by default.
|
* Sets the initialization flag. It is invalid by default.
|
||||||
*/
|
*/
|
||||||
PoolEntry(std::initializer_list<T> initValue = {}, uint8_t setLength = 1,
|
PoolEntry(std::initializer_list<T> initValue = {0}, bool setValid = false);
|
||||||
bool setValid = false);
|
|
||||||
/**
|
/**
|
||||||
* @brief In the classe's constructor, space is allocated on the heap and
|
* @brief In the classe's constructor, space is allocated on the heap and
|
||||||
* potential init values are copied to that space.
|
* potential init values are copied to that space.
|
||||||
@ -66,9 +64,9 @@ public:
|
|||||||
*/
|
*/
|
||||||
PoolEntry(T* initValue, uint8_t setLength = 1, bool setValid = false);
|
PoolEntry(T* initValue, uint8_t setLength = 1, bool setValid = false);
|
||||||
|
|
||||||
//! Explicitely deleted copy ctor, copying is not allowed!
|
//! Explicitely deleted copy ctor, copying is not allowed.
|
||||||
PoolEntry(const PoolEntry&) = delete;
|
PoolEntry(const PoolEntry&) = delete;
|
||||||
//! Explicitely deleted copy assignment, copying is not allowed!
|
//! Explicitely deleted copy assignment, copying is not allowed.
|
||||||
PoolEntry& operator=(const PoolEntry&) = delete;
|
PoolEntry& operator=(const PoolEntry&) = delete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,21 +80,16 @@ public:
|
|||||||
~PoolEntry();
|
~PoolEntry();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This is the address pointing to the allocated memory.
|
* Return typed pointer to start of data.
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
T* address;
|
T* getDataPtr();
|
||||||
/**
|
|
||||||
* @brief This attribute stores the length information.
|
|
||||||
*/
|
|
||||||
uint8_t length;
|
|
||||||
/**
|
|
||||||
* @brief Here, the validity information for a variable is stored.
|
|
||||||
* Every entry (single variable or vector) has one valid flag.
|
|
||||||
*/
|
|
||||||
uint8_t valid;
|
|
||||||
/**
|
/**
|
||||||
* @brief getSize returns the array size of the entry.
|
* @brief getSize returns the array size of the entry.
|
||||||
* @details A single parameter has size 1.
|
* @details
|
||||||
|
* For non-array pool entries return type size, for vector entries
|
||||||
|
* return type size times the number of entries.
|
||||||
*/
|
*/
|
||||||
uint8_t getSize();
|
uint8_t getSize();
|
||||||
/**
|
/**
|
||||||
@ -123,8 +116,22 @@ public:
|
|||||||
* information to the screen. It prints all array entries in a row.
|
* information to the screen. It prints all array entries in a row.
|
||||||
*/
|
*/
|
||||||
void print();
|
void print();
|
||||||
|
|
||||||
Type getType();
|
Type getType();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* @brief This attribute stores the length information.
|
||||||
|
*/
|
||||||
|
uint8_t length;
|
||||||
|
/**
|
||||||
|
* @brief Here, the validity information for a variable is stored.
|
||||||
|
* Every entry (single variable or vector) has one valid flag.
|
||||||
|
*/
|
||||||
|
uint8_t valid;
|
||||||
|
/**
|
||||||
|
* @brief This is the address pointing to the allocated memory.
|
||||||
|
*/
|
||||||
|
T* address;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_DATAPOOL_POOLENTRY_H_ */
|
#endif /* FSFW_DATAPOOL_POOLENTRY_H_ */
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "../housekeeping/HousekeepingPacketUpdate.h"
|
#include "../housekeeping/HousekeepingPacketUpdate.h"
|
||||||
#include "../housekeeping/HousekeepingSetPacket.h"
|
#include "../housekeeping/HousekeepingSetPacket.h"
|
||||||
#include "../housekeeping/AcceptsHkPacketsIF.h"
|
#include "../housekeeping/AcceptsHkPacketsIF.h"
|
||||||
|
|
||||||
#include "../timemanager/CCSDSTime.h"
|
#include "../timemanager/CCSDSTime.h"
|
||||||
#include "../ipc/MutexFactory.h"
|
#include "../ipc/MutexFactory.h"
|
||||||
#include "../ipc/MutexHelper.h"
|
#include "../ipc/MutexHelper.h"
|
||||||
@ -21,19 +20,17 @@ LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner,
|
|||||||
MessageQueueIF* queueToUse, bool appendValidityBuffer):
|
MessageQueueIF* queueToUse, bool appendValidityBuffer):
|
||||||
appendValidityBuffer(appendValidityBuffer) {
|
appendValidityBuffer(appendValidityBuffer) {
|
||||||
if(owner == nullptr) {
|
if(owner == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
|
"LocalDataPoolManager", HasReturnvaluesIF::RETURN_FAILED,
|
||||||
<< "Invalid supplied owner!" << std::endl;
|
"Invalid supplied owner");
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this->owner = owner;
|
this->owner = owner;
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
if(mutex == nullptr) {
|
if(mutex == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
|
"LocalDataPoolManager", HasReturnvaluesIF::RETURN_FAILED,
|
||||||
<< "Could not create mutex." << std::endl;
|
"Could not create mutex");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hkQueue = queueToUse;
|
hkQueue = queueToUse;
|
||||||
@ -43,21 +40,18 @@ LocalDataPoolManager::~LocalDataPoolManager() {}
|
|||||||
|
|
||||||
ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
||||||
if(queueToUse == nullptr) {
|
if(queueToUse == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
// error, all destinations invalid
|
||||||
sif::error << "LocalDataPoolManager::initialize: "
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
<< std::hex << "0x" << owner->getObjectId() << ". Supplied "
|
"initialize", QUEUE_OR_DESTINATION_INVALID);
|
||||||
<< "queue invalid!" << std::dec << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
hkQueue = queueToUse;
|
hkQueue = queueToUse;
|
||||||
|
|
||||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||||
if(ipcStore == nullptr) {
|
if(ipcStore == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
// error, all destinations invalid
|
||||||
sif::error << "LocalDataPoolManager::initialize: "
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
<< std::hex << "0x" << owner->getObjectId() << ": Could not "
|
"initialize", HasReturnvaluesIF::RETURN_FAILED,
|
||||||
<< "set IPC store." <<std::dec << std::endl;
|
"Could not set IPC store.");
|
||||||
#endif
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,11 +63,9 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
|||||||
hkDestinationId = hkPacketReceiver->getHkQueue();
|
hkDestinationId = hkPacketReceiver->getHkQueue();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
|
"initialize", QUEUE_OR_DESTINATION_INVALID);
|
||||||
<< "Default HK destination object is invalid!" << std::endl;
|
return QUEUE_OR_DESTINATION_INVALID;
|
||||||
#endif
|
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +87,10 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "HousekeepingManager: The map should only be initialized "
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
<< "once!" << std::endl;
|
"initialize", HasReturnvaluesIF::RETURN_FAILED,
|
||||||
#endif
|
"The map should only be initialized once");
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +155,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(
|
|||||||
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
||||||
receiver.dataId.localPoolId);
|
receiver.dataId.localPoolId);
|
||||||
if(poolObj == nullptr) {
|
if(poolObj == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"handleNotificationUpdate", POOLOBJECT_NOT_FOUND);
|
||||||
|
return POOLOBJECT_NOT_FOUND;
|
||||||
}
|
}
|
||||||
if(poolObj->hasChanged()) {
|
if(poolObj->hasChanged()) {
|
||||||
// prepare and send update notification.
|
// prepare and send update notification.
|
||||||
@ -183,7 +177,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(
|
|||||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||||
receiver.dataId.sid);
|
receiver.dataId.sid);
|
||||||
if(dataSet == nullptr) {
|
if(dataSet == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"handleNotificationUpdate", DATASET_NOT_FOUND);
|
||||||
|
return DATASET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
if(dataSet->hasChanged()) {
|
if(dataSet->hasChanged()) {
|
||||||
// prepare and send update notification
|
// prepare and send update notification
|
||||||
@ -213,7 +209,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
|||||||
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
||||||
receiver.dataId.localPoolId);
|
receiver.dataId.localPoolId);
|
||||||
if(poolObj == nullptr) {
|
if(poolObj == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"handleNotificationSnapshot", POOLOBJECT_NOT_FOUND);
|
||||||
|
return POOLOBJECT_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (not poolObj->hasChanged()) {
|
if (not poolObj->hasChanged()) {
|
||||||
@ -249,7 +247,9 @@ ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
|||||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||||
receiver.dataId.sid);
|
receiver.dataId.sid);
|
||||||
if(dataSet == nullptr) {
|
if(dataSet == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"handleNotificationSnapshot", DATASET_NOT_FOUND);
|
||||||
|
return DATASET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(not dataSet->hasChanged()) {
|
if(not dataSet->hasChanged()) {
|
||||||
@ -351,11 +351,9 @@ ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
|
|||||||
AcceptsHkPacketsIF* hkReceiverObject =
|
AcceptsHkPacketsIF* hkReceiverObject =
|
||||||
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
|
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
|
||||||
if(hkReceiverObject == nullptr) {
|
if(hkReceiverObject == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:"
|
"subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
|
||||||
<< " Invalid receiver!"<< std::endl;
|
return QUEUE_OR_DESTINATION_INVALID;
|
||||||
#endif
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HkReceiver hkReceiver;
|
struct HkReceiver hkReceiver;
|
||||||
@ -383,11 +381,9 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePackets(sid_t sid,
|
|||||||
AcceptsHkPacketsIF* hkReceiverObject =
|
AcceptsHkPacketsIF* hkReceiverObject =
|
||||||
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
|
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
|
||||||
if(hkReceiverObject == nullptr) {
|
if(hkReceiverObject == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:"
|
"subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
|
||||||
<< " Invalid receiver!"<< std::endl;
|
return QUEUE_OR_DESTINATION_INVALID;
|
||||||
#endif
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct HkReceiver hkReceiver;
|
struct HkReceiver hkReceiver;
|
||||||
@ -591,10 +587,8 @@ ReturnValue_t LocalDataPoolManager::printPoolEntry(
|
|||||||
lp_id_t localPoolId) {
|
lp_id_t localPoolId) {
|
||||||
auto poolIter = localPoolMap.find(localPoolId);
|
auto poolIter = localPoolMap.find(localPoolId);
|
||||||
if (poolIter == localPoolMap.end()) {
|
if (poolIter == localPoolMap.end()) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING, "printPoolEntry",
|
||||||
sif::debug << "HousekeepingManager::fechPoolEntry:"
|
HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND);
|
||||||
<< " Pool entry not found." << std::endl;
|
|
||||||
#endif
|
|
||||||
return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
|
return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
poolIter->second->print();
|
poolIter->second->print();
|
||||||
@ -614,11 +608,10 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
|||||||
MessageQueueId_t destination) {
|
MessageQueueId_t destination) {
|
||||||
if(dataSet == nullptr) {
|
if(dataSet == nullptr) {
|
||||||
// Configuration error.
|
// Configuration error.
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
|
"generateHousekeepingPacket",
|
||||||
<< " Set ID not found or dataset not assigned!" << std::endl;
|
DATASET_NOT_FOUND);
|
||||||
#endif
|
return DATASET_NOT_FOUND;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
store_address_t storeId;
|
store_address_t storeId;
|
||||||
@ -640,12 +633,18 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(hkQueue == nullptr) {
|
if(hkQueue == nullptr) {
|
||||||
return QUEUE_OR_DESTINATION_NOT_SET;
|
// error, all destinations invalid
|
||||||
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"generateHousekeepingPacket",
|
||||||
|
QUEUE_OR_DESTINATION_INVALID);
|
||||||
|
return QUEUE_OR_DESTINATION_INVALID;
|
||||||
}
|
}
|
||||||
if(destination == MessageQueueIF::NO_QUEUE) {
|
if(destination == MessageQueueIF::NO_QUEUE) {
|
||||||
if(hkDestinationId == MessageQueueIF::NO_QUEUE) {
|
if(hkDestinationId == MessageQueueIF::NO_QUEUE) {
|
||||||
// error, all destinations invalid
|
// error, all destinations invalid
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"generateHousekeepingPacket",
|
||||||
|
QUEUE_OR_DESTINATION_INVALID);
|
||||||
}
|
}
|
||||||
destination = hkDestinationId;
|
destination = hkDestinationId;
|
||||||
}
|
}
|
||||||
@ -681,6 +680,13 @@ void LocalDataPoolManager::setNonDiagnosticIntervalFactor(
|
|||||||
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
||||||
sid_t sid = receiver.dataId.sid;
|
sid_t sid = receiver.dataId.sid;
|
||||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||||
|
if(dataSet == nullptr) {
|
||||||
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"performPeriodicHkGeneration",
|
||||||
|
DATASET_NOT_FOUND);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(not dataSet->getReportingEnabled()) {
|
if(not dataSet->getReportingEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -699,10 +705,11 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
|||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
// configuration error
|
// configuration error
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::debug << "LocalDataPoolManager::performHkOperation:"
|
sif::warning << "LocalDataPoolManager::performHkOperation: "
|
||||||
<< "0x" << std::hex << std::setfill('0') << std::setw(8)
|
<< "HK generation failed." << std::endl;
|
||||||
<< owner->getObjectId() << " Error generating "
|
#else
|
||||||
<< "HK packet" << std::setfill(' ') << std::dec << std::endl;
|
fsfw::printWarning("LocalDataPoolManager::performHkOperation: "
|
||||||
|
"HK generation failed.\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -748,11 +755,10 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
|||||||
// Get and check dataset first.
|
// Get and check dataset first.
|
||||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(sid);
|
||||||
if(dataSet == nullptr) {
|
if(dataSet == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
|
"performPeriodicHkGeneration",
|
||||||
<< " Set ID not found" << std::endl;
|
DATASET_NOT_FOUND);
|
||||||
#endif
|
return DATASET_NOT_FOUND;
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -776,10 +782,9 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
|||||||
ReturnValue_t result = ipcStore->getFreeElement(&storeId,
|
ReturnValue_t result = ipcStore->getFreeElement(&storeId,
|
||||||
expectedSize,&storePtr);
|
expectedSize,&storePtr);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
sif::error << "HousekeepingManager::generateHousekeepingPacket: "
|
"generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED,
|
||||||
<< "Could not get free element from IPC store." << std::endl;
|
"Could not get free element from IPC store.");
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -788,10 +793,9 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
|||||||
result = setPacket.serialize(&storePtr, &size, expectedSize,
|
result = setPacket.serialize(&storePtr, &size, expectedSize,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
if(expectedSize != size) {
|
if(expectedSize != size) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::error << "HousekeepingManager::generateSetStructurePacket: "
|
"generateSetStructurePacket", HasReturnvaluesIF::RETURN_FAILED,
|
||||||
<< "Expected size is not equal to serialized size" << std::endl;
|
"Expected size is not equal to serialized size");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send structure reporting reply.
|
// Send structure reporting reply.
|
||||||
@ -808,3 +812,58 @@ ReturnValue_t LocalDataPoolManager::generateSetStructurePacket(sid_t sid,
|
|||||||
hkQueue->reply(&reply);
|
hkQueue->reply(&reply);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalDataPoolManager::printWarningOrError(fsfw::OutputTypes outputType,
|
||||||
|
const char* functionName, ReturnValue_t error, const char* errorPrint) {
|
||||||
|
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 == fsfw::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 == HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT) {
|
||||||
|
errorPrint = "Pool entry type conflict";
|
||||||
|
}
|
||||||
|
else if(error == HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND) {
|
||||||
|
errorPrint = "Pool entry not found";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errorPrint = "Unknown error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(outputType == fsfw::OutputTypes::OUT_WARNING) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "LocalDataPoolManager::" << functionName
|
||||||
|
<< ": Object ID " << std::setw(8) << std::setfill('0')
|
||||||
|
<< std::hex << owner->getObjectId() << " | " << errorPrint
|
||||||
|
<< std::dec << std::setfill(' ') << std::endl;
|
||||||
|
#else
|
||||||
|
fsfw::printWarning("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
|
||||||
|
owner->getObjectId(), errorPrint);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if(outputType == fsfw::OutputTypes::OUT_ERROR) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "LocalDataPoolManager::" << functionName
|
||||||
|
<< ": Object ID " << std::setw(8) << std::setfill('0')
|
||||||
|
<< std::hex << owner->getObjectId() << " | " << errorPrint
|
||||||
|
<< std::dec << std::setfill(' ') << std::endl;
|
||||||
|
#else
|
||||||
|
fsfw::printError("LocalDataPoolManager::%s: Object ID 0x%08x | %s\n",
|
||||||
|
owner->getObjectId(), errorPrint);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -56,11 +56,13 @@ class LocalDataPoolManager {
|
|||||||
public:
|
public:
|
||||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
|
static constexpr uint8_t INTERFACE_ID = CLASS_ID::HOUSEKEEPING_MANAGER;
|
||||||
|
|
||||||
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_NOT_SET = MAKE_RETURN_CODE(0x0);
|
static constexpr ReturnValue_t QUEUE_OR_DESTINATION_INVALID = MAKE_RETURN_CODE(0);
|
||||||
|
|
||||||
static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(0x01);
|
static constexpr ReturnValue_t WRONG_HK_PACKET_TYPE = MAKE_RETURN_CODE(1);
|
||||||
static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(0x02);
|
static constexpr ReturnValue_t REPORTING_STATUS_UNCHANGED = MAKE_RETURN_CODE(2);
|
||||||
static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(0x03);
|
static constexpr ReturnValue_t PERIODIC_HELPER_INVALID = MAKE_RETURN_CODE(3);
|
||||||
|
static constexpr ReturnValue_t POOLOBJECT_NOT_FOUND = MAKE_RETURN_CODE(4);
|
||||||
|
static constexpr ReturnValue_t DATASET_NOT_FOUND = MAKE_RETURN_CODE(5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructor is used by a class which wants to implement
|
* This constructor is used by a class which wants to implement
|
||||||
@ -368,6 +370,11 @@ private:
|
|||||||
ReturnValue_t& status);
|
ReturnValue_t& status);
|
||||||
ReturnValue_t addUpdateToStore(HousekeepingPacketUpdate& updatePacket,
|
ReturnValue_t addUpdateToStore(HousekeepingPacketUpdate& updatePacket,
|
||||||
store_address_t& storeId);
|
store_address_t& storeId);
|
||||||
|
|
||||||
|
void printWarningOrError(fsfw::OutputTypes outputType,
|
||||||
|
const char* functionName,
|
||||||
|
ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED,
|
||||||
|
const char* errorPrint = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -376,25 +383,15 @@ ReturnValue_t LocalDataPoolManager::fetchPoolEntry(lp_id_t localPoolId,
|
|||||||
PoolEntry<T> **poolEntry) {
|
PoolEntry<T> **poolEntry) {
|
||||||
auto poolIter = localPoolMap.find(localPoolId);
|
auto poolIter = localPoolMap.find(localPoolId);
|
||||||
if (poolIter == localPoolMap.end()) {
|
if (poolIter == localPoolMap.end()) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR, "fetchPoolEntry",
|
||||||
sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry "
|
HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND);
|
||||||
"not found." << std::endl;
|
|
||||||
#else
|
|
||||||
fsfw::printWarning("HousekeepingManager::fechPoolEntry: Pool entry "
|
|
||||||
"not found.");
|
|
||||||
#endif
|
|
||||||
return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
|
return HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
*poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
|
*poolEntry = dynamic_cast< PoolEntry<T>* >(poolIter->second);
|
||||||
if(*poolEntry == nullptr) {
|
if(*poolEntry == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR, "fetchPoolEntry",
|
||||||
sif::warning << "HousekeepingManager::fetchPoolEntry:"
|
HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT);
|
||||||
" Pool entry type conflict." << std::endl;
|
|
||||||
#else
|
|
||||||
fsfw::printWarning("HousekeepingManager::fetchPoolEntry:"
|
|
||||||
" Pool entry type conflict.");
|
|
||||||
#endif
|
|
||||||
return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT;
|
return HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT;
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
@ -110,13 +110,12 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType,
|
|||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << variableType << ": " << type << " call | " << errMsg
|
sif::warning << variableType << ": " << type << " call | " << errMsg
|
||||||
<< " | Owner: " << std::hex << std::setw(8)
|
<< " | Owner: 0x" << std::hex << std::setw(8)
|
||||||
<< std::setfill('0') << objectId << " LPID: 0x" << lpId
|
<< std::setfill('0') << objectId << std::dec << " LPID: " << lpId
|
||||||
<< std::dec << std::endl;
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
fsfw::printWarning("LocalPoolVariable: %s of local pool variable of "
|
fsfw::printWarning("%s: %s call | %s | Owner: 0x%08x LPID: %lu\n",
|
||||||
"object 0x%08x and lp ID 0x%08x failed.\n\r",
|
variableType, type, errMsg, objectId, lpId);
|
||||||
type, objectId, lpId);
|
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||||
}
|
}
|
||||||
|
@ -33,13 +33,10 @@ inline ReturnValue_t LocalPoolVariable<T>::read(
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
|
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
|
||||||
sif::warning << "LocalPoolVariable: Invalid read write "
|
reportReadCommitError("LocalPoolVector",
|
||||||
"mode for read call." << std::endl;
|
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
|
||||||
#else
|
localPoolId);
|
||||||
fsfw::printWarning("LocalPoolVariable: Invalid read write "
|
|
||||||
"mode for read call.\n\r");
|
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,16 +50,16 @@ inline ReturnValue_t LocalPoolVariable<T>::readWithoutLock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Actually this should never happen..
|
// Actually this should never happen..
|
||||||
if(poolEntry->address == nullptr) {
|
// if(poolEntry->address == nullptr) {
|
||||||
result = PoolVariableIF::INVALID_POOL_ENTRY;
|
// result = PoolVariableIF::INVALID_POOL_ENTRY;
|
||||||
object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
|
// object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
|
||||||
reportReadCommitError("LocalPoolVariable", result,
|
// reportReadCommitError("LocalPoolVariable", result,
|
||||||
false, ownerObjectId, localPoolId);
|
// false, ownerObjectId, localPoolId);
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
this->value = *(poolEntry->address);
|
this->value = *(poolEntry->getDataPtr());
|
||||||
this->valid = poolEntry->valid;
|
this->valid = poolEntry->getValid();
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,15 +80,13 @@ inline ReturnValue_t LocalPoolVariable<T>::commit(
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_READ) {
|
if(readWriteMode == pool_rwm_t::VAR_READ) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
|
||||||
sif::warning << "LocalPoolVariable: Invalid read write "
|
reportReadCommitError("LocalPoolVector",
|
||||||
"mode for commit call." << std::endl;
|
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
|
||||||
#else
|
localPoolId);
|
||||||
fsfw::printWarning("LocalPoolVariable: Invalid read write "
|
|
||||||
"mode for commit call.\n\r");
|
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
|
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
|
||||||
if(result != RETURN_OK) {
|
if(result != RETURN_OK) {
|
||||||
@ -101,8 +96,8 @@ inline ReturnValue_t LocalPoolVariable<T>::commitWithoutLock() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
*(poolEntry->address) = this->value;
|
*(poolEntry->getDataPtr()) = this->value;
|
||||||
poolEntry->valid = this->valid;
|
poolEntry->setValid(this->valid);
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ public:
|
|||||||
return vectorSize;
|
return vectorSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
T& operator [](int i);
|
T& operator [](size_t i);
|
||||||
const T &operator [](int i) const;
|
const T &operator [](size_t i) const;
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
|
||||||
const size_t maxSize,
|
const size_t maxSize,
|
||||||
@ -126,6 +126,7 @@ public:
|
|||||||
ReturnValue_t read(MutexIF::TimeoutType timeoutType =
|
ReturnValue_t read(MutexIF::TimeoutType timeoutType =
|
||||||
MutexIF::TimeoutType::WAITING,
|
MutexIF::TimeoutType::WAITING,
|
||||||
uint32_t timeoutMs = 20) override;
|
uint32_t timeoutMs = 20) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The commit call copies the array values back to the data pool.
|
* @brief The commit call copies the array values back to the data pool.
|
||||||
* @details
|
* @details
|
||||||
@ -139,6 +140,14 @@ public:
|
|||||||
MutexIF::TimeoutType::WAITING,
|
MutexIF::TimeoutType::WAITING,
|
||||||
uint32_t timeoutMs = 20) override;
|
uint32_t timeoutMs = 20) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This commit call also sets the validity of the pool entry.
|
||||||
|
* @details
|
||||||
|
*/
|
||||||
|
ReturnValue_t commit(bool valid, MutexIF::TimeoutType timeoutType =
|
||||||
|
MutexIF::TimeoutType::WAITING,
|
||||||
|
uint32_t timeoutMs = 20);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Like #read, but without a lock protection of the global pool.
|
* @brief Like #read, but without a lock protection of the global pool.
|
||||||
|
@ -32,10 +32,10 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
|
|||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
|
if(readWriteMode == pool_rwm_t::VAR_WRITE) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
|
||||||
sif::warning << "LocalPoolVector: Invalid read write "
|
reportReadCommitError("LocalPoolVector",
|
||||||
"mode for read() call." << std::endl;
|
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
|
||||||
#endif
|
localPoolId);
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,11 +49,18 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
|
|||||||
localPoolId);
|
localPoolId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize());
|
std::memcpy(this->value, poolEntry->getDataPtr(), poolEntry->getByteSize());
|
||||||
this->valid = poolEntry->valid;
|
this->valid = poolEntry->getValid();
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T, uint16_t vectorSize>
|
||||||
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(bool valid,
|
||||||
|
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||||
|
this->setValid(valid);
|
||||||
|
return commit(timeoutType, timeoutMs);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
||||||
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
|
||||||
@ -64,54 +71,57 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::commit(
|
|||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
inline ReturnValue_t LocalPoolVector<T, vectorSize>::commitWithoutLock() {
|
||||||
if(readWriteMode == pool_rwm_t::VAR_READ) {
|
if(readWriteMode == pool_rwm_t::VAR_READ) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
|
||||||
sif::warning << "LocalPoolVector: Invalid read write "
|
reportReadCommitError("LocalPoolVector",
|
||||||
"mode for commit call." << std::endl;
|
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
|
||||||
#else
|
localPoolId);
|
||||||
sif::warning << "LocalPoolVector: Invalid read write "
|
|
||||||
"mode for commit call." << std::endl;
|
|
||||||
#endif
|
|
||||||
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
return PoolVariableIF::INVALID_READ_WRITE_MODE;
|
||||||
}
|
}
|
||||||
PoolEntry<T>* poolEntry = nullptr;
|
PoolEntry<T>* poolEntry = nullptr;
|
||||||
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
|
ReturnValue_t result = hkManager->fetchPoolEntry(localPoolId, &poolEntry);
|
||||||
if(result != RETURN_OK) {
|
if(result != RETURN_OK) {
|
||||||
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
|
object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
|
||||||
reportReadCommitError("LocalPoolVector", result, true, targetObjectId,
|
reportReadCommitError("LocalPoolVector", result, false, targetObjectId,
|
||||||
localPoolId);
|
localPoolId);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize());
|
std::memcpy(poolEntry->getDataPtr(), this->value, poolEntry->getByteSize());
|
||||||
poolEntry->valid = this->valid;
|
poolEntry->setValid(this->valid);
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline T& LocalPoolVector<T, vectorSize>::operator [](int i) {
|
inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
|
||||||
if(i <= vectorSize) {
|
if(i < vectorSize) {
|
||||||
return value[i];
|
return value[i];
|
||||||
}
|
}
|
||||||
// If this happens, I have to set some value. I consider this
|
// If this happens, I have to set some value. I consider this
|
||||||
// a configuration error, but I wont exit here.
|
// a configuration error, but I wont exit here.
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "LocalPoolVector: Invalid index. Setting or returning"
|
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||||
" last value!" << std::endl;
|
" last value!" << std::endl;
|
||||||
|
#else
|
||||||
|
fsfw::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
||||||
|
" last value!\n");
|
||||||
#endif
|
#endif
|
||||||
return value[i];
|
return value[vectorSize - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
inline const T& LocalPoolVector<T, vectorSize>::operator [](int i) const {
|
inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
|
||||||
if(i <= vectorSize) {
|
if(i < vectorSize) {
|
||||||
return value[i];
|
return value[i];
|
||||||
}
|
}
|
||||||
// If this happens, I have to set some value. I consider this
|
// If this happens, I have to set some value. I consider this
|
||||||
// a configuration error, but I wont exit here.
|
// a configuration error, but I wont exit here.
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "LocalPoolVector: Invalid index. Setting or returning"
|
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||||
" last value!" << std::endl;
|
" last value!" << std::endl;
|
||||||
|
#else
|
||||||
|
fsfw::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
||||||
|
" last value!\n");
|
||||||
#endif
|
#endif
|
||||||
return value[i];
|
return value[vectorSize - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T, uint16_t vectorSize>
|
template<typename T, uint16_t vectorSize>
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
//! the C stdio functions can be used alternatively
|
//! the C stdio functions can be used alternatively
|
||||||
#define FSFW_CPP_OSTREAM_ENABLED 1
|
#define FSFW_CPP_OSTREAM_ENABLED 1
|
||||||
|
|
||||||
//! More FSFW related printouts.
|
//! More FSFW related printouts. Useful for development.
|
||||||
//! Be careful, this also turns off most diagnostic prinouts!
|
|
||||||
#define FSFW_ENHANCED_PRINTOUT 0
|
#define FSFW_ENHANCED_PRINTOUT 0
|
||||||
|
|
||||||
//! Can be used to completely disable printouts, even the C stdio ones.
|
//! Can be used to completely disable printouts, even the C stdio ones.
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "AcceptsDeviceResponsesIF.h"
|
#include "AcceptsDeviceResponsesIF.h"
|
||||||
#include "DeviceTmReportingWrapper.h"
|
#include "DeviceTmReportingWrapper.h"
|
||||||
|
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include "../objectmanager/ObjectManager.h"
|
#include "../objectmanager/ObjectManager.h"
|
||||||
#include "../storagemanager/StorageManagerIF.h"
|
#include "../storagemanager/StorageManagerIF.h"
|
||||||
#include "../thermal/ThermalComponentIF.h"
|
#include "../thermal/ThermalComponentIF.h"
|
||||||
@ -13,9 +13,6 @@
|
|||||||
#include "../subsystem/SubsystemBase.h"
|
#include "../subsystem/SubsystemBase.h"
|
||||||
#include "../datapoollocal/LocalPoolVariable.h"
|
#include "../datapoollocal/LocalPoolVariable.h"
|
||||||
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
|
|
||||||
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
|
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
|
||||||
object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
|
object_id_t DeviceHandlerBase::rawDataReceiverId = objects::NO_OBJECT;
|
||||||
object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT;
|
object_id_t DeviceHandlerBase::defaultFdirParentId = objects::NO_OBJECT;
|
||||||
@ -39,13 +36,8 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
|
|||||||
cookieInfo.state = COOKIE_UNUSED;
|
cookieInfo.state = COOKIE_UNUSED;
|
||||||
cookieInfo.pendingCommand = deviceCommandMap.end();
|
cookieInfo.pendingCommand = deviceCommandMap.end();
|
||||||
if (comCookie == nullptr) {
|
if (comCookie == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR, "DeviceHandlerBase",
|
||||||
sif::error << "DeviceHandlerBase: ObjectID 0x" << std::hex
|
HasReturnvaluesIF::RETURN_FAILED, "Invalid cookie");
|
||||||
<< std::setw(8) << std::setfill('0') << this->getObjectId()
|
|
||||||
<< std::dec << ": Do not pass nullptr as a cookie, consider "
|
|
||||||
<< std::setfill(' ') << "passing a dummy cookie instead!"
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (this->fdirInstance == nullptr) {
|
if (this->fdirInstance == nullptr) {
|
||||||
this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId,
|
this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId,
|
||||||
@ -132,30 +124,24 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
communicationInterface = objectManager->get<DeviceCommunicationIF>(
|
communicationInterface = objectManager->get<DeviceCommunicationIF>(
|
||||||
deviceCommunicationId);
|
deviceCommunicationId);
|
||||||
if (communicationInterface == nullptr) {
|
if (communicationInterface == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR, "initialize",
|
||||||
sif::error << "DeviceHandlerBase::initialize: Communication interface "
|
ObjectManagerIF::CHILD_INIT_FAILED,
|
||||||
"invalid." << std::endl;
|
"Passed communication IF invalid");
|
||||||
sif::error << "Make sure it is set up properly and implements"
|
|
||||||
" DeviceCommunicationIF" << std::endl;
|
|
||||||
#endif
|
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = communicationInterface->initializeInterface(comCookie);
|
result = communicationInterface->initializeInterface(comCookie);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR, "initialize",
|
||||||
sif::error << "DeviceHandlerBase::initialize: Initializing "
|
ObjectManagerIF::CHILD_INIT_FAILED,
|
||||||
"communication interface failed!" << std::endl;
|
"ComIF initialization failed");
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||||
if (IPCStore == nullptr) {
|
if (IPCStore == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR, "initialize",
|
||||||
sif::error << "DeviceHandlerBase::initialize: IPC store not set up in "
|
ObjectManagerIF::CHILD_INIT_FAILED, "IPC Store not set up");
|
||||||
"factory." << std::endl;
|
|
||||||
#endif
|
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,11 +150,15 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
AcceptsDeviceResponsesIF>(rawDataReceiverId);
|
AcceptsDeviceResponsesIF>(rawDataReceiverId);
|
||||||
|
|
||||||
if (rawReceiver == nullptr) {
|
if (rawReceiver == nullptr) {
|
||||||
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
|
"initialize", ObjectManagerIF::CHILD_INIT_FAILED,
|
||||||
|
"Raw receiver object ID set but no valid object found.");
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "DeviceHandlerBase::initialize: Raw receiver object "
|
|
||||||
"ID set but no valid object found." << std::endl;
|
|
||||||
sif::error << "Make sure the raw receiver object is set up properly"
|
sif::error << "Make sure the raw receiver object is set up properly"
|
||||||
" and implements AcceptsDeviceResponsesIF" << std::endl;
|
" and implements AcceptsDeviceResponsesIF" << std::endl;
|
||||||
|
#else
|
||||||
|
fsfw::printError("Make sure the raw receiver object is set up "
|
||||||
|
"properly and implements AcceptsDeviceResponsesIF\n");
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
@ -178,11 +168,15 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
if(powerSwitcherId != objects::NO_OBJECT) {
|
if(powerSwitcherId != objects::NO_OBJECT) {
|
||||||
powerSwitcher = objectManager->get<PowerSwitchIF>(powerSwitcherId);
|
powerSwitcher = objectManager->get<PowerSwitchIF>(powerSwitcherId);
|
||||||
if (powerSwitcher == nullptr) {
|
if (powerSwitcher == nullptr) {
|
||||||
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
|
"initialize", ObjectManagerIF::CHILD_INIT_FAILED,
|
||||||
|
"Power switcher set but no valid object found.");
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "DeviceHandlerBase::initialize: Power switcher "
|
sif::error << "Make sure the power switcher object is set up "
|
||||||
<< "object ID set but no valid object found." << std::endl;
|
<< "properly and implements PowerSwitchIF" << std::endl;
|
||||||
sif::error << "Make sure the raw receiver object is set up properly"
|
#else
|
||||||
<< " and implements PowerSwitchIF" << std::endl;
|
fsfw::printError("Make sure the power switcher object is set up "
|
||||||
|
"properly and implements PowerSwitchIF\n");
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
@ -556,17 +550,17 @@ void DeviceHandlerBase::replyReturnvalueToCommand(ReturnValue_t status,
|
|||||||
|
|
||||||
void DeviceHandlerBase::replyToCommand(ReturnValue_t status,
|
void DeviceHandlerBase::replyToCommand(ReturnValue_t status,
|
||||||
uint32_t parameter) {
|
uint32_t parameter) {
|
||||||
//Check if we reply to a raw command.
|
// Check if we reply to a raw command.
|
||||||
if (cookieInfo.pendingCommand->first == RAW_COMMAND_ID) {
|
if (cookieInfo.pendingCommand->first == RAW_COMMAND_ID) {
|
||||||
if (status == NO_REPLY_EXPECTED) {
|
if (status == NO_REPLY_EXPECTED) {
|
||||||
status = RETURN_OK;
|
status = RETURN_OK;
|
||||||
}
|
}
|
||||||
replyReturnvalueToCommand(status, parameter);
|
replyReturnvalueToCommand(status, parameter);
|
||||||
//Always delete data from a raw command.
|
// Always delete data from a raw command.
|
||||||
IPCStore->deleteData(storedRawData);
|
IPCStore->deleteData(storedRawData);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Check if we were externally commanded.
|
// Check if we were externally commanded.
|
||||||
if (cookieInfo.pendingCommand->second.sendReplyTo != NO_COMMANDER) {
|
if (cookieInfo.pendingCommand->second.sendReplyTo != NO_COMMANDER) {
|
||||||
MessageQueueId_t queueId = cookieInfo.pendingCommand->second.sendReplyTo;
|
MessageQueueId_t queueId = cookieInfo.pendingCommand->second.sendReplyTo;
|
||||||
if (status == NO_REPLY_EXPECTED) {
|
if (status == NO_REPLY_EXPECTED) {
|
||||||
@ -581,15 +575,17 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status,
|
|||||||
|
|
||||||
void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
|
void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
|
||||||
ReturnValue_t status) {
|
ReturnValue_t status) {
|
||||||
//No need to check if iter exists, as this is checked by callers. If someone else uses the method, add check.
|
// 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 (iter->second.command == deviceCommandMap.end()) {
|
||||||
//Is most likely periodic reply. Silent return.
|
//Is most likely periodic reply. Silent return.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Check if more replies are expected. If so, do nothing.
|
// Check if more replies are expected. If so, do nothing.
|
||||||
DeviceCommandInfo* info = &(iter->second.command->second);
|
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.
|
// Check if it was transition or internal command.
|
||||||
|
// Don't send any replies in that case.
|
||||||
if (info->sendReplyTo != NO_COMMANDER) {
|
if (info->sendReplyTo != NO_COMMANDER) {
|
||||||
actionHelper.finish(info->sendReplyTo, iter->first, status);
|
actionHelper.finish(info->sendReplyTo, iter->first, status);
|
||||||
}
|
}
|
||||||
@ -606,7 +602,7 @@ void DeviceHandlerBase::doSendWrite() {
|
|||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
cookieInfo.state = COOKIE_WRITE_SENT;
|
cookieInfo.state = COOKIE_WRITE_SENT;
|
||||||
} else {
|
} else {
|
||||||
//always generate a failure event, so that FDIR knows what's up
|
// always generate a failure event, so that FDIR knows what's up
|
||||||
triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result,
|
triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result,
|
||||||
cookieInfo.pendingCommand->first);
|
cookieInfo.pendingCommand->first);
|
||||||
replyToCommand(result);
|
replyToCommand(result);
|
||||||
@ -721,10 +717,9 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
|
|||||||
case RETURN_OK:
|
case RETURN_OK:
|
||||||
handleReply(receivedData, foundId, foundLen);
|
handleReply(receivedData, foundId, foundLen);
|
||||||
if(foundLen == 0) {
|
if(foundLen == 0) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
|
"parseReply", ObjectManagerIF::CHILD_INIT_FAILED,
|
||||||
" Packet parsing will be stuck." << std::endl;
|
"Found length is one, parsing might be stuck");
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case APERIODIC_REPLY: {
|
case APERIODIC_REPLY: {
|
||||||
@ -735,6 +730,9 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
|
|||||||
foundId);
|
foundId);
|
||||||
}
|
}
|
||||||
if(foundLen == 0) {
|
if(foundLen == 0) {
|
||||||
|
printWarningOrError(fsfw::OutputTypes::OUT_ERROR,
|
||||||
|
"parseReply", ObjectManagerIF::CHILD_INIT_FAILED,
|
||||||
|
"Power switcher set but no valid object found.");
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
|
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
|
||||||
" Packet parsing will be stuck." << std::endl;
|
" Packet parsing will be stuck." << std::endl;
|
||||||
@ -747,7 +745,8 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
|
|||||||
case IGNORE_FULL_PACKET:
|
case IGNORE_FULL_PACKET:
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
//We need to wait for timeout.. don't know what command failed and who sent it.
|
// We need to wait for timeout.. don't know what command failed
|
||||||
|
// and who sent it.
|
||||||
replyRawReplyIfnotWiretapped(receivedData, foundLen);
|
replyRawReplyIfnotWiretapped(receivedData, foundLen);
|
||||||
triggerEvent(DEVICE_READING_REPLY_FAILED, result, foundLen);
|
triggerEvent(DEVICE_READING_REPLY_FAILED, result, foundLen);
|
||||||
break;
|
break;
|
||||||
@ -968,7 +967,8 @@ ReturnValue_t DeviceHandlerBase::getStateOfSwitches(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Mode_t DeviceHandlerBase::getBaseMode(Mode_t transitionMode) {
|
Mode_t DeviceHandlerBase::getBaseMode(Mode_t transitionMode) {
|
||||||
//only child action special modes are handled, as a child should never see any base action modes
|
// only child action special modes are handled, as a child should
|
||||||
|
// never see any base action modes
|
||||||
if (transitionMode == _MODE_START_UP) {
|
if (transitionMode == _MODE_START_UP) {
|
||||||
return _MODE_TO_ON;
|
return _MODE_TO_ON;
|
||||||
}
|
}
|
||||||
@ -1291,12 +1291,11 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
|||||||
if (mode == MODE_NORMAL) {
|
if (mode == MODE_NORMAL) {
|
||||||
result = buildNormalDeviceCommand(&deviceCommandId);
|
result = buildNormalDeviceCommand(&deviceCommandId);
|
||||||
if (result == BUSY) {
|
if (result == BUSY) {
|
||||||
//so we can track misconfigurations
|
// so we can track misconfigurations
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
sif::debug << std::hex << getObjectId()
|
"buildInternalCommand",
|
||||||
<< ": DHB::buildInternalCommand: Busy" << std::dec
|
HasReturnvaluesIF::RETURN_FAILED,
|
||||||
<< std::endl;
|
"Busy.");
|
||||||
#endif
|
|
||||||
result = NOTHING_TO_SEND; //no need to report this
|
result = NOTHING_TO_SEND; //no need to report this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1320,12 +1319,15 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
|||||||
if (iter == deviceCommandMap.end()) {
|
if (iter == deviceCommandMap.end()) {
|
||||||
result = COMMAND_NOT_SUPPORTED;
|
result = COMMAND_NOT_SUPPORTED;
|
||||||
} else if (iter->second.isExecuting) {
|
} else if (iter->second.isExecuting) {
|
||||||
//so we can track misconfigurations
|
#if FSFW_DISABLE_PRINTOUT == 0
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
char output[36];
|
||||||
sif::debug << std::hex << getObjectId()
|
sprintf(output, "Command 0x%08x is executing",
|
||||||
<< ": DHB::buildInternalCommand: Command "
|
static_cast<unsigned int>(deviceCommandId));
|
||||||
<< deviceCommandId << " isExecuting" << std::dec
|
// so we can track misconfigurations
|
||||||
<< std::endl;
|
printWarningOrError(fsfw::OutputTypes::OUT_WARNING,
|
||||||
|
"buildInternalCommand",
|
||||||
|
HasReturnvaluesIF::RETURN_FAILED,
|
||||||
|
output);
|
||||||
#endif
|
#endif
|
||||||
// this is an internal command, no need to report a failure here,
|
// this is an internal command, no need to report a failure here,
|
||||||
// missed reply will track if a reply is too late, otherwise, it's ok
|
// missed reply will track if a reply is too late, otherwise, it's ok
|
||||||
@ -1485,3 +1487,48 @@ void DeviceHandlerBase::setNormalDatapoolEntriesInvalid() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceHandlerBase::printWarningOrError(fsfw::OutputTypes errorType,
|
||||||
|
const char *functionName, ReturnValue_t errorCode,
|
||||||
|
const char *errorPrint) {
|
||||||
|
if(errorPrint == nullptr) {
|
||||||
|
if(errorCode == ObjectManagerIF::CHILD_INIT_FAILED) {
|
||||||
|
errorPrint = "Initialization error";
|
||||||
|
}
|
||||||
|
if(errorCode == HasReturnvaluesIF::RETURN_FAILED) {
|
||||||
|
if(errorType == fsfw::OutputTypes::OUT_WARNING) {
|
||||||
|
errorPrint = "Generic Warning";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errorPrint = "Generic Error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errorPrint = "Unknown error";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(errorType == fsfw::OutputTypes::OUT_WARNING) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "DeviceHandlerBase::" << functionName << ": Object ID "
|
||||||
|
<< std::hex << std::setw(8) << std::setfill('0')
|
||||||
|
<< this->getObjectId() << " | " << errorPrint << std::dec
|
||||||
|
<< std::setfill(' ') << std::endl;
|
||||||
|
#else
|
||||||
|
fsfw::printWarning("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n",
|
||||||
|
this->getObjectId(), errorPrint);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if(errorType == fsfw::OutputTypes::OUT_ERROR) {
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::error << "DeviceHandlerBase::" << functionName << ": Object ID "
|
||||||
|
<< std::hex << std::setw(8) << std::setfill('0')
|
||||||
|
<< this->getObjectId() << " | " << errorPrint << std::dec
|
||||||
|
<< std::setfill(' ') << std::endl;
|
||||||
|
#else
|
||||||
|
fsfw::printError("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n",
|
||||||
|
this->getObjectId(), errorPrint);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include "DeviceHandlerFailureIsolation.h"
|
#include "DeviceHandlerFailureIsolation.h"
|
||||||
#include "DeviceHandlerThermalSet.h"
|
#include "DeviceHandlerThermalSet.h"
|
||||||
|
|
||||||
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
|
#include "../serviceinterface/serviceInterfaceDefintions.h"
|
||||||
#include "../objectmanager/SystemObject.h"
|
#include "../objectmanager/SystemObject.h"
|
||||||
#include "../tasks/ExecutableObjectIF.h"
|
#include "../tasks/ExecutableObjectIF.h"
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||||
@ -1111,7 +1113,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* @brief The mode the current transition originated from
|
* @brief The mode the current transition originated from
|
||||||
*
|
*
|
||||||
* This is private so the child can not change it and fuck up the timeouts
|
* This is private so the child can not change it and mess up the timeouts
|
||||||
*
|
*
|
||||||
* IMPORTANT: This is not valid during _MODE_SHUT_DOWN and _MODE_START_UP!!
|
* IMPORTANT: This is not valid during _MODE_SHUT_DOWN and _MODE_START_UP!!
|
||||||
* (it is _MODE_POWER_DOWN during this modes)
|
* (it is _MODE_POWER_DOWN during this modes)
|
||||||
@ -1190,7 +1192,8 @@ private:
|
|||||||
* Check if the RMAP sendWrite action was successful.
|
* Check if the RMAP sendWrite action was successful.
|
||||||
*
|
*
|
||||||
* Depending on the result, the following is done
|
* Depending on the result, the following is done
|
||||||
* - if the device command was external commanded, a reply is sent indicating the result
|
* - if the device command was external commanded, a reply is sent
|
||||||
|
* indicating the result
|
||||||
* - if the action was successful, the reply timout counter is initialized
|
* - if the action was successful, the reply timout counter is initialized
|
||||||
*/
|
*/
|
||||||
void doGetWrite(void);
|
void doGetWrite(void);
|
||||||
@ -1206,9 +1209,9 @@ private:
|
|||||||
/**
|
/**
|
||||||
* Check the getRead reply and the contained data.
|
* Check the getRead reply and the contained data.
|
||||||
*
|
*
|
||||||
* If data was received scanForReply() and, if successful, handleReply() are called.
|
* If data was received scanForReply() and, if successful, handleReply()
|
||||||
* If the current mode is @c MODE_RAW, the received packet is sent to the commanding object
|
* are called. If the current mode is @c MODE_RAW, the received packet
|
||||||
* via commandQueue.
|
* is sent to the commanding object via commandQueue.
|
||||||
*/
|
*/
|
||||||
void doGetRead(void);
|
void doGetRead(void);
|
||||||
|
|
||||||
@ -1227,7 +1230,7 @@ private:
|
|||||||
uint32_t *len);
|
uint32_t *len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param modeTo either @c MODE_ON, MODE_NORMAL or MODE_RAW NOTHING ELSE!!!
|
* @param modeTo either @c MODE_ON, MODE_NORMAL or MODE_RAW, nothing else!
|
||||||
*/
|
*/
|
||||||
void setTransition(Mode_t modeTo, Submode_t submodeTo);
|
void setTransition(Mode_t modeTo, Submode_t submodeTo);
|
||||||
|
|
||||||
@ -1247,6 +1250,11 @@ private:
|
|||||||
|
|
||||||
void handleTransitionToOnMode(Mode_t commandedMode,
|
void handleTransitionToOnMode(Mode_t commandedMode,
|
||||||
Submode_t commandedSubmode);
|
Submode_t commandedSubmode);
|
||||||
|
|
||||||
|
void printWarningOrError(fsfw::OutputTypes errorType,
|
||||||
|
const char* functionName,
|
||||||
|
ReturnValue_t errorCode = HasReturnvaluesIF::RETURN_FAILED,
|
||||||
|
const char* errorPrint = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */
|
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "arrayprinter.h"
|
#include "arrayprinter.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterface.h"
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
||||||
@ -9,6 +9,8 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
|||||||
sif::info << "Printing data with size " << size << ": ";
|
sif::info << "Printing data with size " << size << ": ";
|
||||||
}
|
}
|
||||||
sif::info << "[";
|
sif::info << "[";
|
||||||
|
#else
|
||||||
|
fsfw::printInfo("Printing data with size %zu: [", size);
|
||||||
#endif
|
#endif
|
||||||
if(type == OutputType::HEX) {
|
if(type == OutputType::HEX) {
|
||||||
arrayprinter::printHex(data, size, maxCharPerLine);
|
arrayprinter::printHex(data, size, maxCharPerLine);
|
||||||
@ -37,6 +39,8 @@ void arrayprinter::printHex(const uint8_t *data, size_t size,
|
|||||||
}
|
}
|
||||||
sif::info << std::dec;
|
sif::info << std::dec;
|
||||||
sif::info << "]" << std::endl;
|
sif::info << "]" << std::endl;
|
||||||
|
#else
|
||||||
|
// how much memory to reserve for printout?
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,6 +58,8 @@ void arrayprinter::printDec(const uint8_t *data, size_t size,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sif::info << "]" << std::endl;
|
sif::info << "]" << std::endl;
|
||||||
|
#else
|
||||||
|
// how much memory to reserve for printout?
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,5 +71,7 @@ void arrayprinter::printBin(const uint8_t *data, size_t size) {
|
|||||||
std::bitset<8>(data[i]) << ",\n" << std::flush;
|
std::bitset<8>(data[i]) << ",\n" << std::flush;
|
||||||
}
|
}
|
||||||
sif::info << "]" << std::endl;
|
sif::info << "]" << std::endl;
|
||||||
|
#else
|
||||||
|
// how much memory to reserve for printout?
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ public:
|
|||||||
|
|
||||||
std::timed_mutex* getMutexHandle();
|
std::timed_mutex* getMutexHandle();
|
||||||
private:
|
private:
|
||||||
//bool locked = false;
|
|
||||||
std::timed_mutex mutex;
|
std::timed_mutex mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_
|
#define FSFW_SERVICEINTERFACE_SERVICEINTERFACE_H_
|
||||||
|
|
||||||
#include <FSFWConfig.h>
|
#include <FSFWConfig.h>
|
||||||
|
#include "serviceInterfaceDefintions.h"
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG;
|
static fsfw::PrintLevel printLevel = fsfw::PrintLevel::DEBUG_LEVEL;
|
||||||
#if defined(WIN32) && FSFW_COLORED_OUTPUT == 1
|
#if defined(WIN32) && FSFW_COLORED_OUTPUT == 1
|
||||||
bool consoleInitialized = false;
|
static bool consoleInitialized = false;
|
||||||
#endif /* defined(WIN32) && FSFW_COLORED_OUTPUT == 1 */
|
#endif /* defined(WIN32) && FSFW_COLORED_OUTPUT == 1 */
|
||||||
|
static bool addCrAtEnd = false;
|
||||||
|
|
||||||
#if FSFW_DISABLE_PRINTOUT == 0
|
#if FSFW_DISABLE_PRINTOUT == 0
|
||||||
uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE];
|
uint8_t printBuffer[fsfwconfig::FSFW_PRINT_BUFFER_SIZE];
|
||||||
@ -39,31 +39,31 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) {
|
|||||||
/* Log message to terminal */
|
/* Log message to terminal */
|
||||||
|
|
||||||
#if FSFW_COLORED_OUTPUT == 1
|
#if FSFW_COLORED_OUTPUT == 1
|
||||||
if(printType == fsfw::PrintLevel::INFO) {
|
if(printType == fsfw::PrintLevel::INFO_LEVEL) {
|
||||||
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_GREEN);
|
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_GREEN);
|
||||||
}
|
}
|
||||||
else if(printType == fsfw::PrintLevel::DEBUG) {
|
else if(printType == fsfw::PrintLevel::DEBUG_LEVEL) {
|
||||||
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_MAGENTA);
|
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_MAGENTA);
|
||||||
}
|
}
|
||||||
else if(printType == fsfw::PrintLevel::WARNING) {
|
else if(printType == fsfw::PrintLevel::WARNING_LEVEL) {
|
||||||
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_YELLOW);
|
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_YELLOW);
|
||||||
}
|
}
|
||||||
else if(printType == fsfw::PrintLevel::ERROR_TYPE) {
|
else if(printType == fsfw::PrintLevel::ERROR_LEVEL) {
|
||||||
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_RED);
|
len += sprintf(bufferPosition, fsfw::ANSI_COLOR_RED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (printType == fsfw::PrintLevel::INFO) {
|
if (printType == fsfw::PrintLevel::INFO_LEVEL) {
|
||||||
len += sprintf(bufferPosition + len, "INFO: ");
|
len += sprintf(bufferPosition + len, "INFO: ");
|
||||||
}
|
}
|
||||||
if(printType == fsfw::PrintLevel::DEBUG) {
|
if(printType == fsfw::PrintLevel::DEBUG_LEVEL) {
|
||||||
len += sprintf(bufferPosition + len, "DEBUG: ");
|
len += sprintf(bufferPosition + len, "DEBUG: ");
|
||||||
}
|
}
|
||||||
if(printType == fsfw::PrintLevel::WARNING) {
|
if(printType == fsfw::PrintLevel::WARNING_LEVEL) {
|
||||||
len += sprintf(bufferPosition + len, "WARNING: ");
|
len += sprintf(bufferPosition + len, "WARNING: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(printType == fsfw::PrintLevel::ERROR_TYPE) {
|
if(printType == fsfw::PrintLevel::ERROR_LEVEL) {
|
||||||
len += sprintf(bufferPosition + len, "ERROR: ");
|
len += sprintf(bufferPosition + len, "ERROR: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +80,10 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) {
|
|||||||
|
|
||||||
len += vsnprintf(bufferPosition + len, sizeof(printBuffer) - len, fmt, arg);
|
len += vsnprintf(bufferPosition + len, sizeof(printBuffer) - len, fmt, arg);
|
||||||
|
|
||||||
|
if(addCrAtEnd) {
|
||||||
|
len += sprintf(bufferPosition + len, "\r");
|
||||||
|
}
|
||||||
|
|
||||||
printf("%s", printBuffer);
|
printf("%s", printBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,28 +91,32 @@ void fsfwPrint(fsfw::PrintLevel printType, const char* fmt, va_list arg) {
|
|||||||
void fsfw::printInfo(const char *fmt, ...) {
|
void fsfw::printInfo(const char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
fsfwPrint(fsfw::PrintLevel::INFO, fmt, args);
|
fsfwPrint(fsfw::PrintLevel::INFO_LEVEL, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsfw::printWarning(const char *fmt, ...) {
|
void fsfw::printWarning(const char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
fsfwPrint(fsfw::PrintLevel::WARNING, fmt, args);
|
fsfwPrint(fsfw::PrintLevel::WARNING_LEVEL, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fsfw::printDebug(const char *fmt, ...) {
|
void fsfw::printDebug(const char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
fsfwPrint(fsfw::PrintLevel::DEBUG, fmt, args);
|
fsfwPrint(fsfw::PrintLevel::DEBUG_LEVEL, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fsfw::setToAddCrAtEnd(bool addCrAtEnd_) {
|
||||||
|
addCrAtEnd = addCrAtEnd_;
|
||||||
|
}
|
||||||
|
|
||||||
void fsfw::printError(const char *fmt, ...) {
|
void fsfw::printError(const char *fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
fsfwPrint(fsfw::PrintLevel::ERROR_TYPE, fmt, args);
|
fsfwPrint(fsfw::PrintLevel::ERROR_LEVEL, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,29 @@
|
|||||||
#if FSFW_DISABLE_PRINTOUT == 0
|
#if FSFW_DISABLE_PRINTOUT == 0
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace fsfw {
|
namespace fsfw {
|
||||||
|
|
||||||
enum class PrintLevel {
|
enum PrintLevel {
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
//! Strange error when using just ERROR..
|
//! Strange error when using just ERROR..
|
||||||
ERROR_TYPE = 1,
|
ERROR_LEVEL = 1,
|
||||||
WARNING = 2,
|
WARNING_LEVEL = 2,
|
||||||
INFO = 3,
|
INFO_LEVEL = 3,
|
||||||
DEBUG = 4
|
DEBUG_LEVEL = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the print level. All print types with a smaller level will be printed
|
||||||
|
* as well. For example, set to PrintLevel::WARNING to only enable error
|
||||||
|
* and warning output.
|
||||||
|
* @param printLevel
|
||||||
|
*/
|
||||||
void setPrintLevel(PrintLevel printLevel);
|
void setPrintLevel(PrintLevel printLevel);
|
||||||
PrintLevel getPrintLevel();
|
PrintLevel getPrintLevel();
|
||||||
|
|
||||||
|
void setToAddCrAtEnd(bool addCrAtEnd_);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These functions can be used like the C stdio printf and forward the
|
* These functions can be used like the C stdio printf and forward the
|
||||||
* supplied formatted string arguments to a printf function.
|
* supplied formatted string arguments to a printf function.
|
||||||
|
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
namespace fsfw {
|
namespace fsfw {
|
||||||
|
|
||||||
|
enum class OutputTypes {
|
||||||
|
OUT_INFO,
|
||||||
|
OUT_DEBUG,
|
||||||
|
OUT_WARNING,
|
||||||
|
OUT_ERROR
|
||||||
|
};
|
||||||
|
|
||||||
static const char* const ANSI_COLOR_RED = "\x1b[31m";
|
static const char* const ANSI_COLOR_RED = "\x1b[31m";
|
||||||
static const char* const ANSI_COLOR_GREEN = "\x1b[32m";
|
static const char* const ANSI_COLOR_GREEN = "\x1b[32m";
|
||||||
static const char* const ANSI_COLOR_YELLOW = "\x1b[33m";
|
static const char* const ANSI_COLOR_YELLOW = "\x1b[33m";
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
target_sources(${TARGET_NAME} PRIVATE
|
target_sources(${TARGET_NAME} PRIVATE
|
||||||
LocalPoolVariableTest.cpp
|
LocalPoolVariableTest.cpp
|
||||||
|
LocalPoolVectorTest.cpp
|
||||||
|
DataSetTest.cpp
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||||
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
#include <unittest/core/CatchDefinitions.h>
|
#include <unittest/core/CatchDefinitions.h>
|
||||||
|
|
||||||
TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
|
TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
|
||||||
@ -11,9 +12,10 @@ TEST_CASE("LocalDataSet" , "[LocDataSetTest]") {
|
|||||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||||
== retval::CATCH_OK);
|
== retval::CATCH_OK);
|
||||||
|
const uint32_t setId = 0;
|
||||||
SECTION("BasicTest") {
|
SECTION("BasicTest") {
|
||||||
//StaticLocalDataSet<3> localSet = StaticLocalDataSet<3>()
|
StaticLocalDataSet<3> localSet = StaticLocalDataSet<3>(
|
||||||
|
sid_t(objects::TEST_LOCAL_POOL_OWNER_BASE, setId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ TEST_CASE("LocalPoolVariable" , "[LocPoolVarTest]") {
|
|||||||
REQUIRE(testVariable.commit() == retval::CATCH_OK);
|
REQUIRE(testVariable.commit() == retval::CATCH_OK);
|
||||||
REQUIRE(testVariable.read() == retval::CATCH_OK);
|
REQUIRE(testVariable.read() == retval::CATCH_OK);
|
||||||
REQUIRE(testVariable.value == 5);
|
REQUIRE(testVariable.value == 5);
|
||||||
|
|
||||||
CHECK(not testVariable.isValid());
|
CHECK(not testVariable.isValid());
|
||||||
testVariable.setValid(true);
|
testVariable.setValid(true);
|
||||||
CHECK(testVariable.isValid());
|
CHECK(testVariable.isValid());
|
||||||
|
CHECK(testVariable.commit(true) == retval::CATCH_OK);
|
||||||
|
|
||||||
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ);
|
testVariable.setReadWriteMode(pool_rwm_t::VAR_READ);
|
||||||
CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ);
|
CHECK(testVariable.getReadWriteMode() == pool_rwm_t::VAR_READ);
|
||||||
|
@ -11,6 +11,110 @@ TEST_CASE("LocalPoolVector" , "[LocPoolVecTest]") {
|
|||||||
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
REQUIRE(poolOwner->initializeHkManager() == retval::CATCH_OK);
|
||||||
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
REQUIRE(poolOwner->initializeHkManagerAfterTaskCreation()
|
||||||
== retval::CATCH_OK);
|
== retval::CATCH_OK);
|
||||||
|
|
||||||
|
SECTION("BasicTest") {
|
||||||
|
// very basic test.
|
||||||
|
lp_vec_t<uint16_t, 3> testVector = lp_vec_t<uint16_t, 3>(
|
||||||
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id);
|
||||||
|
REQUIRE(testVector.read() == retval::CATCH_OK);
|
||||||
|
testVector.value[0] = 5;
|
||||||
|
testVector.value[1] = 232;
|
||||||
|
testVector.value[2] = 32023;
|
||||||
|
|
||||||
|
REQUIRE(testVector.commit(true) == retval::CATCH_OK);
|
||||||
|
CHECK(testVector.isValid());
|
||||||
|
|
||||||
|
testVector.value[0] = 0;
|
||||||
|
testVector.value[1] = 0;
|
||||||
|
testVector.value[2] = 0;
|
||||||
|
|
||||||
|
CHECK(testVector.read() == retval::CATCH_OK);
|
||||||
|
CHECK(testVector.value[0] == 5);
|
||||||
|
CHECK(testVector.value[1] == 232);
|
||||||
|
CHECK(testVector.value[2] == 32023);
|
||||||
|
|
||||||
|
CHECK(testVector[0] == 5);
|
||||||
|
|
||||||
|
// This is invalid access, so the last value will be set instead.
|
||||||
|
// (we can't throw exceptions)
|
||||||
|
testVector[4] = 12;
|
||||||
|
CHECK(testVector[2] == 12);
|
||||||
|
CHECK(testVector.commit() == retval::CATCH_OK);
|
||||||
|
|
||||||
|
// Use read-only reference.
|
||||||
|
const lp_vec_t<uint16_t, 3>& roTestVec = testVector;
|
||||||
|
uint16_t valueOne = roTestVec[0];
|
||||||
|
CHECK(valueOne == 5);
|
||||||
|
|
||||||
|
uint16_t lastVal = roTestVec[25];
|
||||||
|
CHECK(lastVal == 12);
|
||||||
|
|
||||||
|
size_t maxSize = testVector.getSerializedSize();
|
||||||
|
CHECK(maxSize == 6);
|
||||||
|
|
||||||
|
uint16_t serializedVector[3];
|
||||||
|
uint8_t* vecPtr = reinterpret_cast<uint8_t*>(serializedVector);
|
||||||
|
size_t serSize = 0;
|
||||||
|
REQUIRE(testVector.serialize(&vecPtr, &serSize,
|
||||||
|
maxSize, SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
||||||
|
|
||||||
|
CHECK(serSize == 6);
|
||||||
|
CHECK(serializedVector[0] == 5);
|
||||||
|
CHECK(serializedVector[1] == 232);
|
||||||
|
CHECK(serializedVector[2] == 12);
|
||||||
|
|
||||||
|
maxSize = 1;
|
||||||
|
REQUIRE(testVector.serialize(&vecPtr, &serSize,
|
||||||
|
maxSize, SerializeIF::Endianness::MACHINE) ==
|
||||||
|
static_cast<int>(SerializeIF::BUFFER_TOO_SHORT));
|
||||||
|
|
||||||
|
serializedVector[0] = 16;
|
||||||
|
serializedVector[1] = 7832;
|
||||||
|
serializedVector[2] = 39232;
|
||||||
|
|
||||||
|
const uint8_t* constVecPtr = reinterpret_cast<const uint8_t*>(
|
||||||
|
serializedVector);
|
||||||
|
REQUIRE(testVector.deSerialize(&constVecPtr, &serSize,
|
||||||
|
SerializeIF::Endianness::MACHINE) == retval::CATCH_OK);
|
||||||
|
CHECK(testVector[0] == 16);
|
||||||
|
CHECK(testVector[1] == 7832);
|
||||||
|
CHECK(testVector[2] == 39232);
|
||||||
|
|
||||||
|
serSize = 1;
|
||||||
|
REQUIRE(testVector.deSerialize(&constVecPtr, &serSize,
|
||||||
|
SerializeIF::Endianness::MACHINE) ==
|
||||||
|
static_cast<int>(SerializeIF::STREAM_TOO_SHORT));
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION("ErrorHandling") {
|
||||||
|
// not try to use a local pool variable which does not exist
|
||||||
|
lp_vec_t<uint16_t, 3> invalidVector = lp_vec_t<uint16_t, 3>(
|
||||||
|
objects::TEST_LOCAL_POOL_OWNER_BASE, 0xffffffff);
|
||||||
|
REQUIRE(invalidVector.read() ==
|
||||||
|
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND));
|
||||||
|
REQUIRE(invalidVector.commit() ==
|
||||||
|
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND));
|
||||||
|
|
||||||
|
// now try to access with wrong type
|
||||||
|
lp_vec_t<uint32_t, 3> invalidVector2 = lp_vec_t<uint32_t, 3>(
|
||||||
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id);
|
||||||
|
REQUIRE(invalidVector2.read() ==
|
||||||
|
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT));
|
||||||
|
REQUIRE(invalidVector2.commit() ==
|
||||||
|
static_cast<int>(HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT));
|
||||||
|
|
||||||
|
lp_vec_t<uint16_t, 3> writeOnlyVec = lp_vec_t<uint16_t, 3>(
|
||||||
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id,
|
||||||
|
nullptr, pool_rwm_t::VAR_WRITE);
|
||||||
|
REQUIRE(writeOnlyVec.read() ==
|
||||||
|
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
||||||
|
|
||||||
|
lp_vec_t<uint16_t, 3> readOnlyVec = lp_vec_t<uint16_t, 3>(
|
||||||
|
objects::TEST_LOCAL_POOL_OWNER_BASE, lpool::uint16Vec3Id,
|
||||||
|
nullptr, pool_rwm_t::VAR_READ);
|
||||||
|
REQUIRE(readOnlyVec.commit() ==
|
||||||
|
static_cast<int>(PoolVariableIF::INVALID_READ_WRITE_MODE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user