From ea2e58249dc02bfa4114c3759db65fd7e7ffd72b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 30 Aug 2023 11:18:49 +0200 Subject: [PATCH] API improvements --- src/fsfw/cfdp/handler/DestHandler.cpp | 6 +++--- src/fsfw/cfdp/handler/DestHandler.h | 2 +- src/fsfw/cfdp/pdu/MetadataGenericInfo.cpp | 4 +++- src/fsfw/cfdp/pdu/MetadataGenericInfo.h | 4 +++- src/fsfw/cfdp/pdu/MetadataPduReader.cpp | 4 +++- src/fsfw/cfdp/pdu/MetadataPduReader.h | 1 + 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/fsfw/cfdp/handler/DestHandler.cpp b/src/fsfw/cfdp/handler/DestHandler.cpp index 999cb155..4bb1cf5c 100644 --- a/src/fsfw/cfdp/handler/DestHandler.cpp +++ b/src/fsfw/cfdp/handler/DestHandler.cpp @@ -146,7 +146,7 @@ ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) { return handleMetadataParseError(result, constAccessorPair.second.data(), constAccessorPair.second.size()); } - return startTransaction(reader, metadataInfo); + return startTransaction(reader); } ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) { @@ -274,8 +274,7 @@ ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result, return returnvalue::FAILED; } -ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, - MetadataGenericInfo& info) { +ReturnValue_t cfdp::DestHandler::startTransaction(const MetadataPduReader& reader) { if (fsmRes.state != CfdpState::IDLE) { // According to standard, discard metadata PDU if we are busy return OK; @@ -344,6 +343,7 @@ ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, } else if (reader.getTransmissionMode() == TransmissionMode::ACKNOWLEDGED) { fsmRes.state = CfdpState::BUSY_CLASS_2_ACKED; } + auto& info = reader.getGenericInfo(); transactionParams.checksumType = info.getChecksumType(); transactionParams.closureRequested = info.isClosureRequested(); reader.fillConfig(transactionParams.pduConf); diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 0940ab70..de1104c8 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -153,7 +153,7 @@ class DestHandler { cfdp::FsfwParams fsfwParams; FsmResult fsmRes; - ReturnValue_t startTransaction(MetadataPduReader& reader, MetadataGenericInfo& info); + ReturnValue_t startTransaction(const MetadataPduReader& reader); ReturnValue_t handleMetadataPdu(const PacketInfo& info); ReturnValue_t handleFileDataPdu(const PacketInfo& info); ReturnValue_t handleEofPdu(const PacketInfo& info); diff --git a/src/fsfw/cfdp/pdu/MetadataGenericInfo.cpp b/src/fsfw/cfdp/pdu/MetadataGenericInfo.cpp index efbe620e..f3b1c751 100644 --- a/src/fsfw/cfdp/pdu/MetadataGenericInfo.cpp +++ b/src/fsfw/cfdp/pdu/MetadataGenericInfo.cpp @@ -21,7 +21,7 @@ void MetadataGenericInfo::setClosureRequested(bool closureRequested_) { closureRequested = closureRequested_; } -cfdp::Fss& MetadataGenericInfo::getFileSize() { return fileSize; } +const cfdp::Fss& MetadataGenericInfo::getFileSize() const { return fileSize; } size_t MetadataGenericInfo::getSerializedSize(bool fssLarge) { // 1 byte + minimal FSS 4 bytes @@ -31,3 +31,5 @@ size_t MetadataGenericInfo::getSerializedSize(bool fssLarge) { } return size; } + +cfdp::Fss& MetadataGenericInfo::getMutFileSize() { return fileSize; } diff --git a/src/fsfw/cfdp/pdu/MetadataGenericInfo.h b/src/fsfw/cfdp/pdu/MetadataGenericInfo.h index 59caabb3..73a54972 100644 --- a/src/fsfw/cfdp/pdu/MetadataGenericInfo.h +++ b/src/fsfw/cfdp/pdu/MetadataGenericInfo.h @@ -22,7 +22,9 @@ class MetadataGenericInfo { [[nodiscard]] bool isClosureRequested() const; void setClosureRequested(bool closureRequested = false); - cfdp::Fss& getFileSize(); + [[nodiscard]] const cfdp::Fss& getFileSize() const; + + cfdp::Fss& getMutFileSize(); private: bool closureRequested = false; diff --git a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp index 69a7d4aa..e6160ce8 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduReader.cpp +++ b/src/fsfw/cfdp/pdu/MetadataPduReader.cpp @@ -25,7 +25,7 @@ ReturnValue_t MetadataPduReader::parseData() { remSize -= 1; buf += 1; auto endianness = getEndianness(); - result = info.getFileSize().deSerialize(&buf, &remSize, endianness); + result = info.getMutFileSize().deSerialize(&buf, &remSize, endianness); if (result != returnvalue::OK) { return result; } @@ -63,3 +63,5 @@ size_t MetadataPduReader::getNumberOfParsedOptions() const { return parsedOption const cfdp::StringLv& MetadataPduReader::getSourceFileName() const { return srcFileName; } const cfdp::StringLv& MetadataPduReader::getDestFileName() const { return destFileName; } + +const MetadataGenericInfo& MetadataPduReader::getGenericInfo() const { return info; } diff --git a/src/fsfw/cfdp/pdu/MetadataPduReader.h b/src/fsfw/cfdp/pdu/MetadataPduReader.h index e619d4f5..a409928e 100644 --- a/src/fsfw/cfdp/pdu/MetadataPduReader.h +++ b/src/fsfw/cfdp/pdu/MetadataPduReader.h @@ -11,6 +11,7 @@ class MetadataPduReader : public FileDirectiveReader { ReturnValue_t parseData() override; + [[nodiscard]] const MetadataGenericInfo& getGenericInfo() const; [[nodiscard]] const cfdp::StringLv& getSourceFileName() const; [[nodiscard]] const cfdp::StringLv& getDestFileName() const;