CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
CCSDS::Packet Class Reference

Represents a CCSDS (Consultative Committee for Space Data Systems) packet. More...

#include <CCSDSPacket.h>

Collaboration diagram for CCSDS::Packet:
[legend]

Public Member Functions

 Packet ()=default
 
void setPrimaryHeader (PrimaryHeader data)
 Sets the primary header using the provided PrimaryHeader object.
 
ResultBool setPrimaryHeader (std::uint64_t data)
 Sets the primary header using the provided 64-bit data.
 
ResultBool setPrimaryHeader (const std::vector< std::uint8_t > &data)
 Sets the primary header using the provided vector of std::uint8_tdata.
 
void setPrimaryHeader (const Header &header)
 Sets the primary header using the provided header object.
 
void setDataFieldHeader (const std::shared_ptr< SecondaryHeaderAbstract > &header)
 Sets the data field header using the provided SecondaryHeaderAbstract derived header.
 
template<typename T >
ResultBool RegisterSecondaryHeader ()
 Registers a new header type with the data field secondary header creation function.
 
ResultBool setDataFieldHeader (const std::vector< std::uint8_t > &data, const std::string &headerType)
 Sets the data field header for the packet using a vector of bytes.
 
ResultBool setDataFieldHeader (const std::uint8_t *pData, size_t sizeData, const std::string &headerType)
 Sets the data field header for the packet using a raw data pointer.
 
ResultBool setDataFieldHeader (const std::vector< std::uint8_t > &data)
 Sets the data field header using the provided vector of bytes.
 
ResultBool setDataFieldHeader (const std::uint8_t *pData, size_t sizeData)
 Sets the data field header using the provided pointer and size.
 
ResultBool setApplicationData (const std::vector< std::uint8_t > &data)
 Sets the application data for the packet.
 
ResultBool setApplicationData (const std::uint8_t *pData, size_t sizeData)
 Sets the application data for the packet.
 
void setSequenceFlags (ESequenceFlag flags)
 Sets the sequence flags for the packet's primary header.
 
ResultBool setSequenceCount (std::uint16_t count)
 Sets the sequence count for the packet.
 
void setDataFieldSize (std::uint16_t size)
 Sets the maximum data packet size for the CCSDS DataField.
 
void setUpdatePacketEnable (bool enable)
 needs to be called as soon as possible, probably also from constructor.
 
ResultBool deserialize (const std::vector< std::uint8_t > &data)
 Deserializes a vector of bytes into a CCSDS packet.
 
ResultBool deserialize (const std::vector< std::uint8_t > &data, const std::string &headerType, std::int32_t headerSize=-1)
 Deserializes a CCSDS packet using a vector and a registered header type.
 
ResultBool deserialize (const std::vector< uint8_t > &data, std::uint16_t headerDataSizeBytes)
 Deserializes a CCSDS packet using a vector and a header data size.
 
ResultBool deserialize (const std::vector< uint8_t > &headerData, const std::vector< uint8_t > &data)
 Deserializes a CCSDS packet using separate header and data vectors.
 
std::uint64_t getPrimaryHeader64bit ()
 Retrieves the primary header of the packet.
 
std::uint16_t getFullPacketLength ()
 Retrieves the current size of the CCSDS Packet.
 
std::vector< uint8_t > serialize ()
 Retrieves the full packet as a vector of bytes.
 
std::vector< uint8_t > getPrimaryHeaderBytes ()
 Retrieves the primary header of the packet as a vector of bytes.
 
std::vector< uint8_t > getDataFieldHeaderBytes ()
 Retrieves the secondary header data from the data field.
 
std::vector< uint8_t > getApplicationDataBytes ()
 Retrieves the application data from the data field.
 
std::vector< uint8_t > getFullDataFieldBytes ()
 Retrieves the full data field data.
 
std::vector< uint8_t > getCRCVectorBytes ()
 Retrieves the CRC-16 checksum as a vector of bytes.
 
std::uint16_t getCRC ()
 Computes and retrieves the CRC-16 checksum of the packet.
 
std::uint16_t getDataFieldMaximumSize () const
 returns the maximum data field size
 
bool getDataFieldHeaderFlag ()
 @ returns the data field header flag
 
DataFieldgetDataField ()
 returns the CCSDS packet's DataField.
 
HeadergetPrimaryHeader ()
 returns the CCSDS packet's Primary Header.
 
void setCrcConfig (const CRC16Config crcConfig)
 Sets the crc configuration of the crc calculation.
 
