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 24 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 36 of file PusServices.h.

37 : m_version(version & 0x7),
38 m_serviceType(serviceType),
39 m_serviceSubType(serviceSubtype),
40 m_sourceID(sourceID), m_dataLength(dataLength) {
41 }
std::uint8_t m_serviceType
Definition PusServices.h:62
std::uint8_t m_serviceSubType
Definition PusServices.h:63
std::uint8_t m_sourceID
Definition PusServices.h:64
std::uint8_t m_version
Definition PusServices.h:61
std::uint16_t m_dataLength
Definition PusServices.h:65

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 6 of file PusServices.cpp.

6 {
8 "PUS-A header not correct size (size != 6 bytes)");
9
10 m_version = data[0] & 0x7;
11 m_serviceType = data[1];
12 m_serviceSubType = data[2];
13 m_sourceID = data[3];
14 m_dataLength = data[4] << 8 | data[5];
15 return true;
16}
#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:68
@ INVALID_SECONDARY_HEADER_DATA
Secondary header data is invalid.
Definition CCSDSResult.h:26

◆ getDataLength()

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

Definition at line 47 of file PusServices.h.

47{ return m_dataLength; }

◆ getServiceSubtype()

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

Definition at line 45 of file PusServices.h.

45{ return m_serviceSubType; }

◆ getServiceType()

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

Definition at line 44 of file PusServices.h.

44{ 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 48 of file PusServices.h.

48{ return m_size; }

◆ getSourceID()

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

Definition at line 46 of file PusServices.h.

46{ 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 49 of file PusServices.h.

49{ return m_type; }
const std::string m_type
Definition PusServices.h:67

◆ getVersion()

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

Definition at line 43 of file PusServices.h.

43{ return m_version; }

◆ loadFromConfig()

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

Definition at line 106 of file PusServices.cpp.

106 {
107 std::uint8_t version = 0;
108 std::uint8_t serviceType = 0;
109 std::uint8_t serviceSubType = 0;
110 std::uint8_t sourceId = 0;
111
112 RET_IF_ERR_MSG(!cfg.isKey("pus_version"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_version");
113 RET_IF_ERR_MSG(!cfg.isKey("pus_service_type"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_service_type");
114 RET_IF_ERR_MSG(!cfg.isKey("pus_service_sub_type"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_service_sub_type");
115 RET_IF_ERR_MSG(!cfg.isKey("pus_source_id"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_source_id");
116
117 ASSIGN_OR_PRINT(version, cfg.get<int>("pus_version"));
118 ASSIGN_OR_PRINT(serviceType, cfg.get<int>("pus_service_type"));
119 ASSIGN_OR_PRINT(serviceSubType,cfg.get< int>("pus_service_sub_type"));
120 ASSIGN_OR_PRINT(sourceId,cfg.get<int>("pus_source_id"));
121
122 m_version = version & 0x7;
123 m_serviceType = serviceType & 0xFF;
124 m_serviceSubType = serviceSubType & 0xFF;
125 m_sourceID = sourceId & 0xFF;
126
127 return true;
128}
#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:20
@ CONFIG_FILE_ERROR
Configuration file error.
Definition CCSDSResult.h:34
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 18 of file PusServices.cpp.

18 {
19 std::vector data{
20 static_cast<std::uint8_t>(m_version & 0x7),
24 static_cast<std::uint8_t>(m_dataLength >> 8 & 0xFF),
25 static_cast<std::uint8_t>(m_dataLength & 0xFF),
26 };
27
28 return data;
29}

◆ 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 31 of file PusServices.cpp.

31 {
33}
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 65 of file PusServices.h.

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

◆ m_serviceSubType

std::uint8_t PusA::m_serviceSubType {}
private

Definition at line 63 of file PusServices.h.

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

◆ m_serviceType

std::uint8_t PusA::m_serviceType {}
private

Definition at line 62 of file PusServices.h.

62{}; // 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 68 of file PusServices.h.

◆ m_sourceID

std::uint8_t PusA::m_sourceID {}
private

Definition at line 64 of file PusServices.h.

64{}; // 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 67 of file PusServices.h.

◆ m_version

std::uint8_t PusA::m_version {}
private

Definition at line 61 of file PusServices.h.

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

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