Merge remote-tracking branch 'upstream/mueller/master' into mueller/master

This commit is contained in:
Robin Müller 2021-01-07 20:31:44 +01:00
commit bd5cc7ae3e
154 changed files with 2077 additions and 468 deletions

View File

@ -70,3 +70,15 @@ now
### Commanding Service Base ### Commanding Service Base
- CSB uses the new fsfwconfig::FSFW_CSB_FIFO_DEPTH variable to determine the FIFO depth for each CSB instance. This variable has to be set in the FSFWConfig.h file - CSB uses the new fsfwconfig::FSFW_CSB_FIFO_DEPTH variable to determine the FIFO depth for each CSB instance. This variable has to be set in the FSFWConfig.h file
### Service Interface
- Proper printf support contained in ServiceInterfacePrinter.h
- CPP ostream support now optional (can reduce executable size by 150 - 250 kB)
- Amalagated header which determines automatically which service interface to use depending on FSFWConfig.h configuration.
Users can just use #include <fsfw/serviceinterface/ServiceInterface.h>
- If CPP streams are excluded, sif:: calls won't work anymore and need to be replaced by their printf counterparts.
For the fsfw, this can be done by checking the processor define FSFW_CPP_OSTREAM_ENABLED from FSFWConfig.h.
For mission code, developers need to replace sif:: calls by the printf counterparts, but only if the CPP stream are excluded.
If this is not the case, everything should work as usual.
-

View File

@ -3,6 +3,7 @@
#include "ArrayList.h" #include "ArrayList.h"
#include <cstring> #include <cstring>
#include <functional>
/** /**
* @brief An associative container which allows multiple entries of the same key. * @brief An associative container which allows multiple entries of the same key.

View File

@ -47,9 +47,11 @@ ReturnValue_t SharedRingBuffer::initialize() {
DynamicFIFO<size_t>* SharedRingBuffer::getReceiveSizesFIFO() { DynamicFIFO<size_t>* SharedRingBuffer::getReceiveSizesFIFO() {
if(receiveSizesFIFO == nullptr) { if(receiveSizesFIFO == nullptr) {
// Configuration error. // Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer" sif::warning << "SharedRingBuffer::getReceiveSizesFIFO: Ring buffer"
<< " was not configured to have sizes FIFO, returning nullptr!" << " was not configured to have sizes FIFO, returning nullptr!"
<< std::endl; << std::endl;
#endif
} }
return receiveSizesFIFO; return receiveSizesFIFO;
} }

View File

@ -107,7 +107,9 @@ MessageQueueId_t ExtendedControllerBase::getCommandQueue() const {
} }
LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) { LocalPoolDataSetBase* ExtendedControllerBase::getDataSetHandle(sid_t sid) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "ExtendedControllerBase::getDataSetHandle: No child " sif::warning << "ExtendedControllerBase::getDataSetHandle: No child "
<< " implementation provided, returning nullptr!" << std::endl; << " implementation provided, returning nullptr!" << std::endl;
#endif
return nullptr; return nullptr;
} }

View File

@ -55,7 +55,9 @@ void Clcw::setBitLock(bool bitLock) {
} }
void Clcw::print() { void Clcw::print() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Clcw::print: Clcw is: " << std::hex << getAsWhole() << std::dec << std::endl; sif::debug << "Clcw::print: Clcw is: " << std::hex << getAsWhole() << std::dec << std::endl;
#endif
} }
void Clcw::setWhole(uint32_t rawClcw) { void Clcw::setWhole(uint32_t rawClcw) {

View File

@ -98,8 +98,10 @@ ReturnValue_t DataLinkLayer::processFrame(uint16_t length) {
receivedDataLength = length; receivedDataLength = length;
ReturnValue_t status = allFramesReception(); ReturnValue_t status = allFramesReception();
if (status != RETURN_OK) { if (status != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataLinkLayer::processFrame: frame reception failed. " sif::error << "DataLinkLayer::processFrame: frame reception failed. "
"Error code: " << std::hex << status << std::dec << std::endl; "Error code: " << std::hex << status << std::dec << std::endl;
#endif
// currentFrame.print(); // currentFrame.print();
return status; return status;
} else { } else {
@ -124,7 +126,9 @@ ReturnValue_t DataLinkLayer::initialize() {
if ( virtualChannels.begin() != virtualChannels.end() ) { if ( virtualChannels.begin() != virtualChannels.end() ) {
clcw->setVirtualChannel( virtualChannels.begin()->second->getChannelId() ); clcw->setVirtualChannel( virtualChannels.begin()->second->getChannelId() );
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl; sif::error << "DataLinkLayer::initialize: No VC assigned to this DLL instance! " << std::endl;
#endif
return RETURN_FAILED; return RETURN_FAILED;
} }

View File

@ -29,9 +29,11 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
bufferPosition = &packetBuffer[packetLength]; bufferPosition = &packetBuffer[packetLength];
status = RETURN_OK; status = RETURN_OK;
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Packet too large! Size: " << "MapPacketExtraction::extractPackets. Packet too large! Size: "
<< packetLength << std::endl; << packetLength << std::endl;
#endif
clearBuffers(); clearBuffers();
status = CONTENT_TOO_LARGE; status = CONTENT_TOO_LARGE;
} }
@ -51,24 +53,30 @@ ReturnValue_t MapPacketExtraction::extractPackets(TcTransferFrame* frame) {
} }
status = RETURN_OK; status = RETURN_OK;
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Packet too large! Size: " << "MapPacketExtraction::extractPackets. Packet too large! Size: "
<< packetLength << std::endl; << packetLength << std::endl;
#endif
clearBuffers(); clearBuffers();
status = CONTENT_TOO_LARGE; status = CONTENT_TOO_LARGE;
} }
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Illegal segment! Last flag: " << "MapPacketExtraction::extractPackets. Illegal segment! Last flag: "
<< (int) lastSegmentationFlag << std::endl; << (int) lastSegmentationFlag << std::endl;
#endif
clearBuffers(); clearBuffers();
status = ILLEGAL_SEGMENTATION_FLAG; status = ILLEGAL_SEGMENTATION_FLAG;
} }
break; break;
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error sif::error
<< "MapPacketExtraction::extractPackets. Illegal segmentationFlag: " << "MapPacketExtraction::extractPackets. Illegal segmentationFlag: "
<< (int) segmentationFlag << std::endl; << (int) segmentationFlag << std::endl;
#endif
clearBuffers(); clearBuffers();
status = DATA_CORRUPTED; status = DATA_CORRUPTED;
break; break;
@ -135,10 +143,14 @@ ReturnValue_t MapPacketExtraction::initialize() {
} }
void MapPacketExtraction::printPacketBuffer(void) { void MapPacketExtraction::printPacketBuffer(void) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "DLL: packet_buffer contains: " << std::endl; sif::debug << "DLL: packet_buffer contains: " << std::endl;
#endif
for (uint32_t i = 0; i < this->packetLength; ++i) { for (uint32_t i = 0; i < this->packetLength; ++i) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "packet_buffer[" << std::dec << i << "]: 0x" << std::hex sif::debug << "packet_buffer[" << std::dec << i << "]: 0x" << std::hex
<< (uint16_t) this->packetBuffer[i] << std::endl; << (uint16_t) this->packetBuffer[i] << std::endl;
#endif
} }
} }

View File

@ -87,16 +87,25 @@ uint8_t* TcTransferFrame::getFullDataField() {
} }
void TcTransferFrame::print() { void TcTransferFrame::print() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Raw Frame: " << std::hex << std::endl; sif::debug << "Raw Frame: " << std::hex << std::endl;
for (uint16_t count = 0; count < this->getFullSize(); count++ ) { for (uint16_t count = 0; count < this->getFullSize(); count++ ) {
sif::debug << (uint16_t)this->getFullFrame()[count] << " "; sif::debug << (uint16_t)this->getFullFrame()[count] << " ";
} }
sif::debug << std::dec << std::endl; sif::debug << std::dec << std::endl;
// debug << "Frame Header:" << std::endl;
// debug << "Version Number: " << std::hex << (uint16_t)this->current_frame.getVersionNumber() << std::endl; sif::debug << "Frame Header:" << std::endl;
// debug << "Bypass Flag set?| Ctrl Cmd Flag set?: " << (uint16_t)this->current_frame.bypassFlagSet() << " | " << (uint16_t)this->current_frame.controlCommandFlagSet() << std::endl; sif::debug << "Version Number: " << std::hex
// debug << "SCID : " << this->current_frame.getSpacecraftId() << std::endl; << (uint16_t)this->getVersionNumber() << std::endl;
// debug << "VCID : " << (uint16_t)this->current_frame.getVirtualChannelId() << std::endl; sif::debug << "Bypass Flag set?| Ctrl Cmd Flag set?: "
// debug << "Frame length: " << std::dec << this->current_frame.getFrameLength() << std::endl; << (uint16_t)this->bypassFlagSet() << " | "
// debug << "Sequence Number: " << (uint16_t)this->current_frame.getSequenceNumber() << std::endl; << (uint16_t)this->controlCommandFlagSet() << std::endl;
sif::debug << "SCID : " << this->getSpacecraftId() << std::endl;
sif::debug << "VCID : " << (uint16_t)this->getVirtualChannelId()
<< std::endl;
sif::debug << "Frame length: " << std::dec << this->getFrameLength()
<< std::endl;
sif::debug << "Sequence Number: " << (uint16_t)this->getSequenceNumber()
<< std::endl;
#endif
} }

View File

@ -37,7 +37,9 @@ TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uin
this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8; this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8;
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF); this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "TcTransferFrameLocal: dataSize too large: " << dataSize << std::endl; sif::debug << "TcTransferFrameLocal: dataSize too large: " << dataSize << std::endl;
#endif
} }
} else { } else {
//No data in frame //No data in frame

View File

@ -102,8 +102,10 @@ uint8_t VirtualChannelReception::getChannelId() const {
ReturnValue_t VirtualChannelReception::initialize() { ReturnValue_t VirtualChannelReception::initialize() {
ReturnValue_t returnValue = RETURN_FAILED; ReturnValue_t returnValue = RETURN_FAILED;
if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) { if ((slidingWindowWidth > 254) || (slidingWindowWidth % 2 != 0)) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: " sif::error << "VirtualChannelReception::initialize: Illegal sliding window width: "
<< (int) slidingWindowWidth << std::endl; << (int) slidingWindowWidth << std::endl;
#endif
return RETURN_FAILED; return RETURN_FAILED;
} }
for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end(); for (mapChannelIterator iterator = mapChannels.begin(); iterator != mapChannels.end();

View File

@ -13,18 +13,24 @@ PoolDataSetBase::~PoolDataSetBase() {}
ReturnValue_t PoolDataSetBase::registerVariable( ReturnValue_t PoolDataSetBase::registerVariable(
PoolVariableIF *variable) { PoolVariableIF *variable) {
if (state != States::STATE_SET_UNINITIALISED) { if (state != States::STATE_SET_UNINITIALISED) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: " sif::error << "DataSet::registerVariable: "
"Call made in wrong position." << std::endl; "Call made in wrong position." << std::endl;
#endif
return DataSetIF::DATA_SET_UNINITIALISED; return DataSetIF::DATA_SET_UNINITIALISED;
} }
if (variable == nullptr) { if (variable == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: " sif::error << "DataSet::registerVariable: "
"Pool variable is nullptr." << std::endl; "Pool variable is nullptr." << std::endl;
#endif
return DataSetIF::POOL_VAR_NULL; return DataSetIF::POOL_VAR_NULL;
} }
if (fillCount >= maxFillCount) { if (fillCount >= maxFillCount) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::registerVariable: " sif::error << "DataSet::registerVariable: "
"DataSet is full." << std::endl; "DataSet is full." << std::endl;
#endif
return DataSetIF::DATA_SET_FULL; return DataSetIF::DATA_SET_FULL;
} }
registeredVariables[fillCount] = variable; registeredVariables[fillCount] = variable;
@ -32,11 +38,12 @@ ReturnValue_t PoolDataSetBase::registerVariable(
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t PoolDataSetBase::read(uint32_t lockTimeout) { ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
ReturnValue_t error = result; ReturnValue_t error = result;
if (state == States::STATE_SET_UNINITIALISED) { if (state == States::STATE_SET_UNINITIALISED) {
lockDataPool(lockTimeout); lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) { for (uint16_t count = 0; count < fillCount; count++) {
result = readVariable(count); result = readVariable(count);
if(result != RETURN_OK) { if(result != RETURN_OK) {
@ -47,9 +54,11 @@ ReturnValue_t PoolDataSetBase::read(uint32_t lockTimeout) {
unlockDataPool(); unlockDataPool();
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::read(): " sif::error << "DataSet::read(): "
"Call made in wrong position. Don't forget to commit" "Call made in wrong position. Don't forget to commit"
" member datasets!" << std::endl; " member datasets!" << std::endl;
#endif
result = SET_WAS_ALREADY_READ; result = SET_WAS_ALREADY_READ;
} }
@ -78,7 +87,8 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
!= PoolVariableIF::NO_PARAMETER) != PoolVariableIF::NO_PARAMETER)
{ {
if(protectEveryReadCommitCall) { if(protectEveryReadCommitCall) {
result = registeredVariables[count]->read(mutexTimeout); result = registeredVariables[count]->read(
MutexIF::TimeoutType::WAITING, mutexTimeout);
} }
else { else {
result = registeredVariables[count]->readWithoutLock(); result = registeredVariables[count]->readWithoutLock();
@ -91,25 +101,28 @@ ReturnValue_t PoolDataSetBase::readVariable(uint16_t count) {
return result; return result;
} }
ReturnValue_t PoolDataSetBase::commit(uint32_t lockTimeout) { ReturnValue_t PoolDataSetBase::commit(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
if (state == States::STATE_SET_WAS_READ) { if (state == States::STATE_SET_WAS_READ) {
handleAlreadyReadDatasetCommit(lockTimeout); handleAlreadyReadDatasetCommit(timeoutType, lockTimeout);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
else { else {
return handleUnreadDatasetCommit(lockTimeout); return handleUnreadDatasetCommit(timeoutType, lockTimeout);
} }
} }
void PoolDataSetBase::handleAlreadyReadDatasetCommit(uint32_t lockTimeout) { void PoolDataSetBase::handleAlreadyReadDatasetCommit(
lockDataPool(lockTimeout); MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) {
lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) { for (uint16_t count = 0; count < fillCount; count++) {
if (registeredVariables[count]->getReadWriteMode() if (registeredVariables[count]->getReadWriteMode()
!= PoolVariableIF::VAR_READ != PoolVariableIF::VAR_READ
&& registeredVariables[count]->getDataPoolId() && registeredVariables[count]->getDataPoolId()
!= PoolVariableIF::NO_PARAMETER) { != PoolVariableIF::NO_PARAMETER) {
if(protectEveryReadCommitCall) { if(protectEveryReadCommitCall) {
registeredVariables[count]->commit(mutexTimeout); registeredVariables[count]->commit(
MutexIF::TimeoutType::WAITING, mutexTimeout);
} }
else { else {
registeredVariables[count]->commitWithoutLock(); registeredVariables[count]->commitWithoutLock();
@ -120,16 +133,18 @@ void PoolDataSetBase::handleAlreadyReadDatasetCommit(uint32_t lockTimeout) {
unlockDataPool(); unlockDataPool();
} }
ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) { ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(
MutexIF::TimeoutType timeoutType, uint32_t lockTimeout) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
lockDataPool(lockTimeout); lockDataPool(timeoutType, lockTimeout);
for (uint16_t count = 0; count < fillCount; count++) { for (uint16_t count = 0; count < fillCount; count++) {
if (registeredVariables[count]->getReadWriteMode() if (registeredVariables[count]->getReadWriteMode()
== PoolVariableIF::VAR_WRITE == PoolVariableIF::VAR_WRITE
&& registeredVariables[count]->getDataPoolId() && registeredVariables[count]->getDataPoolId()
!= PoolVariableIF::NO_PARAMETER) { != PoolVariableIF::NO_PARAMETER) {
if(protectEveryReadCommitCall) { if(protectEveryReadCommitCall) {
result = registeredVariables[count]->commit(mutexTimeout); result = registeredVariables[count]->commit(
MutexIF::TimeoutType::WAITING, mutexTimeout);
} }
else { else {
result = registeredVariables[count]->commitWithoutLock(); result = registeredVariables[count]->commitWithoutLock();
@ -138,8 +153,10 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) {
} else if (registeredVariables[count]->getDataPoolId() } else if (registeredVariables[count]->getDataPoolId()
!= PoolVariableIF::NO_PARAMETER) { != PoolVariableIF::NO_PARAMETER) {
if (result != COMMITING_WITHOUT_READING) { if (result != COMMITING_WITHOUT_READING) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DataSet::commit(): commit-without-read call made " sif::error << "DataSet::commit(): commit-without-read call made "
"with non write-only variable." << std::endl; "with non write-only variable." << std::endl;
#endif
result = COMMITING_WITHOUT_READING; result = COMMITING_WITHOUT_READING;
} }
} }
@ -150,7 +167,8 @@ ReturnValue_t PoolDataSetBase::handleUnreadDatasetCommit(uint32_t lockTimeout) {
} }
ReturnValue_t PoolDataSetBase::lockDataPool(uint32_t timeoutMs) { ReturnValue_t PoolDataSetBase::lockDataPool(MutexIF::TimeoutType timeoutType,
uint32_t lockTimeout) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -62,8 +62,9 @@ public:
* - @c SET_WAS_ALREADY_READ if read() is called twice without calling * - @c SET_WAS_ALREADY_READ if read() is called twice without calling
* commit() in between * commit() in between
*/ */
virtual ReturnValue_t read(uint32_t lockTimeout = virtual ReturnValue_t read(
MutexIF::BLOCKING) override; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t lockTimeout = 20) override;
/** /**
* @brief The commit call initializes writing back the registered variables. * @brief The commit call initializes writing back the registered variables.
* @details * @details
@ -82,8 +83,9 @@ public:
* - @c COMMITING_WITHOUT_READING if set was not read yet and * - @c COMMITING_WITHOUT_READING if set was not read yet and
* contains non write-only variables * contains non write-only variables
*/ */
virtual ReturnValue_t commit(uint32_t lockTimeout = virtual ReturnValue_t commit(
MutexIF::BLOCKING) override; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t lockTimeout = 20) override;
/** /**
* Register the passed pool variable instance into the data set. * Register the passed pool variable instance into the data set.
@ -97,8 +99,9 @@ public:
* thread-safety. Default implementation is empty * thread-safety. Default implementation is empty
* @return Always returns -@c RETURN_OK * @return Always returns -@c RETURN_OK
*/ */
virtual ReturnValue_t lockDataPool(uint32_t timeoutMs = virtual ReturnValue_t lockDataPool(
MutexIF::BLOCKING) override; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/** /**
* Provides the means to unlock the underlying data structure to ensure * Provides the means to unlock the underlying data structure to ensure
* thread-safety. Default implementation is empty * thread-safety. Default implementation is empty
@ -160,8 +163,12 @@ private:
uint32_t mutexTimeout = 20; uint32_t mutexTimeout = 20;
ReturnValue_t readVariable(uint16_t count); ReturnValue_t readVariable(uint16_t count);
void handleAlreadyReadDatasetCommit(uint32_t lockTimeout); void handleAlreadyReadDatasetCommit(
ReturnValue_t handleUnreadDatasetCommit(uint32_t lockTimeout); MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20);
ReturnValue_t handleUnreadDatasetCommit(
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20);
}; };
#endif /* FSFW_DATAPOOL_POOLDATASETBASE_H_ */ #endif /* FSFW_DATAPOOL_POOLDATASETBASE_H_ */

View File

@ -18,7 +18,10 @@ public:
* thread-safety * thread-safety
* @return Lock operation result * @return Lock operation result
*/ */
virtual ReturnValue_t lockDataPool(dur_millis_t timeoutMs) = 0; virtual ReturnValue_t lockDataPool(
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) = 0;
/** /**
* @brief Unlock call corresponding to the lock call. * @brief Unlock call corresponding to the lock call.
* @return Unlock operation result * @return Unlock operation result

View File

@ -3,6 +3,7 @@
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#include "../globalfunctions/arrayprinter.h" #include "../globalfunctions/arrayprinter.h"
#include <cstring> #include <cstring>
#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, uint8_t setLength,
@ -12,9 +13,11 @@ PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, uint8_t setLength,
std::memset(this->address, 0, this->getByteSize()); std::memset(this->address, 0, this->getByteSize());
} }
else if (initValue.size() != setLength){ else if (initValue.size() != setLength){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "PoolEntry: setLength is not equal to initializer list" sif::warning << "PoolEntry: setLength is not equal to initializer list"
"length! Performing zero initialization with given setLength" "length! Performing zero initialization with given setLength"
<< std::endl; << std::endl;
#endif
std::memset(this->address, 0, this->getByteSize()); std::memset(this->address, 0, this->getByteSize());
} }
else { else {
@ -67,10 +70,14 @@ bool PoolEntry<T>::getValid() {
template <typename T> template <typename T>
void PoolEntry<T>::print() { void PoolEntry<T>::print() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Pool Entry Validity: " << sif::debug << "Pool Entry Validity: " <<
(this->valid? " (valid) " : " (invalid) ") << std::endl; (this->valid? " (valid) " : " (invalid) ") << std::endl;
#endif
arrayprinter::print(reinterpret_cast<uint8_t*>(address), length); arrayprinter::print(reinterpret_cast<uint8_t*>(address), length);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << std::dec << std::endl; sif::debug << std::dec << std::endl;
#endif
} }
template<typename T> template<typename T>
@ -81,8 +88,10 @@ Type PoolEntry<T>::getType() {
template class PoolEntry<uint8_t>; template class PoolEntry<uint8_t>;
template class PoolEntry<uint16_t>; template class PoolEntry<uint16_t>;
template class PoolEntry<uint32_t>; template class PoolEntry<uint32_t>;
template class PoolEntry<uint64_t>;
template class PoolEntry<int8_t>; template class PoolEntry<int8_t>;
template class PoolEntry<int16_t>; template class PoolEntry<int16_t>;
template class PoolEntry<int32_t>; template class PoolEntry<int32_t>;
template class PoolEntry<int64_t>;
template class PoolEntry<float>; template class PoolEntry<float>;
template class PoolEntry<double>; template class PoolEntry<double>;

View File

@ -25,6 +25,7 @@ class PoolVariableIF : public SerializeIF,
public: public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF; static constexpr uint8_t INTERFACE_ID = CLASS_ID::POOL_VARIABLE_IF;
static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0); static constexpr ReturnValue_t INVALID_READ_WRITE_MODE = MAKE_RETURN_CODE(0xA0);
static constexpr ReturnValue_t INVALID_POOL_ENTRY = MAKE_RETURN_CODE(0xA1);
static constexpr bool VALID = 1; static constexpr bool VALID = 1;
static constexpr bool INVALID = 0; static constexpr bool INVALID = 0;

View File

@ -2,6 +2,7 @@
#define FSFW_DATAPOOL_READCOMMITIF_H_ #define FSFW_DATAPOOL_READCOMMITIF_H_
#include <fsfw/returnvalues/HasReturnvaluesIF.h> #include <fsfw/returnvalues/HasReturnvaluesIF.h>
#include <fsfw/ipc/MutexIF.h>
/** /**
* @brief Common interface for all software objects which employ read-commit * @brief Common interface for all software objects which employ read-commit
@ -10,8 +11,10 @@
class ReadCommitIF { class ReadCommitIF {
public: public:
virtual ~ReadCommitIF() {} virtual ~ReadCommitIF() {}
virtual ReturnValue_t read(uint32_t mutexTimeout) = 0; virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType,
virtual ReturnValue_t commit(uint32_t mutexTimeout) = 0; uint32_t timeoutMs) = 0;
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) = 0;
protected: protected:
@ -19,11 +22,11 @@ protected:
//! members with commit and read semantics where the lock is only necessary //! members with commit and read semantics where the lock is only necessary
//! once. //! once.
virtual ReturnValue_t readWithoutLock() { virtual ReturnValue_t readWithoutLock() {
return read(20); return read(MutexIF::TimeoutType::WAITING, 20);
} }
virtual ReturnValue_t commitWithoutLock() { virtual ReturnValue_t commitWithoutLock() {
return commit(20); return commit(MutexIF::TimeoutType::WAITING, 20);
} }
}; };

View File

@ -89,8 +89,10 @@ public:
* @return * @return
*/ */
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) { virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden" sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden"
<< ". Returning nullptr!" << std::endl; << ". Returning nullptr!" << std::endl;
#endif
return nullptr; return nullptr;
} }

