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
PusA Class Referencefinal

Represents a PUS Type A (Telemetry) header. More...

#include <PusServices.h>

Inheritance diagram for PusA:
[legend]
Collaboration diagram for PusA:
[legend]

Public Member Functions

 PusA ()=default
 
 PusA (const std::uint8_t version, const std::uint8_t serviceType, const std::uint8_t serviceSubtype, const std::uint8_t sourceID, const std::uint32_t dataLength)
 Constructs a PusA object with all fields explicitly set.
 
std::uint8_t getVersion () const
 
std::uint8_t getServiceType () const
 
std::uint8_t getServiceSubtype () const
 
std::uint8_t getSourceID () const
 
std::uint16_t getDataLength () const
 
std::uint16_t getSize () const override
 Gets the size of the header in bytes.
 
std::string getType () const override
 Retrieves the name of the packet.
 
std::vector< std::uint8_t > serialize () const override
 Retrieves the serialized representation of the header.
 
CCSDS::ResultBool deserialize (const std::vector< std::uint8_t > &data) override
 takes a buffer if data (vector std::uint8) and creates the header
 
void update (CCSDS::DataField *dataField) override
 Defines how the packet secondary header is updated using the data field as reference.
 
CCSDS::ResultBool loadFromConfig (const ::Config &cfg) override
 
- Public Member Functions inherited from CCSDS::SecondaryHeaderAbstract
virtual ~SecondaryHeaderAbstract ()=default
 
virtual ResultBool loadFromConfig (const Config &config)=0
 
void setVariableLength (const bool bEnable)
 

Private Attributes

std::uint8_t m_version {}
 
std::uint8_t m_serviceType {}
 
std::uint8_t m_serviceSubType {}
 
std::uint8_t m_sourceID {}
 
std::uint16_t m_dataLength {}
 
const std::string m_type = "PusA"
 
const std::uint16_t m_size = 6
 

Additional Inherited Members

- Public Attributes inherited from CCSDS::SecondaryHeaderAbstract
bool variableLength {false}
 

Detailed Description

Represents a PUS Type A (Telemetry) header.

Contains fields used for telemetry data.

Field Summary:

Definition at line 27 of file PusServices.h.

Constructor & Destructor Documentation

◆ PusA() [1/2]

PusA::PusA ( )
default

◆ PusA() [2/2]

PusA::PusA ( const std::uint8_t  version,
const std::uint8_t  serviceType,
const std::uint8_t  serviceSubtype,
const std::uint8_t  sourceID,
const std::uint32_t  dataLength 
)
inlineexplicit

Constructs a PusA object with all fields explicitly set.

Parameters
versionPUS version (3 bits).
serviceTypeService type (8 bits).
serviceSubtypeService subtype (8 bits).
sourceIDSource identifier (8 bits).
dataLengthLength of the telemetry data (16 bits).

Definition at line 39 of file PusServices.h.

40 : m_version(version & 0x7),
41 m_serviceType(serviceType),
42 m_serviceSubType(serviceSubtype),
43 m_sourceID(sourceID), m_dataLength(dataLength) {
44 }
std::uint8_t m_serviceType
Definition PusServices.h:65
std::uint8_t m_serviceSubType
Definition PusServices.h:66
std::uint8_t m_sourceID
Definition PusServices.h:67
std::uint8_t m_version
Definition PusServices.h:64
std::uint16_t m_dataLength
Definition PusServices.h:68

Member Function Documentation

◆ deserialize()

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

takes a buffer if data (vector std::uint8) and creates the header

Returns
Boolean true on success or Error.

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 9 of file PusServices.cpp.

9 {
11 "PUS-A header not correct size (size != 6 bytes)");
12
13 m_version = data[0] & 0x7;
14 m_serviceType = data[1];
15 m_serviceSubType = data[2];
16 m_sourceID = data[3];
17 m_dataLength = data[4] << 8 | data[5];
18 return true;
19}
#define RET_IF_ERR_MSG(condition, errorCode, message)
Macro to return an error with an error message if a condition is met.
const std::uint16_t m_size
Definition PusServices.h:71
@ INVALID_SECONDARY_HEADER_DATA
Secondary header data is invalid.
Definition CCSDSResult.h:29

◆ getDataLength()

std::uint16_t PusA::getDataLength ( ) const
inline

Definition at line 50 of file PusServices.h.

50{ return m_dataLength; }

◆ getServiceSubtype()

std::uint8_t PusA::getServiceSubtype ( ) const
inline

Definition at line 48 of file PusServices.h.

48{ return m_serviceSubType; }

◆ getServiceType()

std::uint8_t PusA::getServiceType ( ) const
inline

Definition at line 47 of file PusServices.h.

47{ return m_serviceType; }