void setCrcConfig (const std::uint16_t polynomial, const std::uint16_t initialValue, const std::uint16_t finalXorValue)
 Sets the crc configuration of the crc calculation.
 
void update ()
 Updates Primary headers data field size.
 
ResultBool loadFromConfigFile (const std::string &configPath)
 Loads a packet from a configuration file, including secondary header if present.
 
ResultBool loadFromConfig (const Config &cfg)
 Loads a packet from a configuration object, including secondary header if present.
 

Private Attributes

Header m_primaryHeader {}
 6 bytes / 48 bits / 12 hex
 
DataField m_dataField {}
 variable
 
std::uint16_t m_CRC16 {}
 Cyclic Redundancy check 16 bits.
 
CRC16Config m_CRC16Config
 structure holding configuration of crc calculation.
 
bool m_updateStatus {false}
 When setting data thus value should be set to false.
 
bool m_enableUpdatePacket {true}
 Enables primary header and secondary header update.
 
std::uint16_t m_sequenceCounter {0}
 

Detailed Description

Represents a CCSDS (Consultative Committee for Space Data Systems) packet.

This class provides functionality to construct and manage a CCSDS packet, which includes both the primary header and the data field. It allows setting and getting the primary header, data field headers (PusA, PusB, PusC), and application data. The packet also includes a CRC-16 checksum for error detection.

The class provides methods for managing the packet's data structure, including printing the headers and data field, calculating the CRC-16, and combining the primary header, data field, and CRC into a complete packet. The header is updated automatically when necessary, and it provides both raw and vector representations of the data for further use or transmission.

The Packet class also handles the internal state for CRC calculation and header updates to ensure data consistency.

Definition at line 59 of file CCSDSPacket.h.

Constructor & Destructor Documentation

◆ Packet()

CCSDS::Packet::Packet ( )
default

Member Function Documentation

◆ deserialize() [1/4]

CCSDS::ResultBool CCSDS::Packet::deserialize ( const std::vector< std::uint8_t > &  data)

Deserializes a vector of bytes into a CCSDS packet.

Definition at line 173 of file CCSDSPacket.cpp.

173 {
175 "Cannot Deserialize Packet, Invalid Data provided data size must be at least 8 bytes");
176
177 std::vector<std::uint8_t> dataFieldVector;
178 std::copy(data.begin() + 6, data.end(), std::back_inserter(dataFieldVector));
179
180 FORWARD_RESULT(deserialize({data[0], data[1], data[2], data[3], data[4], data[5]}, dataFieldVector));
181
182 return true;
183}
#define RET_IF_ERR_MSG(condition, errorCode, message)
Macro to return an error with an error message if a condition is met.
#define FORWARD_RESULT(result)
Macro to return a result as-is (for functions returning Result<T>).
ResultBool deserialize(const std::vector< std::uint8_t > &data)
Deserializes a vector of bytes into a CCSDS packet.
@ INVALID_HEADER_DATA
Header data is invalid.
Definition CCSDSResult.h:25
Here is the caller graph for this function:

◆ deserialize() [2/4]

CCSDS::ResultBool CCSDS::Packet::deserialize ( const std::vector< std::uint8_t > &  data,
const std::string &  headerType,
std::int32_t  headerSize = -1 
)

Deserializes a CCSDS packet using a vector and a registered header type.

Definition at line 185 of file CCSDSPacket.cpp.

