From ec1e07b466980795430497323daa220738fe6932 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Sep 2022 11:53:06 +0200 Subject: [PATCH] some more returncodes --- src/fsfw/cfdp/definitions.h | 6 ++++-- src/fsfw/cfdp/handler/DestHandler.h | 4 ++-- src/fsfw/cfdp/pdu/FileDirectiveReader.cpp | 4 ++-- src/fsfw/cfdp/pdu/FileDirectiveReader.h | 3 +-- unittests/cfdp/pdu/testAckPdu.cpp | 2 +- unittests/cfdp/pdu/testFileDirective.cpp | 2 +- unittests/cfdp/testCfdp.cpp | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index e5c11a0b..35c4c5f8 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -20,7 +20,7 @@ static constexpr uint8_t VERSION_BITS = CFDP_VERSION_2 << 5; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; static constexpr ReturnValue_t INVALID_TLV_TYPE = returnvalue::makeCode(CFDP_CLASS_ID, 1); -static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = returnvalue::makeCode(CFDP_CLASS_ID, 2); +static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELD = returnvalue::makeCode(CFDP_CLASS_ID, 2); static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = returnvalue::makeCode(CFDP_CLASS_ID, 3); static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = returnvalue::makeCode(CFDP_CLASS_ID, 4); @@ -30,13 +30,14 @@ static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 5); static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = returnvalue::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = - returnvalue::makeCode(CFDP_CLASS_ID, 6); + returnvalue::makeCode(CFDP_CLASS_ID, 7); static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = returnvalue::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = returnvalue::makeCode(CFDP_CLASS_ID, 9); +static constexpr ReturnValue_t INVALID_PDU_FORMAT = returnvalue::makeCode(CFDP_CLASS_ID, 10); //! Checksum types according to the SANA Checksum Types registry //! https://sanaregistry.org/r/checksum_identifiers/ @@ -71,6 +72,7 @@ enum WidthInBytes : uint8_t { enum FileDirectives : uint8_t { INVALID_DIRECTIVE = 0x0f, + // The _DIRECTIVE suffix is mandatory here because of some nameclash! EOF_DIRECTIVE = 0x04, FINISH = 0x05, ACK = 0x06, diff --git a/src/fsfw/cfdp/handler/DestHandler.h b/src/fsfw/cfdp/handler/DestHandler.h index 8a8dd28e..000fc2c0 100644 --- a/src/fsfw/cfdp/handler/DestHandler.h +++ b/src/fsfw/cfdp/handler/DestHandler.h @@ -62,9 +62,9 @@ struct DestHandlerParams { }; struct FsfwParams { - FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue, - EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, StorageManagerIF& tmStore) + EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore, + StorageManagerIF& tmStore) : FsfwParams(packetDest, msgQueue, eventReporter) { this->tcStore = &tcStore; this->tmStore = &tmStore; diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp index 5d43ebb0..748ac830 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.cpp @@ -18,7 +18,7 @@ ReturnValue_t FileDirectiveReader::parseData() { } size_t currentIdx = PduHeaderReader::getHeaderSize(); if (not checkFileDirective(pointers.rawPtr[currentIdx])) { - return cfdp::INVALID_DIRECTIVE_FIELDS; + return cfdp::INVALID_DIRECTIVE_FIELD; } setFileDirective(static_cast(pointers.rawPtr[currentIdx])); return returnvalue::OK; @@ -32,7 +32,7 @@ size_t FileDirectiveReader::getHeaderSize() const { bool FileDirectiveReader::checkFileDirective(uint8_t rawByte) { if (rawByte < cfdp::FileDirectives::EOF_DIRECTIVE or (rawByte > cfdp::FileDirectives::PROMPT and rawByte != cfdp::FileDirectives::KEEP_ALIVE)) { - // Invalid directive field. TODO: Custom returnvalue + // Invalid directive field return false; } return true; diff --git a/src/fsfw/cfdp/pdu/FileDirectiveReader.h b/src/fsfw/cfdp/pdu/FileDirectiveReader.h index 83a71c71..5bec486c 100644 --- a/src/fsfw/cfdp/pdu/FileDirectiveReader.h +++ b/src/fsfw/cfdp/pdu/FileDirectiveReader.h @@ -26,10 +26,9 @@ class FileDirectiveReader : public PduHeaderReader { void setEndianness(SerializeIF::Endianness endianness); [[nodiscard]] SerializeIF::Endianness getEndianness() const; - - protected: static bool checkFileDirective(uint8_t rawByte); + protected: private: void setFileDirective(cfdp::FileDirectives fileDirective); cfdp::FileDirectives fileDirective = cfdp::FileDirectives::INVALID_DIRECTIVE; diff --git a/unittests/cfdp/pdu/testAckPdu.cpp b/unittests/cfdp/pdu/testAckPdu.cpp index 1eb1b340..02832d9f 100644 --- a/unittests/cfdp/pdu/testAckPdu.cpp +++ b/unittests/cfdp/pdu/testAckPdu.cpp @@ -91,7 +91,7 @@ TEST_CASE("ACK PDU", "[cfdp][pdu]") { buf[sz - 2] = prevVal; buf[sz - 3] = cfdp::FileDirectives::INVALID_DIRECTIVE; result = reader2.parseData(); - REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELDS); + REQUIRE(result == cfdp::INVALID_DIRECTIVE_FIELD); buf[sz - 3] = cfdp::FileDirectives::ACK; auto maxSizeTooSmall = AckPduDeserializer(buf.data(), sz - 2, ackInfo2); result = maxSizeTooSmall.parseData(); diff --git a/unittests/cfdp/pdu/testFileDirective.cpp b/unittests/cfdp/pdu/testFileDirective.cpp index cb1df08d..31e627a6 100644 --- a/unittests/cfdp/pdu/testFileDirective.cpp +++ b/unittests/cfdp/pdu/testFileDirective.cpp @@ -80,6 +80,6 @@ TEST_CASE("CFDP File Directive", "[cfdp][pdu]") { serBuf[7] = 0xff; // Invalid file directive - REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELDS); + REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELD); } } \ No newline at end of file diff --git a/unittests/cfdp/testCfdp.cpp b/unittests/cfdp/testCfdp.cpp index 2e493539..38504a5b 100644 --- a/unittests/cfdp/testCfdp.cpp +++ b/unittests/cfdp/testCfdp.cpp @@ -72,7 +72,7 @@ TEST_CASE("CFDP Base", "[cfdp]") { serBuf[7] = 0xff; // Invalid file directive - REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELDS); + REQUIRE(fdDeser.parseData() == cfdp::INVALID_DIRECTIVE_FIELD); } SECTION("File Size") {