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 (uint64_t data)
 Sets the primary header using the provided 64-bit data.
 
ResultBool setPrimaryHeader (const std::vector< uint8_t > &data)
 Sets the primary header using the provided vector of 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.
 
ResultBool setDataFieldHeader (const std::vector< uint8_t > &data, const std::string &headerType)
 Sets the data field header for the packet using a vector of bytes.
 
ResultBool setDataFieldHeader (const 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< uint8_t > &data)
 Sets the data field header using the provided vector of bytes.
 
ResultBool setDataFieldHeader (const uint8_t *pData, size_t sizeData)
 Sets the data field header using the provided pointer and size.
 
ResultBool setApplicationData (const std::vector< uint8_t > &data)
 Sets the application data for the packet.
 
ResultBool setApplicationData (const 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 (uint16_t count)
 Sets the sequence count for the packet.
 
void setDataFieldSize (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< uint8_t > &data)
 Deserializes a vector of bytes into a CCSDS packet.
 
ResultBool deserialize (const std::vector< uint8_t > &data, const std::string &headerType)
 Deserializes a CCSDS packet using a vector and a registered header type.
 
ResultBool deserialize (const std::vector< uint8_t > &data, 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.
 
uint64_t getPrimaryHeader64bit ()
 Retrieves the primary header of the packet.
 
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.
 
uint16_t getCRC ()
 Computes and retrieves the CRC-16 checksum of the packet.
 
uint16_t getDataFieldMaximumSize ()
 returns the maximum data field size
 
bool getDataFieldHeaderFlag ()
 @ returns the data field header flag
 
CCSDS::DataFieldgetDataField ()
 returns the CCSDS packet's DataField.
 
CCSDS::HeadergetPrimaryHeader ()
 returns the CCSDS packet's Primary Header.
 
void setCrcConfig (const CRC16Config crcConfig)
 Sets the crc configuration of the crc calculation.
 
void setCrcConfig (const uint16_t polynomial, const uint16_t initialValue, const uint16_t finalXorValue)
 Sets the crc configuration of the crc calculation.
 
void update ()
 Updates Primary headers data field size.
 

Private Attributes

Header m_primaryHeader {}
 6 bytes / 48 bits / 12 hex
 
DataField m_dataField {}
 variable
 
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.
 
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 60 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< uint8_t > &  data)

Deserializes a vector of bytes into a CCSDS packet.

Definition at line 96 of file CCSDSPacket.cpp.

96 {
98 "Cannot Deserialize Packet, Invalid Data provided data size must be at least 8 bytes");
99
100 std::vector<uint8_t> dataFieldVector;
101 std::copy(data.begin() + 6, data.end(), std::back_inserter(dataFieldVector));
102
103 FORWARD_RESULT(deserialize({data[0], data[1], data[2], data[3], data[4], data[5]}, dataFieldVector));
104
105 return true;
106}
#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< uint8_t > &data)
Deserializes a vector of bytes into a CCSDS packet.
@ INVALID_HEADER_DATA
Header data is invalid.
Definition CCSDSResult.h:24
Here is the caller graph for this function:

◆ deserialize() [2/4]

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

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

Definition at line 108 of file CCSDSPacket.cpp.

108 {
109 RET_IF_ERR_MSG(data.size() <= 8, ErrorCode::INVALID_DATA,
110 "Cannot Deserialize Packet, Invalid Data provided data size must be at least 8 bytes");
111 RET_IF_ERR_MSG(headerType == "BufferHeader", ErrorCode::INVALID_SECONDARY_HEADER_DATA,
112 "Cannot Deserialize Packet, BufferHeader is not of defined size");
114 "Cannot Deserialize Packet, Unregistered Secondary header: " + headerType);
115
116 const auto secondaryHeader = m_dataField.getDataFieldHeaderFactory().create(headerType);
117 const auto headerDataSizeBytes = secondaryHeader->getSize();
118
119 std::vector<uint8_t> dataFieldHeaderVector;
120 std::copy_n(data.begin() + 6, headerDataSizeBytes , std::back_inserter(dataFieldHeaderVector));
121 FORWARD_RESULT( secondaryHeader->deserialize(dataFieldHeaderVector ));
122 setDataFieldHeader(secondaryHeader);
123
124 if (data.size() > (8 + headerDataSizeBytes)) {
125 std::vector<uint8_t> dataFieldVector;
126
127 if (data.size() > (9 + headerDataSizeBytes)) {
128 std::copy(data.begin() + 6 + headerDataSizeBytes, data.end(), std::back_inserter(dataFieldVector));
129 }
130 FORWARD_RESULT(deserialize({data[0], data[1], data[2], data[3], data[4], data[5]}, dataFieldVector));
131 }
132
133 return true;
134}
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:23
@ INVALID_SECONDARY_HEADER_DATA
Secondary header data is invalid.
Definition CCSDSResult.h:25

