diff --git a/fsfw b/fsfw index b39e1c7e..60dcacf4 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit b39e1c7e076914d18fbb78716d3b5b9b12b8504b +Subproject commit 60dcacf432aa0a7b739f8fdf8bf4aaa37ac614e5 diff --git a/mission/cfdp/CfdpHandler.cpp b/mission/cfdp/CfdpHandler.cpp index 8a9e155e..2badd560 100644 --- a/mission/cfdp/CfdpHandler.cpp +++ b/mission/cfdp/CfdpHandler.cpp @@ -11,9 +11,10 @@ using namespace cfdp; CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpHandlerCfg& cfdpCfg) : SystemObject(fsfwHandlerParams.objectId), - msgQueue(fsfwHandlerParams.msgQueue), + tmtcQueue(fsfwHandlerParams.tmtcQueue), + cfdpRequestQueue(fsfwHandlerParams.cfdpQueue), localCfg(cfdpCfg.id, cfdpCfg.indicCfg, cfdpCfg.faultHandler), - fsfwParams(fsfwHandlerParams.packetDest, &fsfwHandlerParams.msgQueue, this, + fsfwParams(fsfwHandlerParams.packetDest, &fsfwHandlerParams.tmtcQueue, this, fsfwHandlerParams.tcStore, fsfwHandlerParams.tmStore), destHandler(DestHandlerParams(localCfg, cfdpCfg.userHandler, cfdpCfg.remoteCfgProvider, cfdpCfg.packetInfoList, cfdpCfg.lostSegmentsList), @@ -27,7 +28,7 @@ CfdpHandler::CfdpHandler(const FsfwHandlerParams& fsfwHandlerParams, const CfdpH return destHandler.getDestHandlerParams().cfg.localId.getValue(); } -[[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return msgQueue.getId(); } +[[nodiscard]] MessageQueueId_t CfdpHandler::getRequestQueue() const { return tmtcQueue.getId(); } ReturnValue_t CfdpHandler::initialize() { ReturnValue_t result = destHandler.initialize(); @@ -46,19 +47,23 @@ 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 = tmtcQueue.receiveMessage(&tmtcMsg); status == returnvalue::OK; + status = tmtcQueue.receiveMessage(&tmtcMsg)) { result = handleCfdpPacket(tmtcMsg); if (result != OK) { status = result; } } - auto& fsmRes = destHandler.performStateMachine(); + const DestHandler::FsmResult& destResult = destHandler.stateMachine(); // TODO: Error handling? - while (fsmRes.callStatus == CallStatus::CALL_AGAIN) { - destHandler.performStateMachine(); + while (destResult.callStatus == CallStatus::CALL_AGAIN) { + destHandler.stateMachine(); // TODO: Error handling? } + const SourceHandler::FsmResult& srcResult = srcHandler.stateMachine(); + while (srcResult.callStatus == CallStatus::CALL_AGAIN) { + srcHandler.stateMachine(); + } return status; } diff --git a/mission/cfdp/CfdpHandler.h b/mission/cfdp/CfdpHandler.h index c7f71eda..da526590 100644 --- a/mission/cfdp/CfdpHandler.h +++ b/mission/cfdp/CfdpHandler.h @@ -14,19 +14,22 @@ struct FsfwHandlerParams { FsfwHandlerParams(object_id_t objectId, HasFileSystemIF& vfs, AcceptsTelemetryIF& packetDest, - StorageManagerIF& tcStore, StorageManagerIF& tmStore, MessageQueueIF& msgQueue) + StorageManagerIF& tcStore, StorageManagerIF& tmStore, MessageQueueIF& tmtcQueue, + MessageQueueIF& cfdpQueue) : objectId(objectId), vfs(vfs), packetDest(packetDest), tcStore(tcStore), tmStore(tmStore), - msgQueue(msgQueue) {} + tmtcQueue(tmtcQueue), + cfdpQueue(cfdpQueue) {} object_id_t objectId{}; HasFileSystemIF& vfs; AcceptsTelemetryIF& packetDest; StorageManagerIF& tcStore; StorageManagerIF& tmStore; - MessageQueueIF& msgQueue; + MessageQueueIF& tmtcQueue; + MessageQueueIF& cfdpQueue; }; struct CfdpHandlerCfg { @@ -63,7 +66,8 @@ class CfdpHandler : public SystemObject, public ExecutableObjectIF, public Accep ReturnValue_t performOperation(uint8_t operationCode) override; private: - MessageQueueIF& msgQueue; + MessageQueueIF& tmtcQueue; + MessageQueueIF& cfdpRequestQueue; cfdp::LocalEntityCfg localCfg; cfdp::FsfwParams fsfwParams; SeqCountProviderU16 seqCntProvider; diff --git a/mission/cfdp/Config.h b/mission/cfdp/Config.h index 45f84155..89a3cdd1 100644 --- a/mission/cfdp/Config.h +++ b/mission/cfdp/Config.h @@ -7,8 +7,13 @@ namespace cfdp { class EiveUserHandler : public cfdp::UserBase { public: - explicit EiveUserHandler(HasFileSystemIF& vfs) : cfdp::UserBase(vfs) {} - virtual ~EiveUserHandler() = default; + explicit EiveUserHandler(HasFileSystemIF& vfs, MessageQueueId_t cfdpRequestId) + : cfdp::UserBase(vfs) { + userQueue = QueueFactory::instance()->createMessageQueue(10); + userQueue->setDefaultDestination(cfdpRequestId); + } + + virtual ~EiveUserHandler() { QueueFactory::instance()->deleteMessageQueue(userQueue); } void transactionIndication(const cfdp::TransactionId& id) override {} void eofSentIndication(const cfdp::TransactionId& id) override {} @@ -16,6 +21,7 @@ class EiveUserHandler : public cfdp::UserBase { sif::info << "File transaction finished for transaction with " << params.id << std::endl; } void metadataRecvdIndication(const cfdp::MetadataRecvdParams& params) override { + // TODO: Parse user messages and convert them into put requests where applicable. sif::info << "Metadata received for transaction with " << params.id << std::endl; } void fileSegmentRecvdIndication(const cfdp::FileSegmentRecvdParams& params) override {} @@ -29,6 +35,9 @@ class EiveUserHandler : public cfdp::UserBase { void eofRecvIndication(const cfdp::TransactionId& id) override { sif::info << "EOF PDU received for transaction with " << id << std::endl; } + + private: + MessageQueueIF* userQueue; }; class EiveFaultHandler : public cfdp::FaultHandlerBase { diff --git a/mission/genericFactory.cpp b/mission/genericFactory.cpp index 3d9d0c81..79035f9c 100644 --- a/mission/genericFactory.cpp +++ b/mission/genericFactory.cpp @@ -85,7 +85,7 @@ EntityId REMOTE_CFDP_ID(UnsignedByteField(config::EIVE_GROUND_CFDP_ENT RemoteEntityCfg GROUND_REMOTE_CFG(REMOTE_CFDP_ID); OneRemoteConfigProvider REMOTE_CFG_PROVIDER(GROUND_REMOTE_CFG); HostFilesystem HOST_FS; -EiveUserHandler USER_HANDLER(HOST_FS); +// EiveUserHandler USER_HANDLER(HOST_FS); EiveFaultHandler EIVE_FAULT_HANDLER; } // namespace cfdp @@ -274,14 +274,16 @@ void ObjectFactory::produceGenericObjects(HealthTableIF** healthTable_, PusTmFun CfdpDistribCfg distribCfg(objects::CFDP_DISTRIBUTOR, *tcStore, cfdpMsgQueue); new CfdpDistributor(distribCfg); - auto* msgQueue = QueueFactory::instance()->createMessageQueue(32); + auto* tmtcQueue = QueueFactory::instance()->createMessageQueue(32); + auto* cfdpQueue = QueueFactory::instance()->createMessageQueue(16); + auto eiveUserHandler = new EiveUserHandler(HOST_FS, cfdpQueue->getId()); FsfwHandlerParams params(objects::CFDP_HANDLER, HOST_FS, **cfdpFunnel, *tcStore, **tmStore, - *msgQueue); + *tmtcQueue, *cfdpQueue); cfdp::IndicationCfg indicationCfg; UnsignedByteField apid(config::EIVE_LOCAL_CFDP_ENTITY_ID); cfdp::EntityId localId(apid); GROUND_REMOTE_CFG.defaultChecksum = cfdp::ChecksumType::CRC_32; - CfdpHandlerCfg cfdpCfg(localId, indicationCfg, USER_HANDLER, EIVE_FAULT_HANDLER, PACKET_LIST, + CfdpHandlerCfg cfdpCfg(localId, indicationCfg, *eiveUserHandler, EIVE_FAULT_HANDLER, PACKET_LIST, LOST_SEGMENTS, REMOTE_CFG_PROVIDER); auto* cfdpHandler = new CfdpHandler(params, cfdpCfg); // All CFDP packets arrive wrapped inside CCSDS space packets