diff --git a/CHANGELOG b/CHANGELOG index 298ef0d4..fc46ee02 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -81,4 +81,7 @@ now 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. -- \ No newline at end of file + +### PUS Parameter Service 20 + +Added PUS parameter service 20 (only custom subservices available). \ No newline at end of file diff --git a/action/ActionHelper.cpp b/action/ActionHelper.cpp index 23c9d732..e32be68b 100644 --- a/action/ActionHelper.cpp +++ b/action/ActionHelper.cpp @@ -3,6 +3,7 @@ #include "../ipc/MessageQueueSenderIF.h" #include "../objectmanager/ObjectManagerIF.h" +#include "../serviceinterface/ServiceInterface.h" ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue) : @@ -86,13 +87,20 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, uint8_t *dataPtr; size_t maxSize = data->getSerializedSize(); if (maxSize == 0) { - //No error, there's simply nothing to report. + /* No error, there's simply nothing to report. */ return HasReturnvaluesIF::RETURN_OK; } size_t size = 0; ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr); if (result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!" << + std::endl; +#else + sif::printWarning("ActionHelper::reportData: Getting free element from IPC " + "store failed!\n"); +#endif return result; } result = data->serialize(&dataPtr, &size, maxSize, @@ -101,14 +109,13 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ipcStore->deleteData(storeAddress); return result; } - // We don't need to report the objectId, as we receive REQUESTED data - // before the completion success message. - // True aperiodic replies need to be reported with - // another dedicated message. + + /* We don't need to report the objectId, as we receive REQUESTED data before the completion + success message. True aperiodic replies need to be reported with another dedicated message. */ ActionMessage::setDataReply(&reply, replyId, storeAddress); - // If the sender needs to be hidden, for example to handle packet - // as unrequested reply, this will be done here. + /* If the sender needs to be hidden, for example to handle packet + as unrequested reply, this will be done here. */ if (hideSender) { result = MessageQueueSenderIF::sendMessage(reportTo, &reply); } @@ -132,6 +139,11 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, store_address_t storeAddress; ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize); if (result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl; +#else + sif::printWarning("ActionHelper::reportData: Adding data to IPC store failed!\n"); +#endif return result; } @@ -140,14 +152,12 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, return result; } - // We don't need to report the objectId, as we receive REQUESTED data - // before the completion success message. - // True aperiodic replies need to be reported with - // another dedicated message. + /* We don't need to report the objectId, as we receive REQUESTED data before the completion + success message. True aperiodic replies need to be reported with another dedicated message. */ ActionMessage::setDataReply(&reply, replyId, storeAddress); - // If the sender needs to be hidden, for example to handle packet - // as unrequested reply, this will be done here. + /* If the sender needs to be hidden, for example to handle packet + as unrequested reply, this will be done here. */ if (hideSender) { result = MessageQueueSenderIF::sendMessage(reportTo, &reply); } diff --git a/action/ActionHelper.h b/action/ActionHelper.h index ae971d38..35ac41d1 100644 --- a/action/ActionHelper.h +++ b/action/ActionHelper.h @@ -101,7 +101,8 @@ public: protected: //! Increase of value of this per step static const uint8_t STEP_OFFSET = 1; - HasActionsIF* owner;//!< Pointer to the owner + //! Pointer to the owner + HasActionsIF* owner; //! Queue to be used as response sender, has to be set in ctor or with //! setQueueToUse MessageQueueIF* queueToUse; diff --git a/action/CMakeLists.txt b/action/CMakeLists.txt index a62d4044..f9ac451d 100644 --- a/action/CMakeLists.txt +++ b/action/CMakeLists.txt @@ -1,7 +1,7 @@ target_sources(${LIB_FSFW_NAME} - PRIVATE - ActionHelper.cpp - ActionMessage.cpp - CommandActionHelper.cpp - SimpleActionHelper.cpp + PRIVATE + ActionHelper.cpp + ActionMessage.cpp + CommandActionHelper.cpp + SimpleActionHelper.cpp ) \ No newline at end of file diff --git a/container/CMakeLists.txt b/container/CMakeLists.txt index 904cde55..13eced1d 100644 --- a/container/CMakeLists.txt +++ b/container/CMakeLists.txt @@ -1,5 +1,5 @@ target_sources(${LIB_FSFW_NAME} - PRIVATE - SharedRingBuffer.cpp - SimpleRingBuffer.cpp + PRIVATE + SharedRingBuffer.cpp + SimpleRingBuffer.cpp ) \ No newline at end of file diff --git a/datapool/PoolDataSetBase.cpp b/datapool/PoolDataSetBase.cpp index 7d50a40a..2fd51966 100644 --- a/datapool/PoolDataSetBase.cpp +++ b/datapool/PoolDataSetBase.cpp @@ -229,20 +229,3 @@ void PoolDataSetBase::setReadCommitProtectionBehaviour( this->timeoutTypeForSingleVars = timeoutType; this->mutexTimeoutForSingleVars = mutexTimeout; } - -/* We really should supply the container as a template argument instead of writing sth like this */ -//PoolDataSetBase::PoolDataSetBase(const PoolDataSetBase &otherSet): -// fillCount(otherSet.fillCount), state(otherSet.state), -// maxFillCount(otherSet.maxFillCount), -// protectEveryReadCommitCall(otherSet.protectEveryReadCommitCall), -// timeoutTypeForSingleVars(otherSet.timeoutTypeForSingleVars), -// mutexTimeoutForSingleVars(otherSet.mutexTimeoutForSingleVars) { -// if(registeredVariables != nullptr and otherSet.registeredVariables != nullptr) { -// std::memcpy(reinterpret_cast(*(this->registeredVariables)), -// reinterpret_cast(*(otherSet.registeredVariables)), -// fillCount * sizeof(PoolVariableIF*)); -// } -//} -// -//const PoolDataSetBase& PoolDataSetBase::operator=(const PoolDataSetBase &otherSet) { -//} diff --git a/datapoollocal/LocalPoolObjectBase.h b/datapoollocal/LocalPoolObjectBase.h index 797cf8b5..3f7fb6dd 100644 --- a/datapoollocal/LocalPoolObjectBase.h +++ b/datapoollocal/LocalPoolObjectBase.h @@ -20,12 +20,10 @@ class LocalPoolObjectBase: public PoolVariableIF, public HasReturnvaluesIF, public MarkChangedIF { public: - LocalPoolObjectBase(lp_id_t poolId, - HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, + LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner, DataSetIF* dataSet, pool_rwm_t setReadWriteMode); - LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, - DataSetIF* dataSet = nullptr, + LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId, DataSetIF* dataSet = nullptr, pool_rwm_t setReadWriteMode = pool_rwm_t::VAR_READ_WRITE); void setReadWriteMode(pool_rwm_t newReadWriteMode); diff --git a/osal/FreeRTOS/TaskFactory.cpp b/osal/FreeRTOS/TaskFactory.cpp index 3ac5cb49..5b64811a 100644 --- a/osal/FreeRTOS/TaskFactory.cpp +++ b/osal/FreeRTOS/TaskFactory.cpp @@ -49,5 +49,11 @@ ReturnValue_t TaskFactory::delayTask(uint32_t delayMs) { return HasReturnvaluesIF::RETURN_OK; } +void TaskFactory::printMissedDeadline() { + /* TODO: Implement */ + return; +} + + TaskFactory::TaskFactory() { } diff --git a/osal/host/TaskFactory.cpp b/osal/host/TaskFactory.cpp index bc65504c..4fafd349 100644 --- a/osal/host/TaskFactory.cpp +++ b/osal/host/TaskFactory.cpp @@ -48,4 +48,9 @@ ReturnValue_t TaskFactory::delayTask(uint32_t delayMs){ return HasReturnvaluesIF::RETURN_OK; } +void TaskFactory::printMissedDeadline() { + /* TODO: Implement */ + return; +} + diff --git a/osal/linux/PeriodicPosixTask.cpp b/osal/linux/PeriodicPosixTask.cpp index a8f2de60..630dd8e0 100644 --- a/osal/linux/PeriodicPosixTask.cpp +++ b/osal/linux/PeriodicPosixTask.cpp @@ -68,20 +68,6 @@ void PeriodicPosixTask::taskFunctionality(void) { } if(not PosixThread::delayUntil(&lastWakeTime, periodMs)){ - char name[20] = {0}; - int status = pthread_getname_np(pthread_self(), name, sizeof(name)); - if(status == 0) { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PeriodicPosixTask " << name << ": Deadline " - "missed." << std::endl; -#endif - } - else { -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PeriodicPosixTask X: Deadline missed. " << - status << std::endl; -#endif - } if (this->deadlineMissedFunc != nullptr) { this->deadlineMissedFunc(); } diff --git a/osal/linux/TaskFactory.cpp b/osal/linux/TaskFactory.cpp index d18a0316..93564647 100644 --- a/osal/linux/TaskFactory.cpp +++ b/osal/linux/TaskFactory.cpp @@ -39,5 +39,26 @@ ReturnValue_t TaskFactory::delayTask(uint32_t delayMs){ return PosixThread::sleep(delayMs*1000000ull); } +void TaskFactory::printMissedDeadline() { + char name[20] = {0}; + int status = pthread_getname_np(pthread_self(), name, sizeof(name)); +#if FSFW_CPP_OSTREAM_ENABLED == 1 + if(status == 0) { + sif::warning << "task::printMissedDeadline: " << name << "" << std::endl; + } + else { + sif::warning << "task::printMissedDeadline: Unknown task name" << status << + std::endl; + } +#else + if(status == 0) { + sif::printWarning("task::printMissedDeadline: %s\n", name); + } + else { + sif::printWarning("task::printMissedDeadline: Unknown task name\n", name); + } +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +} + TaskFactory::TaskFactory() { } diff --git a/osal/rtems/TaskFactory.cpp b/osal/rtems/TaskFactory.cpp index 5dad69fe..095e9a26 100644 --- a/osal/rtems/TaskFactory.cpp +++ b/osal/rtems/TaskFactory.cpp @@ -44,5 +44,10 @@ ReturnValue_t TaskFactory::delayTask(uint32_t delayMs){ return HasReturnvaluesIF::RETURN_OK; } +void TaskFactory::printMissedDeadline() { + /* TODO: Implement */ + return; +} + TaskFactory::TaskFactory() { } diff --git a/tasks/TaskFactory.h b/tasks/TaskFactory.h index 85cdda90..03b5163c 100644 --- a/tasks/TaskFactory.h +++ b/tasks/TaskFactory.h @@ -62,6 +62,12 @@ public: */ static ReturnValue_t delayTask(uint32_t delayMs); + /** + * OS specific implementation to print deadline. In most cases, there is a OS specific + * way to retrieve the task name and print it out as well. + */ + static void printMissedDeadline(); + private: /** * External instantiation is not allowed. diff --git a/tmtcservices/CommandingServiceBase.cpp b/tmtcservices/CommandingServiceBase.cpp index 259f2ccb..8b6f7a09 100644 --- a/tmtcservices/CommandingServiceBase.cpp +++ b/tmtcservices/CommandingServiceBase.cpp @@ -7,6 +7,7 @@ #include "../ipc/QueueFactory.h" #include "../tmtcpacket/pus/TcPacketStored.h" #include "../tmtcpacket/pus/TmPacketStored.h" +#include "../serviceinterface/ServiceInterface.h" object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT; object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT; @@ -104,9 +105,27 @@ ReturnValue_t CommandingServiceBase::initialize() { void CommandingServiceBase::handleCommandQueue() { CommandMessage reply; ReturnValue_t result = RETURN_FAILED; - for (result = commandQueue->receiveMessage(&reply); result == RETURN_OK; - result = commandQueue->receiveMessage(&reply)) { - handleCommandMessage(&reply); + while(true) { + result = commandQueue->receiveMessage(&reply); + if (result == HasReturnvaluesIF::RETURN_OK) { + handleCommandMessage(&reply); + continue; + } + else if(result == MessageQueueIF::EMPTY) { + break; + } + else { +#if FSFW_VERBOSE_LEVEL >= 1 +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::warning << "CommandingServiceBase::handleCommandQueue: Receiving message failed" + "with code" << result << std::endl; +#else + sif::printWarning("CommandingServiceBase::handleCommandQueue: Receiving message " + "failed with code %d\n", result); +#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ +#endif /* FSFW_VERBOSE_LEVEL >= 1 */ + break; + } } }