◆ deserialize() [3/4]

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

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

Definition at line 136 of file CCSDSPacket.cpp.

136 {
137 RET_IF_ERR_MSG(data.size() <= (8 + headerDataSizeBytes), ErrorCode::INVALID_DATA,
138 "Cannot Serialize Packet, Invalid Data provided");
139
140 std::vector<uint8_t> secondaryHeader;
141 std::vector<uint8_t> dataFieldVector;
142 std::copy(data.begin() + 6, data.begin() + 6 + headerDataSizeBytes, std::back_inserter(secondaryHeader));
144 if (data.size() > (7 + headerDataSizeBytes)) {
145 std::copy(data.begin() + 6 + headerDataSizeBytes, data.end(), std::back_inserter(dataFieldVector));
146 }
147 FORWARD_RESULT(deserialize({data[0], data[1], data[2], data[3], data[4], data[5]}, dataFieldVector));
148 return true;
149}
ResultBool setDataFieldHeader(const uint8_t *pData, const size_t &sizeData)
Sets the secondary header data for the data field.

◆ deserialize() [4/4]

CCSDS::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.

Definition at line 151 of file CCSDSPacket.cpp.

151 {
152 RET_IF_ERR_MSG(headerData.size() != 6, ErrorCode::INVALID_HEADER_DATA,
153 "Cannot Deserialize Packet, Invalid Header Data provided.");
156
158 "Cannot Deserialize Packet, Invalid Data provided, at least CRC is required.");
159
160 std::vector<uint8_t> dataCopy;
161 m_CRC16 = (data[data.size() - 2] << 8) + data.back();
162
163 if (data.size() == 2) return true; // returns since no application data is to be written.
164
165 std::copy(data.begin(), data.end() - 2, std::back_inserter(dataCopy));
167
168 return true;;
169}
ResultBool setApplicationData(const std::vector< uint8_t > &applicationData)
Sets the application data using a vector of bytes.
ResultBool deserialize(const std::vector< uint8_t > &data)
Sets the header data from a 64-bit integer representation.
uint16_t getSequenceCount() const
14 bits
Definition CCSDSHeader.h:89
uint16_t m_CRC16
Cyclic Redundancy check 16 bits.
Header m_primaryHeader
6 bytes / 48 bits / 12 hex
uint16_t m_sequenceCounter

◆ getApplicationDataBytes()

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

Retrieves the application data from the data field.

Returns
A vector containing the Application data.

Definition at line 71 of file CCSDSPacket.cpp.

71 {
72 update();
74}
std::vector< 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 24 of file CCSDSPacket.cpp.

24 {
25 update();
26 return m_CRC16;
27}
Here is the caller graph for this function:

◆ getCRCVectorBytes()

std::vector< 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 38 of file CCSDSPacket.cpp.

38 {
39 std::vector<uint8_t> crc(2);
40 const auto crcVar = getCRC();
41 crc[0] = (crcVar >> 8) & 0xFF; // MSB (Most Significant Byte)
42 crc[1] = crcVar & 0xFF; // LSB (Least Significant Byte)
43 return crc;
44}
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 46 of file CCSDSPacket.cpp.

46 {
47 update();
48 return m_dataField;
49}
Here is the caller graph for this function:

◆ getDataFieldHeaderBytes()

std::vector< 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 66 of file CCSDSPacket.cpp.

66 {
67 update();
69}
std::vector< 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 33 of file CCSDSPacket.cpp.

33 {
34 update();
36}
uint8_t getDataFieldHeaderFlag() const
1 bits
Definition CCSDSHeader.h:86