185 {
186 RET_IF_ERR_MSG(data.size() <= 8, ErrorCode::INVALID_DATA,
187 "Cannot Deserialize Packet, Invalid Data provided data size must be at least 8 bytes");
188 RET_IF_ERR_MSG(headerType == "BufferHeader", ErrorCode::INVALID_SECONDARY_HEADER_DATA,
189 "Cannot Deserialize Packet, BufferHeader is not of defined size");
192 "Cannot Deserialize Packet, Unregistered Secondary header: " + headerType);
193 std::uint16_t headerDataSizeBytes{0};
194 const auto secondaryHeader = m_dataField.getDataFieldHeaderFactory().create(headerType);
195 if (headerType == "PusC" && headerSize > 0) {
196 headerDataSizeBytes = headerSize;
197 }else {
198 headerDataSizeBytes = secondaryHeader->getSize();
199 }
200
201 std::vector<std::uint8_t> dataFieldHeaderVector;
202 std::copy_n(data.begin() + 6, headerDataSizeBytes, std::back_inserter(dataFieldHeaderVector));
203 FORWARD_RESULT(secondaryHeader->deserialize(dataFieldHeaderVector ));
204 setDataFieldHeader(secondaryHeader);
205
206 if (data.size() > (8 + headerDataSizeBytes)) {
207 std::vector<std::uint8_t> dataFieldVector;
208
209 if (data.size() > (9 + headerDataSizeBytes)) {
210 std::copy(data.begin() + 6 + headerDataSizeBytes, data.end(), std::back_inserter(dataFieldVector));
211 }
212 FORWARD_RESULT(deserialize({data[0], data[1], data[2], data[3], data[4], data[5]}, dataFieldVector));
213 }
214
215 return true;
216}
SecondaryHeaderFactory & getDataFieldHeaderFactory()
returns the secondary header factory
void setDataFieldHeader(const std::shared_ptr< SecondaryHeaderAbstract > &header)
Sets the data field header using the provided SecondaryHeaderAbstract derived header.
DataField m_dataField
variable
std::shared_ptr< SecondaryHeaderAbstract > create(const std::string &type)
Creates an instance of a registered header type.
bool typeIsRegistered(const std::string &type)
Checks if a header type is registered.
@ INVALID_DATA
Data is invalid.
Definition CCSDSResult.h:24
@ INVALID_SECONDARY_HEADER_DATA
Secondary header data is invalid.
Definition CCSDSResult.h:26

◆ deserialize() [3/4]

ResultBool CCSDS::Packet::deserialize ( const std::vector< uint8_t > &  data,
std::uint16_t  headerDataSizeBytes 
)

Deserializes a CCSDS packet using a vector and a header data size.

◆ deserialize() [4/4]

ResultBool CCSDS::Packet::deserialize ( const std::vector< uint8_t > &  headerData,
const std::vector< uint8_t > &  data 
)

Deserializes a CCSDS packet using separate header and data vectors.

◆ getApplicationDataBytes()

std::vector< std::uint8_t > CCSDS::Packet::getApplicationDataBytes ( )

Retrieves the application data from the data field.

Returns
A vector containing the Application data.

Definition at line 148 of file CCSDSPacket.cpp.

148 {
149 update();
151}
std::vector< std::uint8_t > getApplicationData()
Retrieves the application data from the data field.
void update()
Updates Primary headers data field size.

◆ getCRC()

uint16_t CCSDS::Packet::getCRC ( )

Computes and retrieves the CRC-16 checksum of the packet.

If the CRC-16 has not already been calculated, this function computes it using the full data field of the packet. The result is cached for future calls to improve performance.

Returns
The 16-bit CRC-16 checksum.

Definition at line 101 of file CCSDSPacket.cpp.

101 {
102 update();
103 return m_CRC16;
104}
std::uint16_t m_CRC16
Cyclic Redundancy check 16 bits.
Here is the caller graph for this function:

◆ getCRCVectorBytes()

std::vector< std::uint8_t > CCSDS::Packet::getCRCVectorBytes ( )

Retrieves the CRC-16 checksum as a vector of bytes.

The checksum is split into its most significant byte (MSB) and least significant byte (LSB) and stored in a two-element vector.

Returns
A vector containing the MSB and LSB of the CRC-16 checksum.

Definition at line 115 of file CCSDSPacket.cpp.

115 {
116 std::vector<std::uint8_t> crc(2);
117 const auto crcVar = getCRC();
118 crc[0] = (crcVar >> 8) & 0xFF; // MSB (Most Significant Byte)
119 crc[1] = crcVar & 0xFF; // LSB (Least Significant Byte)
120 return crc;
121}
std::uint16_t getCRC()
Computes and retrieves the CRC-16 checksum of the packet.

◆ getDataField()

CCSDS::DataField & CCSDS::Packet::getDataField ( )

returns the CCSDS packet's DataField.

Definition at line 123 of file CCSDSPacket.cpp.

123 {
124 update();
125 return m_dataField;
126}
Here is the caller graph for this function:

◆ getDataFieldHeaderBytes()

std::vector< std::uint8_t > CCSDS::Packet::getDataFieldHeaderBytes ( )

Retrieves the secondary header data from the data field.

Returns
A vector containing the Secondary header data.

Definition at line 143 of file CCSDSPacket.cpp.

143 {
144 update();
146}
std::vector< std::uint8_t > getDataFieldHeaderBytes()
Retrieves the secondary header data as a vector of bytes.

◆ getDataFieldHeaderFlag()

