From 0a7f2c6646481e1af22afa667aea9abac0497ce0 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 18 Jul 2022 10:20:26 +0200 Subject: [PATCH] refactored space packet interface --- CMakeLists.txt | 2 +- src/fsfw/osal/linux/MessageQueue.cpp | 3 +- src/fsfw/tcdistribution/CCSDSDistributor.cpp | 2 +- src/fsfw/tcdistribution/TcPacketCheckPUS.cpp | 12 +-- src/fsfw/tmtcpacket/CMakeLists.txt | 2 +- .../tmtcpacket/RedirectableDataPointerIF.h | 9 +- src/fsfw/tmtcpacket/SpacePacket.cpp | 28 ------ src/fsfw/tmtcpacket/SpacePacket.h | 89 ------------------ src/fsfw/tmtcpacket/SpacePacketBase.cpp | 86 ++++++------------ src/fsfw/tmtcpacket/SpacePacketBase.h | 85 +++-------------- src/fsfw/tmtcpacket/SpacePacketIF.h | 91 +++++++++++++++++++ src/fsfw/tmtcpacket/ccsds_header.h | 14 +-- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp | 30 +++--- src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h | 7 -- .../tmtcpacket/packetmatcher/ApidMatcher.h | 19 ++-- .../packetmatcher/PacketMatchTree.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp | 4 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h | 2 +- src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h | 2 +- .../tmtcpacket/pus/tc/TcPacketStoredPus.cpp | 8 +- src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp | 10 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp | 4 +- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp | 12 +-- src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h | 2 +- .../tmtcpacket/pus/tm/TmPacketStoredPusC.cpp | 6 +- .../tmtcpacket/pus/tm/TmPacketStoredPusC.h | 2 +- .../tmtcservices/CommandingServiceBase.cpp | 2 +- .../tmtcservices/VerificationReporter.cpp | 10 +- .../fsfw_tests/unit/tmtcpacket/testCcsds.cpp | 10 +- 29 files changed, 218 insertions(+), 339 deletions(-) delete mode 100644 src/fsfw/tmtcpacket/SpacePacket.cpp delete mode 100644 src/fsfw/tmtcpacket/SpacePacket.h create mode 100644 src/fsfw/tmtcpacket/SpacePacketIF.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e9e3e4716..440d7f9bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,7 @@ 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}) +add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION diff --git a/src/fsfw/osal/linux/MessageQueue.cpp b/src/fsfw/osal/linux/MessageQueue.cpp index 4ef7f7568..ec2121651 100644 --- a/src/fsfw/osal/linux/MessageQueue.cpp +++ b/src/fsfw/osal/linux/MessageQueue.cpp @@ -292,7 +292,8 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg << " is too small for requested message depth " << messageDepth << std::endl; sif::error << "This error can be fixed by setting the maximum " - "allowed message depth higher" << std::endl; + "allowed message depth higher" + << std::endl; #else sif::printError( "MessageQueue::MessageQueue: Default MQ size %d is too small for" diff --git a/src/fsfw/tcdistribution/CCSDSDistributor.cpp b/src/fsfw/tcdistribution/CCSDSDistributor.cpp index 628dd8d06..0be177bf4 100644 --- a/src/fsfw/tcdistribution/CCSDSDistributor.cpp +++ b/src/fsfw/tcdistribution/CCSDSDistributor.cpp @@ -46,7 +46,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex << currentPacket.getAPID() << std::dec << std::endl; #endif - auto position = this->queueMap.find(currentPacket.getAPID()); + auto position = this->queueMap.find(currentPacket.getApid()); if (position != this->queueMap.end()) { return position; } else { diff --git a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp index 838443372..6d7092e58 100644 --- a/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp +++ b/src/fsfw/tcdistribution/TcPacketCheckPUS.cpp @@ -11,8 +11,8 @@ TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {} ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { - TcPacketStoredBase* storedPacket = dynamic_cast(currentPacket); - TcPacketPusBase* tcPacketBase = dynamic_cast(currentPacket); + auto* storedPacket = dynamic_cast(currentPacket); + auto* tcPacketBase = dynamic_cast(currentPacket); if (tcPacketBase == nullptr or storedPacket == nullptr) { return RETURN_FAILED; } @@ -21,13 +21,13 @@ ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { if (calculated_crc != 0) { return INCORRECT_CHECKSUM; } - bool condition = (not tcPacketBase->hasSecondaryHeader()) or - (tcPacketBase->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or - (not tcPacketBase->isTelecommand()); + bool condition = (not tcPacketBase->hasSecHeader()) or + (tcPacketBase->getVersion() != CCSDS_VERSION_NUMBER) or + (not tcPacketBase->isTc()); if (condition) { return INCORRECT_PRIMARY_HEADER; } - if (tcPacketBase->getAPID() != this->apid) return ILLEGAL_APID; + if (tcPacketBase->getApid() != this->apid) return ILLEGAL_APID; if (not storedPacket->isSizeCorrect()) { return INCOMPLETE_PACKET; diff --git a/src/fsfw/tmtcpacket/CMakeLists.txt b/src/fsfw/tmtcpacket/CMakeLists.txt index 196ba7528..dc09c9c9f 100644 --- a/src/fsfw/tmtcpacket/CMakeLists.txt +++ b/src/fsfw/tmtcpacket/CMakeLists.txt @@ -1,4 +1,4 @@ -target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacket.cpp SpacePacketBase.cpp) +target_sources(${LIB_FSFW_NAME} PRIVATE SpacePacketBase.cpp) add_subdirectory(cfdp) add_subdirectory(packetmatcher) diff --git a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h index 364feb4e3..6eb16eddf 100644 --- a/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h +++ b/src/fsfw/tmtcpacket/RedirectableDataPointerIF.h @@ -11,7 +11,7 @@ */ class RedirectableDataPointerIF { public: - virtual ~RedirectableDataPointerIF(){}; + virtual ~RedirectableDataPointerIF() = default; /** * Redirect the data pointer, but allow an implementation to change the data. @@ -25,9 +25,12 @@ class RedirectableDataPointerIF { * - RETURN_OK if the pointer was set successfully * - RETURN_FAILED on general error of if the maximum size is too small */ - virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) = 0; + virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) = 0; + virtual ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize) { + return setData(dataPtr, maxSize, nullptr); + } private: }; -#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */ +#endif /* TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */ diff --git a/src/fsfw/tmtcpacket/SpacePacket.cpp b/src/fsfw/tmtcpacket/SpacePacket.cpp deleted file mode 100644 index 16d968fb9..000000000 --- a/src/fsfw/tmtcpacket/SpacePacket.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "fsfw/tmtcpacket/SpacePacket.h" - -#include - -#include "fsfw/tmtcpacket/ccsds_header.h" - -SpacePacket::SpacePacket(uint16_t packetDataLength, bool isTelecommand, uint16_t apid, - uint16_t sequenceCount) - : SpacePacketBase((uint8_t*)&this->localData) { - initSpacePacketHeader(isTelecommand, false, apid, sequenceCount); - this->setPacketSequenceCount(sequenceCount); - if (packetDataLength <= sizeof(this->localData.fields.buffer)) { - this->setPacketDataLength(packetDataLength); - } else { - this->setPacketDataLength(sizeof(this->localData.fields.buffer)); - } -} - -SpacePacket::~SpacePacket(void) {} - -bool SpacePacket::addWholeData(const uint8_t* p_Data, uint32_t packet_size) { - if (packet_size <= sizeof(this->localData)) { - memcpy(this->localData.byteStream, p_Data, packet_size); - return true; - } else { - return false; - } -} diff --git a/src/fsfw/tmtcpacket/SpacePacket.h b/src/fsfw/tmtcpacket/SpacePacket.h deleted file mode 100644 index 10140db10..000000000 --- a/src/fsfw/tmtcpacket/SpacePacket.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef SPACEPACKET_H_ -#define SPACEPACKET_H_ - -#include "SpacePacketBase.h" - -/** - * The SpacePacket class is a representation of a simple CCSDS Space Packet - * without (control over) a secondary header. - * It can be instantiated with a size smaller than \c PACKET_MAX_SIZE. Its - * main use is to serve as an idle packet in case no other packets are sent. - * For the ECSS PUS part the TcPacket and TmPacket classes are used. - * A pointer to \c local_data is passed to the \c SpacePacketBase parent class, - * so the parent's methods are reachable. - * @ingroup tmtcpackets - */ -class SpacePacket : public SpacePacketBase { - public: - static const uint16_t PACKET_MAX_SIZE = 1024; - /** - * The constructor initializes the packet and sets all header information - * according to the passed parameters. - * @param packetDataLength Sets the packet data length field and therefore specifies - * the size of the packet. - * @param isTelecommand Sets the packet type field to either TC (true) or TM (false). - * @param apid Sets the packet's APID field. The default value describes an idle packet. - * @param sequenceCount ets the packet's Source Sequence Count field. - */ - SpacePacket(uint16_t packetDataLength, bool isTelecommand = false, - uint16_t apid = APID_IDLE_PACKET, uint16_t sequenceCount = 0); - /** - * The class's default destructor. - */ - virtual ~SpacePacket(); - /** - * With this call, the complete data content (including the CCSDS Primary - * Header) is overwritten with the byte stream given. - * @param p_data Pointer to data to overwrite the content with - * @param packet_size Size of the data - * @return @li \c true if packet_size is smaller than \c MAX_PACKET_SIZE. - * @li \c false else. - */ - bool addWholeData(const uint8_t* p_data, uint32_t packet_size); - - protected: - /** - * This structure defines the data structure of a Space Packet as local data. - * There's a buffer which corresponds to the Space Packet Data Field with a - * maximum size of \c PACKET_MAX_SIZE. - */ - struct PacketStructured { - CCSDSPrimaryHeader header; - uint8_t buffer[PACKET_MAX_SIZE]; - }; - /** - * This union simplifies accessing the full data content of the Space Packet. - * This is achieved by putting the \c PacketStructured struct in a union with - * a plain buffer. - */ - union SpacePacketData { - PacketStructured fields; - uint8_t byteStream[PACKET_MAX_SIZE + sizeof(CCSDSPrimaryHeader)]; - }; - /** - * This is the data representation of the class. - * It is a struct of CCSDS Primary Header and a data field, which again is - * packed in an union, so the data can be accessed as a byte stream without - * a cast. - */ - SpacePacketData localData; -}; - -namespace spacepacket { - -constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, - bool secondaryHeaderFlag = true) { - return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); -} - -constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { - return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); -} - -constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { - return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); -} - -} // namespace spacepacket - -#endif /* SPACEPACKET_H_ */ diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.cpp b/src/fsfw/tmtcpacket/SpacePacketBase.cpp index 756d7e508..cb18519ef 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.cpp +++ b/src/fsfw/tmtcpacket/SpacePacketBase.cpp @@ -8,12 +8,7 @@ SpacePacketBase::SpacePacketBase(const uint8_t* setAddress) { this->data = reinterpret_cast(const_cast(setAddress)); } -SpacePacketBase::~SpacePacketBase(){}; - -// CCSDS Methods: -uint8_t SpacePacketBase::getPacketVersionNumber(void) { - return (this->data->header.packet_id_h & 0b11100000) >> 5; -} +SpacePacketBase::~SpacePacketBase() = default; ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount) { @@ -30,82 +25,49 @@ ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool ha // reset header to zero: memset(data, 0, sizeof(this->data->header)); // Set TC/TM bit. - data->header.packet_id_h = ((isTelecommand ? 1 : 0)) << 4; + data->header.packetIdHAndVersion = ((isTelecommand ? 1 : 0)) << 4; // Set secondaryHeader bit - data->header.packet_id_h |= ((hasSecondaryHeader ? 1 : 0)) << 3; - this->setAPID(apid); + data->header.packetIdHAndVersion |= ((hasSecondaryHeader ? 1 : 0)) << 3; + this->setApid(apid); // Always initialize as standalone packets. - data->header.sequence_control_h = 0b11000000; + data->header.packetSeqCtrlH = 0b11000000; setPacketSequenceCount(sequenceCount); return HasReturnvaluesIF::RETURN_OK; } -bool SpacePacketBase::isTelecommand(void) { - return (this->data->header.packet_id_h & 0b00010000) >> 4; +inline uint16_t SpacePacketBase::getPacketId() const { + return ((this->data->header.packetIdHAndVersion) << 8) + this->data->header.packetIdL; } -bool SpacePacketBase::hasSecondaryHeader(void) { - return (this->data->header.packet_id_h & 0b00001000) >> 3; -} - -uint16_t SpacePacketBase::getPacketId() { - return ((this->data->header.packet_id_h) << 8) + this->data->header.packet_id_l; -} - -uint16_t SpacePacketBase::getAPID(void) const { - return ((this->data->header.packet_id_h & 0b00000111) << 8) + this->data->header.packet_id_l; -} - -void SpacePacketBase::setAPID(uint16_t new_apid) { +void SpacePacketBase::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.packet_id_h = - (this->data->header.packet_id_h & 0b11111000) | ((new_apid & 0x0700) >> 8); - this->data->header.packet_id_l = (new_apid & 0x00FF); + this->data->header.packetIdHAndVersion = + (this->data->header.packetIdHAndVersion & 0b11111000) | ((setAPID & 0x0700) >> 8); + this->data->header.packetIdL = (setAPID & 0x00FF); } void SpacePacketBase::setSequenceFlags(uint8_t sequenceflags) { - this->data->header.sequence_control_h &= 0x3F; - this->data->header.sequence_control_h |= sequenceflags << 6; -} - -uint16_t SpacePacketBase::getPacketSequenceControl(void) { - return ((this->data->header.sequence_control_h) << 8) + this->data->header.sequence_control_l; -} - -uint8_t SpacePacketBase::getSequenceFlags(void) { - return (this->data->header.sequence_control_h & 0b11000000) >> 6; -} - -uint16_t SpacePacketBase::getPacketSequenceCount(void) const { - return ((this->data->header.sequence_control_h & 0b00111111) << 8) + - this->data->header.sequence_control_l; + this->data->header.packetSeqCtrlH &= 0x3F; + this->data->header.packetSeqCtrlH |= sequenceflags << 6; } void SpacePacketBase::setPacketSequenceCount(uint16_t new_count) { - this->data->header.sequence_control_h = (this->data->header.sequence_control_h & 0b11000000) | - (((new_count % LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8); - this->data->header.sequence_control_l = ((new_count % LIMIT_SEQUENCE_COUNT) & 0x00FF); -} - -uint16_t SpacePacketBase::getPacketDataLength() const { - return ((this->data->header.packet_length_h) << 8) + this->data->header.packet_length_l; + 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) { - this->data->header.packet_length_h = ((new_length & 0xFF00) >> 8); - this->data->header.packet_length_l = (new_length & 0x00FF); + this->data->header.packetLenH = ((new_length & 0xFF00) >> 8); + this->data->header.packetLenL = (new_length & 0x00FF); } size_t SpacePacketBase::getFullSize() { // +1 is done because size in packet data length field is: size of data field -1 - return this->getPacketDataLength() + sizeof(this->data->header) + 1; + return this->getPacketDataLen() + sizeof(this->data->header) + 1; } -uint8_t* SpacePacketBase::getWholeData() { return (uint8_t*)this->data; } - -uint32_t SpacePacketBase::getApidAndSequenceCount() const { - return (getAPID() << 16) + getPacketSequenceCount(); -} +uint8_t* SpacePacketBase::getWholeData() { return reinterpret_cast(this->data); } uint8_t* SpacePacketBase::getPacketData() { return &(data->packet_data); } @@ -116,3 +78,11 @@ ReturnValue_t SpacePacketBase::setData(uint8_t* pData, size_t maxSize, void* arg this->data = reinterpret_cast(const_cast(pData)); return HasReturnvaluesIF::RETURN_OK; } +uint16_t SpacePacketBase::getPacketSeqCtrl() const { + return ((this->data->header.packetSeqCtrlH & 0b00111111) << 8) + + this->data->header.packetSeqCtrlL; +} + +uint16_t SpacePacketBase::getPacketDataLen() const { + return ((this->data->header.packetLenH) << 8) + this->data->header.packetLenL; +} diff --git a/src/fsfw/tmtcpacket/SpacePacketBase.h b/src/fsfw/tmtcpacket/SpacePacketBase.h index d9ee2b83a..862e4725e 100644 --- a/src/fsfw/tmtcpacket/SpacePacketBase.h +++ b/src/fsfw/tmtcpacket/SpacePacketBase.h @@ -5,6 +5,7 @@ #include +#include "SpacePacketIF.h" #include "ccsds_header.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" @@ -39,7 +40,7 @@ struct SpacePacketPointer { * the most significant bit (from left). * @ingroup tmtcpackets */ -class SpacePacketBase : virtual public RedirectableDataPointerIF { +class SpacePacketBase : public SpacePacketIF, public RedirectableDataPointerIF { protected: /** * A pointer to a structure which defines the data structure of @@ -49,11 +50,6 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { SpacePacketPointer* data; public: - static const uint16_t LIMIT_APID = 2048; // 2^1 - static const uint16_t LIMIT_SEQUENCE_COUNT = 16384; // 2^14 - static const uint16_t APID_IDLE_PACKET = 0x7FF; - static const uint8_t TELECOMMAND_PACKET = 1; - static const uint8_t TELEMETRY_PACKET = 0; /** * This definition defines the CRC size in byte. */ @@ -67,53 +63,26 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * It sets its internal data pointer to the address passed. * @param set_address The position where the packet data lies. */ - SpacePacketBase(const uint8_t* set_address); + explicit SpacePacketBase(const uint8_t* set_address); /** * No data is allocated, so the destructor is empty. */ - virtual ~SpacePacketBase(); - - // CCSDS Methods: - /** - * Getter for the packet version number field. - * @return Returns the highest three bit of the packet in one byte. - */ - uint8_t getPacketVersionNumber(void); - /** - * This method checks the type field in the header. - * This bit specifies, if the command is interpreted as Telecommand of - * as Telemetry. For a Telecommand, the bit is set. - * @return Returns true if the bit is set and false if not. - */ - bool isTelecommand(void); + ~SpacePacketBase() override; ReturnValue_t initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, uint16_t sequenceCount = 0); - /** - * The CCSDS header provides a secondary header flag (the fifth-highest bit), - * which is checked with this method. - * @return Returns true if the bit is set and false if not. - */ - bool hasSecondaryHeader(void); - /** - * Returns the complete first two bytes of the packet, which together form - * the CCSDS packet id. - * @return The CCSDS packet id. - */ - uint16_t getPacketId(void); - /** - * Returns the APID of a packet, which are the lowest 11 bit of the packet - * id. - * @return The CCSDS APID. - */ - uint16_t getAPID(void) const; + + [[nodiscard]] uint16_t getPacketId() const override; + [[nodiscard]] uint16_t getPacketSeqCtrl() const override; + [[nodiscard]] uint16_t getPacketDataLen() const override; + /** * Sets the APID of a packet, which are the lowest 11 bit of the packet * id. * @param The APID to set. The highest five bits of the parameter are * ignored. */ - void setAPID(uint16_t setAPID); + void setApid(uint16_t setAPID); /** * Sets the sequence flags of a packet, which are bit 17 and 18 in the space packet header. @@ -121,24 +90,6 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { */ void setSequenceFlags(uint8_t sequenceflags); - /** - * Returns the CCSDS packet sequence control field, which are the third and - * the fourth byte of the CCSDS primary header. - * @return The CCSDS packet sequence control field. - */ - uint16_t getPacketSequenceControl(void); - /** - * Returns the SequenceFlags, which are the highest two bit of the packet - * sequence control field. - * @return The CCSDS sequence flags. - */ - uint8_t getSequenceFlags(void); - /** - * Returns the packet sequence count, which are the lowest 14 bit of the - * packet sequence control field. - * @return The CCSDS sequence count. - */ - uint16_t getPacketSequenceCount(void) const; /** * Sets the packet sequence count, which are the lowest 14 bit of the * packet sequence control field. @@ -146,15 +97,7 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * @param setCount The value to set the count to. */ void setPacketSequenceCount(uint16_t setCount); - /** - * Returns the packet data length, which is the fifth and sixth byte of the - * CCSDS Primary Header. The packet data length is the size of every kind - * of data \b after the CCSDS Primary Header \b -1. - * @return - * The CCSDS packet data length. uint16_t is sufficient, - * because this is limit in CCSDS standard - */ - uint16_t getPacketDataLength(void) const; + /** * Sets the packet data length, which is the fifth and sixth byte of the * CCSDS Primary Header. @@ -170,7 +113,7 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * This method returns a raw uint8_t pointer to the packet. * @return A \c uint8_t pointer to the first byte of the CCSDS primary header. */ - virtual uint8_t* getWholeData(void); + virtual uint8_t* getWholeData(); uint8_t* getPacketData(); @@ -179,14 +122,12 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF { * location. * @param p_Data A pointer to another raw Space Packet. */ - virtual ReturnValue_t setData(uint8_t* p_Data, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* p_Data, size_t maxSize, void* args) override; /** * This method returns the full raw packet size. * @return The full size of the packet in bytes. */ size_t getFullSize(); - - uint32_t getApidAndSequenceCount() const; }; #endif /* FSFW_TMTCPACKET_SPACEPACKETBASE_H_ */ diff --git a/src/fsfw/tmtcpacket/SpacePacketIF.h b/src/fsfw/tmtcpacket/SpacePacketIF.h new file mode 100644 index 000000000..291ba8f9b --- /dev/null +++ b/src/fsfw/tmtcpacket/SpacePacketIF.h @@ -0,0 +1,91 @@ +#ifndef FSFW_TMTCPACKET_SPACEPACKETIF_H +#define FSFW_TMTCPACKET_SPACEPACKETIF_H + +#include + +namespace ccsds { + +enum PacketType : uint8_t { TM = 0, TC = 1 }; + +enum SequenceFlags : uint8_t { + CONTINUATION = 0b00, + FIRST_SEGMENT = 0b01, + LAST_SEGMENT = 0b10, + UNSEGMENTED = 0b11 +}; + +static const uint16_t LIMIT_APID = 2048; // 2^11 +static const uint16_t LIMIT_SEQUENCE_COUNT = 16384; // 2^14 +static const uint16_t APID_IDLE_PACKET = 0x7FF; + +constexpr uint16_t getSpacePacketIdFromApid(bool isTc, uint16_t apid, + bool secondaryHeaderFlag = true) { + return ((isTc << 4) | (secondaryHeaderFlag << 3) | ((apid >> 8) & 0x07)) << 8 | (apid & 0x00ff); +} + +constexpr uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { + return getSpacePacketIdFromApid(true, apid, secondaryHeaderFlag); +} + +constexpr uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag = true) { + return getSpacePacketIdFromApid(false, apid, secondaryHeaderFlag); +} + +} // namespace ccsds + +class SpacePacketIF { + public: + virtual ~SpacePacketIF() = default; + + /** + * Returns the complete first two bytes of the packet, which together form + * the CCSDS packet ID + * @return The CCSDS packet ID + */ + [[nodiscard]] virtual uint16_t getPacketId() const = 0; + /** + * Returns the third and the fourth byte of the CCSDS header which are the packet sequence + * control field + * @return + */ + [[nodiscard]] virtual uint16_t getPacketSeqCtrl() const = 0; + /** + * Returns the fifth and the sixth byte of the CCSDS header which is the packet length field + * @return + */ + [[nodiscard]] virtual uint16_t getPacketDataLen() const = 0; + + [[nodiscard]] virtual uint16_t getApid() const { + uint16_t packetId = getPacketId(); + // Uppermost 11 bits of packet ID + return ((packetId >> 8) & 0b111) | (packetId & 0xFF); + } + + [[nodiscard]] virtual uint8_t getVersion() const { + uint16_t packetId = getPacketId(); + return (packetId >> 13) & 0b111; + } + + [[nodiscard]] virtual ccsds::PacketType getPacketType() const { + return static_cast((getPacketId() >> 12) & 0b1); + } + + [[nodiscard]] virtual bool isTc() const { return getPacketType() == ccsds::PacketType::TC; } + + [[nodiscard]] virtual bool isTm() const { return not isTc(); } + + /** + * The CCSDS header provides a secondary header flag (the fifth-highest bit), + * which is checked with this method. + * @return Returns true if the bit is set and false if not. + */ + [[nodiscard]] virtual bool hasSecHeader() const { return (getPacketId() >> 11) & 0b1; } + + [[nodiscard]] virtual ccsds::SequenceFlags getSequenceFlags() const { + return static_cast(getPacketSeqCtrl() >> 14 & 0b11); + } + + [[nodiscard]] virtual uint16_t getSequenceCount() const { return getPacketSeqCtrl() & 0x3FFF; } +}; + +#endif // FSFW_TMTCPACKET_SPACEPACKETIF_H diff --git a/src/fsfw/tmtcpacket/ccsds_header.h b/src/fsfw/tmtcpacket/ccsds_header.h index 232790c08..c0db194ee 100644 --- a/src/fsfw/tmtcpacket/ccsds_header.h +++ b/src/fsfw/tmtcpacket/ccsds_header.h @@ -1,15 +1,15 @@ #ifndef CCSDS_HEADER_H_ #define CCSDS_HEADER_H_ -#include +#include struct CCSDSPrimaryHeader { - uint8_t packet_id_h; - uint8_t packet_id_l; - uint8_t sequence_control_h; - uint8_t sequence_control_l; - uint8_t packet_length_h; - uint8_t packet_length_l; + uint8_t packetIdHAndVersion; + uint8_t packetIdL; + uint8_t packetSeqCtrlH; + uint8_t packetSeqCtrlL; + uint8_t packetLenH; + uint8_t packetLenL; }; #endif /* CCSDS_HEADER_H_ */ diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp index 9a410b40b..260331ac3 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp @@ -2,8 +2,6 @@ #include "fsfw/objectmanager/ObjectManager.h" -StorageManagerIF* CFDPPacketStored::store = nullptr; - CFDPPacketStored::CFDPPacketStored() : CFDPPacket(nullptr) {} CFDPPacketStored::CFDPPacketStored(store_address_t setAddress) : CFDPPacket(nullptr) { @@ -15,22 +13,22 @@ CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size) : CFDPPacke return; } if (this->checkAndSetStore()) { - ReturnValue_t status = store->addData(&storeAddress, data, size); + ReturnValue_t status = STORE->addData(&storeAddress, data, size); if (status != HasReturnvaluesIF::RETURN_OK) { - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); } const uint8_t* storePtr = nullptr; // Repoint base data pointer to the data in the store. - store->getData(storeAddress, &storePtr, &size); - this->setData(const_cast(storePtr), size); + STORE->getData(storeAddress, &storePtr, &size); + this->setData(const_cast(storePtr), size, nullptr); } } ReturnValue_t CFDPPacketStored::deletePacket() { - ReturnValue_t result = this->store->deleteData(this->storeAddress); + ReturnValue_t result = STORE->deleteData(this->storeAddress); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; // To circumvent size checks - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); return result; } @@ -43,20 +41,20 @@ void CFDPPacketStored::setStoreAddress(store_address_t setAddress) { size_t tempSize; ReturnValue_t status = StorageManagerIF::RETURN_FAILED; if (this->checkAndSetStore()) { - status = this->store->getData(this->storeAddress, &tempData, &tempSize); + status = STORE->getData(this->storeAddress, &tempData, &tempSize); } if (status == StorageManagerIF::RETURN_OK) { - this->setData(const_cast(tempData), tempSize); + this->setData(const_cast(tempData), tempSize, nullptr); } else { // To circumvent size checks - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; } } store_address_t CFDPPacketStored::getStoreAddress() { return this->storeAddress; } -CFDPPacketStored::~CFDPPacketStored() {} +CFDPPacketStored::~CFDPPacketStored() = default; ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { return HasReturnvaluesIF::RETURN_OK; @@ -67,9 +65,9 @@ ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSiz // } bool CFDPPacketStored::checkAndSetStore() { - if (this->store == nullptr) { - this->store = ObjectManager::instance()->get(objects::TC_STORE); - if (this->store == nullptr) { + if (STORE == nullptr) { + STORE = ObjectManager::instance()->get(objects::TC_STORE); + if (STORE == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!" << std::endl; #endif @@ -82,7 +80,7 @@ bool CFDPPacketStored::checkAndSetStore() { bool CFDPPacketStored::isSizeCorrect() { const uint8_t* temp_data = nullptr; size_t temp_size; - ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data, &temp_size); + ReturnValue_t status = STORE->getData(this->storeAddress, &temp_data, &temp_size); if (status == StorageManagerIF::RETURN_OK) { if (this->getFullSize() == temp_size) { return true; diff --git a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h index f9c73bdd9..688067f90 100644 --- a/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h +++ b/src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h @@ -39,13 +39,6 @@ class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase { bool isSizeCorrect(); protected: - /** - * This is a pointer to the store all instances of the class use. - * If the store is not yet set (i.e. @c store is NULL), every constructor - * call tries to set it and throws an error message in case of failures. - * The default store is objects::TC_STORE. - */ - static StorageManagerIF* store; /** * The address where the packet data of the object instance is stored. */ diff --git a/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h b/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h index cf4c88f20..3c835ef81 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h +++ b/src/fsfw/tmtcpacket/packetmatcher/ApidMatcher.h @@ -10,23 +10,26 @@ class ApidMatcher : public SerializeableMatcherIF { uint16_t apid; public: - ApidMatcher(uint16_t setApid) : apid(setApid) {} - ApidMatcher(TmPacketMinimal* test) : apid(test->getAPID()) {} - bool match(TmPacketMinimal* packet) { - if (packet->getAPID() == apid) { + explicit ApidMatcher(uint16_t setApid) : apid(setApid) {} + explicit ApidMatcher(TmPacketMinimal* test) : apid(test->getApid()) {} + bool match(TmPacketMinimal* packet) override { + if (packet->getApid() == apid) { return true; } else { return false; } } ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const { + Endianness streamEndianness) const override { return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness); } - size_t getSerializedSize() const { return SerializeAdapter::getSerializedSize(&apid); } - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { + [[nodiscard]] size_t getSerializedSize() const override { + return SerializeAdapter::getSerializedSize(&apid); + } + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override { return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness); } }; -#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */ +#endif /* FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */ diff --git a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp index 6b900030d..55fd3227a 100644 --- a/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp +++ b/src/fsfw/tmtcpacket/packetmatcher/PacketMatchTree.cpp @@ -34,7 +34,7 @@ ReturnValue_t PacketMatchTree::addMatch(uint16_t apid, uint8_t type, uint8_t sub data.data_field.service_type = type; data.data_field.service_subtype = subtype; TmPacketMinimal testPacket((uint8_t*)&data); - testPacket.setAPID(apid); + testPacket.setApid(apid); iterator lastTest; iterator rollback; ReturnValue_t result = @@ -126,7 +126,7 @@ ReturnValue_t PacketMatchTree::removeMatch(uint16_t apid, uint8_t type, uint8_t data.data_field.service_type = type; data.data_field.service_subtype = subtype; TmPacketMinimal testPacket((uint8_t*)&data); - testPacket.setAPID(apid); + testPacket.setApid(apid); iterator foundElement = findMatch(begin(), &testPacket); if (foundElement == this->end()) { return NO_MATCH; diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.cpp index f5ebe38c3..c9f10b4b6 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 getPacketDataLength() - sizeof(tcData->dataField) - CRC_SIZE + 1; + return SpacePacketBase::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); + ReturnValue_t result = SpacePacketBase::setData(dataPtr, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h index 47173dad7..b630cfeec 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPus.h @@ -63,7 +63,7 @@ class TcPacketPus : public TcPacketPusBase { size_t calculateFullPacketLength(size_t appDataLen) const override; protected: - ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override; /** * Initializes the Tc Packet header. diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h index 9f1d07ed6..c84fc67d2 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h @@ -18,7 +18,7 @@ * check can be performed by making use of the getWholeData method. * @ingroup tmtcpackets */ -class TcPacketPusBase : public SpacePacketBase, virtual public RedirectableDataPointerIF { +class TcPacketPusBase : public SpacePacketBase { friend class TcPacketStoredBase; public: diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp index 643c2ecca..95350ac28 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.cpp @@ -21,7 +21,7 @@ TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t sub #endif return; } - this->setData(pData, TC_PACKET_MIN_SIZE + size); + this->setData(pData, TC_PACKET_MIN_SIZE + size, nullptr); #if FSFW_USE_PUS_C_TELECOMMANDS == 1 pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION; #else @@ -46,12 +46,12 @@ TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size) : TcPacke if (this->checkAndSetStore()) { ReturnValue_t status = STORE->addData(&storeAddress, data, size); if (status != HasReturnvaluesIF::RETURN_OK) { - this->setData(nullptr, size); + this->setData(nullptr, size, nullptr); } const uint8_t* storePtr = nullptr; // Repoint base data pointer to the data in the store. STORE->getData(storeAddress, &storePtr, &size); - this->setData(const_cast(storePtr), size); + this->setData(const_cast(storePtr), size, nullptr); } } @@ -59,7 +59,7 @@ ReturnValue_t TcPacketStoredPus::deletePacket() { ReturnValue_t result = this->STORE->deleteData(this->storeAddress); this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; // To circumvent size checks - this->setData(nullptr, -1); + this->setData(nullptr, -1, nullptr); return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp index bc761d0d8..e04f2b858 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketBase.cpp @@ -13,12 +13,10 @@ object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT; TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketBase(setData) {} -TmPacketBase::~TmPacketBase() { - // Nothing to do. -} +TmPacketBase::~TmPacketBase() = default; uint16_t TmPacketBase::getSourceDataSize() { - return getPacketDataLength() - getDataFieldSize() - CRC_SIZE + 1; + return SpacePacketBase::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1; } uint16_t TmPacketBase::getErrorControl() { @@ -41,9 +39,9 @@ ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const { } bool TmPacketBase::checkAndSetStamper() { - if (timeStamper == NULL) { + if (timeStamper == nullptr) { timeStamper = ObjectManager::instance()->get(timeStamperId); - if (timeStamper == NULL) { + if (timeStamper == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl; #else diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusA.cpp index e8f717172..1a830004a 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 getPacketDataLength() - sizeof(tmData->data_field) - CRC_SIZE + 1; + return SpacePacketBase::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); + ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp index ab690414d..c402a5779 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.cpp @@ -14,9 +14,7 @@ TmPacketPusC::TmPacketPusC(uint8_t* setData) : TmPacketBase(setData) { tmData = reinterpret_cast(setData); } -TmPacketPusC::~TmPacketPusC() { - // Nothing to do. -} +TmPacketPusC::~TmPacketPusC() = default; uint8_t TmPacketPusC::getService() { return tmData->dataField.serviceType; } @@ -25,11 +23,11 @@ uint8_t TmPacketPusC::getSubService() { return tmData->dataField.serviceSubtype; uint8_t* TmPacketPusC::getSourceData() { return &tmData->data; } uint16_t TmPacketPusC::getSourceDataSize() { - return getPacketDataLength() - sizeof(tmData->dataField) - CRC_SIZE + 1; + return SpacePacketBase::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); + ReturnValue_t result = SpacePacketBase::setData(p_Data, maxSize, args); if (result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -64,9 +62,9 @@ ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, u (pus::PusVersion::PUS_C_VERSION << 4) | timeRefField; tmData->dataField.serviceType = service; tmData->dataField.serviceSubtype = subservice; - tmData->dataField.subcounterMsb = packetSubcounter << 8 & 0xff; + tmData->dataField.subcounterMsb = (packetSubcounter << 8) & 0xff; tmData->dataField.subcounterLsb = packetSubcounter & 0xff; - tmData->dataField.destinationIdMsb = destinationId << 8 & 0xff; + tmData->dataField.destinationIdMsb = (destinationId << 8) & 0xff; tmData->dataField.destinationIdLsb = destinationId & 0xff; // Timestamp packet if (TmPacketBase::checkAndSetStamper()) { diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h index bbd69693a..4b3ca18c2 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketPusC.h @@ -114,7 +114,7 @@ class TmPacketPusC : public TmPacketBase { * * @param pData A pointer to another PUS Telemetry Packet. */ - ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args) override; /** * In case data was filled manually (almost never the case). diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp index 9c170aa37..5ade4191c 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.cpp @@ -26,7 +26,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s handleStoreFailure("C", returnValue, sizeToReserve); return; } - setData(pData, sizeToReserve); + setData(pData, sizeToReserve, nullptr); initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); memcpy(getSourceData(), headerData, headerSize); memcpy(getSourceData() + headerSize, data, size); @@ -56,7 +56,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s handleStoreFailure("C", returnValue, sizeToReserve); return; } - TmPacketPusC::setData(pData, sizeToReserve); + TmPacketPusC::setData(pData, sizeToReserve, nullptr); initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); uint8_t *putDataHere = getSourceData(); size_t size = 0; @@ -72,5 +72,5 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s uint8_t *TmPacketStoredPusC::getAllTmData() { return getWholeData(); } ReturnValue_t TmPacketStoredPusC::setData(uint8_t *newPointer, size_t maxSize, void *args) { - return TmPacketPusC::setData(newPointer, maxSize); + return TmPacketPusC::setData(newPointer, maxSize, args); } diff --git a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h index ef84e2383..fe65e2ca2 100644 --- a/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h +++ b/src/fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h @@ -66,7 +66,7 @@ class TmPacketStoredPusC : public TmPacketStoredBase, public TmPacketPusC { * @param args * @return */ - ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args = nullptr) override; + ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args) override; }; #endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */ diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index bbdf8d2af..37232c496 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -350,7 +350,7 @@ void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, Comm iter->second.command = command.getCommand(); iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags(); iter->second.tcInfo.tcPacketId = storedPacket->getPacketId(); - iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSequenceControl(); + iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSeqCtrl(); acceptPacket(tc_verification::START_SUCCESS, storedPacket); } else { command.clearCommandMessage(); diff --git a/src/fsfw/tmtcservices/VerificationReporter.cpp b/src/fsfw/tmtcservices/VerificationReporter.cpp index 9d06adc4e..19277bf3c 100644 --- a/src/fsfw/tmtcservices/VerificationReporter.cpp +++ b/src/fsfw/tmtcservices/VerificationReporter.cpp @@ -22,8 +22,8 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, TcPacketPusB return; } PusVerificationMessage message(set_report_id, currentPacket->getAcknowledgeFlags(), - currentPacket->getPacketId(), - currentPacket->getPacketSequenceControl(), 0, set_step); + currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(), 0, + set_step); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -59,9 +59,9 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, TcPacketPusBase* if (currentPacket == nullptr) { return; } - PusVerificationMessage message( - report_id, currentPacket->getAcknowledgeFlags(), currentPacket->getPacketId(), - currentPacket->getPacketSequenceControl(), error_code, step, parameter1, parameter2); + PusVerificationMessage message(report_id, currentPacket->getAcknowledgeFlags(), + currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(), + error_code, step, parameter1, parameter2); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); if (status != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp index d395449d4..76140c26f 100644 --- a/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp +++ b/tests/src/fsfw_tests/unit/tmtcpacket/testCcsds.cpp @@ -1,11 +1,11 @@ #include -#include "fsfw/tmtcpacket/SpacePacket.h" +#include "fsfw/tmtcpacket/SpacePacketBase.h" TEST_CASE("CCSDS Test", "[ccsds]") { - REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822); - REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822); - REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); - REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); + REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); + REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); }