◆ getDataFieldMaximumSize()

uint16_t CCSDS::Packet::getDataFieldMaximumSize ( )

returns the maximum data field size

Definition at line 29 of file CCSDSPacket.cpp.

29 {
31}
uint16_t getDataFieldAvailableBytesSize()
Retrieves the available size of the data field in bytes.

◆ getFullDataFieldBytes()

std::vector< 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 76 of file CCSDSPacket.cpp.

76 {
78}
std::vector< uint8_t > getFullDataFieldBytes()
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 171 of file CCSDSPacket.cpp.

171 {
172 // where 8 is derived from 6 bytes for Primary header and 2 bytes for CRC16.
174}
uint16_t getDataFieldUsedBytesSize()
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 51 of file CCSDSPacket.cpp.

51 {
52 update();
53 return m_primaryHeader;
54}

◆ 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 56 of file CCSDSPacket.cpp.

56 {
57 update();
59};
uint64_t getFullHeader()
Computes and retrieves the full header as a 64-bit value.

◆ getPrimaryHeaderBytes()

std::vector< 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 61 of file CCSDSPacket.cpp.

61 {
62 update();
64}
std::vector< uint8_t > serialize()
decomposes the Primary header class and returns it as a vector of bytes.

◆ serialize()

std::vector< 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 80 of file CCSDSPacket.cpp.

80 {
81 auto header = getPrimaryHeaderBytes();
82 auto dataField = m_dataField.getFullDataFieldBytes();
83 const auto crc = getCRCVectorBytes();
84
85 std::vector<uint8_t> packet;
86 packet.reserve(header.size() + dataField.size() + crc.size());
87 packet.insert(packet.end(), header.begin(), header.end());
88 if (!getFullDataFieldBytes().empty()) {
89 packet.insert(packet.end(), dataField.begin(), dataField.end());
90 }
91 packet.insert(packet.end(), crc.begin(), crc.end());
92
93 return packet;
94}
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::vector< uint8_t > getPrimaryHeaderBytes()
Retrieves the primary header of the packet as a vector of bytes.

◆ setApplicationData() [1/2]