bool CCSDS::Packet::getDataFieldHeaderFlag ( )

@ returns the data field header flag

Definition at line 110 of file CCSDSPacket.cpp.

110 {
111 update();
113}
std::uint8_t getDataFieldHeaderFlag() const
1 bits
Definition CCSDSHeader.h:86
Header m_primaryHeader
6 bytes / 48 bits / 12 hex

◆ getDataFieldMaximumSize()

uint16_t CCSDS::Packet::getDataFieldMaximumSize ( ) const

returns the maximum data field size

Definition at line 106 of file CCSDSPacket.cpp.

106 {
108}
std::uint16_t getDataFieldAvailableBytesSize() const
Retrieves the available size of the data field in bytes.

◆ getFullDataFieldBytes()

std::vector< std::uint8_t > CCSDS::Packet::getFullDataFieldBytes ( )

Retrieves the full data field data.

i.e. Application data and Secondary header data if applicable.

Returns
A vector containing the data field data.

Definition at line 153 of file CCSDSPacket.cpp.

153 {
154 return m_dataField.serialize();
155}
std::vector< std::uint8_t > serialize()
Retrieves the full data field by combining the data field header and application data.

◆ getFullPacketLength()

uint16_t CCSDS::Packet::getFullPacketLength ( )

Retrieves the current size of the CCSDS Packet.

Returns
16bit unsigned integer

Definition at line 253 of file CCSDSPacket.cpp.

253 {
254 // where 8 is derived from 6 bytes for Primary header and 2 bytes for CRC16.
256}
std::uint16_t getDataFieldUsedBytesSize() const
Retrieves the used size of the data field in bytes.

◆ getPrimaryHeader()

CCSDS::Header & CCSDS::Packet::getPrimaryHeader ( )

returns the CCSDS packet's Primary Header.

Definition at line 128 of file CCSDSPacket.cpp.

128 {
129 update();
130 return m_primaryHeader;
131}
Here is the caller graph for this function:

◆ getPrimaryHeader64bit()

uint64_t CCSDS::Packet::getPrimaryHeader64bit ( )

Retrieves the primary header of the packet.

This function ensures that the primary header is updated by calling the updatePrimaryHeader() function, and then returns the full 48-bit primary header as a 64-bit integer.

Returns
The 64-bit primary header of the packet.

Definition at line 133 of file CCSDSPacket.cpp.

133 {
134 update();
136};
std::uint64_t getFullHeader()
Computes and retrieves the full header as a 64-bit value.

◆ getPrimaryHeaderBytes()

std::vector< std::uint8_t > CCSDS::Packet::getPrimaryHeaderBytes ( )

Retrieves the primary header of the packet as a vector of bytes.

Extracts the 48-bit primary header and converts it into a six-element vector, ordered from the most significant byte (MSB) to the least significant byte (LSB).

Returns
A vector containing the six bytes of the primary header.

Definition at line 138 of file CCSDSPacket.cpp.

138 {
139 update();
140 return m_primaryHeader.serialize();
141}
std::vector< std::uint8_t > serialize()
decomposes the Primary header class and returns it as a vector of bytes.

◆ loadFromConfig()

CCSDS::ResultBool CCSDS::Packet::loadFromConfig ( const Config cfg)

Loads a packet from a configuration object, including secondary header if present.

Parameters
cfgconfiguration object.
Returns
ResultBool

Definition at line 37 of file CCSDSPacket.cpp.