View File

@ -21,15 +21,19 @@ 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
sif::error << "LocalDataPoolManager::LocalDataPoolManager: " sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
<< "Invalid supplied owner!" << std::endl; << "Invalid supplied owner!" << std::endl;
#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
sif::error << "LocalDataPoolManager::LocalDataPoolManager: " sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
<< "Could not create mutex." << std::endl; << "Could not create mutex." << std::endl;
#endif
} }
hkQueue = queueToUse; hkQueue = queueToUse;
@ -39,17 +43,21 @@ 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
sif::error << "LocalDataPoolManager::initialize: " sif::error << "LocalDataPoolManager::initialize: "
<< std::hex << "0x" << owner->getObjectId() << ". Supplied " << std::hex << "0x" << owner->getObjectId() << ". Supplied "
<< "queue invalid!" << std::dec << std::endl; << "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
sif::error << "LocalDataPoolManager::initialize: " sif::error << "LocalDataPoolManager::initialize: "
<< std::hex << "0x" << owner->getObjectId() << ": Could not " << std::hex << "0x" << owner->getObjectId() << ": Could not "
<< "set IPC store." <<std::dec << std::endl; << "set IPC store." <<std::dec << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -61,8 +69,10 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
hkDestinationId = hkPacketReceiver->getHkQueue(); hkDestinationId = hkPacketReceiver->getHkQueue();
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalDataPoolManager::LocalDataPoolManager: " sif::error << "LocalDataPoolManager::LocalDataPoolManager: "
<< "Default HK destination object is invalid!" << std::endl; << "Default HK destination object is invalid!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
} }
@ -85,8 +95,10 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
} }
return result; return result;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "HousekeepingManager: The map should only be initialized " sif::warning << "HousekeepingManager: The map should only be initialized "
<< "once!" << std::endl; << "once!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -339,8 +351,10 @@ 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
sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:" sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:"
<< " Invalid receiver!"<< std::endl; << " Invalid receiver!"<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -369,8 +383,10 @@ 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
sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:" sif::error << "LocalDataPoolManager::subscribeForPeriodicPacket:"
<< " Invalid receiver!"<< std::endl; << " Invalid receiver!"<< std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -575,8 +591,10 @@ 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
sif::debug << "HousekeepingManager::fechPoolEntry:" sif::debug << "HousekeepingManager::fechPoolEntry:"
<< " Pool entry not found." << std::endl; << " 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();
@ -596,8 +614,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
sif::warning << "HousekeepingManager::generateHousekeepingPacket:" sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
<< " Set ID not found or dataset not assigned!" << std::endl; << " Set ID not found or dataset not assigned!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -678,10 +698,12 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
sid, dataSet, true); sid, dataSet, true);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
// configuration error // configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "LocalDataPoolManager::performHkOperation:" sif::debug << "LocalDataPoolManager::performHkOperation:"
<< "0x" << std::hex << std::setfill('0') << std::setw(8) << "0x" << std::hex << std::setfill('0') << std::setw(8)
<< owner->getObjectId() << " Error generating " << owner->getObjectId() << " Error generating "
<< "HK packet" << std::setfill(' ') << std::dec << std::endl; << "HK packet" << std::setfill(' ') << std::dec << std::endl;
#endif
} }
} }
@ -726,8 +748,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
sif::warning << "HousekeepingManager::generateHousekeepingPacket:" sif::warning << "HousekeepingManager::generateHousekeepingPacket:"
<< " Set ID not found" << std::endl; << " Set ID not found" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -752,8 +776,10 @@ 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
sif::error << "HousekeepingManager::generateHousekeepingPacket: " sif::error << "HousekeepingManager::generateHousekeepingPacket: "
<< "Could not get free element from IPC store." << std::endl; << "Could not get free element from IPC store." << std::endl;
#endif
return result; return result;
} }
@ -762,8 +788,10 @@ 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
sif::error << "HousekeepingManager::generateSetStructurePacket: " sif::error << "HousekeepingManager::generateSetStructurePacket: "
<< "Expected size is not equal to serialized size" << std::endl; << "Expected size is not equal to serialized size" << std::endl;
#endif
} }
// Send structure reporting reply. // Send structure reporting reply.

View File

@ -3,6 +3,7 @@
#include "HasLocalDataPoolIF.h" #include "HasLocalDataPoolIF.h"
#include "../serviceinterface/ServiceInterface.h"
#include "../housekeeping/HousekeepingPacketDownlink.h" #include "../housekeeping/HousekeepingPacketDownlink.h"
#include "../housekeeping/HousekeepingMessage.h" #include "../housekeeping/HousekeepingMessage.h"
#include "../housekeeping/PeriodicHousekeepingHelper.h" #include "../housekeeping/PeriodicHousekeepingHelper.h"
@ -375,15 +376,25 @@ 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
sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry " sif::warning << "HousekeepingManager::fechPoolEntry: Pool entry "
"not found." << std::endl; "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) {
sif::debug << "HousekeepingManager::fetchPoolEntry:" #if FSFW_CPP_OSTREAM_ENABLED == 1
" Pool entry not found." << std::endl; sif::warning << "HousekeepingManager::fetchPoolEntry:"
" 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;

View File

