CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
|
Represents a CCSDS (Consultative Committee for Space Data Systems) packet. More...
#include <CCSDSPacket.h>
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::DataField & | getDataField () |
returns the CCSDS packet's DataField. | |
CCSDS::Header & | getPrimaryHeader () |
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} |
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.
|
default |
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.
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.
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.
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.
std::vector< uint8_t > CCSDS::Packet::getApplicationDataBytes | ( | ) |
Retrieves the application data from the data field.
Definition at line 71 of file CCSDSPacket.cpp.
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.
Definition at line 24 of file CCSDSPacket.cpp.
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.
Definition at line 38 of file CCSDSPacket.cpp.
CCSDS::DataField & CCSDS::Packet::getDataField | ( | ) |
returns the CCSDS packet's DataField.
Definition at line 46 of file CCSDSPacket.cpp.
std::vector< uint8_t > CCSDS::Packet::getDataFieldHeaderBytes | ( | ) |
Retrieves the secondary header data from the data field.
Definition at line 66 of file CCSDSPacket.cpp.
bool CCSDS::Packet::getDataFieldHeaderFlag | ( | ) |
@ returns the data field header flag
Definition at line 33 of file CCSDSPacket.cpp.
uint16_t CCSDS::Packet::getDataFieldMaximumSize | ( | ) |
returns the maximum data field size
Definition at line 29 of file CCSDSPacket.cpp.
std::vector< uint8_t > CCSDS::Packet::getFullDataFieldBytes | ( | ) |
Retrieves the full data field data.
i.e. Application data and Secondary header data if applicable.
Definition at line 76 of file CCSDSPacket.cpp.
uint16_t CCSDS::Packet::getFullPacketLength | ( | ) |
Retrieves the current size of the CCSDS Packet.
Definition at line 171 of file CCSDSPacket.cpp.
CCSDS::Header & CCSDS::Packet::getPrimaryHeader | ( | ) |
returns the CCSDS packet's Primary Header.
Definition at line 51 of file CCSDSPacket.cpp.
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.
Definition at line 56 of file CCSDSPacket.cpp.
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).
Definition at line 61 of file CCSDSPacket.cpp.
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.
Definition at line 80 of file CCSDSPacket.cpp.
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.
data | The vector containing the application data. |
Definition at line 230 of file CCSDSPacket.cpp.
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.
pData | A pointer to the application data. |
sizeData | The size of the application data. |
Definition at line 236 of file CCSDSPacket.cpp.
|
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.
crcConfig |
Definition at line 354 of file CCSDSPacket.h.
|
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 | |
initialValue | |
finalXorValue |
Definition at line 370 of file CCSDSPacket.h.
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.
header | The SecondaryHeaderAbstract header object. |
Definition at line 200 of file CCSDSPacket.cpp.
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.
data | The vector containing the header bytes. |
Definition at line 218 of file CCSDSPacket.cpp.
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.
data | A vector containing the data for the data field header. |
headerType | The PUS type that specifies the purpose of the data. |
Definition at line 205 of file CCSDSPacket.cpp.
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.
pData | A pointer to the header data. |
sizeData | The size of the header data. |
Definition at line 224 of file CCSDSPacket.cpp.
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.
pData | Pointer to the raw data for the data field header. |
sizeData | The size of the data pointed to by pData, in bytes. |
headerType | The PUS type that specifies the purpose of the data. |
Definition at line 211 of file CCSDSPacket.cpp.
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.
size | The maximum size of the data packet, in bytes. |
Definition at line 255 of file CCSDSPacket.cpp.
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
header |
Definition at line 190 of file CCSDSPacket.cpp.
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.
data | The vector of 8-bit integers primary header data. |
Definition at line 183 of file CCSDSPacket.cpp.
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.
data | The PrimaryHeader object containing the header data. |
Definition at line 194 of file CCSDSPacket.cpp.
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.
data | The 64-bit primary header data. |
Definition at line 176 of file CCSDSPacket.cpp.
CCSDS::ResultBool CCSDS::Packet::setSequenceCount | ( | uint16_t | count | ) |
Sets the sequence count for the packet.
Definition at line 247 of file CCSDSPacket.cpp.
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.).
flags | The sequence flag to be set, represented by the ESequenceFlag enum : uint8_t. |
Definition at line 242 of file CCSDSPacket.cpp.
void CCSDS::Packet::setUpdatePacketEnable | ( | bool | enable | ) |
needs to be called as soon as possible, probably also from constructor.
enable |
Definition at line 259 of file CCSDSPacket.cpp.
void CCSDS::Packet::update | ( | ) |
Updates Primary headers data field size.
Uses the currently set data field size to set the header.
Definition at line 6 of file CCSDSPacket.cpp.
|
private |
|
private |
structure holding configuration of crc calculation.
Definition at line 385 of file CCSDSPacket.h.
|
private |
|
private |
Enables primary header and secondary header update.
Definition at line 387 of file CCSDSPacket.h.
|
private |
|
private |
Definition at line 388 of file CCSDSPacket.h.
|
private |
When setting data thus value should be set to false.
Definition at line 386 of file CCSDSPacket.h.