37 {
38 std::uint8_t versionNumber;
39 std::uint8_t type;
40 std::uint8_t APID{0};
41 std::uint8_t dataFieldHeaderFlag;
42 std::uint16_t sequenceCount;
43 ESequenceFlag sequenceFlag{};
44 bool segmented{false};
45
46 RET_IF_ERR_MSG(!cfg.isKey( "ccsds_version_number"), ErrorCode::CONFIG_FILE_ERROR,
47 "Config: Missing int field: ccsds_version_number");
49 "Config: Missing bool field: ccsds_type");
50 RET_IF_ERR_MSG(!cfg.isKey("ccsds_data_field_header_flag"), ErrorCode::CONFIG_FILE_ERROR,
51 "Config: Missing bool field: ccsds_data_field_header_flag");
53 "Config: Missing int field: ccsds_APID");
54 RET_IF_ERR_MSG(!cfg.isKey( "ccsds_segmented"), ErrorCode::CONFIG_FILE_ERROR,
55 "Config: Missing bool field: ccsds_segmented");
56
57 ASSIGN_OR_PRINT(versionNumber, cfg.get< int>( "ccsds_version_number"));
58 ASSIGN_OR_PRINT(type, cfg.get<bool>( "ccsds_type"));
59 ASSIGN_OR_PRINT(dataFieldHeaderFlag, cfg.get<bool>("ccsds_data_field_header_flag"));
60 ASSIGN_OR_PRINT(APID, cfg.get< int>( "ccsds_APID"));
61 ASSIGN_OR_PRINT(segmented, cfg.get<bool>( "ccsds_segmented"));
62
63 m_primaryHeader.setVersionNumber(versionNumber);
65 m_primaryHeader.setDataFieldHeaderFlag(dataFieldHeaderFlag);
67 if (segmented) {
68 sequenceCount = 1;
69 sequenceFlag = FIRST_SEGMENT;
70 }else {
71 sequenceCount = 0;
72 sequenceFlag = UNSEGMENTED;
73 }
75 m_primaryHeader.setSequenceCount(sequenceCount);
76
77 if (cfg.isKey( "data_field_size")) { // optional field
78 std::uint16_t dataFieldSize;
79 ASSIGN_OR_PRINT(dataFieldSize, cfg.get< int>( "data_field_size"));
80 m_dataField.setDataPacketSize(dataFieldSize);
81 }
82
83 if (cfg.isKey("define_secondary_header")) { // optional field
84 bool secondaryHeaderFlag{false};
85 ASSIGN_OR_PRINT(secondaryHeaderFlag, cfg.get<bool>("define_secondary_header"));
86 if (secondaryHeaderFlag) {
88 }
89 }
90
91 if (cfg.isKey("application_data")) { // optional field
92 std::vector<std::uint8_t> applicationData{};
93 ASSIGN_OR_PRINT(applicationData, cfg.get<std::vector<std::uint8_t>>("application_data"));
95 }
96
97 return true;
98}
#define ASSIGN_OR_PRINT(var, result)
Macro to assign a result value or print an error message.
void setDataPacketSize(const std::uint16_t &value)
Sets the maximum data packet size for the CCSDS DataField.
ResultBool setDataFieldHeader(const std::uint8_t *pData, const size_t &sizeData)
Sets the secondary header data for the data field.
ResultBool setApplicationData(const std::vector< std::uint8_t > &applicationData)
Sets the application data using a vector of bytes.
void setType(const std::uint8_t &value)
1 bits
void setVersionNumber(const std::uint8_t &value)
3 bits
void setAPID(const std::uint16_t &value)
11 bits
void setSequenceCount(const std::uint16_t &value)
14 bits
void setDataFieldHeaderFlag(const std::uint8_t &value)
1 bits
void setSequenceFlags(const std::uint8_t &value)
2 bits
bool isKey(const std::string &key) const
CCSDS::Result< T > get(const std::string &key) const
Get value by key and type.
Definition CCSDSConfig.h:20
@ CONFIG_FILE_ERROR
Configuration file error.
Definition CCSDSResult.h:34
ESequenceFlag
Represents the sequence flags used in CCSDS telemetry transfer frames.
Definition CCSDSHeader.h:19
@ UNSEGMENTED
11 Complete packet in a single frame.
Definition CCSDSHeader.h:23
@ FIRST_SEGMENT
01 First segment of a new packet.
Definition CCSDSHeader.h:21
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromConfigFile()

CCSDS::ResultBool CCSDS::Packet::loadFromConfigFile ( const std::string &  configPath)

Loads a packet from a configuration file, including secondary header if present.

Parameters
configPathpath to the configuration file.
Returns
ResultBool

Definition at line 30 of file CCSDSPacket.cpp.

30 {
31 Config cfg;
32 cfg.load(configPath);
34 return true;
35}
ResultBool loadFromConfig(const Config &cfg)
Loads a packet from a configuration object, including secondary header if present.
Parses and stores config values from custom file format.
Definition CCSDSConfig.h:11
CCSDS::ResultBool load(const std::string &filename)
Load config file.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterSecondaryHeader()

template<typename T >
ResultBool CCSDS::Packet::RegisterSecondaryHeader ( )
inline

Registers a new header type with the data field secondary header creation function.

This function adds a new header type to the factory by associating the header's type string with a shared pointer to the header.

Parameters
headerA shared pointer to a SecondaryHeaderAbstract object to register.
Returns
ResultBool.

Definition at line 128 of file CCSDSPacket.h.