@ -1,4 +1,6 @@
#include "LocalPoolDataSetBase.h" #include "LocalPoolDataSetBase.h"
#include "../serviceinterface/ServiceInterface.h"
#include "../datapoollocal/LocalDataPoolManager.h" #include "../datapoollocal/LocalDataPoolManager.h"
#include "../housekeeping/PeriodicHousekeepingHelper.h" #include "../housekeeping/PeriodicHousekeepingHelper.h"
#include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeAdapter.h"
@ -12,8 +14,13 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) { PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
if(hkOwner == nullptr) { if(hkOwner == nullptr) {
// Configuration error. // Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner " sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
<< "invalid!" << std::endl; << "invalid!" << std::endl;
#else
fsfw::printError("LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
"invalid!\n\r");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return; return;
} }
hkManager = hkOwner->getHkManagerHandle(); hkManager = hkOwner->getHkManagerHandle();
@ -42,13 +49,26 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid,
mutex = MutexFactory::instance()->createMutex(); mutex = MutexFactory::instance()->createMutex();
} }
LocalPoolDataSetBase::LocalPoolDataSetBase(
PoolVariableIF **registeredVariablesArray,
const size_t maxNumberOfVariables, bool protectFunctions):
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
if(protectFunctions) {
mutex = MutexFactory::instance()->createMutex();
}
}
LocalPoolDataSetBase::~LocalPoolDataSetBase() { LocalPoolDataSetBase::~LocalPoolDataSetBase() {
} }
ReturnValue_t LocalPoolDataSetBase::lockDataPool(uint32_t timeoutMs) { ReturnValue_t LocalPoolDataSetBase::lockDataPool(
MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
if(hkManager != nullptr) { if(hkManager != nullptr) {
MutexIF* mutex = hkManager->getMutexHandle(); MutexIF* poolMutex = hkManager->getMutexHandle();
return mutex->lockMutex(MutexIF::TimeoutType::WAITING, timeoutMs); return poolMutex->lockMutex(timeoutType, timeoutMs);
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -147,8 +167,13 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t** buffer,
auto result = SerializeAdapter::serialize(&currentPoolId, buffer, auto result = SerializeAdapter::serialize(&currentPoolId, buffer,
size, maxSize, streamEndianness); size, maxSize, streamEndianness);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "LocalDataSet::serializeLocalPoolIds: Serialization" #if FSFW_CPP_OSTREAM_ENABLED == 1
" error!" << std::endl; sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: "
<< "Serialization error!" << std::endl;
#else
fsfw::printWarning("LocalPoolDataSetBase::serializeLocalPoolIds: "
"Serialization error!\n\r");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
return result; return result;
} }
} }
@ -206,8 +231,13 @@ ReturnValue_t LocalPoolDataSetBase::serialize(uint8_t **buffer, size_t *size,
void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const { void LocalPoolDataSetBase::bitSetter(uint8_t* byte, uint8_t position) const {
if(position > 7) { if(position > 7) {
sif::debug << "Pool Raw Access: Bit setting invalid position" #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolDataSetBase::bitSetter: Invalid position!"
<< std::endl; << std::endl;
#else
fsfw::printWarning("LocalPoolDataSetBase::bitSetter: "
"Invalid position!\n\r");
#endif
return; return;
} }
uint8_t shiftNumber = position + (7 - 2 * position); uint8_t shiftNumber = position + (7 - 2 * position);
@ -238,14 +268,19 @@ void LocalPoolDataSetBase::initializePeriodicHelper(
} }
void LocalPoolDataSetBase::setChanged(bool changed) { void LocalPoolDataSetBase::setChanged(bool changed) {
// TODO: Make this configurable? if(mutex == nullptr) {
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); this->changed = changed;
return;
}
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeout);
this->changed = changed; this->changed = changed;
} }
bool LocalPoolDataSetBase::hasChanged() const { bool LocalPoolDataSetBase::hasChanged() const {
// TODO: Make this configurable? if(mutex == nullptr) {
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 20); return changed;
}
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, mutexTimeout);
return changed; return changed;
} }
@ -256,8 +291,10 @@ sid_t LocalPoolDataSetBase::getSid() const {
bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte, bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
uint8_t position) const { uint8_t position) const {
if(position > 7) { if(position > 7) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Pool Raw Access: Bit setting invalid position" sif::debug << "Pool Raw Access: Bit setting invalid position"
<< std::endl; << std::endl;
#endif
return false; return false;
} }
uint8_t shiftNumber = position + (7 - 2 * position); uint8_t shiftNumber = position + (7 - 2 * position);
@ -265,18 +302,22 @@ bool LocalPoolDataSetBase::bitGetter(const uint8_t* byte,
} }
bool LocalPoolDataSetBase::isValid() const { bool LocalPoolDataSetBase::isValid() const {
if(mutex == nullptr) {
return this->valid;
}
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5); MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5);
return this->valid; return this->valid;
} }
void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) { void LocalPoolDataSetBase::setValidity(bool valid, bool setEntriesRecursively) {
MutexHelper(mutex, MutexIF::TimeoutType::WAITING, 5); mutex->lockMutex(timeoutType, mutexTimeout);
if(setEntriesRecursively) { if(setEntriesRecursively) {
for(size_t idx = 0; idx < this->getFillCount(); idx++) { for(size_t idx = 0; idx < this->getFillCount(); idx++) {
registeredVariables[idx] -> setValid(valid); registeredVariables[idx] -> setValid(valid);
} }
} }
this->valid = valid; this->valid = valid;
mutex->unlockMutex();
} }
void LocalPoolDataSetBase::setReadCommitProtectionBehaviour( void LocalPoolDataSetBase::setReadCommitProtectionBehaviour(
@ -284,3 +325,9 @@ void LocalPoolDataSetBase::setReadCommitProtectionBehaviour(
PoolDataSetBase::setReadCommitProtectionBehaviour(protectEveryReadCommit, PoolDataSetBase::setReadCommitProtectionBehaviour(protectEveryReadCommit,
mutexTimeout); mutexTimeout);
} }
void LocalPoolDataSetBase::setDataSetMutexTimeout(
MutexIF::TimeoutType timeoutType, uint32_t mutexTimeout) {
this->timeoutType = timeoutType;
this->mutexTimeout = mutexTimeout;
}

View File

@ -67,6 +67,15 @@ public:
LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray, LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
const size_t maxNumberOfVariables); const size_t maxNumberOfVariables);
/**
* Simple constructor, if the dataset is not owner permanently by
* a class with a HK manager.
* @param registeredVariablesArray
* @param maxNumberOfVariables
*/
LocalPoolDataSetBase(PoolVariableIF** registeredVariablesArray,
const size_t maxNumberOfVariables, bool protectFunctions = true);
/** /**
* @brief The destructor automatically manages writing the valid * @brief The destructor automatically manages writing the valid
* information of variables. * information of variables.
@ -87,6 +96,9 @@ public:
void setReadCommitProtectionBehaviour(bool protectEveryReadCommit, void setReadCommitProtectionBehaviour(bool protectEveryReadCommit,
uint32_t mutexTimeout = 20); uint32_t mutexTimeout = 20);
void setDataSetMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t mutexTimeout);
void setValidityBufferGeneration(bool withValidityBuffer); void setValidityBufferGeneration(bool withValidityBuffer);
sid_t getSid() const; sid_t getSid() const;
@ -138,7 +150,12 @@ public:
protected: protected:
sid_t sid; sid_t sid;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t mutexTimeout = 20; uint32_t mutexTimeout = 20;
/**
* This mutex is required because the dataset can potentially be accessed
* by multiple threads for information like change status or validity.
*/
MutexIF* mutex = nullptr; MutexIF* mutex = nullptr;
bool diagnostic = false; bool diagnostic = false;
@ -183,7 +200,9 @@ protected:
* @details * @details
* It makes use of the lockDataPool method offered by the DataPool class. * It makes use of the lockDataPool method offered by the DataPool class.
*/ */
ReturnValue_t lockDataPool(uint32_t timeoutMs) override; ReturnValue_t lockDataPool(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) override;
/** /**
* @brief This is a small helper function to facilitate * @brief This is a small helper function to facilitate
* unlocking the global data pool * unlocking the global data pool

View File

@ -5,12 +5,16 @@ LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId,
pool_rwm_t setReadWriteMode): localPoolId(poolId), pool_rwm_t setReadWriteMode): localPoolId(poolId),
readWriteMode(setReadWriteMode) { readWriteMode(setReadWriteMode) {
if(poolId == PoolVariableIF::NO_PARAMETER) { if(poolId == PoolVariableIF::NO_PARAMETER) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, " sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
<< "which is the NO_PARAMETER value!" << std::endl; << "which is the NO_PARAMETER value!" << std::endl;
#endif
} }
if(hkOwner == nullptr) { if(hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool " sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool "
<< "owner is a invalid!" << std::endl; << "owner is a invalid!" << std::endl;
#endif
return; return;
} }
hkManager = hkOwner->getHkManagerHandle(); hkManager = hkOwner->getHkManagerHandle();
@ -23,15 +27,19 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
DataSetIF *dataSet, pool_rwm_t setReadWriteMode): localPoolId(poolId), DataSetIF *dataSet, pool_rwm_t setReadWriteMode): localPoolId(poolId),
readWriteMode(setReadWriteMode) { readWriteMode(setReadWriteMode) {
if(poolId == PoolVariableIF::NO_PARAMETER) { if(poolId == PoolVariableIF::NO_PARAMETER) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, " sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
<< "which is the NO_PARAMETER value!" << std::endl; << "which is the NO_PARAMETER value!" << std::endl;
#endif
} }
HasLocalDataPoolIF* hkOwner = HasLocalDataPoolIF* hkOwner =
objectManager->get<HasLocalDataPoolIF>(poolOwner); objectManager->get<HasLocalDataPoolIF>(poolOwner);
if(hkOwner == nullptr) { if(hkOwner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "LocalPoolVariable: The supplied pool owner did not " sif::error << "LocalPoolVariable: The supplied pool owner did not "
<< "implement the correct interface" << "implement the correct interface"
<< " HasLocalDataPoolIF!" << std::endl; << " HasLocalDataPoolIF!" << std::endl;
#endif
return; return;
} }
hkManager = hkOwner->getHkManagerHandle(); hkManager = hkOwner->getHkManagerHandle();
@ -71,3 +79,44 @@ bool LocalPoolObjectBase::hasChanged() const {
void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) { void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) {
this->readWriteMode = newReadWriteMode; this->readWriteMode = newReadWriteMode;
} }
void LocalPoolObjectBase::reportReadCommitError(const char* variableType,
ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId) {
#if FSFW_DISABLE_PRINTOUT == 0
const char* type = nullptr;
if(read) {
type = "read";
}
else {
type = "commit";
}
const char* errMsg = nullptr;
if(error == HasLocalDataPoolIF::POOL_ENTRY_NOT_FOUND) {
errMsg = "Pool entry not found";
}
else if(error == HasLocalDataPoolIF::POOL_ENTRY_TYPE_CONFLICT) {
errMsg = "Pool entry type conflict";
}
else if(error == PoolVariableIF::INVALID_READ_WRITE_MODE) {
errMsg = "Pool variable wrong read-write mode";
}
else if(error == PoolVariableIF::INVALID_POOL_ENTRY) {
errMsg = "Pool entry invalid";
}
else {
errMsg = "Unknown error code";
}
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << variableType << ": " << type << " call | " << errMsg
<< " | Owner: " << std::hex << std::setw(8)
<< std::setfill('0') << objectId << " LPID: 0x" << lpId
<< std::dec << std::endl;
#else
fsfw::printWarning("LocalPoolVariable: %s of local pool variable of "
"object 0x%08x and lp ID 0x%08x failed.\n\r",
type, objectId, lpId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
}

View File

@ -56,6 +56,8 @@ protected:
//! @brief Pointer to the class which manages the HK pool. //! @brief Pointer to the class which manages the HK pool.
LocalDataPoolManager* hkManager; LocalDataPoolManager* hkManager;
void reportReadCommitError(const char* variableType,
ReturnValue_t error, bool read, object_id_t objectId, lp_id_t lpId);
}; };

View File

@ -7,6 +7,7 @@
#include "../datapool/PoolVariableIF.h" #include "../datapool/PoolVariableIF.h"
#include "../datapool/DataSetIF.h" #include "../datapool/DataSetIF.h"
#include "../serviceinterface/ServiceInterface.h"
#include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/ObjectManagerIF.h"
#include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeAdapter.h"
@ -105,7 +106,9 @@ public:
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
* *
*/ */
ReturnValue_t read(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; ReturnValue_t read(MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
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
@ -115,8 +118,21 @@ public:
* It is recommended to use DataSets to read and commit multiple variables * It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
*/ */
ReturnValue_t commit(dur_millis_t lockTimeout = MutexIF::BLOCKING) override; ReturnValue_t commit(MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
/**
* @brief This commit function can be used to set the pool variable valid
* as well.
* @param setValid
* @param timeoutType
* @param timeoutMs
* @return
*/
ReturnValue_t commit(bool setValid, MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20);
LocalPoolVariable<T> &operator=(const T& newValue); LocalPoolVariable<T> &operator=(const T& newValue);
LocalPoolVariable<T> &operator=(const LocalPoolVariable<T>& newPoolVariable); LocalPoolVariable<T> &operator=(const LocalPoolVariable<T>& newPoolVariable);
@ -157,12 +173,12 @@ protected:
*/ */
ReturnValue_t commitWithoutLock() override; ReturnValue_t commitWithoutLock() override;
#if FSFW_CPP_OSTREAM_ENABLED == 1
// std::ostream is the type for object std::cout // std::ostream is the type for object std::cout
template <typename U> template <typename U>
friend std::ostream& operator<< (std::ostream &out, friend std::ostream& operator<< (std::ostream &out,
const LocalPoolVariable<U> &var); const LocalPoolVariable<U> &var);
#endif
private:
}; };
#include "LocalPoolVariable.tpp" #include "LocalPoolVariable.tpp"

View File

@ -24,65 +24,87 @@ inline LocalPoolVariable<T>::LocalPoolVariable(gp_id_t globalPoolId,
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::read(dur_millis_t lockTimeout) { inline ReturnValue_t LocalPoolVariable<T>::read(
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
lockTimeout); MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
return readWithoutLock(); return readWithoutLock();
} }
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) {
sif::debug << "LocalPoolVar: Invalid read write " object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
"mode for read() call." << std::endl; reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
localPoolId);
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 or poolEntry == nullptr) { if(result != RETURN_OK) {
sif::error << "PoolVector: Read of local pool variable of object " object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
<< std::hex << std::setw(8) << std::setfill('0') reportReadCommitError("LocalPoolVariable", result,
<< hkManager->getOwner() << " and lp ID " << localPoolId false, ownerObjectId, localPoolId);
<< std::dec << " failed." << std::setfill(' ') << std::endl;
return result; return result;
} }
// Actually this should never happen..
if(poolEntry->address == nullptr) {
result = PoolVariableIF::INVALID_POOL_ENTRY;
object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
reportReadCommitError("LocalPoolVariable", result,
false, ownerObjectId, localPoolId);
return result;
}
this->value = *(poolEntry->address); this->value = *(poolEntry->address);
this->valid = poolEntry->valid; this->valid = poolEntry->valid;
return RETURN_OK; return RETURN_OK;
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(dur_millis_t lockTimeout) { inline ReturnValue_t LocalPoolVariable<T>::commit(bool setValid,
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
lockTimeout); this->setValid(setValid);
return commit(timeoutType, timeoutMs);
}
template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::commit(
MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
return commitWithoutLock(); return commitWithoutLock();
} }
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) {
sif::debug << "LocalPoolVariable: Invalid read write " object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
"mode for commit() call." << std::endl; reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
localPoolId);
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) {
sif::error << "PoolVector: Read of local pool variable of object " object_id_t ownerObjectId = hkManager->getOwner()->getObjectId();
"0x" << std::hex << std::setw(8) << std::setfill('0') << reportReadCommitError("LocalPoolVariable", result,
hkManager->getOwner() << " and lp ID 0x" << localPoolId << false, ownerObjectId, localPoolId);
std::dec << " failed.\n" << std::flush;
return result; return result;
} }
*(poolEntry->address) = this->value; *(poolEntry->address) = this->value;
poolEntry->valid = this->valid; poolEntry->valid = this->valid;
return RETURN_OK; return RETURN_OK;
} }
template<typename T> template<typename T>
inline ReturnValue_t LocalPoolVariable<T>::serialize(uint8_t** buffer, size_t* size, inline ReturnValue_t LocalPoolVariable<T>::serialize(uint8_t** buffer,
const size_t max_size, SerializeIF::Endianness streamEndianness) const { size_t* size, const size_t max_size,
SerializeIF::Endianness streamEndianness) const {
return SerializeAdapter::serialize(&value, return SerializeAdapter::serialize(&value,
buffer, size ,max_size, streamEndianness); buffer, size ,max_size, streamEndianness);
} }
@ -98,12 +120,14 @@ inline ReturnValue_t LocalPoolVariable<T>::deSerialize(const uint8_t** buffer,
return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness); return SerializeAdapter::deSerialize(&value, buffer, size, streamEndianness);
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
template<typename T> template<typename T>
inline std::ostream& operator<< (std::ostream &out, inline std::ostream& operator<< (std::ostream &out,
const LocalPoolVariable<T> &var) { const LocalPoolVariable<T> &var) {
out << var.value; out << var.value;
return out; return out;
} }
#endif
template<typename T> template<typename T>
inline LocalPoolVariable<T>::operator T() const { inline LocalPoolVariable<T>::operator T() const {
@ -111,7 +135,8 @@ inline LocalPoolVariable<T>::operator T() const {
} }
template<typename T> template<typename T>
inline LocalPoolVariable<T> & LocalPoolVariable<T>::operator=(const T& newValue) { inline LocalPoolVariable<T> & LocalPoolVariable<T>::operator=(
const T& newValue) {
value = newValue; value = newValue;
return *this; return *this;
} }
@ -124,7 +149,8 @@ inline LocalPoolVariable<T>& LocalPoolVariable<T>::operator =(
} }
template<typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator ==(const LocalPoolVariable<T> &other) const { inline bool LocalPoolVariable<T>::operator ==(
const LocalPoolVariable<T> &other) const {
return this->value == other.value; return this->value == other.value;
} }
@ -135,7 +161,8 @@ inline bool LocalPoolVariable<T>::operator ==(const T &other) const {
template<typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator !=(const LocalPoolVariable<T> &other) const { inline bool LocalPoolVariable<T>::operator !=(
const LocalPoolVariable<T> &other) const {
return not (*this == other); return not (*this == other);
} }
@ -146,7 +173,8 @@ inline bool LocalPoolVariable<T>::operator !=(const T &other) const {
template<typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator <(const LocalPoolVariable<T> &other) const { inline bool LocalPoolVariable<T>::operator <(
const LocalPoolVariable<T> &other) const {
return this->value < other.value; return this->value < other.value;
} }
@ -157,7 +185,8 @@ inline bool LocalPoolVariable<T>::operator <(const T &other) const {
template<typename T> template<typename T>
inline bool LocalPoolVariable<T>::operator >(const LocalPoolVariable<T> &other) const { inline bool LocalPoolVariable<T>::operator >(
const LocalPoolVariable<T> &other) const {
return not (*this < other); return not (*this < other);
} }

View File

@ -7,7 +7,7 @@
#include "../datapool/PoolVariableIF.h" #include "../datapool/PoolVariableIF.h"
#include "../datapoollocal/LocalDataPoolManager.h" #include "../datapoollocal/LocalDataPoolManager.h"
#include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeAdapter.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterface.h"
/** /**
@ -123,7 +123,9 @@ public:
* It is recommended to use DataSets to read and commit multiple variables * It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
*/ */
ReturnValue_t read(uint32_t lockTimeout = MutexIF::BLOCKING) override; ReturnValue_t read(MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
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
@ -133,7 +135,9 @@ public:
* It is recommended to use DataSets to read and commit multiple variables * It is recommended to use DataSets to read and commit multiple variables
* at once to avoid the overhead of unnecessary lock und unlock operations. * at once to avoid the overhead of unnecessary lock und unlock operations.
*/ */
ReturnValue_t commit(uint32_t lockTimeout = MutexIF::BLOCKING) override; ReturnValue_t commit(MutexIF::TimeoutType timeoutType =
MutexIF::TimeoutType::WAITING,
uint32_t timeoutMs = 20) override;
protected: protected:
/** /**
@ -157,12 +161,12 @@ protected:
private: private:
#if FSFW_CPP_OSTREAM_ENABLED == 1
// std::ostream is the type for object std::cout // std::ostream is the type for object std::cout
template <typename U, uint16_t otherSize> template <typename U, uint16_t otherSize>
friend std::ostream& operator<< (std::ostream &out, friend std::ostream& operator<< (std::ostream &out,
const LocalPoolVector<U, otherSize> &var); const LocalPoolVector<U, otherSize> &var);
#endif
}; };

View File

@ -24,16 +24,18 @@ inline LocalPoolVector<T, vectorSize>::LocalPoolVector(gp_id_t globalPoolId,
dataSet, setReadWriteMode) {} dataSet, setReadWriteMode) {}
template<typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(uint32_t lockTimeout) { inline ReturnValue_t LocalPoolVector<T, vectorSize>::read(
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
lockTimeout); MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
return readWithoutLock(); return readWithoutLock();
} }
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) {
sif::debug << "LocalPoolVar: Invalid read write " object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
"mode for read() call." << std::endl; reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, true, targetObjectId,
localPoolId);
return PoolVariableIF::INVALID_READ_WRITE_MODE; return PoolVariableIF::INVALID_READ_WRITE_MODE;
} }
@ -42,10 +44,9 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
memset(this->value, 0, vectorSize * sizeof(T)); memset(this->value, 0, vectorSize * sizeof(T));
if(result != RETURN_OK) { if(result != RETURN_OK) {
sif::error << "PoolVector: Read of local pool variable of object " object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
"0x" << std::hex << std::setw(8) << std::setfill('0') << reportReadCommitError("LocalPoolVector", result, true, targetObjectId,
hkManager->getOwner() << "and lp ID 0x" << localPoolId << localPoolId);
std::dec << " failed." << std::endl;
return result; return result;
} }
std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize()); std::memcpy(this->value, poolEntry->address, poolEntry->getByteSize());
@ -55,26 +56,26 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::readWithoutLock() {
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(
uint32_t lockTimeout) { MutexIF::TimeoutType timeoutType, uint32_t timeoutMs) {
MutexHelper(hkManager->getMutexHandle(), MutexIF::TimeoutType::WAITING, MutexHelper(hkManager->getMutexHandle(), timeoutType, timeoutMs);
lockTimeout);
return commitWithoutLock(); return commitWithoutLock();
} }
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) {
sif::debug << "LocalPoolVar: Invalid read write " object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
"mode for commit() call." << std::endl; reportReadCommitError("LocalPoolVector",
PoolVariableIF::INVALID_READ_WRITE_MODE, false, targetObjectId,
localPoolId);
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) {
sif::error << "PoolVector: Read of local pool variable of object " object_id_t targetObjectId = hkManager->getOwner()->getObjectId();
"0x" << std::hex << std::setw(8) << std::setfill('0') << reportReadCommitError("LocalPoolVector", result, false, targetObjectId,
hkManager->getOwner() << " and lp ID 0x" << localPoolId << localPoolId);
std::dec << " failed.\n" << std::flush;
return result; return result;
} }
std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize()); std::memcpy(poolEntry->address, this->value, poolEntry->getByteSize());
@ -89,8 +90,10 @@ inline T& LocalPoolVector<T, vectorSize>::operator [](int 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
sif::error << "LocalPoolVector: Invalid index. Setting or returning" sif::error << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" << std::endl; " last value!" << std::endl;
#endif
return value[i]; return value[i];
} }
@ -101,8 +104,10 @@ inline const T& LocalPoolVector<T, vectorSize>::operator [](int i) const {
} }
// 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
sif::error << "LocalPoolVector: Invalid index. Setting or returning" sif::error << "LocalPoolVector: Invalid index. Setting or returning"
" last value!" << std::endl; " last value!" << std::endl;
#endif
return value[i]; return value[i];
} }
@ -141,6 +146,7 @@ inline ReturnValue_t LocalPoolVector<T, vectorSize>::deSerialize(
return result; return result;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
template<typename T, uint16_t vectorSize> template<typename T, uint16_t vectorSize>
inline std::ostream& operator<< (std::ostream &out, inline std::ostream& operator<< (std::ostream &out,
const LocalPoolVector<T, vectorSize> &var) { const LocalPoolVector<T, vectorSize> &var) {
@ -154,5 +160,6 @@ inline std::ostream& operator<< (std::ostream &out,
out << "]"; out << "]";
return out; return out;
} }
#endif
#endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_ */ #endif /* FSFW_DATAPOOLLOCAL_LOCALPOOLVECTOR_TPP_ */

View File

@ -9,12 +9,16 @@
*/ */
class PoolReadHelper { class PoolReadHelper {
public: public:
PoolReadHelper(ReadCommitIF* readObject, uint32_t mutexTimeout = 20): PoolReadHelper(ReadCommitIF* readObject,
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
uint32_t mutexTimeout = 20):
readObject(readObject), mutexTimeout(mutexTimeout) { readObject(readObject), mutexTimeout(mutexTimeout) {
if(readObject != nullptr) { if(readObject != nullptr) {
readResult = readObject->read(mutexTimeout); readResult = readObject->read(timeoutType, mutexTimeout);
#if FSFW_PRINT_VERBOSITY_LEVEL == 1 #if FSFW_PRINT_VERBOSITY_LEVEL == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PoolReadHelper: Read failed!" << std::endl; sif::error << "PoolReadHelper: Read failed!" << std::endl;
#endif
#endif #endif
} }
} }
@ -25,7 +29,7 @@ public:
~PoolReadHelper() { ~PoolReadHelper() {
if(readObject != nullptr) { if(readObject != nullptr) {
readObject->commit(mutexTimeout); readObject->commit(timeoutType, mutexTimeout);
} }
} }
@ -33,6 +37,7 @@ public:
private: private:
ReadCommitIF* readObject = nullptr; ReadCommitIF* readObject = nullptr;
ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK; ReturnValue_t readResult = HasReturnvaluesIF::RETURN_OK;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t mutexTimeout = 20; uint32_t mutexTimeout = 20;
}; };

View File

@ -1,15 +1,15 @@
target_sources(${TARGET_NAME} target_sources(${LIB_FSFW_NAME} PRIVATE
PRIVATE ipc/missionMessageTypes.cpp
objects/FsfwFactory.cpp
pollingsequence/PollingSequenceFactory.cpp
) )
# Add include paths for the executable # Should be added to include path
target_include_directories(${TARGET_NAME} target_include_directories(${TARGET_NAME} PRIVATE
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
) )
# Add include paths for the FSFW library if(NOT FSFW_CONFIG_PATH)
target_include_directories(${LIB_FSFW_NAME} set(FSFW_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR})
PUBLIC endif()
${CMAKE_CURRENT_SOURCE_DIR}
)

View File

@ -4,17 +4,26 @@
#include <cstddef> #include <cstddef>
#include <cstdint> #include <cstdint>
//! Used to determine whether C++ ostreams are used //! Used to determine whether C++ ostreams are used which can increase
//! Those can lead to code bloat. //! 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
//! Reduced printout to further decrease code size //! More FSFW related printouts.
//! Be careful, this also turns off most diagnostic prinouts! //! 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.
#if FSFW_CPP_OSTREAM_ENABLED == 0 && FSFW_ENHANCED_PRINTOUT == 0
#define FSFW_DISABLE_PRINTOUT 0
#endif
//! Can be used to enable additional debugging printouts for developing the FSFW //! Can be used to enable additional debugging printouts for developing the FSFW
#define FSFW_PRINT_VERBOSITY_LEVEL 0 #define FSFW_PRINT_VERBOSITY_LEVEL 0
//! Can be used to disable the ANSI color sequences for C stdio.
#define FSFW_COLORED_OUTPUT 1
//! If FSFW_OBJ_EVENT_TRANSLATION is set to one, //! If FSFW_OBJ_EVENT_TRANSLATION is set to one,
//! additional output which requires the translation files translateObjects //! additional output which requires the translation files translateObjects
//! and translateEvents (and their compiled source files) //! and translateEvents (and their compiled source files)
@ -50,6 +59,8 @@ static constexpr size_t FSFW_EVENTMGMR_RANGEMATCHERS = 120;
//! simulataneously. This will increase the required RAM for //! simulataneously. This will increase the required RAM for
//! each CSB service ! //! each CSB service !
static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6; static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
} }
#endif /* CONFIG_FSFWCONFIG_H_ */ #endif /* CONFIG_FSFWCONFIG_H_ */

View File

@ -1,5 +0,0 @@
#include "logicalAddresses.h"

View File

@ -2,7 +2,7 @@
#define CONFIG_DEVICES_LOGICALADDRESSES_H_ #define CONFIG_DEVICES_LOGICALADDRESSES_H_
#include <fsfw/devicehandlers/CookieIF.h> #include <fsfw/devicehandlers/CookieIF.h>
#include "../objects/systemObjectList.h" #include <objects/systemObjectList.h>
#include <cstdint> #include <cstdint>
/** /**

View File

@ -1,4 +0,0 @@
#include "powerSwitcherList.h"

View File

@ -1,9 +1,5 @@
#include "Factory.h" #include "FsfwFactory.h"
#include "../tmtc/apid.h" #include <OBSWConfig.h>
#include "../tmtc/pusIds.h"
#include "../objects/systemObjectList.h"
#include "../devices/logicalAddresses.h"
#include "../devices/powerSwitcherList.h"
#include <fsfw/devicehandlers/DeviceHandlerBase.h> #include <fsfw/devicehandlers/DeviceHandlerBase.h>
#include <fsfw/events/EventManager.h> #include <fsfw/events/EventManager.h>
@ -11,24 +7,27 @@
#include <fsfw/tmtcpacket/pus/TmPacketStored.h> #include <fsfw/tmtcpacket/pus/TmPacketStored.h>
#include <fsfw/tmtcservices/CommandingServiceBase.h> #include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcservices/PusServiceBase.h> #include <fsfw/tmtcservices/PusServiceBase.h>
#include <internalError/InternalErrorReporter.h> #include <fsfw/internalError/InternalErrorReporter.h>
#include <cstdint> #include <cstdint>
/** /**
* This class should be used to create all system objects required for * This function builds all system objects required for using
* the on-board software, using the object ID list from the configuration * the FSFW. It is recommended to build all other required objects
* folder. * in a function with an identical prototype, call this function in it and
* then pass the function to the object manager so it builds all system
* objects on software startup.
* *
* The objects are registered in the internal object manager automatically. * All system objects are registered in the internal object manager
* This is used later to add objects to tasks. * automatically. The objects should be added to tasks at a later stage, using
* their objects IDs.
* *
* This file also sets static framework IDs. * This function also sets static framework IDs.
* *
* Framework objects are created first. * Framework should be created first before creating mission system objects.
* @ingroup init * @ingroup init
*/ */
void Factory::produce(void) { void Factory::produceFsfwObjects(void) {
setStaticFrameworkObjectIds(); setStaticFrameworkObjectIds();
new EventManager(objects::EVENT_MANAGER); new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE); new HealthTable(objects::HEALTH_TABLE);

View File

@ -1,5 +1,5 @@
#ifndef FACTORY_H_ #ifndef FSFWCONFIG_OBJECTS_FACTORY_H_
#define FACTORY_H_ #define FSFWCONFIG_OBJECTS_FACTORY_H_
#include <fsfw/objectmanager/SystemObjectIF.h> #include <fsfw/objectmanager/SystemObjectIF.h>
#include <cstddef> #include <cstddef>
@ -9,9 +9,9 @@ namespace Factory {
* @brief Creates all SystemObject elements which are persistent * @brief Creates all SystemObject elements which are persistent
* during execution. * during execution.
*/ */
void produce(); void produceFsfwObjects();
void setStaticFrameworkObjectIds(); void setStaticFrameworkObjectIds();
} }
#endif /* FACTORY_H_ */ #endif /* FSFWCONFIG_OBJECTS_FACTORY_H_ */

View File

@ -15,8 +15,10 @@ ReturnValue_t pst::pollingSequenceInitDefault(
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!" sif::error << "pst::pollingSequenceInitDefault: Sequence invalid!"
<< std::endl; << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
} }

View File

