From fa43c5480bdc6486ce0e7179f8a4df49a8c61245 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Aug 2023 11:58:21 +0200 Subject: [PATCH] that should cause a transaction start --- mission/cfdp/CfdpHandler.cpp | 19 +++++++++++++++++-- mission/cfdp/CfdpHandler.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/mission/cfdp/CfdpHandler.cpp b/mission/cfdp/CfdpHandler.cpp index 92a3827b..a5ab231d 100644 --- a/mission/cfdp/CfdpHandler.cpp +++ b/mission/cfdp/CfdpHandler.cpp @@ -17,6 +17,7 @@ CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpH pduQueue(fsfwHandlerParams.tmtcQueue), cfdpRequestQueue(fsfwHandlerParams.cfdpQueue), localCfg(cfdpCfg.id, cfdpCfg.indicCfg, cfdpCfg.faultHandler), + remoteCfgProvider(cfdpCfg.remoteCfgProvider), fsfwParams(fsfwHandlerParams.packetDest, &fsfwHandlerParams.tmtcQueue, this, fsfwHandlerParams.tcStore, fsfwHandlerParams.tmStore), destHandler(DestHandlerParams(localCfg, cfdpCfg.userHandler, cfdpCfg.remoteCfgProvider, @@ -145,7 +146,6 @@ 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. - auto accessorPair = ipcStore.getData(CfdpMessage::getStoreId(&msg)); if (msg.getCommand() == CfdpMessage::PUT_REQUEST) { sif::info << "Received CFDP put request" << std::endl; if (srcHandler.getState() != CfdpState::IDLE) { @@ -156,7 +156,22 @@ ReturnValue_t CfdpHandler::handleCfdpRequest(CommandMessage& msg) { putRequestQueue.push(CfdpMessage::getStoreId(&msg)); } else { // TODO: Retrieve put request and remote configuration. - // srcHandler.transactionStart() + PutRequest putRequest; + auto accessorPair = ipcStore.getData(CfdpMessage::getStoreId(&msg)); + const uint8_t* dataPtr = accessorPair.second.data(); + size_t dataSize = accessorPair.second.size(); + ReturnValue_t result = + putRequest.deSerialize(&dataPtr, &dataSize, SerializeIF::Endianness::MACHINE); + if (result != OK) { + return result; + } + RemoteEntityCfg* remoteCfg; + remoteCfgProvider.getRemoteCfg(putRequest.getDestId(), &remoteCfg); + if (remoteCfg == nullptr) { + // TODO: Trigger event + return FAILED; + } + return srcHandler.transactionStart(putRequest, *remoteCfg); } } return OK; diff --git a/mission/cfdp/CfdpHandler.h b/mission/cfdp/CfdpHandler.h index 2a840fb2..18cf46b7 100644 --- a/mission/cfdp/CfdpHandler.h +++ b/mission/cfdp/CfdpHandler.h @@ -74,6 +74,7 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep MessageQueueIF& pduQueue; MessageQueueIF& cfdpRequestQueue; cfdp::LocalEntityCfg localCfg; + cfdp::RemoteConfigTableIF& remoteCfgProvider; cfdp::FsfwParams fsfwParams; SeqCountProviderU16 seqCntProvider; cfdp::DestHandler destHandler;