128 {
130 return true;
131 }
ResultBool RegisterSecondaryHeader()
Registers a new header type with its creation function.
Here is the call graph for this function:

◆ serialize()

std::vector< std::uint8_t > CCSDS::Packet::serialize ( )

Retrieves the full packet as a vector of bytes.

Combines the primary header, data field, and CRC-16 checksum into a single vector. Ensures that the header and data field sizes meet minimum requirements.

Note
Header size must be 6 bytes and data field size must be greater than 1 byte.
Returns
A vector containing the full packet in byte form.

Definition at line 157 of file CCSDSPacket.cpp.

157 {
158 auto header = getPrimaryHeaderBytes();
159 auto dataField = m_dataField.serialize();
160 const auto crc = getCRCVectorBytes();
161
162 std::vector<std::uint8_t> packet;
163 packet.reserve(header.size() + dataField.size() + crc.size());
164 packet.insert(packet.end(), header.begin(), header.end());
165 if (!getFullDataFieldBytes().empty()) {
166 packet.insert(packet.end(), dataField.begin(), dataField.end());
167 }
168 packet.insert(packet.end(), crc.begin(), crc.end());
169
170 return packet;
171}
std::vector< uint8_t > getPrimaryHeaderBytes()
Retrieves the primary header of the packet as a vector of bytes.
std::vector< uint8_t > getCRCVectorBytes()
Retrieves the CRC-16 checksum as a vector of bytes.
std::vector< uint8_t > getFullDataFieldBytes()
Retrieves the full data field data.

◆ setApplicationData() [1/2]

CCSDS::ResultBool CCSDS::Packet::setApplicationData ( const std::uint8_t *  pData,
size_t  sizeData 
)

Sets the application data for the packet.

This function sets the application data in the data field of the packet using a pointer to the data and its size.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
pDataA pointer to the application data.
sizeDataThe size of the application data.
Returns
ResultBool.

Definition at line 318 of file CCSDSPacket.cpp.

318 {
320 m_updateStatus = false;
321 return true;
322}
bool m_updateStatus
When setting data thus value should be set to false.

◆ setApplicationData() [2/2]

CCSDS::ResultBool CCSDS::Packet::setApplicationData ( const std::vector< std::uint8_t > &  data)

Sets the application data for the packet.

This function sets the application data in the data field of the packet using a vector of bytes.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
dataThe vector containing the application data.
Returns
ResultBool.

Definition at line 312 of file CCSDSPacket.cpp.

312 {
314 m_updateStatus = false;
315 return true;
316}
Here is the caller graph for this function:

◆ setCrcConfig() [1/2]

void CCSDS::Packet::setCrcConfig ( const CRC16Config  crcConfig)
inline

Sets the crc configuration of the crc calculation.

This method sets the following variables to be used when performing the crc calculation of data passed as a structure of CRC16Config.

  • polynomial
  • initial value
  • final xor value
Parameters
crcConfig

Definition at line 367 of file CCSDSPacket.h.

367{m_CRC16Config = crcConfig;}
CRC16Config m_CRC16Config
structure holding configuration of crc calculation.

◆ setCrcConfig() [2/2]

void CCSDS::Packet::setCrcConfig ( const std::uint16_t  polynomial,
const std::uint16_t  initialValue,
const std::uint16_t  finalXorValue 
)
inline

Sets the crc configuration of the crc calculation.

This method sets the following variables to be used when performing the crc calculation of data passed as a structure of CRC16Config.

  • polynomial
  • initial value
  • final xor value
Parameters
polynomial
initialValue
finalXorValue

Definition at line 383 of file CCSDSPacket.h.

383{m_CRC16Config = {polynomial, initialValue, finalXorValue};}

◆ setDataFieldHeader() [1/5]

void CCSDS::Packet::setDataFieldHeader ( const std::shared_ptr< SecondaryHeaderAbstract > &  header)

Sets the data field header using the provided SecondaryHeaderAbstract derived header.

This function sets the data field header of the packet using a SecondaryHeaderAbstract derived header object.

Parameters
headerThe SecondaryHeaderAbstract header object.
Returns
none.

Definition at line 282 of file CCSDSPacket.cpp.

282 {
284 m_updateStatus = false;
285}

◆ setDataFieldHeader() [2/5]

CCSDS::ResultBool CCSDS::Packet::setDataFieldHeader ( const std::uint8_t *  pData,
size_t  sizeData 
)

Sets the data field header using the provided pointer and size.

