From 88c4b2a5390a927d1eda33e9ac410ddc757cfc45 Mon Sep 17 00:00:00 2001 From: "Robin.Mueller" Date: Mon, 28 Sep 2020 16:56:42 +0200 Subject: [PATCH] bugfixes for srv3 --- datapoollocal/LocalDataPoolManager.cpp | 63 +++++++++++++++---------- housekeeping/HousekeepingSetPacket.h | 1 + internalError/InternalErrorReporter.cpp | 8 ++++ internalError/InternalErrorReporter.h | 1 + pus/Service3Housekeeping.cpp | 21 +++++++-- pus/Service3Housekeeping.h | 2 +- 6 files changed, 64 insertions(+), 32 deletions(-) diff --git a/datapoollocal/LocalDataPoolManager.cpp b/datapoollocal/LocalDataPoolManager.cpp index 4299861e..f07f458e 100644 --- a/datapoollocal/LocalDataPoolManager.cpp +++ b/datapoollocal/LocalDataPoolManager.cpp @@ -15,42 +15,53 @@ object_id_t LocalDataPoolManager::defaultHkDestination = objects::NO_OBJECT; LocalDataPoolManager::LocalDataPoolManager(HasLocalDataPoolIF* owner, MessageQueueIF* queueToUse, bool appendValidityBuffer): appendValidityBuffer(appendValidityBuffer) { - if(owner == nullptr) { - sif::error << "HkManager: Invalid supplied owner!" << std::endl; - return; - } - this->owner = owner; - mutex = MutexFactory::instance()->createMutex(); - if(mutex == nullptr) { - sif::error << "LocalDataPoolManager::LocalDataPoolManager: " - "Could not create mutex." << std::endl; - } - ipcStore = objectManager->get(objects::IPC_STORE); - if(ipcStore == nullptr) { - sif::error << "LocalDataPoolManager::LocalDataPoolManager: " - "Could not set IPC store." << std::endl; - } + if(owner == nullptr) { + sif::error << "LocalDataPoolManager::LocalDataPoolManager: " + << "Invalid supplied owner!" << std::endl; + return; + } + this->owner = owner; + mutex = MutexFactory::instance()->createMutex(); + if(mutex == nullptr) { + sif::error << "LocalDataPoolManager::LocalDataPoolManager: " + << "Could not create mutex." << std::endl; + } - hkQueue = queueToUse; - - if(defaultHkDestination != objects::NO_OBJECT) { - AcceptsHkPacketsIF* hkPacketReceiver = - objectManager->get(defaultHkDestination); - if(hkPacketReceiver != nullptr) { - hkDestinationId = hkPacketReceiver->getHkQueue(); - } - } + hkQueue = queueToUse; } LocalDataPoolManager::~LocalDataPoolManager() {} ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) { if(queueToUse == nullptr) { - sif::error << "LocalDataPoolManager::initialize: Supplied queue " - "invalid!" << std::endl; + sif::error << "LocalDataPoolManager::initialize: " + << std::hex << "0x" << owner->getObjectId() << ". Supplied " + << "queue invalid!" << std::dec << std::endl; } hkQueue = queueToUse; + ipcStore = objectManager->get(objects::IPC_STORE); + if(ipcStore == nullptr) { + sif::error << "LocalDataPoolManager::initialize: " + << std::hex << "0x" << owner->getObjectId() << ": Could not " + << "set IPC store." <get(defaultHkDestination); + if(hkPacketReceiver != nullptr) { + hkDestinationId = hkPacketReceiver->getHkQueue(); + } + else { + sif::error << "LocalDataPoolManager::LocalDataPoolManager: " + << "Default HK destination object is invalid!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + return HasReturnvaluesIF::RETURN_OK; } diff --git a/housekeeping/HousekeepingSetPacket.h b/housekeeping/HousekeepingSetPacket.h index 007b95be..051e4c61 100644 --- a/housekeeping/HousekeepingSetPacket.h +++ b/housekeeping/HousekeepingSetPacket.h @@ -12,6 +12,7 @@ public: objectId(sid.objectId), setId(sid.ownerSetId), reportingEnabled(reportingEnabled), valid(valid), collectionIntervalSeconds(collectionInterval), dataSet(dataSetPtr) { + setLinks(); } ReturnValue_t serialize(uint8_t** buffer, size_t* size, diff --git a/internalError/InternalErrorReporter.cpp b/internalError/InternalErrorReporter.cpp index 767ece51..4cdab9e7 100644 --- a/internalError/InternalErrorReporter.cpp +++ b/internalError/InternalErrorReporter.cpp @@ -177,3 +177,11 @@ LocalPoolDataSetBase* InternalErrorReporter::getDataSetHandle(sid_t sid) { void InternalErrorReporter::setTaskIF(PeriodicTaskIF *task) { this->executingTask = task; } + +ReturnValue_t InternalErrorReporter::initialize() { + ReturnValue_t result = poolManager.initialize(commandQueue); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return SystemObject::initialize(); +} diff --git a/internalError/InternalErrorReporter.h b/internalError/InternalErrorReporter.h index 85ac0836..c715f7a0 100644 --- a/internalError/InternalErrorReporter.h +++ b/internalError/InternalErrorReporter.h @@ -45,6 +45,7 @@ public: virtual dur_millis_t getPeriodicOperationFrequency() const override; virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override; + virtual ReturnValue_t initialize() override; virtual ReturnValue_t performOperation(uint8_t opCode) override; virtual void queueMessageNotSent(); diff --git a/pus/Service3Housekeeping.cpp b/pus/Service3Housekeeping.cpp index ad08c328..c668ec8e 100644 --- a/pus/Service3Housekeeping.cpp +++ b/pus/Service3Housekeeping.cpp @@ -181,7 +181,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, switch(command) { case(HousekeepingMessage::HK_REPORT): { - ReturnValue_t result = generateHkReport(reply, + ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::HK_REPORT)); if(result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -190,7 +190,7 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, } case(HousekeepingMessage::DIAGNOSTICS_REPORT): { - ReturnValue_t result = generateHkReport(reply, + ReturnValue_t result = generateHkReply(reply, static_cast(Subservice::DIAGNOSTICS_REPORT)); if(result != HasReturnvaluesIF::RETURN_OK) { return result; @@ -198,6 +198,17 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply, return CommandingServiceBase::EXECUTION_COMPLETE; } + case(HousekeepingMessage::HK_DEFINITIONS_REPORT): { + return generateHkReply(reply, static_cast( + Subservice::HK_DEFINITIONS_REPORT)); + break; + } + case(HousekeepingMessage::DIAGNOSTICS_DEFINITION_REPORT): { + return generateHkReply(reply, static_cast( + Subservice::DIAGNOSTICS_REPORT)); + break; + } + case(HousekeepingMessage::HK_REQUEST_SUCCESS): { return CommandingServiceBase::EXECUTION_COMPLETE; } @@ -226,13 +237,13 @@ void Service3Housekeeping::handleUnrequestedReply( switch(command) { case(HousekeepingMessage::DIAGNOSTICS_REPORT): { - result = generateHkReport(reply, + result = generateHkReply(reply, static_cast(Subservice::DIAGNOSTICS_REPORT)); break; } case(HousekeepingMessage::HK_REPORT): { - result = generateHkReport(reply, + result = generateHkReply(reply, static_cast(Subservice::HK_REPORT)); break; } @@ -254,7 +265,7 @@ MessageQueueId_t Service3Housekeeping::getHkQueue() const { return commandQueue->getId(); } -ReturnValue_t Service3Housekeeping::generateHkReport( +ReturnValue_t Service3Housekeeping::generateHkReply( const CommandMessage* hkMessage, uint8_t subserviceId) { store_address_t storeId; diff --git a/pus/Service3Housekeeping.h b/pus/Service3Housekeeping.h index 01964bab..269710ef 100644 --- a/pus/Service3Housekeeping.h +++ b/pus/Service3Housekeeping.h @@ -82,7 +82,7 @@ private: ReturnValue_t checkInterfaceAndAcquireMessageQueue( MessageQueueId_t* messageQueueToSet, object_id_t* objectId); - ReturnValue_t generateHkReport(const CommandMessage* hkMessage, + ReturnValue_t generateHkReply(const CommandMessage* hkMessage, uint8_t subserviceId); ReturnValue_t prepareReportingTogglingCommand(CommandMessage* command, object_id_t objectId, bool enableReporting, bool isDiagnostics,