|
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 (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 | |
| DataField & | getDataField () |
| returns the CCSDS packet's DataField. | |
| 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 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} |
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.
|
default |
| 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.
| 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.
| 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.
| 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.
| std::vector< std::uint8_t > CCSDS::Packet::getApplicationDataBytes | ( | ) |
Retrieves the application data from the data field.
Definition at line 148 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 101 of file CCSDSPacket.cpp.
| 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.
Definition at line 115 of file CCSDSPacket.cpp.
| CCSDS::DataField & CCSDS::Packet::getDataField | ( | ) |
returns the CCSDS packet's DataField.
Definition at line 123 of file CCSDSPacket.cpp.
| std::vector< std::uint8_t > CCSDS::Packet::getDataFieldHeaderBytes | ( | ) |
Retrieves the secondary header data from the data field.
Definition at line 143 of file CCSDSPacket.cpp.
| bool CCSDS::Packet::getDataFieldHeaderFlag | ( | ) |
@ returns the data field header flag
Definition at line 110 of file CCSDSPacket.cpp.
| uint16_t CCSDS::Packet::getDataFieldMaximumSize | ( | ) | const |
returns the maximum data field size
Definition at line 106 of file CCSDSPacket.cpp.
| std::vector< std::uint8_t > CCSDS::Packet::getFullDataFieldBytes | ( | ) |
Retrieves the full data field data.
i.e. Application data and Secondary header data if applicable.
Definition at line 153 of file CCSDSPacket.cpp.
| uint16_t CCSDS::Packet::getFullPacketLength | ( | ) |
Retrieves the current size of the CCSDS Packet.
Definition at line 253 of file CCSDSPacket.cpp.
| CCSDS::Header & CCSDS::Packet::getPrimaryHeader | ( | ) |
returns the CCSDS packet's Primary Header.
Definition at line 128 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 133 of file CCSDSPacket.cpp.
| 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).
Definition at line 138 of file CCSDSPacket.cpp.
| CCSDS::ResultBool CCSDS::Packet::loadFromConfig | ( | const Config & | cfg | ) |
Loads a packet from a configuration object, including secondary header if present.
| cfg | configuration object. |
Definition at line 37 of file CCSDSPacket.cpp.
| CCSDS::ResultBool CCSDS::Packet::loadFromConfigFile | ( | const std::string & | configPath | ) |
Loads a packet from a configuration file, including secondary header if present.
| configPath | path to the configuration file. |
Definition at line 30 of file CCSDSPacket.cpp.
|
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.
| header | A shared pointer to a SecondaryHeaderAbstract object to register. |
Definition at line 128 of file CCSDSPacket.h.
| 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.
Definition at line 157 of file CCSDSPacket.cpp.
| 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.
| pData | A pointer to the application data. |
| sizeData | The size of the application data. |
Definition at line 318 of file CCSDSPacket.cpp.
| 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.
| data | The vector containing the application data. |
Definition at line 312 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 367 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 383 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 282 of file CCSDSPacket.cpp.
| 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.
| pData | A pointer to the header data. |
| sizeData | The size of the header data. |
Definition at line 306 of file CCSDSPacket.cpp.
| 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.
| 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 293 of file CCSDSPacket.cpp.
| 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.
| data | The vector containing the header bytes. |
| 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.
| data | A vector containing the data for the data field header. |
| headerType | The PUS type that specifies the purpose of the data. |
| 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.
| size | The maximum size of the data packet, in bytes. |
Definition at line 337 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 272 of file CCSDSPacket.cpp.
| 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.
| data | The vector of 8-bit integers primary header data. |
| 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 276 of file CCSDSPacket.cpp.
| 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.
| data | The 64-bit primary header data. |
Definition at line 258 of file CCSDSPacket.cpp.
| CCSDS::ResultBool CCSDS::Packet::setSequenceCount | ( | std::uint16_t | count | ) |
Sets the sequence count for the packet.
Definition at line 329 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 : std::uint8_t. |
Definition at line 324 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 341 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 11 of file CCSDSPacket.cpp.
|
private |
|
private |
structure holding configuration of crc calculation.
Definition at line 416 of file CCSDSPacket.h.
|
private |
|
private |
Enables primary header and secondary header update.
Definition at line 418 of file CCSDSPacket.h.
|
private |
|
private |
Definition at line 419 of file CCSDSPacket.h.
|
private |
When setting data thus value should be set to false.
Definition at line 417 of file CCSDSPacket.h.