◆ getSize()

std::uint16_t PusA::getSize ( ) const
inlineoverridevirtual

Gets the size of the header in bytes.

Returns
The size of the header in bytes.

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 51 of file PusServices.h.

51{ return m_size; }

◆ getSourceID()

std::uint8_t PusA::getSourceID ( ) const
inline

Definition at line 49 of file PusServices.h.

49{ return m_sourceID; }

◆ getType()

std::string PusA::getType ( ) const
inlineoverridevirtual

Retrieves the name of the packet.

Returns
A vector containing the header bytes. (does not include data field)

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 52 of file PusServices.h.

52{ return m_type; }
const std::string m_type
Definition PusServices.h:70

◆ getVersion()

std::uint8_t PusA::getVersion ( ) const
inline

Definition at line 46 of file PusServices.h.

46{ return m_version; }

◆ loadFromConfig()

CCSDS::ResultBool PusA::loadFromConfig ( const ::Config cfg)
override

Definition at line 109 of file PusServices.cpp.

109 {
110 std::uint8_t version = 0;
111 std::uint8_t serviceType = 0;
112 std::uint8_t serviceSubType = 0;
113 std::uint8_t sourceId = 0;
114
115 RET_IF_ERR_MSG(!cfg.isKey("pus_version"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_version");
116 RET_IF_ERR_MSG(!cfg.isKey("pus_service_type"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_service_type");
117 RET_IF_ERR_MSG(!cfg.isKey("pus_service_sub_type"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_service_sub_type");
118 RET_IF_ERR_MSG(!cfg.isKey("pus_source_id"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_source_id");
119
120 ASSIGN_OR_PRINT(version, cfg.get<int>("pus_version"));
121 ASSIGN_OR_PRINT(serviceType, cfg.get<int>("pus_service_type"));
122 ASSIGN_OR_PRINT(serviceSubType,cfg.get< int>("pus_service_sub_type"));
123 ASSIGN_OR_PRINT(sourceId,cfg.get<int>("pus_source_id"));
124
125 m_version = version & 0x7;
126 m_serviceType = serviceType & 0xFF;
127 m_serviceSubType = serviceSubType & 0xFF;
128 m_sourceID = sourceId & 0xFF;
129
130 return true;
131}
#define ASSIGN_OR_PRINT(var, result)
Macro to assign a result value or print an error message.
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:23
@ CONFIG_FILE_ERROR
Configuration file error.
Definition CCSDSResult.h:37
Here is the call graph for this function:

◆ serialize()

std::vector< std::uint8_t > PusA::serialize ( ) const
overridevirtual

Retrieves the serialized representation of the header.

Returns
A vector containing the header bytes. (does not include data field)

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 21 of file PusServices.cpp.

21 {
22 std::vector data{
23 static_cast<std::uint8_t>(m_version & 0x7),
27 static_cast<std::uint8_t>(m_dataLength >> 8 & 0xFF),
28 static_cast<std::uint8_t>(m_dataLength & 0xFF),
29 };
30
31 return data;
32}

◆ update()

void PusA::update ( CCSDS::DataField dataField)
overridevirtual

Defines how the packet secondary header is updated using the data field as reference.

This method is called every time a data get is performed from the packet, that is if update is enabled and method successfully registered.

Parameters
dataField

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 34 of file PusServices.cpp.

34 {
36}
std::uint16_t getApplicationDataBytesSize() const
Retrieves the size of the application data stored in the data field.
Here is the call graph for this function:

Member Data Documentation

◆ m_dataLength

std::uint16_t PusA::m_dataLength {}
private

Definition at line 68 of file PusServices.h.

68{}; // Data Length 16 Length of the telemetry data in bytes

◆ m_serviceSubType

std::uint8_t PusA::m_serviceSubType {}
private

Definition at line 66 of file PusServices.h.

66{}; // Service Subtype 8 Subtype of the service (e.g., specific telemetry type)

◆ m_serviceType

std::uint8_t PusA::m_serviceType {}
private

Definition at line 65 of file PusServices.h.

65{}; // Service Type 8 Type of service (e.g., 0x01 for telemetry)

◆ m_size

const std::uint16_t PusA::m_size = 6
private

Definition at line 71 of file PusServices.h.

◆ m_sourceID

std::uint8_t PusA::m_sourceID {}
private

Definition at line 67 of file PusServices.h.

67{}; // Source ID 8 ID of the source (e.g., satellite or sensor)

◆ m_type

const std::string PusA::m_type = "PusA"
private

Definition at line 70 of file PusServices.h.

◆ m_version

std::uint8_t PusA::m_version {}
private

Definition at line 64 of file PusServices.h.

64{}; // Version 3 Version of the PUS standard

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