This function sets the data field header of the packet using a pointer to the header data and its size.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
pDataA pointer to the header data.
sizeDataThe size of the header data.
Returns
ResultBool.

Definition at line 306 of file CCSDSPacket.cpp.

306 {
308 m_updateStatus = false;
309 return true;;
310}

◆ setDataFieldHeader() [3/5]

CCSDS::ResultBool CCSDS::Packet::setDataFieldHeader ( const std::uint8_t *  pData,
size_t  sizeData,
const std::string &  headerType 
)

Sets the data field header for the packet using a raw data pointer.

This method updates the data field header of the packet by providing a pointer to the raw data and its size, along with the PUS (Packet Utilization Standard) type if applicable.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
pDataPointer to the raw data for the data field header.
sizeDataThe size of the data pointed to by pData, in bytes.
headerTypeThe PUS type that specifies the purpose of the data.
Returns
ResultBool

Definition at line 293 of file CCSDSPacket.cpp.

294 {
295 FORWARD_RESULT(m_dataField.setDataFieldHeader( pData, sizeData, headerType ));
296 m_updateStatus = false;
297 return true;
298}

◆ setDataFieldHeader() [4/5]

ResultBool CCSDS::Packet::setDataFieldHeader ( const std::vector< std::uint8_t > &  data)

Sets the data field header using the provided vector of bytes.

This function sets the data field header of the packet using a vector of bytes.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
dataThe vector containing the header bytes.
Returns
ResultBool.

◆ setDataFieldHeader() [5/5]

ResultBool CCSDS::Packet::setDataFieldHeader ( const std::vector< std::uint8_t > &  data,
const std::string &  headerType 
)

Sets the data field header for the packet using a vector of bytes.

This method updates the data field header of the packet by providing the data as a vector of bytes and specifying the PUS (Packet Utilization Standard) type if applicable.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
dataA vector containing the data for the data field header.
headerTypeThe PUS type that specifies the purpose of the data.
Returns
ResultBool

◆ setDataFieldSize()

void CCSDS::Packet::setDataFieldSize ( std::uint16_t  size)

Sets the maximum data packet size for the CCSDS DataField.

This method updates the maximum allowed size for the data packet. The data packet size is used to validate that the combined size of the header and application data does not exceed this limit.

Parameters
sizeThe maximum size of the data packet, in bytes.

Definition at line 337 of file CCSDSPacket.cpp.

337 {
339}

◆ setPrimaryHeader() [1/4]

void CCSDS::Packet::setPrimaryHeader ( const Header header)

Sets the primary header using the provided header object.

This function sets the primary header of the packet using the header object

Parameters
header
Returns
ResultBool.

Definition at line 272 of file CCSDSPacket.cpp.

272 {
273 m_primaryHeader = header;
274}

◆ setPrimaryHeader() [2/4]

ResultBool CCSDS::Packet::setPrimaryHeader ( const std::vector< std::uint8_t > &  data)

Sets the primary header using the provided vector of std::uint8_tdata.

This function sets the primary header of the packet using vector of 8-bit integers as the header data.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
dataThe vector of 8-bit integers primary header data.
Returns
ResultBool.

◆ setPrimaryHeader() [3/4]

void CCSDS::Packet::setPrimaryHeader ( PrimaryHeader  data)

Sets the primary header using the provided PrimaryHeader object.

This function sets the primary header of the packet using a PrimaryHeader object as the header data.

Parameters
dataThe PrimaryHeader object containing the header data.
Returns
none.

Definition at line 276 of file CCSDSPacket.cpp.

276 {
279 m_updateStatus = false;
280}
std::uint16_t getSequenceCount() const
14 bits
Definition CCSDSHeader.h:89
ResultBool setData(const std::uint64_t &data)
Sets the header data from a 64-bit integer representation.
std::uint16_t m_sequenceCounter
Here is the call graph for this function:

◆ setPrimaryHeader() [4/4]

CCSDS::ResultBool CCSDS::Packet::setPrimaryHeader ( std::uint64_t  data)

Sets the primary header using the provided 64-bit data.

This function sets the primary header of the packet using a 64-bit integer as the header data.

Note
The method will log an error to standard error and ErrorCode is returned by ResultBool if provided data is invalid.
Parameters
dataThe 64-bit primary header data.
Returns
ResultBool.

Definition at line 258 of file CCSDSPacket.cpp.

258 {
261 m_updateStatus = false;
262 return true;
263}

◆ setSequenceCount()

