From 8fcc4eab609ed703ef5d62f759d8911e7b41ef3a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jul 2023 15:03:08 +0200 Subject: [PATCH] some internal state handling --- src/fsfw/cfdp/handler/SourceHandler.cpp | 10 ++++++++++ src/fsfw/cfdp/handler/defs.h | 16 ++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/fsfw/cfdp/handler/SourceHandler.cpp b/src/fsfw/cfdp/handler/SourceHandler.cpp index 49c6160d..85dfcef9 100644 --- a/src/fsfw/cfdp/handler/SourceHandler.cpp +++ b/src/fsfw/cfdp/handler/SourceHandler.cpp @@ -26,6 +26,7 @@ void cfdp::SourceHandler::fsmNacked() { if (result != OK) { // TODO: Some error handling } + step = TransactionStep::SENDING_METADATA; } if (step == TransactionStep::SENDING_METADATA) { // TODO: Prepare and send metadata PDU @@ -83,9 +84,18 @@ ReturnValue_t cfdp::SourceHandler::checksumGeneration() { } ReturnValue_t cfdp::SourceHandler::putRequest(PutRequestFull& putRequest, RemoteEntityCfg& cfg) { + if (state != CfdpState::IDLE) { + return SOURCE_TRANSACTION_PENDING; + } transactionParams.closureRequested = putRequest.closureRequested; transactionParams.destId = putRequest.destId; transactionParams.transmissionMode = putRequest.transmissionMode; + if (transactionParams.transmissionMode == TransmissionMode::ACKNOWLEDGED) { + state = cfdp::CfdpState::BUSY_CLASS_2_ACKED; + } else if (transactionParams.transmissionMode == TransmissionMode::UNACKNOWLEDGED) { + state = cfdp::CfdpState::BUSY_CLASS_1_NACKED; + } + step = TransactionStep::IDLE; if (transactionParams.transmissionMode == TransmissionMode::ACKNOWLEDGED) { } if (putRequest.sourceNameSize > transactionParams.sourceName.size()) { diff --git a/src/fsfw/cfdp/handler/defs.h b/src/fsfw/cfdp/handler/defs.h index 06bcd87e..395d991a 100644 --- a/src/fsfw/cfdp/handler/defs.h +++ b/src/fsfw/cfdp/handler/defs.h @@ -12,6 +12,7 @@ namespace cfdp { enum class CfdpState { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED }; static constexpr uint8_t SSID = SUBSYSTEM_ID::CFDP; +static constexpr uint8_t CID = CLASS_ID::CFDP; struct PacketInfo { PacketInfo(PduType type, store_address_t storeId, @@ -48,13 +49,14 @@ using PacketInfoList = etl::list; using PacketInfoListBase = etl::ilist; struct PutRequestFull { + public: EntityId destId; - TransmissionMode transmissionMode; - char destName[524]; - size_t destNameSize; - char sourceName[524]; - size_t sourceNameSize; - bool closureRequested; + TransmissionMode transmissionMode = TransmissionMode::UNACKNOWLEDGED; + char destName[524]{}; + size_t destNameSize = 0; + char sourceName[524]{}; + size_t sourceNameSize = 0; + bool closureRequested = true; }; namespace events { @@ -68,5 +70,7 @@ static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent(SSID, 4, seve } // namespace events +static constexpr ReturnValue_t SOURCE_TRANSACTION_PENDING = returnvalue::makeCode(CID, 0); + } // namespace cfdp #endif // FSFW_CFDP_HANDLER_DEFS_H