From d7a2eada945a3d1b77d71153d88d15ca1ce1bff3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 10:42:56 +0200 Subject: [PATCH] add space packet creator class --- CMakeLists.txt | 9 ++- .../datalinklayer/MapPacketExtraction.cpp | 2 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 4 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckCFDP.h | 2 +- src/fsfw/tcdistribution/TcPacketCheckIF.h | 4 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckPUS.h | 2 +- src/fsfw/tmtcpacket/CMakeLists.txt | 2 +- src/fsfw/tmtcpacket/SpacePacketCreator.cpp | 36 +++++++++++ src/fsfw/tmtcpacket/SpacePacketCreator.h | 26 ++++++++ ...cePacketBase.cpp => SpacePacketReader.cpp} | 32 +++++----- ...{SpacePacketBase.h => SpacePacketReader.h} | 8 ++- src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp | 2 +- src/fsfw/tmtcpacket/cfdp/CFDPPacket.h | 4 +- src/fsfw/tmtcpacket/pus/tc/PusTcIF.h | 60 +++++++++---------- .../tmtcpacket/pus/tc/TcPacketDeserializer.h | 4 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 4 +- .../tmtcpacket/pus/tc/TcPacketPusBase.cpp | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h | 4 +- .../tmtcpacket/pus/tm/TmPacketMinimal.cpp | 2 +- src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h | 2 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h | 2 +- src/fsfw/tmtcservices/SourceSequenceCounter.h | 2 +- .../fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 14 +++-- 30 files changed, 164 insertions(+), 89 deletions(-) create mode 100644 src/fsfw/tmtcpacket/SpacePacketCreator.cpp create mode 100644 src/fsfw/tmtcpacket/SpacePacketCreator.h rename src/fsfw/tmtcpacket/{SpacePacketBase.cpp => SpacePacketReader.cpp} (69%) rename src/fsfw/tmtcpacket/{SpacePacketBase.h => SpacePacketReader.h} (93%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a8b703d2..066f10280 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,14 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) -add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp src/fsfw/tmtcpacket/pus/tc/PusTcIF.h) +add_library( + ${LIB_FSFW_NAME} + src/fsfw/tmtcpacket/SpacePacketIF.h + src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h + src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp + src/fsfw/tmtcpacket/pus/tc/PusTcIF.h + src/fsfw/tmtcpacket/SpacePacketCreator.h + src/fsfw/tmtcpacket/SpacePacketCreator.cpp) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION diff --git a/src/fsfw/datalinklayer/MapPacketExtraction.cpp b/src/fsfw/datalinklayer/MapPacketExtraction.cpp index 57aa2f087..1467f2aa7 100644 --- a/src/fsfw/datalinklayer/MapPacketExtraction.cpp +++ b/src/fsfw/datalinklayer/MapPacketExtraction.cpp @@ -6,7 +6,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/storagemanager/StorageManagerIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" #include "fsfw/tmtcservices/AcceptsTelecommandsIF.h" #include "fsfw/tmtcservices/TmTcMessage.h" diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 0be177bf4..a32cbc754 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -2,7 +2,7 @@ #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" #define CCSDS_DISTRIBUTOR_DEBUGGING 0 @@ -40,7 +40,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { #endif return queueMap.end(); } - SpacePacketBase currentPacket(packet); + SpacePacketReader currentPacket(packet); #if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1 sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp index d1eb43bc5..7d2bfe88f 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp @@ -4,6 +4,6 @@ TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid) : apid(setApid) {} -ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) { return RETURN_OK; } +ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketReader* currentPacket) { return RETURN_OK; } uint16_t TcPacketCheckCFDP::getApid() const { return apid; } diff --git a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h index 3fe281d19..5a4abd4f0 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckCFDP.h +++ b/src/fsfw/tcdistribution/TcPacketCheckCFDP.h @@ -25,7 +25,7 @@ class TcPacketCheckCFDP : public TcPacketCheckIF, public HasReturnvaluesIF { */ TcPacketCheckCFDP(uint16_t setApid); - ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override; + ReturnValue_t checkPacket(SpacePacketReader* currentPacket) override; uint16_t getApid() const; }; diff --git a/src/fsfw/tcdistribution/TcPacketCheckIF.h b/src/fsfw/tcdistribution/TcPacketCheckIF.h index 858c3093a..a9ec14a28 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckIF.h +++ b/src/fsfw/tcdistribution/TcPacketCheckIF.h @@ -3,7 +3,7 @@ #include "../returnvalues/HasReturnvaluesIF.h" -class SpacePacketBase; +class SpacePacketReader; /** * This interface is used by PacketCheckers for PUS packets and CFDP packets . @@ -24,7 +24,7 @@ class TcPacketCheckIF { * - @c INCORRECT_CHECKSUM if checksum is invalid. * - @c ILLEGAL_APID if APID does not match. */ - virtual ReturnValue_t checkPacket(SpacePacketBase* currentPacket) = 0; + virtual ReturnValue_t checkPacket(SpacePacketReader* currentPacket) = 0; }; #endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */ diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 6d7092e58..304c644af 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -10,7 +10,7 @@ TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {} -ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { +ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketReader* currentPacket) { auto* storedPacket = dynamic_cast(currentPacket); auto* tcPacketBase = dynamic_cast(currentPacket); if (tcPacketBase == nullptr or storedPacket == nullptr) { diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.h b/src/fsfw/tcdistribution/TcPacketCheckPUS.h index e3eca1a4d..4804a619d 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.h +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.h @@ -53,7 +53,7 @@ class TcPacketCheckPUS : public TcPacketCheckIF, public HasReturnvaluesIF { */ TcPacketCheckPUS(uint16_t setApid); - ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override; + ReturnValue_t checkPacket(SpacePacketReader* currentPacket) override; uint16_t getApid() const; }; diff --git a/src/fsfw/tmtcpacket/CMakeLists.txt b/src/fsfw/tmtcpacket/CMakeLists.txt index dc09c9c9f..85376d01b 100644 --- a/src/fsfw/tmtcpacket/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketReader.cpp) add_subdirectory(cfdp) add_subdirectory(packetmatcher) diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.cpp b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp new file mode 100644 index 000000000..d5eb73c23 --- /dev/null +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.cpp @@ -0,0 +1,36 @@ +#include "SpacePacketCreator.h" + +#include "fsfw/serialize/SerializeAdapter.h" + +SpacePacketCreator::SpacePacketCreator(uint16_t packetId_, uint16_t packetSeqCtrl_, + uint16_t packetLen_, uint8_t version_) { + packetId = packetId_; + packetSeqCtrl = packetSeqCtrl_; + packetLen = packetLen_; + version = version_; +} + +uint16_t SpacePacketCreator::getPacketId() const { return 0; } +uint16_t SpacePacketCreator::getPacketSeqCtrl() const { return 0; } +uint16_t SpacePacketCreator::getPacketDataLen() const { return 0; } + +ReturnValue_t SpacePacketCreator::serialize(uint8_t **buffer, size_t *size, size_t maxSize, + SerializeIF::Endianness streamEndianness) const { + uint16_t packetIdAndVersion = version << 13 | packetId; + ReturnValue_t result = + SerializeAdapter::serialize(&packetIdAndVersion, buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + result = SerializeAdapter::serialize(&packetSeqCtrl, buffer, size, maxSize, streamEndianness); + if (result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return SerializeAdapter::serialize(&packetLen, buffer, size, maxSize, streamEndianness); +} + +size_t SpacePacketCreator::getSerializedSize() const { return 0; } +ReturnValue_t SpacePacketCreator::deSerialize(const uint8_t **buffer, size_t *size, + SerializeIF::Endianness streamEndianness) { + return HasReturnvaluesIF::RETURN_FAILED; +} diff --git a/src/fsfw/tmtcpacket/SpacePacketCreator.h b/src/fsfw/tmtcpacket/SpacePacketCreator.h new file mode 100644 index 000000000..2e7d2537c --- /dev/null +++ b/src/fsfw/tmtcpacket/SpacePacketCreator.h @@ -0,0 +1,26 @@ +#ifndef FSFW_TMTCPACKET_SPACEPACKETCREATOR_H +#define FSFW_TMTCPACKET_SPACEPACKETCREATOR_H + +#include "SpacePacketIF.h" +#include "fsfw/serialize/SerializeIF.h" + +class SpacePacketCreator : public SerializeIF, public SpacePacketIF { + public: + SpacePacketCreator(uint16_t packetId, uint16_t packetSeqCtrl, uint16_t packetLen, + uint8_t version = 0); + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize, + Endianness streamEndianness) const override; + size_t getSerializedSize() const override; + ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size, + Endianness streamEndianness) override; + + private: + uint16_t packetId; + uint16_t packetSeqCtrl; + uint16_t packetLen; + uint8_t version; +}; +#endif // FSFW_TMTCPACKET_SPACEPACKETCREATOR_H diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketReader.cpp similarity index 69% rename from src/fsfw/tmtcpacket/SpacePacketBase.cpp rename to src/fsfw/tmtcpacket/SpacePacketReader.cpp index cb18519ef..a1bcd465f 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketReader.cpp @@ -1,17 +1,17 @@ -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" #include #include "fsfw/serviceinterface/ServiceInterface.h" -SpacePacketBase::SpacePacketBase(const uint8_t* setAddress) { +SpacePacketReader::SpacePacketReader(const uint8_t* setAddress) { this->data = reinterpret_cast(const_cast(setAddress)); } -SpacePacketBase::~SpacePacketBase() = default; +SpacePacketReader::~SpacePacketReader() = default; -ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, - uint16_t apid, uint16_t sequenceCount) { +ReturnValue_t SpacePacketReader::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, + uint16_t apid, uint16_t sequenceCount) { if (data == nullptr) { #if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -35,54 +35,54 @@ ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool ha return HasReturnvaluesIF::RETURN_OK; } -inline uint16_t SpacePacketBase::getPacketId() const { +inline uint16_t SpacePacketReader::getPacketId() const { return ((this->data->header.packetIdHAndVersion) << 8) + this->data->header.packetIdL; } -void SpacePacketBase::setApid(uint16_t setAPID) { +void SpacePacketReader::setApid(uint16_t setAPID) { // Use first three bits of new APID, but keep rest of packet id as it was (see specification). this->data->header.packetIdHAndVersion = (this->data->header.packetIdHAndVersion & 0b11111000) | ((setAPID & 0x0700) >> 8); this->data->header.packetIdL = (setAPID & 0x00FF); } -void SpacePacketBase::setSequenceFlags(uint8_t sequenceflags) { +void SpacePacketReader::setSequenceFlags(uint8_t sequenceflags) { this->data->header.packetSeqCtrlH &= 0x3F; this->data->header.packetSeqCtrlH |= sequenceflags << 6; } -void SpacePacketBase::setPacketSequenceCount(uint16_t new_count) { +void SpacePacketReader::setPacketSequenceCount(uint16_t new_count) { this->data->header.packetSeqCtrlH = (this->data->header.packetSeqCtrlH & 0b11000000) | (((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8); this->data->header.packetSeqCtrlL = ((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x00FF); } -void SpacePacketBase::setPacketDataLength(uint16_t new_length) { +void SpacePacketReader::setPacketDataLength(uint16_t new_length) { this->data->header.packetLenH = ((new_length & 0xFF00) >> 8); this->data->header.packetLenL = (new_length & 0x00FF); } -size_t SpacePacketBase::getFullSize() { +size_t SpacePacketReader::getFullSize() { // +1 is done because size in packet data length field is: size of data field -1 return this->getPacketDataLen() + sizeof(this->data->header) + 1; } -uint8_t* SpacePacketBase::getWholeData() { return reinterpret_cast(this->data); } +uint8_t* SpacePacketReader::getWholeData() { return reinterpret_cast(this->data); } -uint8_t* SpacePacketBase::getPacketData() { return &(data->packet_data); } +uint8_t* SpacePacketReader::getPacketData() { return &(data->packet_data); } -ReturnValue_t SpacePacketBase::setData(uint8_t* pData, size_t maxSize, void* args) { +ReturnValue_t SpacePacketReader::setData(uint8_t* pData, size_t maxSize, void* args) { if (maxSize < 6) { return HasReturnvaluesIF::RETURN_FAILED; } this->data = reinterpret_cast(const_cast(pData)); return HasReturnvaluesIF::RETURN_OK; } -uint16_t SpacePacketBase::getPacketSeqCtrl() const { +uint16_t SpacePacketReader::getPacketSeqCtrl() const { return ((this->data->header.packetSeqCtrlH & 0b00111111) << 8) + this->data->header.packetSeqCtrlL; } -uint16_t SpacePacketBase::getPacketDataLen() const { +uint16_t SpacePacketReader::getPacketDataLen() const { return ((this->data->header.packetLenH) << 8) + this->data->header.packetLenL; } diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.h b/src/fsfw/tmtcpacket/SpacePacketReader.h similarity index 93% rename from src/fsfw/tmtcpacket/SpacePacketBase.h rename to src/fsfw/tmtcpacket/SpacePacketReader.h index 862e4725e..7fc88577c 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.h +++ b/src/fsfw/tmtcpacket/SpacePacketReader.h @@ -40,7 +40,7 @@ struct SpacePacketPointer { * the most significant bit (from left). * @ingroup tmtcpackets */ -class SpacePacketBase : public SpacePacketIF, public RedirectableDataPointerIF { +class SpacePacketReader : public SpacePacketIF, public RedirectableDataPointerIF { protected: /** * A pointer to a structure which defines the data structure of @@ -58,16 +58,18 @@ class SpacePacketBase : public SpacePacketIF, public RedirectableDataPointerIF { * This is the minimum size of a SpacePacket. */ static const uint16_t MINIMUM_SIZE = sizeof(CCSDSPrimaryHeader) + CRC_SIZE; + SpacePacketReader(uint16_t apid, ccsds::PacketType packetType, bool secHeader, uint16_t seqCount, + uint16_t dataLen); /** * This is the default constructor. * It sets its internal data pointer to the address passed. * @param set_address The position where the packet data lies. */ - explicit SpacePacketBase(const uint8_t* set_address); + explicit SpacePacketReader(const uint8_t* set_address); /** * No data is allocated, so the destructor is empty. */ - ~SpacePacketBase() override; + ~SpacePacketReader() override; ReturnValue_t initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount = 0); diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp index 5df50cd79..29b6c5612 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp @@ -6,7 +6,7 @@ #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface/ServiceInterface.h" -CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketBase(setData) {} +CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketReader(setData) {} CFDPPacket::~CFDPPacket() {} diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h index 30ba98ae2..a70c39381 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacket.h @@ -1,9 +1,9 @@ #ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ #define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" -class CFDPPacket : public SpacePacketBase { +class CFDPPacket : public SpacePacketReader { public: /** * This is the default constructor. diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h index 91f8fe1e1..3a2eaddc7 100644 --- a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -4,76 +4,76 @@ #include class PusTcIF { - public: - virtual ~PusTcIF() = default; + public: + virtual ~PusTcIF() = default; - /** + /** * This command returns the CCSDS Secondary Header Flag. * It shall always be zero for PUS Packets. This is the * highest bit of the first byte of the Data Field Header. * @return the CCSDS Secondary Header Flag - */ - [[nodiscard]] virtual uint8_t getSecondaryHeaderFlag() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getSecondaryHeaderFlag() const = 0; + /** * This command returns the TC Packet PUS Version Number. * The version number of ECSS PUS 2003 is 1. * It consists of the second to fourth highest bits of the * first byte. * @return - */ - [[nodiscard]] virtual uint8_t getPusVersion() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getPusVersion() const = 0; + /** * This is a getter for the packet's Ack field, which are the lowest four * bits of the first byte of the Data Field Header. * * It is packed in a uint8_t variable. * @return The packet's PUS Ack field. - */ - [[nodiscard]] virtual uint8_t getAcknowledgeFlags() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getAcknowledgeFlags() const = 0; + /** * This is a getter for the packet's PUS Service ID, which is the second * byte of the Data Field Header. * @return The packet's PUS Service ID. - */ - [[nodiscard]] virtual uint8_t getService() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getService() const = 0; + /** * This is a getter for the packet's PUS Service Subtype, which is the * third byte of the Data Field Header. * @return The packet's PUS Service Subtype. - */ - [[nodiscard]] virtual uint8_t getSubService() const = 0; - /** + */ + [[nodiscard]] virtual uint8_t getSubService() const = 0; + /** * The source ID can be used to have an additional identifier, e.g. for different ground * station. * @return - */ - [[nodiscard]] virtual uint16_t getSourceId() const = 0; + */ + [[nodiscard]] virtual uint16_t getSourceId() const = 0; - /** + /** * This is a getter for a pointer to the packet's Application data. * * These are the bytes that follow after the Data Field Header. They form * the packet's application data. * @return A pointer to the PUS Application Data. - */ - [[nodiscard]] virtual const uint8_t* getApplicationData() const = 0; - /** + */ + [[nodiscard]] virtual const uint8_t* getApplicationData() const = 0; + /** * This method calculates the size of the PUS Application data field. * * It takes the information stored in the CCSDS Packet Data Length field * and subtracts the Data Field Header size and the CRC size. * @return The size of the PUS Application Data (without Error Control * field) - */ - [[nodiscard]] virtual uint16_t getApplicationDataSize() const = 0; - /** + */ + [[nodiscard]] virtual uint16_t getApplicationDataSize() const = 0; + /** * This getter returns the Error Control Field of the packet. * * The field is placed after any possible Application Data. If no * Application Data is present there's still an Error Control field. It is * supposed to be a 16bit-CRC. * @return The PUS Error Control - */ - [[nodiscard]] virtual uint16_t getErrorControl() const = 0; - }; + */ + [[nodiscard]] virtual uint16_t getErrorControl() const = 0; +}; #endif // FSFW_TMTCPACKET_PUSTCIF_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h index b3b350840..1e2e7bba0 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h @@ -4,11 +4,11 @@ #include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" #include "fsfw/tmtcpacket/SpacePacketIF.h" -class TcPacketDeserializer: public SpacePacketIF, public RedirectableDataPointerIF { +class TcPacketDeserializer : public SpacePacketIF, public RedirectableDataPointerIF { public: TcPacketDeserializer(const uint8_t* data, size_t maxSize); - private: + private: }; #endif // FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp index c9f10b4b6..faada828b 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp @@ -37,7 +37,7 @@ uint8_t TcPacketPus::getAcknowledgeFlags() const { const uint8_t *TcPacketPus::getApplicationData() const { return &tcData->appData; } uint16_t TcPacketPus::getApplicationDataSize() const { - return SpacePacketBase::getPacketDataLen() - sizeof(tcData->dataField) - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - sizeof(tcData->dataField) - CRC_SIZE + 1; } uint16_t TcPacketPus::getErrorControl() const { @@ -85,7 +85,7 @@ size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const { } ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args) { - ReturnValue_t result = SpacePacketBase::setData(dataPtr, maxSize, args); + ReturnValue_t result = SpacePacketReader::setData(dataPtr, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp index 812bae433..3d7ff8881 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.cpp @@ -6,7 +6,7 @@ #include "fsfw/globalfunctions/arrayprinter.h" #include "fsfw/serviceinterface/ServiceInterface.h" -TcPacketPusBase::TcPacketPusBase(const uint8_t* setData) : SpacePacketBase(setData) {} +TcPacketPusBase::TcPacketPusBase(const uint8_t* setData) : SpacePacketReader(setData) {} TcPacketPusBase::~TcPacketPusBase() {} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h index c84fc67d2..ce30cb18c 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h @@ -5,7 +5,7 @@ #include -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" /** * This class is the basic data handler for any ECSS PUS Telecommand packet. @@ -18,7 +18,7 @@ * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class TcPacketPusBase : public SpacePacketBase { +class TcPacketPusBase : public SpacePacketReader { friend class TcPacketStoredBase; public: diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp index e04f2b858..c81c2d4d9 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp @@ -11,12 +11,12 @@ TimeStamperIF* TmPacketBase::timeStamper = nullptr; object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT; -TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketBase(setData) {} +TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketReader(setData) {} TmPacketBase::~TmPacketBase() = default; uint16_t TmPacketBase::getSourceDataSize() { - return SpacePacketBase::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1; } uint16_t TmPacketBase::getErrorControl() { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h index 72f3abd4f..e16224663 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.h @@ -4,7 +4,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" namespace Factory { @@ -23,7 +23,7 @@ void setStaticFrameworkObjectIds(); * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class TmPacketBase : public SpacePacketBase { +class TmPacketBase : public SpacePacketReader { friend void(Factory::setStaticFrameworkObjectIds)(); public: diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp index 388a4098a..c1a5c4ba7 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.cpp @@ -5,7 +5,7 @@ #include "fsfw/tmtcpacket/pus/PacketTimestampInterpreterIF.h" -TmPacketMinimal::TmPacketMinimal(const uint8_t* set_data) : SpacePacketBase(set_data) { +TmPacketMinimal::TmPacketMinimal(const uint8_t* set_data) : SpacePacketReader(set_data) { this->tm_data = (TmPacketMinimalPointer*)set_data; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h index dc9c33aee..197bf6e6b 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketMinimal.h @@ -2,7 +2,7 @@ #define FRAMEWORK_TMTCPACKET_PUS_TMPACKETMINIMAL_H_ #include "../../../returnvalues/HasReturnvaluesIF.h" -#include "../../SpacePacketBase.h" +#include "../../SpacePacketReader.h" struct timeval; class PacketTimestampInterpreterIF; @@ -12,7 +12,7 @@ class PacketTimestampInterpreterIF; * This is required for handling TM packets with different APIDs with different * secondary headers. */ -class TmPacketMinimal : public SpacePacketBase { +class TmPacketMinimal : public SpacePacketReader { public: /** * This is the default constructor. diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp index 1a830004a..8ccb87b5c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp @@ -25,11 +25,11 @@ uint8_t TmPacketPusA::getSubService() { return tmData->data_field.service_subtyp uint8_t* TmPacketPusA::getSourceData() { return &tmData->data; } uint16_t TmPacketPusA::getSourceDataSize() { - return SpacePacketBase::getPacketDataLen() - sizeof(tmData->data_field) - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - sizeof(tmData->data_field) - CRC_SIZE + 1; } ReturnValue_t TmPacketPusA::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); + ReturnValue_t result = SpacePacketReader::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h index a84547ffe..6808a8d6a 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.h @@ -5,7 +5,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" namespace Factory { void setStaticFrameworkObjectIds(); diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index c402a5779..fd2248aa7 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -23,11 +23,11 @@ uint8_t TmPacketPusC::getSubService() { return tmData->dataField.serviceSubtype; uint8_t* TmPacketPusC::getSourceData() { return &tmData->data; } uint16_t TmPacketPusC::getSourceDataSize() { - return SpacePacketBase::getPacketDataLen() - sizeof(tmData->dataField) - CRC_SIZE + 1; + return SpacePacketReader::getPacketDataLen() - sizeof(tmData->dataField) - CRC_SIZE + 1; } ReturnValue_t TmPacketPusC::setData(uint8_t* p_Data, size_t maxSize, void* args) { - ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); + ReturnValue_t result = SpacePacketReader::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h index 4b3ca18c2..bf9de122d 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h @@ -5,7 +5,7 @@ #include "fsfw/objectmanager/SystemObjectIF.h" #include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/TimeStamperIF.h" -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" namespace Factory { void setStaticFrameworkObjectIds(); diff --git a/src/fsfw/tmtcservices/SourceSequenceCounter.h b/src/fsfw/tmtcservices/SourceSequenceCounter.h index e981a9452..836ac5e99 100644 --- a/src/fsfw/tmtcservices/SourceSequenceCounter.h +++ b/src/fsfw/tmtcservices/SourceSequenceCounter.h @@ -1,7 +1,7 @@ #ifndef FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ #define FSFW_TMTCSERVICES_SOURCESEQUENCECOUNTER_H_ -#include "../tmtcpacket/SpacePacketBase.h" +#include "../tmtcpacket/SpacePacketReader.h" class SourceSequenceCounter { private: diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index 76140c26f..6d3b63a78 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -1,11 +1,15 @@ #include -#include "fsfw/tmtcpacket/SpacePacketBase.h" +#include "fsfw/tmtcpacket/SpacePacketReader.h" TEST_CASE("CCSDS Test", "[ccsds]") { - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); + SECTION("Constexpr Helpers") { + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); - REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); - REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + } + + SECTION("Header Tests") { SpacePacketReader base = SpacePacketReader(); } }