From c09c0ee9471a23b919fcca2b55d1219be71e1acf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 14 Aug 2023 21:22:01 +0200 Subject: [PATCH] clean up handler a bit --- fsfw | 2 +- mission/cfdp/CfdpHandler.cpp | 56 +++++++++++++++++++++++++++++------- mission/cfdp/CfdpHandler.h | 4 +++ 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/fsfw b/fsfw index cb1aaea6..8c116852 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit cb1aaea6cd10f34bf46adf8f91f86af1fb42041a +Subproject commit 8c1168524049ef0e5b2144b6c04aeb01538053c2 diff --git a/mission/cfdp/CfdpHandler.cpp b/mission/cfdp/CfdpHandler.cpp index 72a54a88..7545aa11 100644 --- a/mission/cfdp/CfdpHandler.cpp +++ b/mission/cfdp/CfdpHandler.cpp @@ -1,5 +1,7 @@ #include "CfdpHandler.h" +#include + #include "fsfw/cfdp/pdu/AckPduReader.h" #include "fsfw/cfdp/pdu/PduHeaderReader.h" #include "fsfw/globalfunctions/arrayprinter.h" @@ -42,17 +44,14 @@ ReturnValue_t CfdpHandler::initialize() { } ReturnValue_t CfdpHandler::performOperation(uint8_t operationCode) { - // TODO: Receive TC packets and route them to source and dest handler, depending on which is - // correct or more appropriate - ReturnValue_t status; - ReturnValue_t result = OK; - TmTcMessage tmtcMsg; - for (status = pduQueue.receiveMessage(&tmtcMsg); status == returnvalue::OK; - status = pduQueue.receiveMessage(&tmtcMsg)) { - result = handlePduPacket(tmtcMsg); - if (result != OK) { - status = result; - } + ReturnValue_t status = OK; + ReturnValue_t result = handlePduPacketMessages(); + if (result != OK) { + status = result; + } + result = handleCfdpMessages(); + if (result != OK) { + status = result; } const DestHandler::FsmResult& destResult = destHandler.stateMachine(); // TODO: Error handling? @@ -139,3 +138,38 @@ ReturnValue_t CfdpHandler::handlePduPacket(TmTcMessage& msg) { } return result; } + +ReturnValue_t CfdpHandler::handleCfdpRequest(CommandMessage& msg) { + // TODO: Handle CFDP requests here, most importantly put requests. If a put request is received, + // check whether one is pending. If none are, start a transaction with the put request, otherwise + // store for put request inside a FIFO for later processing. + return OK; +} + +ReturnValue_t CfdpHandler::handlePduPacketMessages() { + ReturnValue_t status; + ReturnValue_t result = OK; + TmTcMessage pduMsg; + for (status = pduQueue.receiveMessage(&pduMsg); status == returnvalue::OK; + status = pduQueue.receiveMessage(&pduMsg)) { + result = handlePduPacket(pduMsg); + if (result != OK) { + status = result; + } + } + return status; +} + +ReturnValue_t CfdpHandler::handleCfdpMessages() { + ReturnValue_t status; + ReturnValue_t result; + CommandMessage cfdpMsg; + for (status = cfdpRequestQueue.receiveMessage(&cfdpMsg); status == returnvalue::OK; + status = cfdpRequestQueue.receiveMessage(&cfdpMsg)) { + result = handleCfdpRequest(cfdpMsg); + if (result != OK) { + status = result; + } + } + return status; +} diff --git a/mission/cfdp/CfdpHandler.h b/mission/cfdp/CfdpHandler.h index 6ee4b07b..4bea5b95 100644 --- a/mission/cfdp/CfdpHandler.h +++ b/mission/cfdp/CfdpHandler.h @@ -2,6 +2,7 @@ #define FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H #include +#include #include @@ -77,7 +78,10 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep StorageManagerIF* tcStore = nullptr; StorageManagerIF* tmStore = nullptr; + ReturnValue_t handlePduPacketMessages(); ReturnValue_t handlePduPacket(TmTcMessage& msg); + ReturnValue_t handleCfdpRequest(CommandMessage& msg); + ReturnValue_t handleCfdpMessages(); }; #endif // FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H