CCSDS::ResultBool CCSDS::Packet::setSequenceCount ( std::uint16_t  count)

Sets the sequence count for the packet.

Definition at line 329 of file CCSDSPacket.cpp.

329 {
331 "Unable to set non 0 value for UNSEGMENTED packet");
332 m_sequenceCounter = count;
333 m_updateStatus = false;
334 return true;
335}
std::uint8_t getSequenceFlags() const
2 bits
Definition CCSDSHeader.h:88
Here is the caller graph for this function:

◆ setSequenceFlags()

void CCSDS::Packet::setSequenceFlags ( ESequenceFlag  flags)

Sets the sequence flags for the packet's primary header.

This method updates the sequence flags in the primary header of the packet. The sequence flags indicate the position or type of the data segment within the CCSDS telemetry transfer frame (e.g., first segment, last segment, etc.).

Parameters
flagsThe sequence flag to be set, represented by the ESequenceFlag enum : std::uint8_t.

Definition at line 324 of file CCSDSPacket.cpp.

324 {
326 m_updateStatus = false;
327}
Here is the caller graph for this function:

◆ setUpdatePacketEnable()

void CCSDS::Packet::setUpdatePacketEnable ( bool  enable)

needs to be called as soon as possible, probably also from constructor.

Parameters
enable

Definition at line 341 of file CCSDSPacket.cpp.

341 {
342 m_enableUpdatePacket = enable;
344}
void setDataFieldHeaderAutoUpdateStatus(const bool enable)
Sets The auto update variable, if disabled the data size in the header field will not be updated.
bool m_enableUpdatePacket
Enables primary header and secondary header update.
Here is the caller graph for this function:

◆ update()

void CCSDS::Packet::update ( )

Updates Primary headers data field size.

Uses the currently set data field size to set the header.

Returns
none.

Definition at line 11 of file CCSDSPacket.cpp.

11 {
13 const auto dataField = m_dataField.serialize();
14 const auto dataFiledSize = static_cast<std::uint16_t>(dataField.size());
15 const auto dataFieldHeaderFlag(m_dataField.getDataFieldHeaderFlag());
16 m_primaryHeader.setDataLength(dataFiledSize);
17 m_primaryHeader.setDataFieldHeaderFlag(dataFieldHeaderFlag);
18 // todo this part needs to be moved out of conditional updating
21 } else {
23 }
25 m_updateStatus = true;
26 }
27}
uint16_t crc16(const std::vector< std::uint8_t > &data, std::uint16_t polynomial=0x1021, std::uint16_t initialValue=0xFFFF, std::uint16_t finalXorValue=0x0000)
Computes the CRC-16 checksum for a given data vector with configurable parameters.
bool getDataFieldHeaderFlag() const
retrieves true if a known secondary header has been set
void setDataLength(const std::uint16_t &value)
16 bits
std::uint16_t initialValue
Definition CCSDSPacket.h:37
std::uint16_t polynomial
Definition CCSDSPacket.h:36
std::uint16_t finalXorValue
Definition CCSDSPacket.h:38
Here is the call graph for this function:

Member Data Documentation

◆ m_CRC16

std::uint16_t CCSDS::Packet::m_CRC16 {}
private

Cyclic Redundancy check 16 bits.

Definition at line 415 of file CCSDSPacket.h.

415{};

◆ m_CRC16Config

CRC16Config CCSDS::Packet::m_CRC16Config
private

structure holding configuration of crc calculation.

Definition at line 416 of file CCSDSPacket.h.

◆ m_dataField

DataField CCSDS::Packet::m_dataField {}
private

variable

Definition at line 414 of file CCSDSPacket.h.

414{};

◆ m_enableUpdatePacket

bool CCSDS::Packet::m_enableUpdatePacket {true}
private

Enables primary header and secondary header update.

Definition at line 418 of file CCSDSPacket.h.

418{true};

◆ m_primaryHeader

Header CCSDS::Packet::m_primaryHeader {}
private

6 bytes / 48 bits / 12 hex

Definition at line 413 of file CCSDSPacket.h.

413{};

◆ m_sequenceCounter

std::uint16_t CCSDS::Packet::m_sequenceCounter {0}
private

Definition at line 419 of file CCSDSPacket.h.

419{0};

◆ m_updateStatus

bool CCSDS::Packet::m_updateStatus {false}
private

When setting data thus value should be set to false.

Definition at line 417 of file CCSDSPacket.h.

417{false};

The documentation for this class was generated from the following files: