refactored space packet interface

This commit is contained in:
Robin Müller 2022-07-18 10:20:26 +02:00
parent 3686bbc486
commit 0a7f2c6646
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
29 changed files with 218 additions and 339 deletions

View File

@ -133,7 +133,7 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF)
set(FSFW_TEST_TGT fsfw-tests) set(FSFW_TEST_TGT fsfw-tests)
set(FSFW_DUMMY_TGT fsfw-dummy) 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) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO)
set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION

View File

@ -292,7 +292,8 @@ ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes, uint32_t messag
sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg
<< " is too small for requested message depth " << messageDepth << std::endl; << " is too small for requested message depth " << messageDepth << std::endl;
sif::error << "This error can be fixed by setting the maximum " sif::error << "This error can be fixed by setting the maximum "
"allowed message depth higher" << std::endl; "allowed message depth higher"
<< std::endl;
#else #else
sif::printError( sif::printError(
"MessageQueue::MessageQueue: Default MQ size %d is too small for" "MessageQueue::MessageQueue: Default MQ size %d is too small for"

View File

@ -46,7 +46,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex
<< currentPacket.getAPID() << std::dec << std::endl; << currentPacket.getAPID() << std::dec << std::endl;
#endif #endif
auto position = this->queueMap.find(currentPacket.getAPID()); auto position = this->queueMap.find(currentPacket.getApid());
if (position != this->queueMap.end()) { if (position != this->queueMap.end()) {
return position; return position;
} else { } else {

View File

@ -11,8 +11,8 @@
TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {} TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid) : apid(setApid) {}
ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) { ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) {
TcPacketStoredBase* storedPacket = dynamic_cast<TcPacketStoredBase*>(currentPacket); auto* storedPacket = dynamic_cast<TcPacketStoredBase*>(currentPacket);
TcPacketPusBase* tcPacketBase = dynamic_cast<TcPacketPusBase*>(currentPacket); auto* tcPacketBase = dynamic_cast<TcPacketPusBase*>(currentPacket);
if (tcPacketBase == nullptr or storedPacket == nullptr) { if (tcPacketBase == nullptr or storedPacket == nullptr) {
return RETURN_FAILED; return RETURN_FAILED;
} }
@ -21,13 +21,13 @@ ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) {
if (calculated_crc != 0) { if (calculated_crc != 0) {
return INCORRECT_CHECKSUM; return INCORRECT_CHECKSUM;
} }
bool condition = (not tcPacketBase->hasSecondaryHeader()) or bool condition = (not tcPacketBase->hasSecHeader()) or
(tcPacketBase->getPacketVersionNumber() != CCSDS_VERSION_NUMBER) or (tcPacketBase->getVersion() != CCSDS_VERSION_NUMBER) or
(not tcPacketBase->isTelecommand()); (not tcPacketBase->isTc());
if (condition) { if (condition) {
return INCORRECT_PRIMARY_HEADER; return INCORRECT_PRIMARY_HEADER;
} }
if (tcPacketBase->getAPID() != this->apid) return ILLEGAL_APID; if (tcPacketBase->getApid() != this->apid) return ILLEGAL_APID;
if (not storedPacket->isSizeCorrect()) { if (not storedPacket->isSizeCorrect()) {
return INCOMPLETE_PACKET; return INCOMPLETE_PACKET;

View File

@ -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(cfdp)
add_subdirectory(packetmatcher) add_subdirectory(packetmatcher)

View File

@ -11,7 +11,7 @@
*/ */
class RedirectableDataPointerIF { class RedirectableDataPointerIF {
public: public:
virtual ~RedirectableDataPointerIF(){}; virtual ~RedirectableDataPointerIF() = default;
/** /**
* Redirect the data pointer, but allow an implementation to change the data. * 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_OK if the pointer was set successfully
* - RETURN_FAILED on general error of if the maximum size is too small * - 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: private:
}; };
#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */ #endif /* TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */

View File

@ -1,28 +0,0 @@
#include "fsfw/tmtcpacket/SpacePacket.h"
#include <cstring>
#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;
}
}

View File

@ -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_ */

View File

@ -8,12 +8,7 @@ SpacePacketBase::SpacePacketBase(const uint8_t* setAddress) {
this->data = reinterpret_cast<SpacePacketPointer*>(const_cast<uint8_t*>(setAddress)); this->data = reinterpret_cast<SpacePacketPointer*>(const_cast<uint8_t*>(setAddress));
} }
SpacePacketBase::~SpacePacketBase(){}; SpacePacketBase::~SpacePacketBase() = default;
// CCSDS Methods:
uint8_t SpacePacketBase::getPacketVersionNumber(void) {
return (this->data->header.packet_id_h & 0b11100000) >> 5;
}
ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader,
uint16_t apid, uint16_t sequenceCount) { uint16_t apid, uint16_t sequenceCount) {
@ -30,82 +25,49 @@ ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool ha
// reset header to zero: // reset header to zero:
memset(data, 0, sizeof(this->data->header)); memset(data, 0, sizeof(this->data->header));
// Set TC/TM bit. // Set TC/TM bit.
data->header.packet_id_h = ((isTelecommand ? 1 : 0)) << 4; data->header.packetIdHAndVersion = ((isTelecommand ? 1 : 0)) << 4;
// Set secondaryHeader bit // Set secondaryHeader bit
data->header.packet_id_h |= ((hasSecondaryHeader ? 1 : 0)) << 3; data->header.packetIdHAndVersion |= ((hasSecondaryHeader ? 1 : 0)) << 3;
this->setAPID(apid); this->setApid(apid);
// Always initialize as standalone packets. // Always initialize as standalone packets.
data->header.sequence_control_h = 0b11000000; data->header.packetSeqCtrlH = 0b11000000;
setPacketSequenceCount(sequenceCount); setPacketSequenceCount(sequenceCount);
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
bool SpacePacketBase::isTelecommand(void) { inline uint16_t SpacePacketBase::getPacketId() const {
return (this->data->header.packet_id_h & 0b00010000) >> 4; return ((this->data->header.packetIdHAndVersion) << 8) + this->data->header.packetIdL;
} }
bool SpacePacketBase::hasSecondaryHeader(void) { void SpacePacketBase::setApid(uint16_t setAPID) {
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) {
// Use first three bits of new APID, but keep rest of packet id as it was (see specification). // 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.packetIdHAndVersion =
(this->data->header.packet_id_h & 0b11111000) | ((new_apid & 0x0700) >> 8); (this->data->header.packetIdHAndVersion & 0b11111000) | ((setAPID & 0x0700) >> 8);
this->data->header.packet_id_l = (new_apid & 0x00FF); this->data->header.packetIdL = (setAPID & 0x00FF);
} }
void SpacePacketBase::setSequenceFlags(uint8_t sequenceflags) { void SpacePacketBase::setSequenceFlags(uint8_t sequenceflags) {
this->data->header.sequence_control_h &= 0x3F; this->data->header.packetSeqCtrlH &= 0x3F;
this->data->header.sequence_control_h |= sequenceflags << 6; this->data->header.packetSeqCtrlH |= 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;
} }
void SpacePacketBase::setPacketSequenceCount(uint16_t new_count) { void SpacePacketBase::setPacketSequenceCount(uint16_t new_count) {
this->data->header.sequence_control_h = (this->data->header.sequence_control_h & 0b11000000) | this->data->header.packetSeqCtrlH = (this->data->header.packetSeqCtrlH & 0b11000000) |
(((new_count % LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8); (((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x3F00) >> 8);
this->data->header.sequence_control_l = ((new_count % LIMIT_SEQUENCE_COUNT) & 0x00FF); this->data->header.packetSeqCtrlL = ((new_count % ccsds::LIMIT_SEQUENCE_COUNT) & 0x00FF);
}
uint16_t SpacePacketBase::getPacketDataLength() const {
return ((this->data->header.packet_length_h) << 8) + this->data->header.packet_length_l;
} }
void SpacePacketBase::setPacketDataLength(uint16_t new_length) { void SpacePacketBase::setPacketDataLength(uint16_t new_length) {
this->data->header.packet_length_h = ((new_length & 0xFF00) >> 8); this->data->header.packetLenH = ((new_length & 0xFF00) >> 8);
this->data->header.packet_length_l = (new_length & 0x00FF); this->data->header.packetLenL = (new_length & 0x00FF);
} }
size_t SpacePacketBase::getFullSize() { size_t SpacePacketBase::getFullSize() {
// +1 is done because size in packet data length field is: size of data field -1 // +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; } uint8_t* SpacePacketBase::getWholeData() { return reinterpret_cast<uint8_t*>(this->data); }
uint32_t SpacePacketBase::getApidAndSequenceCount() const {
return (getAPID() << 16) + getPacketSequenceCount();
}
uint8_t* SpacePacketBase::getPacketData() { return &(data->packet_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<SpacePacketPointer*>(const_cast<uint8_t*>(pData)); this->data = reinterpret_cast<SpacePacketPointer*>(const_cast<uint8_t*>(pData));
return HasReturnvaluesIF::RETURN_OK; 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;
}

View File

@ -5,6 +5,7 @@
#include <cstddef> #include <cstddef>
#include "SpacePacketIF.h"
#include "ccsds_header.h" #include "ccsds_header.h"
#include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h"
@ -39,7 +40,7 @@ struct SpacePacketPointer {
* the most significant bit (from left). * the most significant bit (from left).
* @ingroup tmtcpackets * @ingroup tmtcpackets
*/ */
class SpacePacketBase : virtual public RedirectableDataPointerIF { class SpacePacketBase : public SpacePacketIF, public RedirectableDataPointerIF {
protected: protected:
/** /**
* A pointer to a structure which defines the data structure of * A pointer to a structure which defines the data structure of
@ -49,11 +50,6 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF {
SpacePacketPointer* data; SpacePacketPointer* data;
public: 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. * 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. * It sets its internal data pointer to the address passed.
* @param set_address The position where the packet data lies. * @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. * No data is allocated, so the destructor is empty.
*/ */
virtual ~SpacePacketBase(); ~SpacePacketBase() override;
// 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);
ReturnValue_t initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid, ReturnValue_t initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader, uint16_t apid,
uint16_t sequenceCount = 0); uint16_t sequenceCount = 0);
/**
* The CCSDS header provides a secondary header flag (the fifth-highest bit), [[nodiscard]] uint16_t getPacketId() const override;
* which is checked with this method. [[nodiscard]] uint16_t getPacketSeqCtrl() const override;
* @return Returns true if the bit is set and false if not. [[nodiscard]] uint16_t getPacketDataLen() const override;
*/
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;
/** /**
* Sets the APID of a packet, which are the lowest 11 bit of the packet * Sets the APID of a packet, which are the lowest 11 bit of the packet
* id. * id.
* @param The APID to set. The highest five bits of the parameter are * @param The APID to set. The highest five bits of the parameter are
* ignored. * 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. * 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); 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 * Sets the packet sequence count, which are the lowest 14 bit of the
* packet sequence control field. * packet sequence control field.
@ -146,15 +97,7 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF {
* @param setCount The value to set the count to. * @param setCount The value to set the count to.
*/ */
void setPacketSequenceCount(uint16_t setCount); 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 * Sets the packet data length, which is the fifth and sixth byte of the
* CCSDS Primary Header. * CCSDS Primary Header.
@ -170,7 +113,7 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF {
* This method returns a raw uint8_t pointer to the packet. * 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. * @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(); uint8_t* getPacketData();
@ -179,14 +122,12 @@ class SpacePacketBase : virtual public RedirectableDataPointerIF {
* location. * location.
* @param p_Data A pointer to another raw Space Packet. * @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. * This method returns the full raw packet size.
* @return The full size of the packet in bytes. * @return The full size of the packet in bytes.
*/ */
size_t getFullSize(); size_t getFullSize();
uint32_t getApidAndSequenceCount() const;
}; };
#endif /* FSFW_TMTCPACKET_SPACEPACKETBASE_H_ */ #endif /* FSFW_TMTCPACKET_SPACEPACKETBASE_H_ */

View File

@ -0,0 +1,91 @@
#ifndef FSFW_TMTCPACKET_SPACEPACKETIF_H
#define FSFW_TMTCPACKET_SPACEPACKETIF_H
#include <cstdint>
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<ccsds::PacketType>((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<ccsds::SequenceFlags>(getPacketSeqCtrl() >> 14 & 0b11);
}
[[nodiscard]] virtual uint16_t getSequenceCount() const { return getPacketSeqCtrl() & 0x3FFF; }
};
#endif // FSFW_TMTCPACKET_SPACEPACKETIF_H

View File

@ -1,15 +1,15 @@
#ifndef CCSDS_HEADER_H_ #ifndef CCSDS_HEADER_H_
#define CCSDS_HEADER_H_ #define CCSDS_HEADER_H_
#include <stdint.h> #include <cstdint>
struct CCSDSPrimaryHeader { struct CCSDSPrimaryHeader {
uint8_t packet_id_h; uint8_t packetIdHAndVersion;
uint8_t packet_id_l; uint8_t packetIdL;
uint8_t sequence_control_h; uint8_t packetSeqCtrlH;
uint8_t sequence_control_l; uint8_t packetSeqCtrlL;
uint8_t packet_length_h; uint8_t packetLenH;
uint8_t packet_length_l; uint8_t packetLenL;
}; };
#endif /* CCSDS_HEADER_H_ */ #endif /* CCSDS_HEADER_H_ */

View File

@ -2,8 +2,6 @@
#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/ObjectManager.h"
StorageManagerIF* CFDPPacketStored::store = nullptr;
CFDPPacketStored::CFDPPacketStored() : CFDPPacket(nullptr) {} CFDPPacketStored::CFDPPacketStored() : CFDPPacket(nullptr) {}
CFDPPacketStored::CFDPPacketStored(store_address_t setAddress) : 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; return;
} }
if (this->checkAndSetStore()) { if (this->checkAndSetStore()) {
ReturnValue_t status = store->addData(&storeAddress, data, size); ReturnValue_t status = STORE->addData(&storeAddress, data, size);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
this->setData(nullptr, -1); this->setData(nullptr, -1, nullptr);
} }
const uint8_t* storePtr = nullptr; const uint8_t* storePtr = nullptr;
// Repoint base data pointer to the data in the store. // Repoint base data pointer to the data in the store.
store->getData(storeAddress, &storePtr, &size); STORE->getData(storeAddress, &storePtr, &size);
this->setData(const_cast<uint8_t*>(storePtr), size); this->setData(const_cast<uint8_t*>(storePtr), size, nullptr);
} }
} }
ReturnValue_t CFDPPacketStored::deletePacket() { 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; this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
// To circumvent size checks // To circumvent size checks
this->setData(nullptr, -1); this->setData(nullptr, -1, nullptr);
return result; return result;
} }
@ -43,20 +41,20 @@ void CFDPPacketStored::setStoreAddress(store_address_t setAddress) {
size_t tempSize; size_t tempSize;
ReturnValue_t status = StorageManagerIF::RETURN_FAILED; ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
if (this->checkAndSetStore()) { if (this->checkAndSetStore()) {
status = this->store->getData(this->storeAddress, &tempData, &tempSize); status = STORE->getData(this->storeAddress, &tempData, &tempSize);
} }
if (status == StorageManagerIF::RETURN_OK) { if (status == StorageManagerIF::RETURN_OK) {
this->setData(const_cast<uint8_t*>(tempData), tempSize); this->setData(const_cast<uint8_t*>(tempData), tempSize, nullptr);
} else { } else {
// To circumvent size checks // To circumvent size checks
this->setData(nullptr, -1); this->setData(nullptr, -1, nullptr);
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
} }
} }
store_address_t CFDPPacketStored::getStoreAddress() { return this->storeAddress; } store_address_t CFDPPacketStored::getStoreAddress() { return this->storeAddress; }
CFDPPacketStored::~CFDPPacketStored() {} CFDPPacketStored::~CFDPPacketStored() = default;
ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) { ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSize) {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
@ -67,9 +65,9 @@ ReturnValue_t CFDPPacketStored::getData(const uint8_t** dataPtr, size_t* dataSiz
// } // }
bool CFDPPacketStored::checkAndSetStore() { bool CFDPPacketStored::checkAndSetStore() {
if (this->store == nullptr) { if (STORE == nullptr) {
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE); STORE = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
if (this->store == nullptr) { if (STORE == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!" << std::endl; sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!" << std::endl;
#endif #endif
@ -82,7 +80,7 @@ bool CFDPPacketStored::checkAndSetStore() {
bool CFDPPacketStored::isSizeCorrect() { bool CFDPPacketStored::isSizeCorrect() {
const uint8_t* temp_data = nullptr; const uint8_t* temp_data = nullptr;
size_t temp_size; 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 (status == StorageManagerIF::RETURN_OK) {
if (this->getFullSize() == temp_size) { if (this->getFullSize() == temp_size) {
return true; return true;

View File

@ -39,13 +39,6 @@ class CFDPPacketStored : public CFDPPacket, public TcPacketStoredBase {
bool isSizeCorrect(); bool isSizeCorrect();
protected: 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. * The address where the packet data of the object instance is stored.
*/ */

View File

@ -10,23 +10,26 @@ class ApidMatcher : public SerializeableMatcherIF<TmPacketMinimal*> {
uint16_t apid; uint16_t apid;
public: public:
ApidMatcher(uint16_t setApid) : apid(setApid) {} explicit ApidMatcher(uint16_t setApid) : apid(setApid) {}
ApidMatcher(TmPacketMinimal* test) : apid(test->getAPID()) {} explicit ApidMatcher(TmPacketMinimal* test) : apid(test->getApid()) {}
bool match(TmPacketMinimal* packet) { bool match(TmPacketMinimal* packet) override {
if (packet->getAPID() == apid) { if (packet->getApid() == apid) {
return true; return true;
} else { } else {
return false; return false;
} }
} }
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, 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); return SerializeAdapter::serialize(&apid, buffer, size, maxSize, streamEndianness);
} }
size_t getSerializedSize() const { return SerializeAdapter::getSerializedSize(&apid); } [[nodiscard]] size_t getSerializedSize() const override {
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, Endianness streamEndianness) { return SerializeAdapter::getSerializedSize(&apid);
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override {
return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness); return SerializeAdapter::deSerialize(&apid, buffer, size, streamEndianness);
} }
}; };
#endif /* FRAMEWORK_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */ #endif /* FSFW_TMTCPACKET_PACKETMATCHER_APIDMATCHER_H_ */

View File

@ -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_type = type;
data.data_field.service_subtype = subtype; data.data_field.service_subtype = subtype;
TmPacketMinimal testPacket((uint8_t*)&data); TmPacketMinimal testPacket((uint8_t*)&data);
testPacket.setAPID(apid); testPacket.setApid(apid);
iterator lastTest; iterator lastTest;
iterator rollback; iterator rollback;
ReturnValue_t result = 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_type = type;
data.data_field.service_subtype = subtype; data.data_field.service_subtype = subtype;
TmPacketMinimal testPacket((uint8_t*)&data); TmPacketMinimal testPacket((uint8_t*)&data);
testPacket.setAPID(apid); testPacket.setApid(apid);
iterator foundElement = findMatch(begin(), &testPacket); iterator foundElement = findMatch(begin(), &testPacket);
if (foundElement == this->end()) { if (foundElement == this->end()) {
return NO_MATCH; return NO_MATCH;

View File

@ -37,7 +37,7 @@ uint8_t TcPacketPus::getAcknowledgeFlags() const {
const uint8_t *TcPacketPus::getApplicationData() const { return &tcData->appData; } const uint8_t *TcPacketPus::getApplicationData() const { return &tcData->appData; }
uint16_t TcPacketPus::getApplicationDataSize() const { 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 { 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 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) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -63,7 +63,7 @@ class TcPacketPus : public TcPacketPusBase {
size_t calculateFullPacketLength(size_t appDataLen) const override; size_t calculateFullPacketLength(size_t appDataLen) const override;
protected: 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. * Initializes the Tc Packet header.

View File

@ -18,7 +18,7 @@
* check can be performed by making use of the getWholeData method. * check can be performed by making use of the getWholeData method.
* @ingroup tmtcpackets * @ingroup tmtcpackets
*/ */
class TcPacketPusBase : public SpacePacketBase, virtual public RedirectableDataPointerIF { class TcPacketPusBase : public SpacePacketBase {
friend class TcPacketStoredBase; friend class TcPacketStoredBase;
public: public:

View File

@ -21,7 +21,7 @@ TcPacketStoredPus::TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t sub
#endif #endif
return; 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 #if FSFW_USE_PUS_C_TELECOMMANDS == 1
pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION; pus::PusVersion pusVersion = pus::PusVersion::PUS_C_VERSION;
#else #else
@ -46,12 +46,12 @@ TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size) : TcPacke
if (this->checkAndSetStore()) { if (this->checkAndSetStore()) {
ReturnValue_t status = STORE->addData(&storeAddress, data, size); ReturnValue_t status = STORE->addData(&storeAddress, data, size);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
this->setData(nullptr, size); this->setData(nullptr, size, nullptr);
} }
const uint8_t* storePtr = nullptr; const uint8_t* storePtr = nullptr;
// Repoint base data pointer to the data in the store. // Repoint base data pointer to the data in the store.
STORE->getData(storeAddress, &storePtr, &size); STORE->getData(storeAddress, &storePtr, &size);
this->setData(const_cast<uint8_t*>(storePtr), size); this->setData(const_cast<uint8_t*>(storePtr), size, nullptr);
} }
} }
@ -59,7 +59,7 @@ ReturnValue_t TcPacketStoredPus::deletePacket() {
ReturnValue_t result = this->STORE->deleteData(this->storeAddress); ReturnValue_t result = this->STORE->deleteData(this->storeAddress);
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS; this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
// To circumvent size checks // To circumvent size checks
this->setData(nullptr, -1); this->setData(nullptr, -1, nullptr);
return result; return result;
} }

View File

@ -13,12 +13,10 @@ object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT;
TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketBase(setData) {} TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketBase(setData) {}
TmPacketBase::~TmPacketBase() { TmPacketBase::~TmPacketBase() = default;
// Nothing to do.
}
uint16_t TmPacketBase::getSourceDataSize() { uint16_t TmPacketBase::getSourceDataSize() {
return getPacketDataLength() - getDataFieldSize() - CRC_SIZE + 1; return SpacePacketBase::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1;
} }
uint16_t TmPacketBase::getErrorControl() { uint16_t TmPacketBase::getErrorControl() {
@ -41,9 +39,9 @@ ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const {
} }
bool TmPacketBase::checkAndSetStamper() { bool TmPacketBase::checkAndSetStamper() {
if (timeStamper == NULL) { if (timeStamper == nullptr) {
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId); timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId);
if (timeStamper == NULL) { if (timeStamper == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl; sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl;
#else #else

View File

@ -25,11 +25,11 @@ uint8_t TmPacketPusA::getSubService() { return tmData->data_field.service_subtyp
uint8_t* TmPacketPusA::getSourceData() { return &tmData->data; } uint8_t* TmPacketPusA::getSourceData() { return &tmData->data; }
uint16_t TmPacketPusA::getSourceDataSize() { 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 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) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }

View File

@ -14,9 +14,7 @@ TmPacketPusC::TmPacketPusC(uint8_t* setData) : TmPacketBase(setData) {
tmData = reinterpret_cast<TmPacketPointerPusC*>(setData); tmData = reinterpret_cast<TmPacketPointerPusC*>(setData);
} }
TmPacketPusC::~TmPacketPusC() { TmPacketPusC::~TmPacketPusC() = default;
// Nothing to do.
}
uint8_t TmPacketPusC::getService() { return tmData->dataField.serviceType; } 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; } uint8_t* TmPacketPusC::getSourceData() { return &tmData->data; }
uint16_t TmPacketPusC::getSourceDataSize() { 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 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) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -64,9 +62,9 @@ ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, u
(pus::PusVersion::PUS_C_VERSION << 4) | timeRefField; (pus::PusVersion::PUS_C_VERSION << 4) | timeRefField;
tmData->dataField.serviceType = service; tmData->dataField.serviceType = service;
tmData->dataField.serviceSubtype = subservice; tmData->dataField.serviceSubtype = subservice;
tmData->dataField.subcounterMsb = packetSubcounter << 8 & 0xff; tmData->dataField.subcounterMsb = (packetSubcounter << 8) & 0xff;
tmData->dataField.subcounterLsb = packetSubcounter & 0xff; tmData->dataField.subcounterLsb = packetSubcounter & 0xff;
tmData->dataField.destinationIdMsb = destinationId << 8 & 0xff; tmData->dataField.destinationIdMsb = (destinationId << 8) & 0xff;
tmData->dataField.destinationIdLsb = destinationId & 0xff; tmData->dataField.destinationIdLsb = destinationId & 0xff;
// Timestamp packet // Timestamp packet
if (TmPacketBase::checkAndSetStamper()) { if (TmPacketBase::checkAndSetStamper()) {

View File

@ -114,7 +114,7 @@ class TmPacketPusC : public TmPacketBase {
* *
* @param pData A pointer to another PUS Telemetry Packet. * @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). * In case data was filled manually (almost never the case).

View File

@ -26,7 +26,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s
handleStoreFailure("C", returnValue, sizeToReserve); handleStoreFailure("C", returnValue, sizeToReserve);
return; return;
} }
setData(pData, sizeToReserve); setData(pData, sizeToReserve, nullptr);
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
memcpy(getSourceData(), headerData, headerSize); memcpy(getSourceData(), headerData, headerSize);
memcpy(getSourceData() + headerSize, data, size); memcpy(getSourceData() + headerSize, data, size);
@ -56,7 +56,7 @@ TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t s
handleStoreFailure("C", returnValue, sizeToReserve); handleStoreFailure("C", returnValue, sizeToReserve);
return; return;
} }
TmPacketPusC::setData(pData, sizeToReserve); TmPacketPusC::setData(pData, sizeToReserve, nullptr);
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField); initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
uint8_t *putDataHere = getSourceData(); uint8_t *putDataHere = getSourceData();
size_t size = 0; 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(); } uint8_t *TmPacketStoredPusC::getAllTmData() { return getWholeData(); }
ReturnValue_t TmPacketStoredPusC::setData(uint8_t *newPointer, size_t maxSize, void *args) { ReturnValue_t TmPacketStoredPusC::setData(uint8_t *newPointer, size_t maxSize, void *args) {
return TmPacketPusC::setData(newPointer, maxSize); return TmPacketPusC::setData(newPointer, maxSize, args);
} }

View File

@ -66,7 +66,7 @@ class TmPacketStoredPusC : public TmPacketStoredBase, public TmPacketPusC {
* @param args * @param args
* @return * @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_ */ #endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */

View File

@ -350,7 +350,7 @@ void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket, Comm
iter->second.command = command.getCommand(); iter->second.command = command.getCommand();
iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags(); iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
iter->second.tcInfo.tcPacketId = storedPacket->getPacketId(); iter->second.tcInfo.tcPacketId = storedPacket->getPacketId();
iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSequenceControl(); iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSeqCtrl();
acceptPacket(tc_verification::START_SUCCESS, storedPacket); acceptPacket(tc_verification::START_SUCCESS, storedPacket);
} else { } else {
command.clearCommandMessage(); command.clearCommandMessage();

View File

@ -22,8 +22,8 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, TcPacketPusB
return; return;
} }
PusVerificationMessage message(set_report_id, currentPacket->getAcknowledgeFlags(), PusVerificationMessage message(set_report_id, currentPacket->getAcknowledgeFlags(),
currentPacket->getPacketId(), currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(), 0,
currentPacket->getPacketSequenceControl(), 0, set_step); set_step);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -59,9 +59,9 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, TcPacketPusBase*
if (currentPacket == nullptr) { if (currentPacket == nullptr) {
return; return;
} }
PusVerificationMessage message( PusVerificationMessage message(report_id, currentPacket->getAcknowledgeFlags(),
report_id, currentPacket->getAcknowledgeFlags(), currentPacket->getPacketId(), currentPacket->getPacketId(), currentPacket->getPacketSeqCtrl(),
currentPacket->getPacketSequenceControl(), error_code, step, parameter1, parameter2); error_code, step, parameter1, parameter2);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message); ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
if (status != HasReturnvaluesIF::RETURN_OK) { if (status != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1

View File

@ -1,11 +1,11 @@
#include <catch2/catch_test_macros.hpp> #include <catch2/catch_test_macros.hpp>
#include "fsfw/tmtcpacket/SpacePacket.h" #include "fsfw/tmtcpacket/SpacePacketBase.h"
TEST_CASE("CCSDS Test", "[ccsds]") { TEST_CASE("CCSDS Test", "[ccsds]") {
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x22) == 0x1822); REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x22) == 0x1822);
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x22) == 0x0822); REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x22) == 0x0822);
REQUIRE(spacepacket::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff); REQUIRE(ccsds::getTcSpacePacketIdFromApid(0x7ff) == 0x1fff);
REQUIRE(spacepacket::getTmSpacePacketIdFromApid(0x7ff) == 0xfff); REQUIRE(ccsds::getTmSpacePacketIdFromApid(0x7ff) == 0xfff);
} }