From 35712070cf66bf3d8c60c952ab65f5be504a395e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jul 2023 10:15:06 +0200 Subject: [PATCH] source handler --- src/fsfw/cfdp/handler/SourceHandler.cpp | 6 +++++- src/fsfw/cfdp/handler/SourceHandler.h | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/fsfw/cfdp/handler/SourceHandler.cpp b/src/fsfw/cfdp/handler/SourceHandler.cpp index 50d0de3d..2b64de7a 100644 --- a/src/fsfw/cfdp/handler/SourceHandler.cpp +++ b/src/fsfw/cfdp/handler/SourceHandler.cpp @@ -9,7 +9,9 @@ using namespace returnvalue; cfdp::SourceHandler::SourceHandler(SourceHandlerParams params, FsfwSourceParams fsfwParams) - : transactionParams(params.maxFilePathSize), sourceParams(std::move(params)) {} + : transactionParams(params.maxFilePathSize), + sourceParams(std::move(params)), + fsfwParams(fsfwParams) {} void cfdp::SourceHandler::fsmNacked() { if (step == TransactionStep::IDLE) { @@ -79,3 +81,5 @@ ReturnValue_t cfdp::SourceHandler::checksumGeneration() { transactionParams.crc = crcCalc.value(); return OK; } + +ReturnValue_t cfdp::SourceHandler::putRequest() { return 0; } diff --git a/src/fsfw/cfdp/handler/SourceHandler.h b/src/fsfw/cfdp/handler/SourceHandler.h index a0dc4163..211b436b 100644 --- a/src/fsfw/cfdp/handler/SourceHandler.h +++ b/src/fsfw/cfdp/handler/SourceHandler.h @@ -10,6 +10,7 @@ #include "fsfw/cfdp/handler/mib.h" #include "fsfw/events/EventReportingProxyIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" +#include "fsfw/tmtcservices/AcceptsTelemetryIF.h" namespace cfdp { @@ -21,18 +22,37 @@ struct SourceHandlerParams { size_t maxFilePathSize = 256; }; +// TODO: This class in identical to the ones used by the destination handler. Consider unifying +// them. struct FsfwSourceParams { - FsfwSourceParams(EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore) - : tcStore(&tcStore){}; + FsfwSourceParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, + EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, + StorageManagerIF& tmStore) + : FsfwSourceParams(packetDest, msgQueue, eventReporter) { + this->tcStore = &tcStore; + this->tmStore = &tmStore; + } + FsfwSourceParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, + EventReportingProxyIF* eventReporter) + : packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {} + AcceptsTelemetryIF& packetDest; + MessageQueueIF* msgQueue; EventReportingProxyIF* eventReporter = nullptr; StorageManagerIF* tcStore = nullptr; + StorageManagerIF* tmStore = nullptr; }; class SourceHandler { public: SourceHandler(SourceHandlerParams params, FsfwSourceParams fsfwParams); + /** + * Pass a put request to the source handler, which might initiate a CFDP transaction and start + * the state machine + * @return + */ + ReturnValue_t putRequest(); void stateMachine(); private: @@ -60,6 +80,7 @@ class SourceHandler { cfdp::CfdpState state = cfdp::CfdpState::IDLE; TransactionStep step = TransactionStep::IDLE; SourceHandlerParams sourceParams; + FsfwSourceParams fsfwParams; void fsmNacked(); ReturnValue_t checksumGeneration();