diff --git a/mission/cfdp/CfdpHandler.cpp b/mission/cfdp/CfdpHandler.cpp index b2121022..92a3827b 100644 --- a/mission/cfdp/CfdpHandler.cpp +++ b/mission/cfdp/CfdpHandler.cpp @@ -143,11 +143,22 @@ ReturnValue_t CfdpHandler::handlePduPacket(TmTcMessage& msg) { 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. + // 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)); - - sif::info << "received CFDP request" << std::endl; + if (msg.getCommand() == CfdpMessage::PUT_REQUEST) { + sif::info << "Received CFDP put request" << std::endl; + if (srcHandler.getState() != CfdpState::IDLE) { + if (putRequestQueue.full()) { + // TODO: Trigger event and discard request. Queue is full, too many requests. + return FAILED; + } + putRequestQueue.push(CfdpMessage::getStoreId(&msg)); + } else { + // TODO: Retrieve put request and remote configuration. + // srcHandler.transactionStart() + } + } return OK; } @@ -159,6 +170,7 @@ ReturnValue_t CfdpHandler::handlePduPacketMessages() { status = pduQueue.receiveMessage(&pduMsg)) { result = handlePduPacket(pduMsg); if (result != OK) { + // TODO: Maybe add printout with context specific information? status = result; } } @@ -173,6 +185,7 @@ ReturnValue_t CfdpHandler::handleCfdpMessages() { status = cfdpRequestQueue.receiveMessage(&cfdpMsg)) { result = handleCfdpRequest(cfdpMsg); if (result != OK) { + // TODO: Maybe add printout with context specific information? status = result; } } diff --git a/mission/cfdp/CfdpHandler.h b/mission/cfdp/CfdpHandler.h index 45314d40..2a840fb2 100644 --- a/mission/cfdp/CfdpHandler.h +++ b/mission/cfdp/CfdpHandler.h @@ -1,6 +1,7 @@ #ifndef FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H #define FSFW_EXAMPLE_HOSTED_CFDPHANDLER_H +#include #include #include @@ -77,6 +78,7 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep SeqCountProviderU16 seqCntProvider; cfdp::DestHandler destHandler; cfdp::SourceHandler srcHandler; + etl::queue putRequestQueue; StorageManagerIF& ipcStore; StorageManagerIF* tcStore = nullptr;