From 740644f2c8398227734fd4a4110b3d8ae09f3351 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 14:40:51 +0200 Subject: [PATCH] updates for PusDistributor --- src/fsfw/tcdistribution/PusDistributor.cpp | 28 +++++++++------------- src/fsfw/tcdistribution/PusDistributor.h | 12 ++++------ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/fsfw/tcdistribution/PusDistributor.cpp b/src/fsfw/tcdistribution/PusDistributor.cpp index 9b436dec..36bcd34b 100644 --- a/src/fsfw/tcdistribution/PusDistributor.cpp +++ b/src/fsfw/tcdistribution/PusDistributor.cpp @@ -9,12 +9,12 @@ #define PUS_DISTRIBUTOR_DEBUGGING 0 PusDistributor::PusDistributor(uint16_t setApid, object_id_t setObjectId, - object_id_t setPacketSource, StorageManagerIF* store_) + CCSDSDistributorIF* distributor, StorageManagerIF* store_) : TcDistributor(setObjectId), store(store_), checker(setApid, ccsds::PacketType::TC), - tcStatus(RETURN_FAILED), - packetSource(setPacketSource) {} + ccsdsDistributor(distributor), + tcStatus(RETURN_FAILED) {} PusDistributor::~PusDistributor() = default; @@ -25,7 +25,7 @@ PusDistributor::TcMqMapIter PusDistributor::selectDestination() { << storeId.packetIndex << std::endl; #endif auto queueMapIt = this->queueMap.end(); - if (this->currentPacket == nullptr) { + if (reader.isNull()) { return queueMapIt; } // TODO: Need to set the data @@ -135,13 +135,13 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) { uint16_t PusDistributor::getIdentifier() { return checker.getApid(); } ReturnValue_t PusDistributor::initialize() { - if (currentPacket == nullptr) { - // Should not happen, memory allocation failed! - return ObjectManagerIF::CHILD_INIT_FAILED; + if (store == nullptr) { + store = ObjectManager::instance()->get(objects::TC_STORE); + if (store == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } } - - auto* ccsdsDistributor = ObjectManager::instance()->get(packetSource); - if (ccsdsDistributor == nullptr) { + if(ccsdsDistributor == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl; sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl; @@ -149,13 +149,7 @@ ReturnValue_t PusDistributor::initialize() { sif::printError("PusDistributor::initialize: Packet source invalid\n"); sif::printError("Make sure it exists and implements CCSDSDistributorIF\n"); #endif - return RETURN_FAILED; - } - if (store == nullptr) { - store = ObjectManager::instance()->get(objects::TC_STORE); - if (store == nullptr) { - return ObjectManagerIF::CHILD_INIT_FAILED; - } + return ObjectManagerIF::CHILD_INIT_FAILED; } return ccsdsDistributor->registerApplication(this); } diff --git a/src/fsfw/tcdistribution/PusDistributor.h b/src/fsfw/tcdistribution/PusDistributor.h index b16f1478..bb0c7a04 100644 --- a/src/fsfw/tcdistribution/PusDistributor.h +++ b/src/fsfw/tcdistribution/PusDistributor.h @@ -9,7 +9,7 @@ #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/VerificationReporter.h" -class PacketStorageHelper; +class CCSDSDistributorIF; /** * This class accepts PUS Telecommands and forwards them to Application @@ -27,7 +27,7 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * @param setPacketSource Object ID of the source of TC packets. * Must implement CCSDSDistributorIF. */ - PusDistributor(uint16_t setApid, object_id_t setObjectId, object_id_t setPacketSource, + PusDistributor(uint16_t setApid, object_id_t setObjectId, CCSDSDistributorIF* packetSource, StorageManagerIF* store = nullptr); /** * The destructor is empty. @@ -49,10 +49,8 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc * TC Verification service. */ VerificationReporterIF* verifyChannel = nullptr; - /** - * The currently handled packet is stored here. - */ - PacketStorageHelper* currentPacket = nullptr; + //! Cached for initialization + CCSDSDistributorIF* ccsdsDistributor = nullptr; PusTcReader reader; /** @@ -61,8 +59,6 @@ class PusDistributor : public TcDistributor, public PUSDistributorIF, public Acc */ ReturnValue_t tcStatus; - const object_id_t packetSource; - /** * This method reads the packet service, checks if such a service is * registered and forwards the packet to the destination.