CCSDS::ResultBool CCSDS::Packet::setApplicationData ( const std::vector< 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 230 of file CCSDSPacket.cpp.

230 {
232 m_updateStatus = false;
233 return true;
234}
bool m_updateStatus
When setting data thus value should be set to false.
Here is the caller graph for this function:

◆ setApplicationData() [2/2]

CCSDS::ResultBool CCSDS::Packet::setApplicationData ( const 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 236 of file CCSDSPacket.cpp.

236 {
238 m_updateStatus = false;
239 return true;
240}

◆ 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 354 of file CCSDSPacket.h.

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

◆ setCrcConfig() [2/2]

void CCSDS::Packet::setCrcConfig ( const uint16_t  polynomial,
const uint16_t  initialValue,
const 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 370 of file CCSDSPacket.h.

370{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 200 of file CCSDSPacket.cpp.

200 {
202 m_updateStatus = false;
203}

◆ setDataFieldHeader() [2/5]

CCSDS::ResultBool CCSDS::Packet::setDataFieldHeader ( const std::vector< 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.

Definition at line 218 of file CCSDSPacket.cpp.

218 {
220 m_updateStatus = false;
221 return true;
222}

◆ setDataFieldHeader() [3/5]

CCSDS::ResultBool CCSDS::Packet::setDataFieldHeader ( const std::vector< 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

Definition at line 205 of file CCSDSPacket.cpp.

205 {
206 FORWARD_RESULT(m_dataField.setDataFieldHeader( data, headerType ));
207 m_updateStatus = false;
208 return true;
209}

◆ setDataFieldHeader() [4/5]

CCSDS::ResultBool CCSDS::Packet::setDataFieldHeader ( const 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 224 of file CCSDSPacket.cpp.

224 {
226 m_updateStatus = false;
227 return true;;
228}

◆ setDataFieldHeader() [5/5]

CCSDS::ResultBool CCSDS::Packet::setDataFieldHeader ( const 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 211 of file CCSDSPacket.cpp.

212 {
213 FORWARD_RESULT(m_dataField.setDataFieldHeader( pData, sizeData, headerType ));
214 m_updateStatus = false;
215 return true;
216}

◆ setDataFieldSize()

void CCSDS::Packet::setDataFieldSize ( 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 255 of file CCSDSPacket.cpp.

255 {
257}
void setDataPacketSize(const uint16_t &value)
Sets the maximum data packet size for the CCSDS DataField.

◆ 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 190 of file CCSDSPacket.cpp.

190 {
191 m_primaryHeader = header;
192}

◆ setPrimaryHeader() [2/4]

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

Sets the primary header using the provided vector of 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.

Definition at line 183 of file CCSDSPacket.cpp.

183 {
186 m_updateStatus = false;
187 return true;
188}

◆ 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 194 of file CCSDSPacket.cpp.

194 {
197 m_updateStatus = false;
198}
ResultBool setData(const uint64_t &data)
Sets the header data from a 64-bit integer representation.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPrimaryHeader() [4/4]

CCSDS::ResultBool CCSDS::Packet::setPrimaryHeader ( 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 176 of file CCSDSPacket.cpp.

176 {
179 m_updateStatus = false;
180 return true;
181}

◆ setSequenceCount()

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

Sets the sequence count for the packet.

Definition at line 247 of file CCSDSPacket.cpp.

247 {
249 "Unable to set non 0 value for UNSEGMENTED packet");
250 m_sequenceCounter = count;
251 m_updateStatus = false;
252 return true;
253}
uint8_t getSequenceFlags() const
2 bits
Definition CCSDSHeader.h:88
@ UNSEGMENTED
11 Complete packet in a single frame.
Definition CCSDSHeader.h:23
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 : uint8_t.

Definition at line 242 of file CCSDSPacket.cpp.

242 {
244 m_updateStatus = false;
245}
void setSequenceFlags(const uint8_t &value)
2 bits
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 259 of file CCSDSPacket.cpp.

259 {
260 m_enableUpdatePacket = enable;
262}
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 6 of file CCSDSPacket.cpp.

6 {
8 const auto dataField = m_dataField.getFullDataFieldBytes();
9 const auto dataFiledSize = static_cast<uint16_t>(dataField.size());
10 const auto dataFieldHeaderFlag(m_dataField.getDataFieldHeaderFlag());
11 m_primaryHeader.setDataLength(dataFiledSize);
12 m_primaryHeader.setDataFieldHeaderFlag(dataFieldHeaderFlag);
13 // todo this part needs to be moved out of conditional updating
16 } else {
18 }
20 m_updateStatus = true;
21 }
22}
uint16_t crc16(const std::vector< uint8_t > &data, uint16_t polynomial=0x1021, uint16_t initialValue=0xFFFF, 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 uint16_t &value)
16 bits
void setSequenceCount(const uint16_t &value)
14 bits
void setDataFieldHeaderFlag(const uint8_t &value)
1 bits
uint16_t finalXorValue
Definition CCSDSPacket.h:39
uint16_t initialValue
Definition CCSDSPacket.h:38
Here is the call graph for this function:

Member Data Documentation

◆ m_CRC16

uint16_t CCSDS::Packet::m_CRC16 {}
private

Cyclic Redundancy check 16 bits.

Definition at line 384 of file CCSDSPacket.h.

384{};

◆ m_CRC16Config

CRC16Config CCSDS::Packet::m_CRC16Config
private

structure holding configuration of crc calculation.

Definition at line 385 of file CCSDSPacket.h.

◆ m_dataField

DataField CCSDS::Packet::m_dataField {}
private

variable

Definition at line 383 of file CCSDSPacket.h.

383{};

◆ m_enableUpdatePacket

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

Enables primary header and secondary header update.

Definition at line 387 of file CCSDSPacket.h.

387{true};

◆ m_primaryHeader

Header CCSDS::Packet::m_primaryHeader {}
private

6 bytes / 48 bits / 12 hex

Definition at line 382 of file CCSDSPacket.h.

382{};

◆ m_sequenceCounter

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

Definition at line 388 of file CCSDSPacket.h.

388{0};

◆ m_updateStatus

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

When setting data thus value should be set to false.

Definition at line 386 of file CCSDSPacket.h.

386{false};

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