@ -39,11 +39,13 @@ 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
sif::error << "DeviceHandlerBase: ObjectID 0x" << std::hex sif::error << "DeviceHandlerBase: ObjectID 0x" << std::hex
<< std::setw(8) << std::setfill('0') << this->getObjectId() << std::setw(8) << std::setfill('0') << this->getObjectId()
<< std::dec << ": Do not pass nullptr as a cookie, consider " << std::dec << ": Do not pass nullptr as a cookie, consider "
<< std::setfill(' ') << "passing a dummy cookie instead!" << std::setfill(' ') << "passing a dummy cookie instead!"
<< std::endl; << std::endl;
#endif
} }
if (this->fdirInstance == nullptr) { if (this->fdirInstance == nullptr) {
this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId,
@ -130,24 +132,30 @@ 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
sif::error << "DeviceHandlerBase::initialize: Communication interface " sif::error << "DeviceHandlerBase::initialize: Communication interface "
"invalid." << std::endl; "invalid." << std::endl;
sif::error << "Make sure it is set up properly and implements" sif::error << "Make sure it is set up properly and implements"
" DeviceCommunicationIF" << std::endl; " 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
sif::error << "DeviceHandlerBase::initialize: Initializing " sif::error << "DeviceHandlerBase::initialize: Initializing "
"communication interface failed!" << std::endl; "communication interface failed!" << std::endl;
#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
sif::error << "DeviceHandlerBase::initialize: IPC store not set up in " sif::error << "DeviceHandlerBase::initialize: IPC store not set up in "
"factory." << std::endl; "factory." << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
@ -156,10 +164,12 @@ ReturnValue_t DeviceHandlerBase::initialize() {
AcceptsDeviceResponsesIF>(rawDataReceiverId); AcceptsDeviceResponsesIF>(rawDataReceiverId);
if (rawReceiver == nullptr) { if (rawReceiver == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase::initialize: Raw receiver object " sif::error << "DeviceHandlerBase::initialize: Raw receiver object "
"ID set but no valid object found." << std::endl; "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;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
defaultRawReceiver = rawReceiver->getDeviceQueue(); defaultRawReceiver = rawReceiver->getDeviceQueue();
@ -168,10 +178,12 @@ 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) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerBase::initialize: Power switcher " sif::error << "DeviceHandlerBase::initialize: Power switcher "
<< "object ID set but no valid object found." << std::endl; << "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 PowerSwitchIF" << std::endl; << " and implements PowerSwitchIF" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
} }
@ -217,7 +229,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
thermalSet->heaterRequest.value = thermalSet->heaterRequest.value =
ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
thermalSet->commit(PoolVariableIF::VALID); thermalSet->heaterRequest.setValid(true);
thermalSet->commit();
} }
} }
@ -682,8 +695,10 @@ void DeviceHandlerBase::doGetRead() {
replyRawData(receivedData, receivedDataLen, requestedRawTraffic); replyRawData(receivedData, receivedDataLen, requestedRawTraffic);
} }
if (mode == MODE_RAW and defaultRawReceiver != MessageQueueIF::NO_QUEUE) { if (mode == MODE_RAW) {
replyRawReplyIfnotWiretapped(receivedData, receivedDataLen); if (defaultRawReceiver != MessageQueueIF::NO_QUEUE) {
replyRawReplyIfnotWiretapped(receivedData, receivedDataLen);
}
} }
else { else {
parseReply(receivedData, receivedDataLen); parseReply(receivedData, receivedDataLen);
@ -706,8 +721,10 @@ 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
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;
#endif
} }
break; break;
case APERIODIC_REPLY: { case APERIODIC_REPLY: {
@ -718,8 +735,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
foundId); foundId);
} }
if(foundLen == 0) { if(foundLen == 0) {
#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;
#endif
} }
break; break;
} }
@ -1273,9 +1292,11 @@ void DeviceHandlerBase::buildInternalCommand(void) {
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
sif::debug << std::hex << getObjectId() sif::debug << std::hex << getObjectId()
<< ": DHB::buildInternalCommand: Busy" << std::dec << ": DHB::buildInternalCommand: Busy" << std::dec
<< std::endl; << std::endl;
#endif
result = NOTHING_TO_SEND; //no need to report this result = NOTHING_TO_SEND; //no need to report this
} }
} }
@ -1300,10 +1321,12 @@ void DeviceHandlerBase::buildInternalCommand(void) {
result = COMMAND_NOT_SUPPORTED; result = COMMAND_NOT_SUPPORTED;
} else if (iter->second.isExecuting) { } else if (iter->second.isExecuting) {
//so we can track misconfigurations //so we can track misconfigurations
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << std::hex << getObjectId() sif::debug << std::hex << getObjectId()
<< ": DHB::buildInternalCommand: Command " << ": DHB::buildInternalCommand: Command "
<< deviceCommandId << " isExecuting" << std::dec << deviceCommandId << " isExecuting" << std::dec
<< std::endl; << std::endl;
#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
return; return;

View File

@ -169,8 +169,10 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() {
ReturnValue_t DeviceHandlerFailureIsolation::initialize() { ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
ReturnValue_t result = FailureIsolationBase::initialize(); ReturnValue_t result = FailureIsolationBase::initialize();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerFailureIsolation::initialize: Could not" sif::error << "DeviceHandlerFailureIsolation::initialize: Could not"
" initialize FailureIsolationBase." << std::endl; " initialize FailureIsolationBase." << std::endl;
#endif
return result; return result;
} }
ConfirmsFailuresIF* power = objectManager->get<ConfirmsFailuresIF>( ConfirmsFailuresIF* power = objectManager->get<ConfirmsFailuresIF>(
@ -250,8 +252,10 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty(
if (owner == nullptr) { if (owner == nullptr) {
// Configuration error. // Configuration error.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DeviceHandlerFailureIsolation::" sif::error << "DeviceHandlerFailureIsolation::"
<< "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl; << "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl;
#endif
return false; return false;
} }

View File

@ -122,6 +122,7 @@ void EventManager::printEvent(EventMessage* message) {
case severity::INFO: case severity::INFO:
#if DEBUG_INFO_EVENT == 1 #if DEBUG_INFO_EVENT == 1
string = translateObject(message->getReporter()); string = translateObject(message->getReporter());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "EVENT: "; sif::info << "EVENT: ";
if (string != 0) { if (string != 0) {
sif::info << string; sif::info << string;
@ -132,10 +133,12 @@ void EventManager::printEvent(EventMessage* message) {
<< std::dec << message->getEventId() << std::hex << ") P1: 0x" << std::dec << message->getEventId() << std::hex << ") P1: 0x"
<< message->getParameter1() << " P2: 0x" << message->getParameter1() << " P2: 0x"
<< message->getParameter2() << std::dec << std::endl; << message->getParameter2() << std::dec << std::endl;
#endif #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* DEBUG_INFO_EVENT == 1 */
break; break;
default: default:
string = translateObject(message->getReporter()); string = translateObject(message->getReporter());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "EventManager: "; sif::debug << "EventManager: ";
if (string != 0) { if (string != 0) {
sif::debug << string; sif::debug << string;
@ -146,22 +149,28 @@ void EventManager::printEvent(EventMessage* message) {
sif::debug << " reported " << translateEvents(message->getEvent()) sif::debug << " reported " << translateEvents(message->getEvent())
<< " (" << std::dec << message->getEventId() << ") " << " (" << std::dec << message->getEventId() << ") "
<< std::endl; << std::endl;
sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1() sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1()
<< ", P1 Dec: " << std::dec << message->getParameter1() << ", P1 Dec: " << std::dec << message->getParameter1()
<< std::endl; << std::endl;
sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2() sif::debug << std::hex << "P2 Hex: 0x" << message->getParameter2()
<< ", P2 Dec: " << std::dec << message->getParameter2() << ", P2 Dec: " << std::dec << message->getParameter2()
<< std::endl; << std::endl;
#endif
break; break;
} }
} }
#endif #endif
void EventManager::lockMutex() { void EventManager::lockMutex() {
mutex->lockMutex(MutexIF::BLOCKING); mutex->lockMutex(timeoutType, timeoutMs);
} }
void EventManager::unlockMutex() { void EventManager::unlockMutex() {
mutex->unlockMutex(); mutex->unlockMutex();
} }
void EventManager::setMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
this->timeoutType = timeoutType;
this->timeoutMs = timeoutMs;
}

View File

@ -29,6 +29,8 @@ public:
EventManager(object_id_t setObjectId); EventManager(object_id_t setObjectId);
virtual ~EventManager(); virtual ~EventManager();
void setMutexTimeout(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs);
MessageQueueId_t getEventReportQueue(); MessageQueueId_t getEventReportQueue();
ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false); ReturnValue_t registerListener(MessageQueueId_t listener, bool forwardAllButSelected = false);
@ -51,6 +53,8 @@ protected:
std::map<MessageQueueId_t, EventMatchTree> listenerList; std::map<MessageQueueId_t, EventMatchTree> listenerList;
MutexIF* mutex = nullptr; MutexIF* mutex = nullptr;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 20;
static const uint8_t N_POOLS = 3; static const uint8_t N_POOLS = 3;
LocalPool factoryBackend; LocalPool factoryBackend;

View File

@ -21,8 +21,10 @@ ReturnValue_t FailureIsolationBase::initialize() {
EventManagerIF* manager = objectManager->get<EventManagerIF>( EventManagerIF* manager = objectManager->get<EventManagerIF>(
objects::EVENT_MANAGER); objects::EVENT_MANAGER);
if (manager == nullptr) { if (manager == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::initialize: Event Manager has not" sif::error << "FailureIsolationBase::initialize: Event Manager has not"
" been initialized!" << std::endl; " been initialized!" << std::endl;
#endif
return RETURN_FAILED; return RETURN_FAILED;
} }
ReturnValue_t result = manager->registerListener(eventQueue->getId()); ReturnValue_t result = manager->registerListener(eventQueue->getId());
@ -36,8 +38,10 @@ ReturnValue_t FailureIsolationBase::initialize() {
} }
owner = objectManager->get<HasHealthIF>(ownerId); owner = objectManager->get<HasHealthIF>(ownerId);
if (owner == nullptr) { if (owner == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::intialize: Owner object " sif::error << "FailureIsolationBase::intialize: Owner object "
"invalid. Make sure it implements HasHealthIF" << std::endl; "invalid. Make sure it implements HasHealthIF" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
} }
@ -45,10 +49,14 @@ ReturnValue_t FailureIsolationBase::initialize() {
ConfirmsFailuresIF* parentIF = objectManager->get<ConfirmsFailuresIF>( ConfirmsFailuresIF* parentIF = objectManager->get<ConfirmsFailuresIF>(
faultTreeParent); faultTreeParent);
if (parentIF == nullptr) { if (parentIF == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FailureIsolationBase::intialize: Parent object" sif::error << "FailureIsolationBase::intialize: Parent object"
<< "invalid." << std::endl; << "invalid." << std::endl;
#endif
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Make sure it implements ConfirmsFailuresIF." sif::error << "Make sure it implements ConfirmsFailuresIF."
<< std::endl; << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
return RETURN_FAILED; return RETURN_FAILED;
} }

View File

@ -4,10 +4,12 @@
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
bool printInfo, size_t maxCharPerLine) { bool printInfo, size_t maxCharPerLine) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
if(printInfo) { if(printInfo) {
sif::info << "Printing data with size " << size << ": "; sif::info << "Printing data with size " << size << ": ";
} }
sif::info << "["; sif::info << "[";
#endif
if(type == OutputType::HEX) { if(type == OutputType::HEX) {
arrayprinter::printHex(data, size, maxCharPerLine); arrayprinter::printHex(data, size, maxCharPerLine);
} }
@ -21,6 +23,7 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
void arrayprinter::printHex(const uint8_t *data, size_t size, void arrayprinter::printHex(const uint8_t *data, size_t size,
size_t maxCharPerLine) { size_t maxCharPerLine) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << std::hex; sif::info << std::hex;
for(size_t i = 0; i < size; i++) { for(size_t i = 0; i < size; i++) {
sif::info << "0x" << static_cast<int>(data[i]); sif::info << "0x" << static_cast<int>(data[i]);
@ -28,16 +31,18 @@ void arrayprinter::printHex(const uint8_t *data, size_t size,
sif::info << " , "; sif::info << " , ";
if(i > 0 and i % maxCharPerLine == 0) { if(i > 0 and i % maxCharPerLine == 0) {
sif::info << std::endl; sif::info << std::endl;
} }
} }
} }
sif::info << std::dec; sif::info << std::dec;
sif::info << "]" << std::endl; sif::info << "]" << std::endl;
#endif
} }
void arrayprinter::printDec(const uint8_t *data, size_t size, void arrayprinter::printDec(const uint8_t *data, size_t size,
size_t maxCharPerLine) { size_t maxCharPerLine) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << std::dec; sif::info << std::dec;
for(size_t i = 0; i < size; i++) { for(size_t i = 0; i < size; i++) {
sif::info << static_cast<int>(data[i]); sif::info << static_cast<int>(data[i]);
@ -49,13 +54,16 @@ void arrayprinter::printDec(const uint8_t *data, size_t size,
} }
} }
sif::info << "]" << std::endl; sif::info << "]" << std::endl;
#endif
} }
void arrayprinter::printBin(const uint8_t *data, size_t size) { void arrayprinter::printBin(const uint8_t *data, size_t size) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "\n" << std::flush; sif::info << "\n" << std::flush;
for(size_t i = 0; i < size; i++) { for(size_t i = 0; i < size; i++) {
sif::info << "Byte " << i + 1 << ": 0b"<< sif::info << "Byte " << i + 1 << ": 0b"<<
std::bitset<8>(data[i]) << ",\n" << std::flush; std::bitset<8>(data[i]) << ",\n" << std::flush;
} }
sif::info << "]" << std::endl; sif::info << "]" << std::endl;
#endif
} }

View File

@ -41,14 +41,18 @@ ReturnValue_t HealthHelper::initialize() {
eventSender = objectManager->get<EventReportingProxyIF>(objectId); eventSender = objectManager->get<EventReportingProxyIF>(objectId);
if (healthTable == nullptr) { if (healthTable == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "HealthHelper::initialize: Health table object needs" sif::error << "HealthHelper::initialize: Health table object needs"
"to be created in factory." << std::endl; "to be created in factory." << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
if(eventSender == nullptr) { if(eventSender == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "HealthHelper::initialize: Owner has to implement " sif::error << "HealthHelper::initialize: Owner has to implement "
"ReportingProxyIF." << std::endl; "ReportingProxyIF." << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
@ -79,8 +83,10 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
health, oldHealth); health, oldHealth);
if (MessageQueueSenderIF::sendMessage(parentQueue, &information, if (MessageQueueSenderIF::sendMessage(parentQueue, &information,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "HealthHelper::informParent: sending health reply failed." sif::debug << "HealthHelper::informParent: sending health reply failed."
<< std::endl; << std::endl;
#endif
} }
} }
@ -98,8 +104,10 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
} }
if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) { owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "HealthHelper::handleHealthCommand: sending health " sif::debug << "HealthHelper::handleHealthCommand: sending health "
"reply failed." << std::endl; "reply failed." << std::endl;
#endif
} }
} }

View File

@ -5,6 +5,8 @@
#include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/ObjectManagerIF.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include <utility>
class HealthTableIF: public ManagesHealthIF { class HealthTableIF: public ManagesHealthIF {
public: public:
virtual ~HealthTableIF() {} virtual ~HealthTableIF() {}

View File

@ -23,20 +23,22 @@ void InternalErrorReporter::setDiagnosticPrintout(bool enable) {
} }
ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) { ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
internalErrorDataset.read(INTERNAL_ERROR_MUTEX_TIMEOUT); internalErrorDataset.read(timeoutType, timeoutMs);
uint32_t newQueueHits = getAndResetQueueHits(); uint32_t newQueueHits = getAndResetQueueHits();
uint32_t newTmHits = getAndResetTmHits(); uint32_t newTmHits = getAndResetTmHits();
uint32_t newStoreHits = getAndResetStoreHits(); uint32_t newStoreHits = getAndResetStoreHits();
#ifdef DEBUG #if FSFW_ENHANCED_PRINTOUT == 1
if(diagnosticPrintout) { if(diagnosticPrintout) {
if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) { if((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "InternalErrorReporter::performOperation: Errors " sif::debug << "InternalErrorReporter::performOperation: Errors "
<< "occured!" << std::endl; << "occured!" << std::endl;
sif::debug << "Queue errors: " << newQueueHits << std::endl; sif::debug << "Queue errors: " << newQueueHits << std::endl;
sif::debug << "TM errors: " << newTmHits << std::endl; sif::debug << "TM errors: " << newTmHits << std::endl;
sif::debug << "Store errors: " << newStoreHits << std::endl; sif::debug << "Store errors: " << newStoreHits << std::endl;
#endif
} }
} }
#endif #endif
@ -44,8 +46,8 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
internalErrorDataset.queueHits.value += newQueueHits; internalErrorDataset.queueHits.value += newQueueHits;
internalErrorDataset.storeHits.value += newStoreHits; internalErrorDataset.storeHits.value += newStoreHits;
internalErrorDataset.tmHits.value += newTmHits; internalErrorDataset.tmHits.value += newTmHits;
internalErrorDataset.setValidity(true, true);
internalErrorDataset.commit(INTERNAL_ERROR_MUTEX_TIMEOUT); internalErrorDataset.commit(timeoutType, timeoutMs);
poolManager.performHkOperation(); poolManager.performHkOperation();
@ -67,7 +69,7 @@ void InternalErrorReporter::lostTm() {
uint32_t InternalErrorReporter::getAndResetQueueHits() { uint32_t InternalErrorReporter::getAndResetQueueHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = queueHits; value = queueHits;
queueHits = 0; queueHits = 0;
mutex->unlockMutex(); mutex->unlockMutex();
@ -76,21 +78,21 @@ uint32_t InternalErrorReporter::getAndResetQueueHits() {
uint32_t InternalErrorReporter::getQueueHits() { uint32_t InternalErrorReporter::getQueueHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = queueHits; value = queueHits;
mutex->unlockMutex(); mutex->unlockMutex();
return value; return value;
} }
void InternalErrorReporter::incrementQueueHits() { void InternalErrorReporter::incrementQueueHits() {
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
queueHits++; queueHits++;
mutex->unlockMutex(); mutex->unlockMutex();
} }
uint32_t InternalErrorReporter::getAndResetTmHits() { uint32_t InternalErrorReporter::getAndResetTmHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = tmHits; value = tmHits;
tmHits = 0; tmHits = 0;
mutex->unlockMutex(); mutex->unlockMutex();
@ -99,14 +101,14 @@ uint32_t InternalErrorReporter::getAndResetTmHits() {
uint32_t InternalErrorReporter::getTmHits() { uint32_t InternalErrorReporter::getTmHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = tmHits; value = tmHits;
mutex->unlockMutex(); mutex->unlockMutex();
return value; return value;
} }
void InternalErrorReporter::incrementTmHits() { void InternalErrorReporter::incrementTmHits() {
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
tmHits++; tmHits++;
mutex->unlockMutex(); mutex->unlockMutex();
} }
@ -117,7 +119,7 @@ void InternalErrorReporter::storeFull() {
uint32_t InternalErrorReporter::getAndResetStoreHits() { uint32_t InternalErrorReporter::getAndResetStoreHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = storeHits; value = storeHits;
storeHits = 0; storeHits = 0;
mutex->unlockMutex(); mutex->unlockMutex();
@ -126,14 +128,14 @@ uint32_t InternalErrorReporter::getAndResetStoreHits() {
uint32_t InternalErrorReporter::getStoreHits() { uint32_t InternalErrorReporter::getStoreHits() {
uint32_t value; uint32_t value;
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
value = storeHits; value = storeHits;
mutex->unlockMutex(); mutex->unlockMutex();
return value; return value;
} }
void InternalErrorReporter::incrementStoreHits() { void InternalErrorReporter::incrementStoreHits() {
mutex->lockMutex(MutexIF::WAITING, INTERNAL_ERROR_MUTEX_TIMEOUT); mutex->lockMutex(timeoutType, timeoutMs);
storeHits++; storeHits++;
mutex->unlockMutex(); mutex->unlockMutex();
} }
@ -188,3 +190,8 @@ ReturnValue_t InternalErrorReporter::initializeAfterTaskCreation() {
return poolManager.initializeAfterTaskCreation(); return poolManager.initializeAfterTaskCreation();
} }
void InternalErrorReporter::setMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs) {
this->timeoutType = timeoutType;
this->timeoutMs = timeoutMs;
}

View File

@ -22,7 +22,6 @@ class InternalErrorReporter: public SystemObject,
public InternalErrorReporterIF, public InternalErrorReporterIF,
public HasLocalDataPoolIF { public HasLocalDataPoolIF {
public: public:
static constexpr uint8_t INTERNAL_ERROR_MUTEX_TIMEOUT = 20;
InternalErrorReporter(object_id_t setObjectId, InternalErrorReporter(object_id_t setObjectId,
uint32_t messageQueueDepth = 5); uint32_t messageQueueDepth = 5);
@ -34,6 +33,9 @@ public:
*/ */
void setDiagnosticPrintout(bool enable); void setDiagnosticPrintout(bool enable);
void setMutexTimeout(MutexIF::TimeoutType timeoutType,
uint32_t timeoutMs);
virtual ~InternalErrorReporter(); virtual ~InternalErrorReporter();
virtual object_id_t getObjectId() const override; virtual object_id_t getObjectId() const override;
@ -61,7 +63,11 @@ protected:
LocalDataPoolManager poolManager; LocalDataPoolManager poolManager;
PeriodicTaskIF* executingTask = nullptr; PeriodicTaskIF* executingTask = nullptr;
MutexIF* mutex = nullptr; MutexIF* mutex = nullptr;
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
uint32_t timeoutMs = 20;
sid_t internalErrorSid; sid_t internalErrorSid;
InternalErrorDataset internalErrorDataset; InternalErrorDataset internalErrorDataset;

View File

@ -15,8 +15,10 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) :
this->messageSize = this->HEADER_SIZE + size; this->messageSize = this->HEADER_SIZE + size;
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "MessageQueueMessage: Passed size larger than maximum" sif::warning << "MessageQueueMessage: Passed size larger than maximum"
"allowed size! Setting content to 0" << std::endl; "allowed size! Setting content to 0" << std::endl;
#endif
memset(this->internalBuffer, 0, sizeof(this->internalBuffer)); memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
this->messageSize = this->HEADER_SIZE; this->messageSize = this->HEADER_SIZE;
} }
@ -52,7 +54,9 @@ void MessageQueueMessage::setSender(MessageQueueId_t setId) {
} }
void MessageQueueMessage::print(bool printWholeMessage) { void MessageQueueMessage::print(bool printWholeMessage) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "MessageQueueMessage content: " << std::endl; sif::debug << "MessageQueueMessage content: " << std::endl;
#endif
if(printWholeMessage) { if(printWholeMessage) {
arrayprinter::print(getData(), getMaximumMessageSize()); arrayprinter::print(getData(), getMaximumMessageSize());
} }

View File

@ -12,12 +12,16 @@ public:
ReturnValue_t status = mutex->lockMutex(timeoutType, ReturnValue_t status = mutex->lockMutex(timeoutType,
timeoutMs); timeoutMs);
if(status == MutexIF::MUTEX_TIMEOUT) { if(status == MutexIF::MUTEX_TIMEOUT) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexHelper: Lock of mutex failed with timeout of " sif::error << "MutexHelper: Lock of mutex failed with timeout of "
<< timeoutMs << " milliseconds!" << std::endl; << timeoutMs << " milliseconds!" << std::endl;
#endif
} }
else if(status != HasReturnvaluesIF::RETURN_OK){ else if(status != HasReturnvaluesIF::RETURN_OK){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexHelper: Lock of Mutex failed with code " sif::error << "MutexHelper: Lock of Mutex failed with code "
<< status << std::endl; << status << std::endl;
#endif
} }
} }

View File

@ -14,7 +14,7 @@ public:
/** /**
* Different types of timeout for the mutex lock. * Different types of timeout for the mutex lock.
*/ */
enum TimeoutType { enum class TimeoutType {
POLLING, //!< If mutex is not available, return immediately POLLING, //!< If mutex is not available, return immediately
WAITING, //!< Wait a specified time for the mutex to become available WAITING, //!< Wait a specified time for the mutex to become available
BLOCKING //!< Block indefinitely until the mutex becomes available. BLOCKING //!< Block indefinitely until the mutex becomes available.

View File

@ -16,7 +16,9 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {
lastSender = message->getSender(); lastSender = message->getSender();
lastCommand = message->getCommand(); lastCommand = message->getCommand();
if (busy) { if (busy) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "MemHelper: Busy!" << std::endl; sif::debug << "MemHelper: Busy!" << std::endl;
#endif
} }
switch (lastCommand) { switch (lastCommand) {
case MemoryMessage::CMD_MEMORY_DUMP: case MemoryMessage::CMD_MEMORY_DUMP:

View File

@ -72,8 +72,10 @@ private:
if (timeStamper == nullptr) { if (timeStamper == nullptr) {
timeStamper = objectManager->get<TimeStamperIF>( timeStamperId ); timeStamper = objectManager->get<TimeStamperIF>( timeStamperId );
if ( timeStamper == nullptr ) { if ( timeStamper == nullptr ) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MonitoringReportContent::checkAndSetStamper: " sif::error << "MonitoringReportContent::checkAndSetStamper: "
"Stamper not found!" << std::endl; "Stamper not found!" << std::endl;
#endif
return false; return false;
} }
} }

View File

@ -1,6 +1,9 @@
#include "ObjectManager.h" #include "ObjectManager.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#if FSFW_CPP_OSTREAM_ENABLED == 1
#include <iomanip> #include <iomanip>
#endif
#include <cstdlib> #include <cstdlib>
ObjectManager::ObjectManager( void (*setProducer)() ): ObjectManager::ObjectManager( void (*setProducer)() ):
@ -18,13 +21,18 @@ ObjectManager::~ObjectManager() {
ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) { ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
auto returnPair = objectList.emplace(id, object); auto returnPair = objectList.emplace(id, object);
if (returnPair.second) { if (returnPair.second) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "ObjectManager::insert: Object " << std::hex // sif::debug << "ObjectManager::insert: Object " << std::hex
// << (int)id << std::dec << " inserted." << std::endl; // << (int)id << std::dec << " inserted." << std::endl;
#endif
return this->RETURN_OK; return this->RETURN_OK;
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::insert: Object id " << std::hex sif::error << "ObjectManager::insert: Object id " << std::hex
<< (int)id << std::dec << " is already in use!" << std::endl; << static_cast<uint32_t>(id) << std::dec
<< " is already in use!" << std::endl;
sif::error << "Terminating program." << std::endl; sif::error << "Terminating program." << std::endl;
#endif
//This is very severe and difficult to handle in other places. //This is very severe and difficult to handle in other places.
std::exit(INSERTION_FAILED); std::exit(INSERTION_FAILED);
} }
@ -33,12 +41,16 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
ReturnValue_t ObjectManager::remove( object_id_t id ) { ReturnValue_t ObjectManager::remove( object_id_t id ) {
if ( this->getSystemObject(id) != NULL ) { if ( this->getSystemObject(id) != NULL ) {
this->objectList.erase( id ); this->objectList.erase( id );
#if FSFW_CPP_OSTREAM_ENABLED == 1
//sif::debug << "ObjectManager::removeObject: Object " << std::hex //sif::debug << "ObjectManager::removeObject: Object " << std::hex
// << (int)id << std::dec << " removed." << std::endl; // << (int)id << std::dec << " removed." << std::endl;
#endif
return RETURN_OK; return RETURN_OK;
} else { } else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::removeObject: Requested object " sif::error << "ObjectManager::removeObject: Requested object "
<< std::hex << (int)id << std::dec << " not found." << std::endl; << std::hex << (int)id << std::dec << " not found." << std::endl;
#endif
return NOT_FOUND; return NOT_FOUND;
} }
} }
@ -60,8 +72,10 @@ ObjectManager::ObjectManager() : produceObjects(nullptr) {
void ObjectManager::initialize() { void ObjectManager::initialize() {
if(produceObjects == nullptr) { if(produceObjects == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::initialize: Passed produceObjects " sif::error << "ObjectManager::initialize: Passed produceObjects "
"functions is nullptr!" << std::endl; "functions is nullptr!" << std::endl;
#endif
return; return;
} }
this->produceObjects(); this->produceObjects();
@ -70,38 +84,49 @@ void ObjectManager::initialize() {
for (auto const& it : objectList) { for (auto const& it : objectList) {
result = it.second->initialize(); result = it.second->initialize();
if ( result != RETURN_OK ) { if ( result != RETURN_OK ) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
object_id_t var = it.first; object_id_t var = it.first;
sif::error << "ObjectManager::initialize: Object 0x" << std::hex << sif::error << "ObjectManager::initialize: Object 0x" << std::hex <<
std::setw(8) << std::setfill('0')<< var << " failed to " std::setw(8) << std::setfill('0')<< var << " failed to "
"initialize with code 0x" << result << std::dec << "initialize with code 0x" << result << std::dec <<
std::setfill(' ') << std::endl; std::setfill(' ') << std::endl;
#endif
errorCount++; errorCount++;
} }
} }
if (errorCount > 0) { if (errorCount > 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
<< " failed initializations." << std::endl; << " failed initializations." << std::endl;
#endif
} }
//Init was successful. Now check successful interconnections. //Init was successful. Now check successful interconnections.
errorCount = 0; errorCount = 0;
for (auto const& it : objectList) { for (auto const& it : objectList) {
result = it.second->checkObjectConnections(); result = it.second->checkObjectConnections();
if ( result != RETURN_OK ) { if ( result != RETURN_OK ) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::ObjectManager: Object " << std::hex << sif::error << "ObjectManager::ObjectManager: Object " << std::hex <<
(int) it.first << " connection check failed with code 0x" (int) it.first << " connection check failed with code 0x"
<< result << std::dec << std::endl; << result << std::dec << std::endl;
#endif
errorCount++; errorCount++;
} }
} }
if (errorCount > 0) { if (errorCount > 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
<< " failed connection checks." << std::endl; << " failed connection checks." << std::endl;
#endif
} }
} }
void ObjectManager::printList() { void ObjectManager::printList() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "ObjectManager: Object List contains:" << std::endl; sif::debug << "ObjectManager: Object List contains:" << std::endl;
for (auto const& it : objectList) { for (auto const& it : objectList) {
sif::debug << std::hex << it.first << " | " << it.second << std::endl; sif::debug << std::hex << it.first << " | " << it.second << std::endl;
} }
#endif
} }

View File

@ -86,8 +86,10 @@ extern ObjectManagerIF *objectManager;
template <typename T> template <typename T>
T* ObjectManagerIF::get( object_id_t id ) { T* ObjectManagerIF::get( object_id_t id ) {
if(objectManager == nullptr) { if(objectManager == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectManagerIF: Global object manager has not " sif::error << "ObjectManagerIF: Global object manager has not "
"been initialized yet!" << std::endl; "been initialized yet!" << std::endl;
#endif
} }
SystemObjectIF* temp = this->getSystemObject(id); SystemObjectIF* temp = this->getSystemObject(id);
return dynamic_cast<T*>(temp); return dynamic_cast<T*>(temp);

View File

@ -8,8 +8,10 @@
BinarySemaphoreUsingTask::BinarySemaphoreUsingTask() { BinarySemaphoreUsingTask::BinarySemaphoreUsingTask() {
handle = TaskManagement::getCurrentTaskHandle(); handle = TaskManagement::getCurrentTaskHandle();
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Could not retrieve task handle. Please ensure the" sif::error << "Could not retrieve task handle. Please ensure the"
"constructor was called inside a task." << std::endl; "constructor was called inside a task." << std::endl;
#endif
} }
xTaskNotifyGive(handle); xTaskNotifyGive(handle);
} }

View File

@ -5,7 +5,9 @@
BinarySemaphore::BinarySemaphore() { BinarySemaphore::BinarySemaphore() {
handle = xSemaphoreCreateBinary(); handle = xSemaphoreCreateBinary();
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Semaphore: Binary semaph creation failure" << std::endl; sif::error << "Semaphore: Binary semaph creation failure" << std::endl;
#endif
} }
// Initiated semaphore must be given before it can be taken. // Initiated semaphore must be given before it can be taken.
xSemaphoreGive(handle); xSemaphoreGive(handle);
@ -18,7 +20,9 @@ BinarySemaphore::~BinarySemaphore() {
BinarySemaphore::BinarySemaphore(BinarySemaphore&& s) { BinarySemaphore::BinarySemaphore(BinarySemaphore&& s) {
handle = xSemaphoreCreateBinary(); handle = xSemaphoreCreateBinary();
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Binary semaphore creation failure" << std::endl; sif::error << "Binary semaphore creation failure" << std::endl;
#endif
} }
xSemaphoreGive(handle); xSemaphoreGive(handle);
} }
@ -28,7 +32,9 @@ BinarySemaphore& BinarySemaphore::operator =(
if(&s != this) { if(&s != this) {
handle = xSemaphoreCreateBinary(); handle = xSemaphoreCreateBinary();
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Binary semaphore creation failure" << std::endl; sif::error << "Binary semaphore creation failure" << std::endl;
#endif
} }
xSemaphoreGive(handle); xSemaphoreGive(handle);
} }

View File

@ -163,7 +163,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) { if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -178,7 +178,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
if (timeMutex == NULL) { if (timeMutex == NULL) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -9,25 +9,31 @@
CountingSemaphoreUsingTask::CountingSemaphoreUsingTask(const uint8_t maxCount, CountingSemaphoreUsingTask::CountingSemaphoreUsingTask(const uint8_t maxCount,
uint8_t initCount): maxCount(maxCount) { uint8_t initCount): maxCount(maxCount) {
if(initCount > maxCount) { if(initCount > maxCount) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CountingSemaphoreUsingTask: Max count bigger than " sif::error << "CountingSemaphoreUsingTask: Max count bigger than "
"intial cout. Setting initial count to max count." << std::endl; "intial cout. Setting initial count to max count." << std::endl;
#endif
initCount = maxCount; initCount = maxCount;
} }
handle = TaskManagement::getCurrentTaskHandle(); handle = TaskManagement::getCurrentTaskHandle();
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CountingSemaphoreUsingTask: Could not retrieve task " sif::error << "CountingSemaphoreUsingTask: Could not retrieve task "
"handle. Please ensure the constructor was called inside a " "handle. Please ensure the constructor was called inside a "
"task." << std::endl; "task." << std::endl;
#endif
} }
uint32_t oldNotificationValue; uint32_t oldNotificationValue;
xTaskNotifyAndQuery(handle, 0, eSetValueWithOverwrite, xTaskNotifyAndQuery(handle, 0, eSetValueWithOverwrite,
&oldNotificationValue); &oldNotificationValue);
if(oldNotificationValue != 0) { if(oldNotificationValue != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "CountinSemaphoreUsingTask: Semaphore initiated but " sif::warning << "CountinSemaphoreUsingTask: Semaphore initiated but "
"current notification value is not 0. Please ensure the " "current notification value is not 0. Please ensure the "
"notification value is not used for other purposes!" << std::endl; "notification value is not used for other purposes!" << std::endl;
#endif
} }
for(int i = 0; i < initCount; i++) { for(int i = 0; i < initCount; i++) {
xTaskNotifyGive(handle); xTaskNotifyGive(handle);

View File

@ -10,14 +10,18 @@
CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount):
maxCount(maxCount), initCount(initCount) { maxCount(maxCount), initCount(initCount) {
if(initCount > maxCount) { if(initCount > maxCount) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CountingSemaphoreUsingTask: Max count bigger than " sif::error << "CountingSemaphoreUsingTask: Max count bigger than "
"intial cout. Setting initial count to max count." << std::endl; "intial cout. Setting initial count to max count." << std::endl;
#endif
initCount = maxCount; initCount = maxCount;
} }
handle = xSemaphoreCreateCounting(maxCount, initCount); handle = xSemaphoreCreateCounting(maxCount, initCount);
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CountingSemaphore: Creation failure" << std::endl; sif::error << "CountingSemaphore: Creation failure" << std::endl;
#endif
} }
} }
@ -25,7 +29,9 @@ CountingSemaphore::CountingSemaphore(CountingSemaphore&& other):
maxCount(other.maxCount), initCount(other.initCount) { maxCount(other.maxCount), initCount(other.initCount) {
handle = xSemaphoreCreateCounting(other.maxCount, other.initCount); handle = xSemaphoreCreateCounting(other.maxCount, other.initCount);
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CountingSemaphore: Creation failure" << std::endl; sif::error << "CountingSemaphore: Creation failure" << std::endl;
#endif
} }
} }
@ -33,7 +39,9 @@ CountingSemaphore& CountingSemaphore::operator =(
CountingSemaphore&& other) { CountingSemaphore&& other) {
handle = xSemaphoreCreateCounting(other.maxCount, other.initCount); handle = xSemaphoreCreateCounting(other.maxCount, other.initCount);
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CountingSemaphore: Creation failure" << std::endl; sif::error << "CountingSemaphore: Creation failure" << std::endl;
#endif
} }
return * this; return * this;
} }

View File

@ -37,15 +37,19 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) {
} }
originalTask->taskFunctionality(); originalTask->taskFunctionality();
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Polling task " << originalTask->handle sif::debug << "Polling task " << originalTask->handle
<< " returned from taskFunctionality." << std::endl; << " returned from taskFunctionality." << std::endl;
#endif
} }
void FixedTimeslotTask::missedDeadlineCounter() { void FixedTimeslotTask::missedDeadlineCounter() {
FixedTimeslotTask::deadlineMissedCount++; FixedTimeslotTask::deadlineMissedCount++;
if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount
<< " deadlines." << std::endl; << " deadlines." << std::endl;
#endif
} }
} }
@ -69,8 +73,10 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << componentId << sif::error << "Component " << std::hex << componentId <<
" not found, not adding it to pst" << std::endl; " not found, not adding it to pst" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }

View File

@ -10,6 +10,7 @@
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
maxMessageSize(maxMessageSize) { maxMessageSize(maxMessageSize) {
handle = xQueueCreate(messageDepth, maxMessageSize); handle = xQueueCreate(messageDepth, maxMessageSize);
#if FSFW_CPP_OSTREAM_ENABLED == 1
if (handle == nullptr) { if (handle == nullptr) {
sif::error << "MessageQueue::MessageQueue:" sif::error << "MessageQueue::MessageQueue:"
<< " Creation failed." << std::endl; << " Creation failed." << std::endl;
@ -17,7 +18,9 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
<< std::endl; << std::endl;
sif::error << "Specified Maximum Message Size: " sif::error << "Specified Maximum Message Size: "
<< maxMessageSize << std::endl; << maxMessageSize << std::endl;
} }
#endif
} }
MessageQueue::~MessageQueue() { MessageQueue::~MessageQueue() {

View File

@ -5,7 +5,9 @@
Mutex::Mutex() { Mutex::Mutex() {
handle = xSemaphoreCreateMutex(); handle = xSemaphoreCreateMutex();
if(handle == nullptr) { if(handle == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl; sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl;
#endif
} }
} }

View File

@ -13,8 +13,10 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
BaseType_t status = xTaskCreate(taskEntryPoint, name, BaseType_t status = xTaskCreate(taskEntryPoint, name,
stackSize, this, setPriority, &handle); stackSize, this, setPriority, &handle);
if(status != pdPASS){ if(status != pdPASS){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PeriodicTask Insufficient heap memory remaining. " sif::debug << "PeriodicTask Insufficient heap memory remaining. "
"Status: " << status << std::endl; "Status: " << status << std::endl;
#endif
} }
} }
@ -41,8 +43,10 @@ void PeriodicTask::taskEntryPoint(void* argument) {
} }
originalTask->taskFunctionality(); originalTask->taskFunctionality();
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Polling task " << originalTask->handle sif::debug << "Polling task " << originalTask->handle
<< " returned from taskFunctionality." << std::endl; << " returned from taskFunctionality." << std::endl;
#endif
} }
ReturnValue_t PeriodicTask::startTask() { ReturnValue_t PeriodicTask::startTask() {
@ -99,8 +103,10 @@ ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>( ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
object); object);
if (newObject == nullptr) { if (newObject == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
"it implement ExecutableObjectIF" << std::endl; "it implement ExecutableObjectIF" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
objectList.push_back(newObject); objectList.push_back(newObject);

View File

@ -32,8 +32,10 @@ SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t argument) {
return new BinarySemaphoreUsingTask(); return new BinarySemaphoreUsingTask();
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "SemaphoreFactory: Invalid argument, return regular" sif::warning << "SemaphoreFactory: Invalid argument, return regular"
"binary semaphore" << std::endl; "binary semaphore" << std::endl;
#endif
return new BinarySemaphore(); return new BinarySemaphore();
} }
} }
@ -47,8 +49,10 @@ SemaphoreIF* SemaphoreFactory::createCountingSemaphore(uint8_t maxCount,
return new CountingSemaphoreUsingTask(maxCount, initCount); return new CountingSemaphoreUsingTask(maxCount, initCount);
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "SemaphoreFactory: Invalid argument, return regular" sif::warning << "SemaphoreFactory: Invalid argument, return regular"
"binary semaphore" << std::endl; "binary semaphore" << std::endl;
#endif
return new CountingSemaphore(maxCount, initCount); return new CountingSemaphore(maxCount, initCount);
} }

View File

@ -14,7 +14,9 @@ MutexIF* Clock::timeMutex = NULL;
using SystemClock = std::chrono::system_clock; using SystemClock = std::chrono::system_clock;
uint32_t Clock::getTicksPerSecond(void){ uint32_t Clock::getTicksPerSecond(void){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getTicksPerSecond: not implemented yet" << std::endl; sif::warning << "Clock::getTicksPerSecond: not implemented yet" << std::endl;
#endif
return 0; return 0;
//return CLOCKS_PER_SEC; //return CLOCKS_PER_SEC;
//uint32_t ticks = sysconf(_SC_CLK_TCK); //uint32_t ticks = sysconf(_SC_CLK_TCK);
@ -23,7 +25,9 @@ uint32_t Clock::getTicksPerSecond(void){
ReturnValue_t Clock::setClock(const TimeOfDay_t* time) { ReturnValue_t Clock::setClock(const TimeOfDay_t* time) {
// do some magic with chrono // do some magic with chrono
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::setClock: not implemented yet" << std::endl; sif::warning << "Clock::setClock: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -36,7 +40,9 @@ ReturnValue_t Clock::setClock(const timeval* time) {
#else #else
#endif #endif
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -60,7 +66,9 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) {
time->tv_usec = timeUnix.tv_nsec / 1000.0; time->tv_usec = timeUnix.tv_nsec / 1000.0;
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
#else #else
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
#endif #endif
@ -68,7 +76,9 @@ ReturnValue_t Clock::getClock_timeval(timeval* time) {
ReturnValue_t Clock::getClock_usecs(uint64_t* time) { ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
// do some magic with chrono // do some magic with chrono
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::gerClock_usecs: not implemented yet" << std::endl; sif::warning << "Clock::gerClock_usecs: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -90,7 +100,9 @@ timeval Clock::getUptime() {
timeval.tv_usec = uptimeSeconds *(double) 1e6 - (timeval.tv_sec *1e6); timeval.tv_usec = uptimeSeconds *(double) 1e6 - (timeval.tv_sec *1e6);
} }
#else #else
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl; sif::warning << "Clock::getUptime: Not implemented for found OS" << std::endl;
#endif
#endif #endif
return timeval; return timeval;
} }
@ -126,7 +138,9 @@ ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
auto usecond = std::chrono::duration_cast<std::chrono::microseconds>(fraction); auto usecond = std::chrono::duration_cast<std::chrono::microseconds>(fraction);
time->usecond = usecond.count(); time->usecond = usecond.count();
#if FSFW_CPP_OSTREAM_ENABLED == 1
//sif::warning << "Clock::getDateAndTime: not implemented yet" << std::endl; //sif::warning << "Clock::getDateAndTime: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -148,7 +162,9 @@ ReturnValue_t Clock::convertTimeOfDayToTimeval(const TimeOfDay_t* from,
to->tv_usec = from->usecond; to->tv_usec = from->usecond;
//Fails in 2038.. //Fails in 2038..
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Clock::convertTimeBla: not implemented yet" << std::endl; sif::warning << "Clock::convertTimeBla: not implemented yet" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -186,7 +202,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){ if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -201,7 +217,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
if(timeMutex == nullptr){ if(timeMutex == nullptr){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -35,15 +35,19 @@ FixedTimeslotTask::FixedTimeslotTask(const char *name, TaskPriority setPriority,
reinterpret_cast<HANDLE>(mainThread.native_handle()), reinterpret_cast<HANDLE>(mainThread.native_handle()),
ABOVE_NORMAL_PRIORITY_CLASS); ABOVE_NORMAL_PRIORITY_CLASS);
if(result != 0) { if(result != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl; << GetLastError() << std::endl;
#endif
} }
result = SetThreadPriority( result = SetThreadPriority(
reinterpret_cast<HANDLE>(mainThread.native_handle()), reinterpret_cast<HANDLE>(mainThread.native_handle()),
THREAD_PRIORITY_NORMAL); THREAD_PRIORITY_NORMAL);
if(result != 0) { if(result != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code " sif::error << "FixedTimeslotTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl; << GetLastError() << std::endl;
#endif
} }
#elif defined(LINUX) #elif defined(LINUX)
// TODO: we can just copy and paste the code from the linux OSAL here. // TODO: we can just copy and paste the code from the linux OSAL here.
@ -70,8 +74,10 @@ void FixedTimeslotTask::taskEntryPoint(void* argument) {
} }
this->taskFunctionality(); this->taskFunctionality();
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "FixedTimeslotTask::taskEntryPoint: " sif::debug << "FixedTimeslotTask::taskEntryPoint: "
"Returned from taskFunctionality." << std::endl; "Returned from taskFunctionality." << std::endl;
#endif
} }
ReturnValue_t FixedTimeslotTask::startTask() { ReturnValue_t FixedTimeslotTask::startTask() {
@ -134,8 +140,10 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << componentId << sif::error << "Component " << std::hex << componentId <<
" not found, not adding it to pst" << std::endl; " not found, not adding it to pst" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }

View File

@ -10,8 +10,10 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
queueLock = MutexFactory::instance()->createMutex(); queueLock = MutexFactory::instance()->createMutex();
auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId); auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::MessageQueue:" sif::error << "MessageQueue::MessageQueue:"
<< " Could not be created" << std::endl; << " Could not be created" << std::endl;
#endif
} }
} }
@ -137,8 +139,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
targetQueue->messageQueue.push(*mqmMessage); targetQueue->messageQueue.push(*mqmMessage);
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message" sif::error << "MessageQueue::sendMessageFromMessageQueue: Message"
"is not MessageQueueMessage!" << std::endl; "is not MessageQueueMessage!" << std::endl;
#endif
} }
} }

View File

@ -4,16 +4,16 @@
Mutex::Mutex() {} Mutex::Mutex() {}
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) { ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType, uint32_t timeoutMs) {
if(timeoutType == MutexIF::BLOCKING) { if(timeoutType == TimeoutType::BLOCKING) {
mutex.lock(); mutex.lock();
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
else if(timeoutType == MutexIF::POLLING) { else if(timeoutType == TimeoutType::POLLING) {
if(mutex.try_lock()) { if(mutex.try_lock()) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
} }
else if(timeoutMs > MutexIF::POLLING){ else if(timeoutType == TimeoutType::WAITING){
auto chronoMs = std::chrono::milliseconds(timeoutMs); auto chronoMs = std::chrono::milliseconds(timeoutMs);
if(mutex.try_lock_for(chronoMs)) { if(mutex.try_lock_for(chronoMs)) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;

View File

@ -33,15 +33,19 @@ PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
reinterpret_cast<HANDLE>(mainThread.native_handle()), reinterpret_cast<HANDLE>(mainThread.native_handle()),
ABOVE_NORMAL_PRIORITY_CLASS); ABOVE_NORMAL_PRIORITY_CLASS);
if(result != 0) { if(result != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " sif::error << "PeriodicTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl; << GetLastError() << std::endl;
#endif
} }
result = SetThreadPriority( result = SetThreadPriority(
reinterpret_cast<HANDLE>(mainThread.native_handle()), reinterpret_cast<HANDLE>(mainThread.native_handle()),
THREAD_PRIORITY_NORMAL); THREAD_PRIORITY_NORMAL);
if(result != 0) { if(result != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask: Windows SetPriorityClass failed with code " sif::error << "PeriodicTask: Windows SetPriorityClass failed with code "
<< GetLastError() << std::endl; << GetLastError() << std::endl;
#endif
} }
#elif defined(LINUX) #elif defined(LINUX)
// we can just copy and paste the code from linux here. // we can just copy and paste the code from linux here.
@ -69,8 +73,10 @@ void PeriodicTask::taskEntryPoint(void* argument) {
} }
this->taskFunctionality(); this->taskFunctionality();
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "PeriodicTask::taskEntryPoint: " sif::debug << "PeriodicTask::taskEntryPoint: "
"Returned from taskFunctionality." << std::endl; "Returned from taskFunctionality." << std::endl;
#endif
} }
ReturnValue_t PeriodicTask::startTask() { ReturnValue_t PeriodicTask::startTask() {

View File

@ -26,8 +26,10 @@ ReturnValue_t QueueMapManager::addMessageQueue(
auto returnPair = queueMap.emplace(currentId, queueToInsert); auto returnPair = queueMap.emplace(currentId, queueToInsert);
if(not returnPair.second) { if(not returnPair.second) {
// this should never happen for the atomic variable. // this should never happen for the atomic variable.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "QueueMapManager: This ID is already inside the map!" sif::error << "QueueMapManager: This ID is already inside the map!"
<< std::endl; << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
if (id != nullptr) { if (id != nullptr) {
@ -44,8 +46,10 @@ MessageQueueIF* QueueMapManager::getMessageQueue(
return queueIter->second; return queueIter->second;
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "QueueMapManager::getQueueHandle: The ID " << sif::warning << "QueueMapManager::getQueueHandle: The ID " <<
messageQueueId << " does not exists in the map" << std::endl; messageQueueId << " does not exists in the map" << std::endl;
#endif
return nullptr; return nullptr;
} }
} }

View File

@ -21,16 +21,20 @@ SemaphoreFactory* SemaphoreFactory::instance() {
SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) { SemaphoreIF* SemaphoreFactory::createBinarySemaphore(uint32_t arguments) {
// Just gonna wait for full C++20 for now. // Just gonna wait for full C++20 for now.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SemaphoreFactory: Binary Semaphore not implemented yet." sif::error << "SemaphoreFactory: Binary Semaphore not implemented yet."
" Returning nullptr!\n" << std::flush; " Returning nullptr!\n" << std::flush;
#endif
return nullptr; return nullptr;
} }
SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount, SemaphoreIF* SemaphoreFactory::createCountingSemaphore(const uint8_t maxCount,
uint8_t initCount, uint32_t arguments) { uint8_t initCount, uint32_t arguments) {
// Just gonna wait for full C++20 for now. // Just gonna wait for full C++20 for now.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "SemaphoreFactory: Counting Semaphore not implemented yet." sif::error << "SemaphoreFactory: Counting Semaphore not implemented yet."
" Returning nullptr!\n" << std::flush; " Returning nullptr!\n" << std::flush;
#endif
return nullptr; return nullptr;
} }

View File

@ -43,8 +43,10 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType,
timeOut.tv_nsec = nseconds - timeOut.tv_sec * 1000000000; timeOut.tv_nsec = nseconds - timeOut.tv_sec * 1000000000;
result = sem_timedwait(&handle, &timeOut); result = sem_timedwait(&handle, &timeOut);
if(result != 0 and errno == EINVAL) { if(result != 0 and errno == EINVAL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "BinarySemaphore::acquire: Invalid time value possible" sif::debug << "BinarySemaphore::acquire: Invalid time value possible"
<< std::endl; << std::endl;
#endif
} }
} }
if(result == 0) { if(result == 0) {
@ -62,8 +64,10 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType,
return SemaphoreIF::SEMAPHORE_INVALID; return SemaphoreIF::SEMAPHORE_INVALID;
case(EINTR): case(EINTR):
// Call was interrupted by signal handler // Call was interrupted by signal handler
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "BinarySemaphore::acquire: Signal handler interrupted." sif::debug << "BinarySemaphore::acquire: Signal handler interrupted."
"Code " << strerror(errno) << std::endl; "Code " << strerror(errno) << std::endl;
#endif
/* No break */ /* No break */
default: default:
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
@ -126,8 +130,10 @@ void BinarySemaphore::initSemaphore(uint8_t initCount) {
// Value exceeds SEM_VALUE_MAX // Value exceeds SEM_VALUE_MAX
case(ENOSYS): case(ENOSYS):
// System does not support process-shared semaphores // System does not support process-shared semaphores
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "BinarySemaphore: Init failed with" << strerror(errno) sif::error << "BinarySemaphore: Init failed with" << strerror(errno)
<< std::endl; << std::endl;
#endif
} }
} }
} }

View File

@ -69,7 +69,9 @@ timeval Clock::getUptime() {
timeval uptime; timeval uptime;
auto result = getUptime(&uptime); auto result = getUptime(&uptime);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Clock::getUptime: Error getting uptime" << std::endl; sif::error << "Clock::getUptime: Error getting uptime" << std::endl;
#endif
} }
return uptime; return uptime;
} }
@ -180,7 +182,7 @@ ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){ if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -195,7 +197,7 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
if(timeMutex==NULL){ if(timeMutex==NULL){
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t result = timeMutex->lockMutex(MutexIF::BLOCKING); ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -207,13 +209,13 @@ ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
} }
ReturnValue_t Clock::checkOrCreateClockMutex(){ ReturnValue_t Clock::checkOrCreateClockMutex(){
if(timeMutex==NULL){ if(timeMutex == nullptr){
MutexFactory* mutexFactory = MutexFactory::instance(); MutexFactory* mutexFactory = MutexFactory::instance();
if (mutexFactory == NULL) { if (mutexFactory == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
timeMutex = mutexFactory->createMutex(); timeMutex = mutexFactory->createMutex();
if (timeMutex == NULL) { if (timeMutex == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
} }

View File

@ -4,8 +4,10 @@
CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount): CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount):
maxCount(maxCount), initCount(initCount) { maxCount(maxCount), initCount(initCount) {
if(initCount > maxCount) { if(initCount > maxCount) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CountingSemaphoreUsingTask: Max count bigger than " sif::error << "CountingSemaphoreUsingTask: Max count bigger than "
"intial cout. Setting initial count to max count." << std::endl; "intial cout. Setting initial count to max count." << std::endl;
#endif
initCount = maxCount; initCount = maxCount;
} }

View File

@ -47,8 +47,10 @@ ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << componentId << sif::error << "Component " << std::hex << componentId <<
" not found, not adding it to pst" << std::dec << std::endl; " not found, not adding it to pst" << std::dec << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -91,7 +93,9 @@ void FixedTimeslotTask::taskFunctionality() {
void FixedTimeslotTask::missedDeadlineCounter() { void FixedTimeslotTask::missedDeadlineCounter() {
FixedTimeslotTask::deadlineMissedCount++; FixedTimeslotTask::deadlineMissedCount++;
if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) { if (FixedTimeslotTask::deadlineMissedCount % 10 == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount sif::error << "PST missed " << FixedTimeslotTask::deadlineMissedCount
<< " deadlines." << std::endl; << " deadlines." << std::endl;
#endif
} }
} }

View File

@ -10,7 +10,6 @@
#include <errno.h> #include <errno.h>
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize): MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize):
id(MessageQueueIF::NO_QUEUE),lastPartner(MessageQueueIF::NO_QUEUE), id(MessageQueueIF::NO_QUEUE),lastPartner(MessageQueueIF::NO_QUEUE),
defaultDestination(MessageQueueIF::NO_QUEUE), defaultDestination(MessageQueueIF::NO_QUEUE),
@ -43,13 +42,17 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize):
MessageQueue::~MessageQueue() { MessageQueue::~MessageQueue() {
int status = mq_close(this->id); int status = mq_close(this->id);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::Destructor: mq_close Failed with status: " sif::error << "MessageQueue::Destructor: mq_close Failed with status: "
<< strerror(errno) <<std::endl; << strerror(errno) <<std::endl;
#endif
} }
status = mq_unlink(name); status = mq_unlink(name);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::Destructor: mq_unlink Failed with status: " sif::error << "MessageQueue::Destructor: mq_unlink Failed with status: "
<< strerror(errno) << std::endl; << strerror(errno) << std::endl;
#endif
} }
} }
@ -57,8 +60,10 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
uint32_t messageDepth) { uint32_t messageDepth) {
switch(errno) { switch(errno) {
case(EINVAL): { case(EINVAL): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::MessageQueue: Invalid name or attributes" sif::error << "MessageQueue::MessageQueue: Invalid name or attributes"
" for message size" << std::endl; " for message size" << std::endl;
#endif
size_t defaultMqMaxMsg = 0; size_t defaultMqMaxMsg = 0;
// Not POSIX conformant, but should work for all UNIX systems. // Not POSIX conformant, but should work for all UNIX systems.
// Just an additional helpful printout :-) // Just an additional helpful printout :-)
@ -79,11 +84,13 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
Append at end: fs/mqueue/msg_max = <newMsgMaxLen> Append at end: fs/mqueue/msg_max = <newMsgMaxLen>
Apply changes with: sudo sysctl -p Apply changes with: sudo sysctl -p
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::MessageQueue: Default MQ size " sif::error << "MessageQueue::MessageQueue: Default MQ size "
<< defaultMqMaxMsg << " is too small for requested size " << defaultMqMaxMsg << " is too small for requested size "
<< messageDepth << std::endl; << messageDepth << std::endl;
sif::error << "This error can be fixed by setting the maximum " sif::error << "This error can be fixed by setting the maximum "
"allowed message size higher!" << std::endl; "allowed message size higher!" << std::endl;
#endif
} }
break; break;
@ -95,8 +102,10 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
//We unlink the other queue //We unlink the other queue
int status = mq_unlink(name); int status = mq_unlink(name);
if (status != 0) { if (status != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "mq_unlink Failed with status: " << strerror(errno) sif::error << "mq_unlink Failed with status: " << strerror(errno)
<< std::endl; << std::endl;
#endif
} }
else { else {
// Successful unlinking, try to open again // Successful unlinking, try to open again
@ -114,9 +123,11 @@ ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
default: default:
// Failed either the first time or the second time // Failed either the first time or the second time
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex
<< name << std::dec << " failed with status: " << name << std::dec << " failed with status: "
<< strerror(errno) << std::endl; << strerror(errno) << std::endl;
#endif
} }
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
@ -151,15 +162,19 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message,
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) { ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
if(message == nullptr) { if(message == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::receiveMessage: Message is " sif::error << "MessageQueue::receiveMessage: Message is "
"nullptr!" << std::endl; "nullptr!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
if(message->getMaximumMessageSize() < maxMessageSize) { if(message->getMaximumMessageSize() < maxMessageSize) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::receiveMessage: Message size " sif::error << "MessageQueue::receiveMessage: Message size "
<< message->getMaximumMessageSize() << message->getMaximumMessageSize()
<< " too small to receive data!" << std::endl; << " too small to receive data!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -187,8 +202,10 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
return MessageQueueIF::EMPTY; return MessageQueueIF::EMPTY;
case EBADF: case EBADF:
//mqdes doesn't represent a valid queue open for reading. //mqdes doesn't represent a valid queue open for reading.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::receive: configuration error " sif::error << "MessageQueue::receive: configuration error "
<< strerror(errno) << std::endl; << strerror(errno) << std::endl;
#endif
/*NO BREAK*/ /*NO BREAK*/
case EINVAL: case EINVAL:
/* /*
@ -200,8 +217,10 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
* queue, and the QNX extended option MQ_READBUF_DYNAMIC hasn't * queue, and the QNX extended option MQ_READBUF_DYNAMIC hasn't
* been set in the queue's mq_flags. * been set in the queue's mq_flags.
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::receive: configuration error " sif::error << "MessageQueue::receive: configuration error "
<< strerror(errno) << std::endl; << strerror(errno) << std::endl;
#endif
/*NO BREAK*/ /*NO BREAK*/
case EMSGSIZE: case EMSGSIZE:
/* /*
@ -213,8 +232,10 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
* given msg_len is too short for the message that would have * given msg_len is too short for the message that would have
* been received. * been received.
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::receive: configuration error " sif::error << "MessageQueue::receive: configuration error "
<< strerror(errno) << std::endl; << strerror(errno) << std::endl;
#endif
/*NO BREAK*/ /*NO BREAK*/
case EINTR: case EINTR:
//The operation was interrupted by a signal. //The operation was interrupted by a signal.
@ -237,8 +258,10 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) {
switch(errno){ switch(errno){
case EBADF: case EBADF:
//mqdes doesn't represent a valid message queue. //mqdes doesn't represent a valid message queue.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::flush configuration error, " sif::error << "MessageQueue::flush configuration error, "
"called flush with an invalid queue ID" << std::endl; "called flush with an invalid queue ID" << std::endl;
#endif
/*NO BREAK*/ /*NO BREAK*/
case EINVAL: case EINVAL:
//mq_attr is NULL //mq_attr is NULL
@ -253,8 +276,10 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) {
switch(errno){ switch(errno){
case EBADF: case EBADF:
//mqdes doesn't represent a valid message queue. //mqdes doesn't represent a valid message queue.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::flush configuration error, " sif::error << "MessageQueue::flush configuration error, "
"called flush with an invalid queue ID" << std::endl; "called flush with an invalid queue ID" << std::endl;
#endif
/*NO BREAK*/ /*NO BREAK*/
case EINVAL: case EINVAL:
/* /*
@ -306,8 +331,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
MessageQueueMessageIF *message, MessageQueueId_t sentFrom, MessageQueueMessageIF *message, MessageQueueId_t sentFrom,
bool ignoreFault) { bool ignoreFault) {
if(message == nullptr) { if(message == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is " sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is "
"nullptr!" << std::endl; "nullptr!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -335,11 +362,13 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
case EBADF: { case EBADF: {
//mq_des doesn't represent a valid message queue descriptor, //mq_des doesn't represent a valid message queue descriptor,
//or mq_des wasn't opened for writing. //or mq_des wasn't opened for writing.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::sendMessage: Configuration error, MQ" sif::error << "MessageQueue::sendMessage: Configuration error, MQ"
<< " destination invalid." << std::endl; << " destination invalid." << std::endl;
sif::error << strerror(errno) << " in " sif::error << strerror(errno) << " in "
<<"mq_send to: " << sendTo << " sent from " <<"mq_send to: " << sendTo << " sent from "
<< sentFrom << std::endl; << sentFrom << std::endl;
#endif
return DESTINVATION_INVALID; return DESTINVATION_INVALID;
} }
case EINTR: case EINTR:
@ -354,14 +383,18 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
* - MQ_PRIO_RESTRICT is set in the mq_attr of mq_des, and * - MQ_PRIO_RESTRICT is set in the mq_attr of mq_des, and
* msg_prio is greater than the priority of the calling process. * msg_prio is greater than the priority of the calling process.
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::sendMessage: Configuration error " sif::error << "MessageQueue::sendMessage: Configuration error "
<< strerror(errno) << " in mq_send" << std::endl; << strerror(errno) << " in mq_send" << std::endl;
#endif
/*NO BREAK*/ /*NO BREAK*/
case EMSGSIZE: case EMSGSIZE:
// The msg_len is greater than the msgsize associated with // The msg_len is greater than the msgsize associated with
//the specified queue. //the specified queue.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::sendMessage: Size error [" << sif::error << "MessageQueue::sendMessage: Size error [" <<
strerror(errno) << "] in mq_send" << std::endl; strerror(errno) << "] in mq_send" << std::endl;
#endif
/*NO BREAK*/ /*NO BREAK*/
default: default:
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;

View File

@ -12,24 +12,32 @@ Mutex::Mutex() {
pthread_mutexattr_t mutexAttr; pthread_mutexattr_t mutexAttr;
int status = pthread_mutexattr_init(&mutexAttr); int status = pthread_mutexattr_init(&mutexAttr);
if (status != 0) { if (status != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex: Attribute init failed with: " << strerror(status) << std::endl; sif::error << "Mutex: Attribute init failed with: " << strerror(status) << std::endl;
#endif
} }
status = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_INHERIT); status = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_INHERIT);
if (status != 0) { if (status != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex: Attribute set PRIO_INHERIT failed with: " << strerror(status) sif::error << "Mutex: Attribute set PRIO_INHERIT failed with: " << strerror(status)
<< std::endl; << std::endl;
#endif
} }
status = pthread_mutex_init(&mutex, &mutexAttr); status = pthread_mutex_init(&mutex, &mutexAttr);
if (status != 0) { if (status != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex: creation with name, id " << mutex.__data.__count sif::error << "Mutex: creation with name, id " << mutex.__data.__count
<< ", " << " failed with " << strerror(status) << std::endl; << ", " << " failed with " << strerror(status) << std::endl;
#endif
} }
// After a mutex attributes object has been used to initialize one or more // After a mutex attributes object has been used to initialize one or more
// mutexes, any function affecting the attributes object // mutexes, any function affecting the attributes object
// (including destruction) shall not affect any previously initialized mutexes. // (including destruction) shall not affect any previously initialized mutexes.
status = pthread_mutexattr_destroy(&mutexAttr); status = pthread_mutexattr_destroy(&mutexAttr);
if (status != 0) { if (status != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex: Attribute destroy failed with " << strerror(status) << std::endl; sif::error << "Mutex: Attribute destroy failed with " << strerror(status) << std::endl;
#endif
} }
} }

View File

@ -25,8 +25,10 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) {
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>( ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
object); object);
if (newObject == nullptr) { if (newObject == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure" sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
<< " it implements ExecutableObjectIF!" << std::endl; << " it implements ExecutableObjectIF!" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
objectList.push_back(newObject); objectList.push_back(newObject);
@ -42,7 +44,9 @@ ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) {
ReturnValue_t PeriodicPosixTask::startTask(void) { ReturnValue_t PeriodicPosixTask::startTask(void) {
started = true; started = true;
#if FSFW_CPP_OSTREAM_ENABLED == 1
//sif::info << stackSize << std::endl; //sif::info << stackSize << std::endl;
#endif
PosixThread::createTask(&taskEntryPoint,this); PosixThread::createTask(&taskEntryPoint,this);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -67,12 +71,16 @@ void PeriodicPosixTask::taskFunctionality(void) {
char name[20] = {0}; char name[20] = {0};
int status = pthread_getname_np(pthread_self(), name, sizeof(name)); int status = pthread_getname_np(pthread_self(), name, sizeof(name));
if(status == 0) { if(status == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicPosixTask " << name << ": Deadline " sif::error << "PeriodicPosixTask " << name << ": Deadline "
"missed." << std::endl; "missed." << std::endl;
#endif
} }
else { else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PeriodicPosixTask X: Deadline missed. " << sif::error << "PeriodicPosixTask X: Deadline missed. " <<
status << std::endl; status << std::endl;
#endif
} }
if (this->deadlineMissedFunc != nullptr) { if (this->deadlineMissedFunc != nullptr) {
this->deadlineMissedFunc(); this->deadlineMissedFunc();

View File

@ -48,8 +48,10 @@ void PosixThread::suspend() {
sigaddset(&waitSignal, SIGUSR1); sigaddset(&waitSignal, SIGUSR1);
sigwait(&waitSignal, &caughtSig); sigwait(&waitSignal, &caughtSig);
if (caughtSig != SIGUSR1) { if (caughtSig != SIGUSR1) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FixedTimeslotTask: Unknown Signal received: " << sif::error << "FixedTimeslotTask: Unknown Signal received: " <<
caughtSig << std::endl; caughtSig << std::endl;
#endif
} }
} }
@ -118,7 +120,9 @@ uint64_t PosixThread::getCurrentMonotonicTimeMs(){
void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) { void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
//sif::debug << "PosixThread::createTask" << std::endl; //sif::debug << "PosixThread::createTask" << std::endl;
#endif
/* /*
* The attr argument points to a pthread_attr_t structure whose contents * The attr argument points to a pthread_attr_t structure whose contents
are used at thread creation time to determine attributes for the new are used at thread creation time to determine attributes for the new
@ -129,53 +133,69 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
pthread_attr_t attributes; pthread_attr_t attributes;
int status = pthread_attr_init(&attributes); int status = pthread_attr_init(&attributes);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Posix Thread attribute init failed with: " << sif::error << "Posix Thread attribute init failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
} }
void* stackPointer; void* stackPointer;
status = posix_memalign(&stackPointer, sysconf(_SC_PAGESIZE), stackSize); status = posix_memalign(&stackPointer, sysconf(_SC_PAGESIZE), stackSize);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PosixThread::createTask: Stack init failed with: " << sif::error << "PosixThread::createTask: Stack init failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
if(errno == ENOMEM) { if(errno == ENOMEM) {
uint64_t stackMb = stackSize/10e6; uint64_t stackMb = stackSize/10e6;
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PosixThread::createTask: Insufficient memory for" sif::error << "PosixThread::createTask: Insufficient memory for"
" the requested " << stackMb << " MB" << std::endl; " the requested " << stackMb << " MB" << std::endl;
#endif
} }
else if(errno == EINVAL) { else if(errno == EINVAL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PosixThread::createTask: Wrong alignment argument!" sif::error << "PosixThread::createTask: Wrong alignment argument!"
<< std::endl; << std::endl;
#endif
} }
return; return;
} }
status = pthread_attr_setstack(&attributes, stackPointer, stackSize); status = pthread_attr_setstack(&attributes, stackPointer, stackSize);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PosixThread::createTask: pthread_attr_setstack " sif::error << "PosixThread::createTask: pthread_attr_setstack "
" failed with: " << strerror(status) << std::endl; " failed with: " << strerror(status) << std::endl;
sif::error << "Make sure the specified stack size is valid and is " sif::error << "Make sure the specified stack size is valid and is "
"larger than the minimum allowed stack size." << std::endl; "larger than the minimum allowed stack size." << std::endl;
#endif
} }
status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED); status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Posix Thread attribute setinheritsched failed with: " << sif::error << "Posix Thread attribute setinheritsched failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
} }
// TODO FIFO -> This needs root privileges for the process // TODO FIFO -> This needs root privileges for the process
status = pthread_attr_setschedpolicy(&attributes,SCHED_FIFO); status = pthread_attr_setschedpolicy(&attributes,SCHED_FIFO);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Posix Thread attribute schedule policy failed with: " << sif::error << "Posix Thread attribute schedule policy failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
} }
sched_param scheduleParams; sched_param scheduleParams;
scheduleParams.__sched_priority = priority; scheduleParams.__sched_priority = priority;
status = pthread_attr_setschedparam(&attributes, &scheduleParams); status = pthread_attr_setschedparam(&attributes, &scheduleParams);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Posix Thread attribute schedule params failed with: " << sif::error << "Posix Thread attribute schedule params failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
} }
//Set Signal Mask for suspend until startTask is called //Set Signal Mask for suspend until startTask is called
@ -184,36 +204,48 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
sigaddset(&waitSignal, SIGUSR1); sigaddset(&waitSignal, SIGUSR1);
status = pthread_sigmask(SIG_BLOCK, &waitSignal, NULL); status = pthread_sigmask(SIG_BLOCK, &waitSignal, NULL);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Posix Thread sigmask failed failed with: " << sif::error << "Posix Thread sigmask failed failed with: " <<
strerror(status) << " errno: " << strerror(errno) << std::endl; strerror(status) << " errno: " << strerror(errno) << std::endl;
#endif
} }
status = pthread_create(&thread,&attributes,fnc_,arg_); status = pthread_create(&thread,&attributes,fnc_,arg_);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Posix Thread create failed with: " << sif::error << "Posix Thread create failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
} }
status = pthread_setname_np(thread,name); status = pthread_setname_np(thread,name);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PosixThread::createTask: setname failed with: " << sif::error << "PosixThread::createTask: setname failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
if(status == ERANGE) { if(status == ERANGE) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PosixThread::createTask: Task name length longer" sif::error << "PosixThread::createTask: Task name length longer"
" than 16 chars. Truncating.." << std::endl; " than 16 chars. Truncating.." << std::endl;
#endif
name[15] = '\0'; name[15] = '\0';
status = pthread_setname_np(thread,name); status = pthread_setname_np(thread,name);
if(status != 0){ if(status != 0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PosixThread::createTask: Setting name" sif::error << "PosixThread::createTask: Setting name"
" did not work.." << std::endl; " did not work.." << std::endl;
#endif
} }
} }
} }
status = pthread_attr_destroy(&attributes); status = pthread_attr_destroy(&attributes);
if(status!=0){ if(status!=0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Posix Thread attribute destroy failed with: " << sif::error << "Posix Thread attribute destroy failed with: " <<
strerror(status) << std::endl; strerror(status) << std::endl;
#endif
} }
} }

View File

@ -39,14 +39,18 @@ ReturnValue_t TcUnixUdpPollingTask::performOperation(uint8_t opCode) {
reinterpret_cast<sockaddr*>(&senderAddress), &senderSockLen); reinterpret_cast<sockaddr*>(&senderAddress), &senderSockLen);
if(bytesReceived < 0) { if(bytesReceived < 0) {
// handle error // handle error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSocketPollingTask::performOperation: Reception" sif::error << "TcSocketPollingTask::performOperation: Reception"
"error." << std::endl; "error." << std::endl;
#endif
handleReadError(); handleReadError();
continue; continue;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived // sif::debug << "TcSocketPollingTask::performOperation: " << bytesReceived
// << " bytes received" << std::endl; // << " bytes received" << std::endl;
#endif
ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); ReturnValue_t result = handleSuccessfullTcRead(bytesReceived);
if(result != HasReturnvaluesIF::RETURN_FAILED) { if(result != HasReturnvaluesIF::RETURN_FAILED) {
@ -65,9 +69,11 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
receptionBuffer.data(), bytesRead); receptionBuffer.data(), bytesRead);
// arrayprinter::print(receptionBuffer.data(), bytesRead); // arrayprinter::print(receptionBuffer.data(), bytesRead);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data "
"storage failed" << std::endl; "storage failed" << std::endl;
sif::error << "Packet size: " << bytesRead << std::endl; sif::error << "Packet size: " << bytesRead << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -75,8 +81,10 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Serial Polling: Sending message to queue failed" sif::error << "Serial Polling: Sending message to queue failed"
<< std::endl; << std::endl;
#endif
tcStore->deleteData(storeId); tcStore->deleteData(storeId);
} }
return result; return result;
@ -85,15 +93,19 @@ ReturnValue_t TcUnixUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
ReturnValue_t TcUnixUdpPollingTask::initialize() { ReturnValue_t TcUnixUdpPollingTask::initialize() {
tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE); tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
if (tcStore == nullptr) { if (tcStore == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!"
<< std::endl; << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
tmtcBridge = objectManager->get<TmTcUnixUdpBridge>(tmtcBridgeId); tmtcBridge = objectManager->get<TmTcUnixUdpBridge>(tmtcBridgeId);
if(tmtcBridge == nullptr) { if(tmtcBridge == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid"
" TMTC bridge object!" << std::endl; " TMTC bridge object!" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
@ -115,8 +127,10 @@ void TcUnixUdpPollingTask::setTimeout(double timeoutSeconds) {
int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO,
&tval, sizeof(receptionTimeout)); &tval, sizeof(receptionTimeout));
if(result == -1) { if(result == -1) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting " sif::error << "TcSocketPollingTask::TcSocketPollingTask: Setting "
"receive timeout failed with " << strerror(errno) << std::endl; "receive timeout failed with " << strerror(errno) << std::endl;
#endif
} }
} }
@ -126,13 +140,17 @@ void TcUnixUdpPollingTask::handleReadError() {
case(EAGAIN): { case(EAGAIN): {
// todo: When working in timeout mode, this will occur more often // todo: When working in timeout mode, this will occur more often
// and is not an error. // and is not an error.
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcUnixUdpPollingTask::handleReadError: Timeout." sif::error << "TcUnixUdpPollingTask::handleReadError: Timeout."
<< std::endl; << std::endl;
#endif
break; break;
} }
default: { default: {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcUnixUdpPollingTask::handleReadError: " sif::error << "TcUnixUdpPollingTask::handleReadError: "
<< strerror(errno) << std::endl; << strerror(errno) << std::endl;
#endif
} }
} }
} }

View File

@ -10,8 +10,10 @@ Timer::Timer() {
sigEvent.sigev_value.sival_ptr = &timerId; sigEvent.sigev_value.sival_ptr = &timerId;
int status = timer_create(CLOCK_MONOTONIC, &sigEvent, &timerId); int status = timer_create(CLOCK_MONOTONIC, &sigEvent, &timerId);
if(status!=0){ if(status!=0){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Timer creation failed with: " << status << sif::error << "Timer creation failed with: " << status <<
" errno: " << errno << std::endl; " errno: " << errno << std::endl;
#endif
} }
} }

View File

@ -26,8 +26,10 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
//clientSocket = socket(AF_INET, SOCK_DGRAM, 0); //clientSocket = socket(AF_INET, SOCK_DGRAM, 0);
serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(serverSocket < 0) { if(serverSocket < 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open" sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not open"
" UDP socket!" << std::endl; " UDP socket!" << std::endl;
#endif
handleSocketError(); handleSocketError();
return; return;
} }
@ -51,9 +53,11 @@ TmTcUnixUdpBridge::TmTcUnixUdpBridge(object_id_t objectId,
reinterpret_cast<struct sockaddr*>(&serverAddress), reinterpret_cast<struct sockaddr*>(&serverAddress),
serverAddressLen); serverAddressLen);
if(result == -1) { if(result == -1) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind " sif::error << "TmTcUnixUdpBridge::TmTcUnixUdpBridge: Could not bind "
"local port " << setServerPort << " to server socket!" "local port " << setServerPort << " to server socket!"
<< std::endl; << std::endl;
#endif
handleBindError(); handleBindError();
return; return;
} }
@ -74,18 +78,24 @@ ReturnValue_t TmTcUnixUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
} }
// char ipAddress [15]; // char ipAddress [15];
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
// &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
#endif
ssize_t bytesSent = sendto(serverSocket, data, dataLen, flags, ssize_t bytesSent = sendto(serverSocket, data, dataLen, flags,
reinterpret_cast<sockaddr*>(&clientAddress), clientAddressLen); reinterpret_cast<sockaddr*>(&clientAddress), clientAddressLen);
if(bytesSent < 0) { if(bytesSent < 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixUdpBridge::sendTm: Send operation failed." sif::error << "TmTcUnixUdpBridge::sendTm: Send operation failed."
<< std::endl; << std::endl;
#endif
handleSendError(); handleSendError();
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" // sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were"
// " sent." << std::endl; // " sent." << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -93,10 +103,12 @@ void TmTcUnixUdpBridge::checkAndSetClientAddress(sockaddr_in& newAddress) {
MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10);
// char ipAddress [15]; // char ipAddress [15];
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
// &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
// sif::debug << "IP Address Old: " << inet_ntop(AF_INET, // sif::debug << "IP Address Old: " << inet_ntop(AF_INET,
// &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
#endif
// Set new IP address if it has changed. // Set new IP address if it has changed.
if(clientAddress.sin_addr.s_addr != newAddress.sin_addr.s_addr) { if(clientAddress.sin_addr.s_addr != newAddress.sin_addr.s_addr) {
@ -117,12 +129,16 @@ void TmTcUnixUdpBridge::handleSocketError() {
case(ENOBUFS): case(ENOBUFS):
case(ENOMEM): case(ENOMEM):
case(EPROTONOSUPPORT): case(EPROTONOSUPPORT):
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixBridge::handleSocketError: Socket creation failed" sif::error << "TmTcUnixBridge::handleSocketError: Socket creation failed"
<< " with " << strerror(errno) << std::endl; << " with " << strerror(errno) << std::endl;
#endif
break; break;
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixBridge::handleSocketError: Unknown error" sif::error << "TmTcUnixBridge::handleSocketError: Unknown error"
<< std::endl; << std::endl;
#endif
break; break;
} }
} }
@ -135,10 +151,12 @@ void TmTcUnixUdpBridge::handleBindError() {
Ephermeral ports can be shown with following command: Ephermeral ports can be shown with following command:
sysctl -A | grep ip_local_port_range sysctl -A | grep ip_local_port_range
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixBridge::handleBindError: Port access issue." sif::error << "TmTcUnixBridge::handleBindError: Port access issue."
"Ports 1-1024 are reserved on UNIX systems and require root " "Ports 1-1024 are reserved on UNIX systems and require root "
"rights while ephermeral ports should not be used as well." "rights while ephermeral ports should not be used as well."
<< std::endl; << std::endl;
#endif
} }
break; break;
case(EADDRINUSE): case(EADDRINUSE):
@ -153,13 +171,17 @@ void TmTcUnixUdpBridge::handleBindError() {
case(ENOMEM): case(ENOMEM):
case(ENOTDIR): case(ENOTDIR):
case(EROFS): { case(EROFS): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixBridge::handleBindError: Socket creation failed" sif::error << "TmTcUnixBridge::handleBindError: Socket creation failed"
<< " with " << strerror(errno) << std::endl; << " with " << strerror(errno) << std::endl;
#endif
break; break;
} }
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixBridge::handleBindError: Unknown error" sif::error << "TmTcUnixBridge::handleBindError: Unknown error"
<< std::endl; << std::endl;
#endif
break; break;
} }
} }
@ -167,8 +189,10 @@ void TmTcUnixUdpBridge::handleBindError() {
void TmTcUnixUdpBridge::handleSendError() { void TmTcUnixUdpBridge::handleSendError() {
switch(errno) { switch(errno) {
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcUnixBridge::handleSendError: " sif::error << "TmTcUnixBridge::handleSendError: "
<< strerror(errno) << std::endl; << strerror(errno) << std::endl;
#endif
} }
} }

18
osal/rtems/CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
target_sources(${LIB_FSFW_NAME}
PRIVATE
Clock.cpp
CpuUsage.cpp
InitTask.cpp
InternalErrorCodes.cpp
MessageQueue.cpp
MultiObjectTask.cpp
Mutex.cpp
MutexFactory.cpp
PollingTask.cpp
QueueFactory.cpp
RtemsBasic.cpp
TaskBase.cpp
TaskFactory.cpp
)

View File

@ -1,6 +1,10 @@
#include "../../timemanager/Clock.h"
#include "RtemsBasic.h" #include "RtemsBasic.h"
#include "../../timemanager/Clock.h"
#include "../../ipc/MutexHelper.h"
#include <rtems/score/todimpl.h> #include <rtems/score/todimpl.h>
#include <rtems/rtems/clockimpl.h>
uint16_t Clock::leapSeconds = 0; uint16_t Clock::leapSeconds = 0;
MutexIF* Clock::timeMutex = nullptr; MutexIF* Clock::timeMutex = nullptr;
@ -33,15 +37,24 @@ ReturnValue_t Clock::setClock(const TimeOfDay_t* time) {
} }
ReturnValue_t Clock::setClock(const timeval* time) { ReturnValue_t Clock::setClock(const timeval* time) {
//TODO This routine uses _TOD_Set which is not
timespec newTime; timespec newTime;
newTime.tv_sec = time->tv_sec; newTime.tv_sec = time->tv_sec;
if(time->tv_usec < 0) {
// better returnvalue.
return HasReturnvaluesIF::RETURN_FAILED;
}
newTime.tv_nsec = time->tv_usec * TOD_NANOSECONDS_PER_MICROSECOND; newTime.tv_nsec = time->tv_usec * TOD_NANOSECONDS_PER_MICROSECOND;
//SHOULDDO: Not sure if we need to protect this call somehow (by thread lock or something).
//Uli: rtems docu says you can call this from an ISR, not sure if this means no protetion needed ISR_lock_Context context;
//TODO Second parameter is ISR_lock_Context _TOD_Lock();
_TOD_Set(&newTime,nullptr); _TOD_Acquire(&context);
return HasReturnvaluesIF::RETURN_OK; Status_Control status = _TOD_Set(&newTime, &context);
_TOD_Unlock();
if(status == STATUS_SUCCESSFUL) {
return HasReturnvaluesIF::RETURN_OK;
}
// better returnvalue
return HasReturnvaluesIF::RETURN_FAILED;
} }
ReturnValue_t Clock::getClock_timeval(timeval* time) { ReturnValue_t Clock::getClock_timeval(timeval* time) {
@ -91,6 +104,7 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
} }
ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) { ReturnValue_t Clock::getDateAndTime(TimeOfDay_t* time) {
// TIsn't this a bug? Are RTEMS ticks always microseconds?
rtems_time_of_day* timeRtems = reinterpret_cast<rtems_time_of_day*>(time); rtems_time_of_day* timeRtems = reinterpret_cast<rtems_time_of_day*>(time);
rtems_status_code status = rtems_clock_get_tod(timeRtems); rtems_status_code status = rtems_clock_get_tod(timeRtems);
switch (status) { switch (status) {

View File

@ -34,8 +34,10 @@ ReturnValue_t InternalErrorCodes::translate(uint8_t code) {
return OUT_OF_PROXIES; return OUT_OF_PROXIES;
case INTERNAL_ERROR_INVALID_GLOBAL_ID: case INTERNAL_ERROR_INVALID_GLOBAL_ID:
return INVALID_GLOBAL_ID; return INVALID_GLOBAL_ID;
#ifndef STM32H743ZI_NUCLEO
case INTERNAL_ERROR_BAD_STACK_HOOK: case INTERNAL_ERROR_BAD_STACK_HOOK:
return BAD_STACK_HOOK; return BAD_STACK_HOOK;
#endif
// case INTERNAL_ERROR_BAD_ATTRIBUTES: // case INTERNAL_ERROR_BAD_ATTRIBUTES:
// return BAD_ATTRIBUTES; // return BAD_ATTRIBUTES;
// case INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY: // case INTERNAL_ERROR_IMPLEMENTATION_KEY_CREATE_INCONSISTENCY:

View File

@ -9,9 +9,11 @@ MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size) :
rtems_status_code status = rtems_message_queue_create(name, message_depth, rtems_status_code status = rtems_message_queue_create(name, message_depth,
max_message_size, 0, &(this->id)); max_message_size, 0, &(this->id));
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex sif::error << "MessageQueue::MessageQueue: Creating Queue " << std::hex
<< name << std::dec << " failed with status:" << name << std::dec << " failed with status:"
<< (uint32_t) status << std::endl; << (uint32_t) status << std::endl;
#endif
this->id = 0; this->id = 0;
} }
} }

View File

@ -30,8 +30,10 @@ ReturnValue_t MultiObjectTask::startTask() {
rtems_status_code status = rtems_task_start(id, MultiObjectTask::taskEntryPoint, rtems_status_code status = rtems_task_start(id, MultiObjectTask::taskEntryPoint,
rtems_task_argument((void *) this)); rtems_task_argument((void *) this));
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectTask::startTask for " << std::hex << this->getId() sif::error << "ObjectTask::startTask for " << std::hex << this->getId()
<< std::dec << " failed." << std::endl; << std::dec << " failed." << std::endl;
#endif
} }
switch(status){ switch(status){
case RTEMS_SUCCESSFUL: case RTEMS_SUCCESSFUL:
@ -63,7 +65,9 @@ void MultiObjectTask::taskFunctionality() {
char nameSpace[8] = { 0 }; char nameSpace[8] = { 0 };
char* ptr = rtems_object_get_name(getId(), sizeof(nameSpace), char* ptr = rtems_object_get_name(getId(), sizeof(nameSpace),
nameSpace); nameSpace);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ObjectTask: " << ptr << " Deadline missed." << std::endl; sif::error << "ObjectTask: " << ptr << " Deadline missed." << std::endl;
#endif
if (this->deadlineMissedFunc != nullptr) { if (this->deadlineMissedFunc != nullptr) {
this->deadlineMissedFunc(); this->deadlineMissedFunc();
} }

View File

@ -10,27 +10,31 @@ Mutex::Mutex() :
RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, 0, RTEMS_BINARY_SEMAPHORE | RTEMS_PRIORITY | RTEMS_INHERIT_PRIORITY, 0,
&mutexId); &mutexId);
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex: creation with name, id " << mutexName << ", " << mutexId sif::error << "Mutex: creation with name, id " << mutexName << ", " << mutexId
<< " failed with " << status << std::endl; << " failed with " << status << std::endl;
#endif
} }
} }
Mutex::~Mutex() { Mutex::~Mutex() {
rtems_status_code status = rtems_semaphore_delete(mutexId); rtems_status_code status = rtems_semaphore_delete(mutexId);
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Mutex: deletion for id " << mutexId sif::error << "Mutex: deletion for id " << mutexId
<< " failed with " << status << std::endl; << " failed with " << status << std::endl;
#endif
} }
} }
ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType = ReturnValue_t Mutex::lockMutex(TimeoutType timeoutType =
TimeoutType::BLOCKING, uint32_t timeoutMs) { TimeoutType::BLOCKING, uint32_t timeoutMs) {
rtems_status_code status = RTEMS_INVALID_ID; rtems_status_code status = RTEMS_INVALID_ID;
if(timeoutMs == MutexIF::TimeoutType::BLOCKING) { if(timeoutType == MutexIF::TimeoutType::BLOCKING) {
status = rtems_semaphore_obtain(mutexId, status = rtems_semaphore_obtain(mutexId,
RTEMS_WAIT, RTEMS_NO_TIMEOUT); RTEMS_WAIT, RTEMS_NO_TIMEOUT);
} }
else if(timeoutMs == MutexIF::TimeoutType::POLLING) { else if(timeoutType == MutexIF::TimeoutType::POLLING) {
timeoutMs = RTEMS_NO_TIMEOUT; timeoutMs = RTEMS_NO_TIMEOUT;
status = rtems_semaphore_obtain(mutexId, status = rtems_semaphore_obtain(mutexId,
RTEMS_NO_WAIT, 0); RTEMS_NO_WAIT, 0);

View File

@ -35,15 +35,19 @@ rtems_task PollingTask::taskEntryPoint(rtems_task_argument argument) {
PollingTask *originalTask(reinterpret_cast<PollingTask*>(argument)); PollingTask *originalTask(reinterpret_cast<PollingTask*>(argument));
//The task's functionality is called. //The task's functionality is called.
originalTask->taskFunctionality(); originalTask->taskFunctionality();
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Polling task " << originalTask->getId() sif::debug << "Polling task " << originalTask->getId()
<< " returned from taskFunctionality." << std::endl; << " returned from taskFunctionality." << std::endl;
#endif
} }
void PollingTask::missedDeadlineCounter() { void PollingTask::missedDeadlineCounter() {
PollingTask::deadlineMissedCount++; PollingTask::deadlineMissedCount++;
if (PollingTask::deadlineMissedCount % 10 == 0) { if (PollingTask::deadlineMissedCount % 10 == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PST missed " << PollingTask::deadlineMissedCount sif::error << "PST missed " << PollingTask::deadlineMissedCount
<< " deadlines." << std::endl; << " deadlines." << std::endl;
#endif
} }
} }
@ -51,8 +55,10 @@ ReturnValue_t PollingTask::startTask() {
rtems_status_code status = rtems_task_start(id, PollingTask::taskEntryPoint, rtems_status_code status = rtems_task_start(id, PollingTask::taskEntryPoint,
rtems_task_argument((void *) this)); rtems_task_argument((void *) this));
if (status != RTEMS_SUCCESSFUL) { if (status != RTEMS_SUCCESSFUL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PollingTask::startTask for " << std::hex << this->getId() sif::error << "PollingTask::startTask for " << std::hex << this->getId()
<< std::dec << " failed." << std::endl; << std::dec << " failed." << std::endl;
#endif
} }
switch(status){ switch(status){
case RTEMS_SUCCESSFUL: case RTEMS_SUCCESSFUL:
@ -75,8 +81,10 @@ ReturnValue_t PollingTask::addSlot(object_id_t componentId,
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Component " << std::hex << componentId << sif::error << "Component " << std::hex << componentId <<
" not found, not adding it to pst" << std::endl; " not found, not adding it to pst" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }

View File

@ -22,9 +22,11 @@ TaskBase::TaskBase(rtems_task_priority set_priority, size_t stack_size,
} }
ReturnValue_t result = convertReturnCode(status); ReturnValue_t result = convertReturnCode(status);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TaskBase::TaskBase: createTask with name " << std::hex sif::error << "TaskBase::TaskBase: createTask with name " << std::hex
<< osalName << std::dec << " failed with return code " << osalName << std::dec << " failed with return code "
<< (uint32_t) status << std::endl; << (uint32_t) status << std::endl;
#endif
this->id = 0; this->id = 0;
} }
} }

View File

@ -43,13 +43,17 @@ ReturnValue_t TcWinUdpPollingTask::performOperation(uint8_t opCode) {
&senderAddressSize); &senderAddressSize);
if(bytesReceived == SOCKET_ERROR) { if(bytesReceived == SOCKET_ERROR) {
// handle error // handle error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcWinUdpPollingTask::performOperation: Reception" sif::error << "TcWinUdpPollingTask::performOperation: Reception"
" error." << std::endl; " error." << std::endl;
#endif
handleReadError(); handleReadError();
continue; continue;
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
//sif::debug << "TcWinUdpPollingTask::performOperation: " << bytesReceived //sif::debug << "TcWinUdpPollingTask::performOperation: " << bytesReceived
// << " bytes received" << std::endl; // << " bytes received" << std::endl;
#endif
ReturnValue_t result = handleSuccessfullTcRead(bytesReceived); ReturnValue_t result = handleSuccessfullTcRead(bytesReceived);
if(result != HasReturnvaluesIF::RETURN_FAILED) { if(result != HasReturnvaluesIF::RETURN_FAILED) {
@ -68,9 +72,11 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
receptionBuffer.data(), bytesRead); receptionBuffer.data(), bytesRead);
// arrayprinter::print(receptionBuffer.data(), bytesRead); // arrayprinter::print(receptionBuffer.data(), bytesRead);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data " sif::error << "TcSerialPollingTask::transferPusToSoftwareBus: Data "
"storage failed" << std::endl; "storage failed" << std::endl;
sif::error << "Packet size: " << bytesRead << std::endl; sif::error << "Packet size: " << bytesRead << std::endl;
#endif
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }
@ -78,8 +84,10 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message); result = MessageQueueSenderIF::sendMessage(targetTcDestination, &message);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Serial Polling: Sending message to queue failed" sif::error << "Serial Polling: Sending message to queue failed"
<< std::endl; << std::endl;
#endif
tcStore->deleteData(storeId); tcStore->deleteData(storeId);
} }
return result; return result;
@ -88,21 +96,27 @@ ReturnValue_t TcWinUdpPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
ReturnValue_t TcWinUdpPollingTask::initialize() { ReturnValue_t TcWinUdpPollingTask::initialize() {
tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE); tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
if (tcStore == nullptr) { if (tcStore == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!" sif::error << "TcSerialPollingTask::initialize: TC Store uninitialized!"
<< std::endl; << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
tmtcBridge = objectManager->get<TmTcWinUdpBridge>(tmtcBridgeId); tmtcBridge = objectManager->get<TmTcWinUdpBridge>(tmtcBridgeId);
if(tmtcBridge == nullptr) { if(tmtcBridge == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid" sif::error << "TcSocketPollingTask::TcSocketPollingTask: Invalid"
" TMTC bridge object!" << std::endl; " TMTC bridge object!" << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
serverUdpSocket = tmtcBridge->serverSocket; serverUdpSocket = tmtcBridge->serverSocket;
#if FSFW_CPP_OSTREAM_ENABLED == 1
//sif::info << "TcWinUdpPollingTask::initialize: Server UDP socket " //sif::info << "TcWinUdpPollingTask::initialize: Server UDP socket "
// << serverUdpSocket << std::endl; // << serverUdpSocket << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -119,8 +133,10 @@ void TcWinUdpPollingTask::setTimeout(double timeoutSeconds) {
int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO, int result = setsockopt(serverUdpSocket, SOL_SOCKET, SO_RCVTIMEO,
reinterpret_cast<const char*>(&timeoutMs), sizeof(DWORD)); reinterpret_cast<const char*>(&timeoutMs), sizeof(DWORD));
if(result == -1) { if(result == -1) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TcWinUdpPollingTask::TcSocketPollingTask: Setting " sif::error << "TcWinUdpPollingTask::TcSocketPollingTask: Setting "
"receive timeout failed with " << strerror(errno) << std::endl; "receive timeout failed with " << strerror(errno) << std::endl;
#endif
} }
} }
@ -128,23 +144,31 @@ void TcWinUdpPollingTask::handleReadError() {
int error = WSAGetLastError(); int error = WSAGetLastError();
switch(error) { switch(error) {
case(WSANOTINITIALISED): { case(WSANOTINITIALISED): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TcWinUdpPollingTask::handleReadError: WSANOTINITIALISED: " sif::info << "TcWinUdpPollingTask::handleReadError: WSANOTINITIALISED: "
<< "WSAStartup(...) call " << "necessary" << std::endl; << "WSAStartup(...) call " << "necessary" << std::endl;
#endif
break; break;
} }
case(WSAEFAULT): { case(WSAEFAULT): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TcWinUdpPollingTask::handleReadError: WSADEFAULT: " sif::info << "TcWinUdpPollingTask::handleReadError: WSADEFAULT: "
<< "Bad address " << std::endl; << "Bad address " << std::endl;
#endif
break; break;
} }
case(WSAEINVAL): { case(WSAEINVAL): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TcWinUdpPollingTask::handleReadError: WSAEINVAL: " sif::info << "TcWinUdpPollingTask::handleReadError: WSAEINVAL: "
<< "Invalid input parameters. " << std::endl; << "Invalid input parameters. " << std::endl;
#endif
break; break;
} }
default: { default: {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TcWinUdpPollingTask::handleReadError: Error code: " sif::info << "TcWinUdpPollingTask::handleReadError: Error code: "
<< error << std::endl; << error << std::endl;
#endif
break; break;
} }
} }

View File

@ -15,8 +15,10 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId,
if (err != 0) { if (err != 0) {
/* Tell the user that we could not find a usable */ /* Tell the user that we could not find a usable */
/* Winsock DLL. */ /* Winsock DLL. */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge:" sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge:"
"WSAStartup failed with error: " << err << std::endl; "WSAStartup failed with error: " << err << std::endl;
#endif
return; return;
} }
@ -34,8 +36,10 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId,
//clientSocket = socket(AF_INET, SOCK_DGRAM, 0); //clientSocket = socket(AF_INET, SOCK_DGRAM, 0);
serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); serverSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(serverSocket == INVALID_SOCKET) { if(serverSocket == INVALID_SOCKET) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not open" sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not open"
" UDP socket!" << std::endl; " UDP socket!" << std::endl;
#endif
handleSocketError(); handleSocketError();
return; return;
} }
@ -59,9 +63,11 @@ TmTcWinUdpBridge::TmTcWinUdpBridge(object_id_t objectId,
reinterpret_cast<struct sockaddr*>(&serverAddress), reinterpret_cast<struct sockaddr*>(&serverAddress),
serverAddressLen); serverAddressLen);
if(result != 0) { if(result != 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not bind " sif::error << "TmTcWinUdpBridge::TmTcWinUdpBridge: Could not bind "
"local port " << setServerPort << " to server socket!" "local port " << setServerPort << " to server socket!"
<< std::endl; << std::endl;
#endif
handleBindError(); handleBindError();
} }
} }
@ -77,19 +83,25 @@ ReturnValue_t TmTcWinUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
//clientAddressLen = sizeof(serverAddress); //clientAddressLen = sizeof(serverAddress);
// char ipAddress [15]; // char ipAddress [15];
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
// &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
#endif
ssize_t bytesSent = sendto(serverSocket, ssize_t bytesSent = sendto(serverSocket,
reinterpret_cast<const char*>(data), dataLen, flags, reinterpret_cast<const char*>(data), dataLen, flags,
reinterpret_cast<sockaddr*>(&clientAddress), clientAddressLen); reinterpret_cast<sockaddr*>(&clientAddress), clientAddressLen);
if(bytesSent == SOCKET_ERROR) { if(bytesSent == SOCKET_ERROR) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmTcWinUdpBridge::sendTm: Send operation failed." sif::error << "TmTcWinUdpBridge::sendTm: Send operation failed."
<< std::endl; << std::endl;
#endif
handleSendError(); handleSendError();
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were" // sif::debug << "TmTcUnixUdpBridge::sendTm: " << bytesSent << " bytes were"
// " sent." << std::endl; // " sent." << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -97,10 +109,12 @@ void TmTcWinUdpBridge::checkAndSetClientAddress(sockaddr_in newAddress) {
MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10); MutexHelper lock(mutex, MutexIF::TimeoutType::WAITING, 10);
// char ipAddress [15]; // char ipAddress [15];
#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET, // sif::debug << "IP Address Sender: "<< inet_ntop(AF_INET,
// &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // &newAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
// sif::debug << "IP Address Old: " << inet_ntop(AF_INET, // sif::debug << "IP Address Old: " << inet_ntop(AF_INET,
// &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl; // &clientAddress.sin_addr.s_addr, ipAddress, 15) << std::endl;
#endif
registerCommConnect(); registerCommConnect();
// Set new IP address if it has changed. // Set new IP address if it has changed.
@ -114,8 +128,10 @@ void TmTcWinUdpBridge::handleSocketError() {
int errCode = WSAGetLastError(); int errCode = WSAGetLastError();
switch(errCode) { switch(errCode) {
case(WSANOTINITIALISED): { case(WSANOTINITIALISED): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: " sif::info << "TmTcWinUdpBridge::handleSocketError: WSANOTINITIALISED: "
<< "WSAStartup(...) call necessary" << std::endl; << "WSAStartup(...) call necessary" << std::endl;
#endif
break; break;
} }
default: { default: {
@ -123,8 +139,10 @@ void TmTcWinUdpBridge::handleSocketError() {
https://docs.microsoft.com/en-us/windows/win32/winsock/ https://docs.microsoft.com/en-us/windows/win32/winsock/
windows-sockets-error-codes-2 windows-sockets-error-codes-2
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcWinUdpBridge::handleSocketError: Error code: " sif::info << "TmTcWinUdpBridge::handleSocketError: Error code: "
<< errCode << std::endl; << errCode << std::endl;
#endif
break; break;
} }
} }
@ -134,13 +152,17 @@ void TmTcWinUdpBridge::handleBindError() {
int errCode = WSAGetLastError(); int errCode = WSAGetLastError();
switch(errCode) { switch(errCode) {
case(WSANOTINITIALISED): { case(WSANOTINITIALISED): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcWinUdpBridge::handleBindError: WSANOTINITIALISED: " sif::info << "TmTcWinUdpBridge::handleBindError: WSANOTINITIALISED: "
<< "WSAStartup(...) call " << "necessary" << std::endl; << "WSAStartup(...) call " << "necessary" << std::endl;
#endif
break; break;
} }
case(WSAEADDRINUSE): { case(WSAEADDRINUSE): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TmTcWinUdpBridge::handleBindError: WSAEADDRINUSE: " sif::warning << "TmTcWinUdpBridge::handleBindError: WSAEADDRINUSE: "
<< "Port is already in use!" << std::endl; << "Port is already in use!" << std::endl;
#endif
break; break;
} }
default: { default: {
@ -148,8 +170,10 @@ void TmTcWinUdpBridge::handleBindError() {
https://docs.microsoft.com/en-us/windows/win32/winsock/ https://docs.microsoft.com/en-us/windows/win32/winsock/
windows-sockets-error-codes-2 windows-sockets-error-codes-2
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcWinUdpBridge::handleBindError: Error code: " sif::info << "TmTcWinUdpBridge::handleBindError: Error code: "
<< errCode << std::endl; << errCode << std::endl;
#endif
break; break;
} }
} }
@ -159,13 +183,17 @@ void TmTcWinUdpBridge::handleSendError() {
int errCode = WSAGetLastError(); int errCode = WSAGetLastError();
switch(errCode) { switch(errCode) {
case(WSANOTINITIALISED): { case(WSANOTINITIALISED): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: " sif::info << "TmTcWinUdpBridge::handleSendError: WSANOTINITIALISED: "
<< "WSAStartup(...) call necessary" << std::endl; << "WSAStartup(...) call necessary" << std::endl;
#endif
break; break;
} }
case(WSAEADDRNOTAVAIL): { case(WSAEADDRNOTAVAIL): {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcWinUdpBridge::handleSendError: WSAEADDRNOTAVAIL: " sif::info << "TmTcWinUdpBridge::handleSendError: WSAEADDRNOTAVAIL: "
<< "Check target address. " << std::endl; << "Check target address. " << std::endl;
#endif
break; break;
} }
default: { default: {
@ -173,8 +201,10 @@ void TmTcWinUdpBridge::handleSendError() {
https://docs.microsoft.com/en-us/windows/win32/winsock/ https://docs.microsoft.com/en-us/windows/win32/winsock/
windows-sockets-error-codes-2 windows-sockets-error-codes-2
*/ */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcWinUdpBridge::handleSendError: Error code: " sif::info << "TmTcWinUdpBridge::handleSendError: Error code: "
<< errCode << std::endl; << errCode << std::endl;
#endif
break; break;
} }
} }

View File

@ -48,8 +48,10 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage *message) {
ConstStorageAccessor accessor(storeId); ConstStorageAccessor accessor(storeId);
result = storage->getData(storeId, accessor); result = storage->getData(storeId, accessor);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "ParameterHelper::handleParameterMessage: Getting" sif::error << "ParameterHelper::handleParameterMessage: Getting"
<< " store data failed for load command." << std::endl; << " store data failed for load command." << std::endl;
#endif
break; break;
} }

View File

@ -65,8 +65,8 @@ ReturnValue_t Fuse::check() {
set.read(); set.read();
if (!healthHelper.healthTable->isHealthy(getObjectId())) { if (!healthHelper.healthTable->isHealthy(getObjectId())) {
setAllMonitorsToUnchecked(); setAllMonitorsToUnchecked();
set.commit(PoolVariableIF::INVALID); set.setValidity(false, true);
return RETURN_OK; return set.commit();
} }
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
checkFuseState(); checkFuseState();
@ -206,7 +206,8 @@ float Fuse::getPower() {
void Fuse::setDataPoolEntriesInvalid() { void Fuse::setDataPoolEntriesInvalid() {
set.read(); set.read();
set.commit(PoolVariableIF::INVALID); set.setValidity(false, true);
set.commit();
} }
ReturnValue_t Fuse::getParameter(uint8_t domainId, uint16_t parameterId, ReturnValue_t Fuse::getParameter(uint8_t domainId, uint16_t parameterId,

View File

@ -97,7 +97,8 @@ void PowerSensor::checkCommandQueue() {
void PowerSensor::setDataPoolEntriesInvalid() { void PowerSensor::setDataPoolEntriesInvalid() {
powerSensorSet.read(); powerSensorSet.read();
powerSensorSet.commit(PoolVariableIF::INVALID); powerSensorSet.setValidity(false, true);
powerSensorSet.commit();
} }
float PowerSensor::getPower() { float PowerSensor::getPower() {

View File

@ -22,7 +22,9 @@ ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice)
case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL): case(Subservice::COMMAND_ANNOUNCE_HEALTH_ALL):
return RETURN_OK; return RETURN_OK;
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Invalid Subservice" << std::endl; sif::error << "Invalid Subservice" << std::endl;
#endif
return AcceptsTelecommandsIF::INVALID_SUBSERVICE; return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
} }
} }

View File

@ -51,8 +51,10 @@ ReturnValue_t Service1TelecommandVerification::sendVerificationReport(
result = generateSuccessReport(message); result = generateSuccessReport(message);
} }
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service1TelecommandVerification::sendVerificationReport: " sif::error << "Service1TelecommandVerification::sendVerificationReport: "
"Sending verification packet failed !" << std::endl; "Sending verification packet failed !" << std::endl;
#endif
} }
return result; return result;
} }
@ -88,9 +90,11 @@ ReturnValue_t Service1TelecommandVerification::initialize() {
AcceptsTelemetryIF* funnel = objectManager-> AcceptsTelemetryIF* funnel = objectManager->
get<AcceptsTelemetryIF>(targetDestination); get<AcceptsTelemetryIF>(targetDestination);
if(funnel == nullptr){ if(funnel == nullptr){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service1TelecommandVerification::initialize: Specified" sif::error << "Service1TelecommandVerification::initialize: Specified"
" TM funnel invalid. Make sure it is set up and implements" " TM funnel invalid. Make sure it is set up and implements"
" AcceptsTelemetryIF." << std::endl; " AcceptsTelemetryIF." << std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
tmQueue->setDefaultDestination(funnel->getReportReceptionQueue()); tmQueue->setDefaultDestination(funnel->getReportReceptionQueue());

View File

@ -25,7 +25,9 @@ ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) {
case Subservice::COMMAND_TOGGLE_WIRETAPPING: case Subservice::COMMAND_TOGGLE_WIRETAPPING:
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Invalid Subservice" << std::endl; sif::error << "Invalid Subservice" << std::endl;
#endif
return AcceptsTelecommandsIF::INVALID_SUBSERVICE; return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
} }
} }
@ -125,9 +127,11 @@ void Service2DeviceAccess::handleUnrequestedReply(CommandMessage* reply) {
static_cast<uint8_t>(Subservice::REPLY_RAW)); static_cast<uint8_t>(Subservice::REPLY_RAW));
break; break;
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Unknown message in Service2DeviceAccess::" sif::error << "Unknown message in Service2DeviceAccess::"
"handleUnrequestedReply with command ID " << "handleUnrequestedReply with command ID " <<
reply->getCommand() << std::endl; reply->getCommand() << std::endl;
#endif
break; break;
} }
//Must be reached by all cases to clear message //Must be reached by all cases to clear message
@ -143,9 +147,11 @@ void Service2DeviceAccess::sendWiretappingTm(CommandMessage *reply,
size_t size = 0; size_t size = 0;
ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size); ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size);
if(result != HasReturnvaluesIF::RETURN_OK){ if(result != HasReturnvaluesIF::RETURN_OK){
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in " sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in "
"handleUnrequestedReply with failure ID "<< result "handleUnrequestedReply with failure ID "<< result
<< std::endl; << std::endl;
#endif
return; return;
} }

View File

@ -222,8 +222,10 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
} }
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service3Housekeeping::handleReply: Invalid reply with " sif::error << "Service3Housekeeping::handleReply: Invalid reply with "
<< "reply command " << command << "!" << std::endl; << "reply command " << command << "!" << std::endl;
#endif
return CommandingServiceBase::INVALID_REPLY; return CommandingServiceBase::INVALID_REPLY;
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
@ -249,16 +251,20 @@ void Service3Housekeeping::handleUnrequestedReply(
} }
default: default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service3Housekeeping::handleUnrequestedReply: Invalid " sif::error << "Service3Housekeeping::handleUnrequestedReply: Invalid "
<< "reply with " << "reply command " << command << "!" << "reply with " << "reply command " << command << "!"
<< std::endl; << std::endl;
#endif
return; return;
} }
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
// Configuration error // Configuration error
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Service3Housekeeping::handleUnrequestedReply:" sif::debug << "Service3Housekeeping::handleUnrequestedReply:"
<< "Could not generate reply!" << std::endl; << "Could not generate reply!" << std::endl;
#endif
} }
} }

View File

@ -37,8 +37,10 @@ ReturnValue_t Service5EventReporting::performService() {
} }
} }
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Service5EventReporting::generateEventReport:" sif::debug << "Service5EventReporting::generateEventReport:"
" Too many events" << std::endl; " Too many events" << std::endl;
#endif
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
@ -53,8 +55,10 @@ ReturnValue_t Service5EventReporting::generateEventReport(
ReturnValue_t result = tmPacket.sendPacket( ReturnValue_t result = tmPacket.sendPacket(
requestQueue->getDefaultDestination(),requestQueue->getId()); requestQueue->getDefaultDestination(),requestQueue->getId());
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Service5EventReporting::generateEventReport:" sif::debug << "Service5EventReporting::generateEventReport:"
" Could not send TM packet" << std::endl; " Could not send TM packet" << std::endl;
#endif
} }
return result; return result;
} }

View File

@ -60,9 +60,11 @@ ReturnValue_t Service8FunctionManagement::prepareCommand(
ReturnValue_t Service8FunctionManagement::prepareDirectCommand( ReturnValue_t Service8FunctionManagement::prepareDirectCommand(
CommandMessage *message, const uint8_t *tcData, size_t tcDataLen) { CommandMessage *message, const uint8_t *tcData, size_t tcDataLen) {
if(tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) { if(tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Service8FunctionManagement::prepareDirectCommand:" sif::debug << "Service8FunctionManagement::prepareDirectCommand:"
<< " TC size smaller thant minimum size of direct command." << " TC size smaller thant minimum size of direct command."
<< std::endl; << std::endl;
#endif
return CommandingServiceBase::INVALID_TC; return CommandingServiceBase::INVALID_TC;
} }
@ -125,8 +127,10 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(
const uint8_t * buffer = nullptr; const uint8_t * buffer = nullptr;
ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size); ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size);
if(result != RETURN_OK) { if(result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "Service 8: Could not retrieve data for data reply" sif::error << "Service 8: Could not retrieve data for data reply"
<< std::endl; << std::endl;
#endif
return result; return result;
} }
DataReply dataReply(objectId, actionId, buffer, size); DataReply dataReply(objectId, actionId, buffer, size);
@ -135,8 +139,10 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(
auto deletionResult = IPCStore->deleteData(storeId); auto deletionResult = IPCStore->deleteData(storeId);
if(deletionResult != HasReturnvaluesIF::RETURN_OK) { if(deletionResult != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "Service8FunctionManagement::handleReply: Deletion" sif::warning << "Service8FunctionManagement::handleReply: Deletion"
<< " of data in pool failed." << std::endl; << " of data in pool failed." << std::endl;
#endif
} }
return result; return result;
} }

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