From bdbe0cc9da5edcaa8b01af4f6462a2f46d4628bd Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 16 Sep 2022 16:27:57 +0200 Subject: [PATCH] pass message queue externally --- src/fsfw/cfdp/handler/CfdpHandler.cpp | 13 ++++++------- src/fsfw/cfdp/handler/CfdpHandler.h | 8 +++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fsfw/cfdp/handler/CfdpHandler.cpp b/src/fsfw/cfdp/handler/CfdpHandler.cpp index 1ea5501b..9d20cc5e 100644 --- a/src/fsfw/cfdp/handler/CfdpHandler.cpp +++ b/src/fsfw/cfdp/handler/CfdpHandler.cpp @@ -11,15 +11,14 @@ using namespace cfdp; CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwParams, const CfdpHandlerCfg& cfdpCfg) : SystemObject(fsfwParams.objectId), + msgQueue(fsfwParams.msgQueue), destHandler( DestHandlerParams(LocalEntityCfg(cfdpCfg.id, cfdpCfg.indicCfg, cfdpCfg.faultHandler), cfdpCfg.userHandler, cfdpCfg.remoteCfgProvider, cfdpCfg.packetInfoList, cfdpCfg.lostSegmentsList), FsfwParams(fsfwParams.packetDest, nullptr, this, fsfwParams.tcStore, - fsfwParams.tmStore)) { - // TODO: Make queue params configurable, or better yet, expect it to be passed externally - msgQueue = QueueFactory::instance()->createMessageQueue(); - destHandler.setMsgQueue(*msgQueue); + fsfwParams.tmStore)) { + destHandler.setMsgQueue(msgQueue); } [[nodiscard]] const char* CfdpHandler::getName() const { return "CFDP Handler"; } @@ -28,7 +27,7 @@ CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwParams, const CfdpHandlerC return destHandler.getDestHandlerParams().cfg.localId.getValue(); } -[[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return msgQueue->getId(); } +[[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return msgQueue.getId(); } ReturnValue_t CfdpHandler::initialize() { ReturnValue_t result = destHandler.initialize(); @@ -47,8 +46,8 @@ ReturnValue_t CfdpHandler::performOperation(uint8_t operationCode) { ReturnValue_t status; ReturnValue_t result = OK; TmTcMessage tmtcMsg; - for (status = msgQueue->receiveMessage(&tmtcMsg); status == returnvalue::OK; - status = msgQueue->receiveMessage(&tmtcMsg)) { + for (status = msgQueue.receiveMessage(&tmtcMsg); status == returnvalue::OK; + status = msgQueue.receiveMessage(&tmtcMsg)) { result = handleCfdpPacket(tmtcMsg); if (result != OK) { status = result; diff --git a/src/fsfw/cfdp/handler/CfdpHandler.h b/src/fsfw/cfdp/handler/CfdpHandler.h index d7472905..147ffc70 100644 --- a/src/fsfw/cfdp/handler/CfdpHandler.h +++ b/src/fsfw/cfdp/handler/CfdpHandler.h @@ -11,13 +11,15 @@ struct FsfwHandlerParams { FsfwHandlerParams(object_id_t objectId, HasFileSystemIF& vfs, AcceptsTelemetryIF& packetDest, - StorageManagerIF& tcStore, StorageManagerIF& tmStore) - : objectId(objectId), vfs(vfs), packetDest(packetDest), tcStore(tcStore), tmStore(tmStore) {} + StorageManagerIF& tcStore, StorageManagerIF& tmStore, MessageQueueIF& msgQueue) + : objectId(objectId), vfs(vfs), packetDest(packetDest), tcStore(tcStore), tmStore(tmStore), + msgQueue(msgQueue) {} object_id_t objectId{}; HasFileSystemIF& vfs; AcceptsTelemetryIF& packetDest; StorageManagerIF& tcStore; StorageManagerIF& tmStore; + MessageQueueIF& msgQueue; }; struct CfdpHandlerCfg { @@ -54,7 +56,7 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep ReturnValue_t performOperation(uint8_t operationCode) override; private: - MessageQueueIF* msgQueue = nullptr; + MessageQueueIF& msgQueue; cfdp::DestHandler destHandler; StorageManagerIF* tcStore = nullptr; StorageManagerIF* tmStore = nullptr;