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

Represents a PUS Type B (Event Reporting) header. More...

#include <PusServices.h>

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

Public Member Functions

 PusB ()=default
 
 PusB (const std::uint8_t version, const std::uint8_t serviceType, const std::uint8_t serviceSubtype, const std::uint8_t sourceID, const std::uint8_t eventID, const std::uint16_t dataLength)
 Constructs a PusB 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 getEventID () 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_eventID {}
 
std::uint16_t m_dataLength {}
 
const std::string m_type = "PusB"
 
const std::uint16_t m_size = 8
 

Additional Inherited Members

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

Detailed Description

Represents a PUS Type B (Event Reporting) header.

Contains fields used for event reporting.

Field Summary:

Definition at line 84 of file PusServices.h.

Constructor & Destructor Documentation

◆ PusB() [1/2]

PusB::PusB ( )
default

◆ PusB() [2/2]

PusB::PusB ( const std::uint8_t  version,
const std::uint8_t  serviceType,
const std::uint8_t  serviceSubtype,
const std::uint8_t  sourceID,
const std::uint8_t  eventID,
const std::uint16_t  dataLength 
)
inlineexplicit

Constructs a PusB object with all fields explicitly set.

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

Definition at line 97 of file PusServices.h.

98 : m_version(version & 0x7),
99 m_serviceType(serviceType), m_serviceSubType(serviceSubtype), m_sourceID(sourceID), m_eventID(eventID),
100 m_dataLength(dataLength) {
101 }
std::uint8_t m_serviceSubType
std::uint8_t m_serviceType
std::uint8_t m_sourceID
std::uint16_t m_eventID
std::uint16_t m_dataLength
std::uint8_t m_version

Member Function Documentation

◆ deserialize()

CCSDS::ResultBool PusB::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 35 of file PusServices.cpp.

35 {
37 "PUS-B header not correct size (size != 8 bytes)");
38 m_version = data[0] & 0x7;
39 m_serviceType = data[1];
40 m_serviceSubType = data[2];
41 m_sourceID = data[3];
42 m_eventID = data[4] << 8 | data[5];
43 m_dataLength = data[6] << 8 | data[7];
44 return true;
45}
#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
@ INVALID_SECONDARY_HEADER_DATA
Secondary header data is invalid.
Definition CCSDSResult.h:26

◆ getDataLength()

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

Definition at line 108 of file PusServices.h.

108{ return m_dataLength; }

◆ getEventID()

std::uint16_t PusB::getEventID ( ) const
inline

Definition at line 107 of file PusServices.h.

107{ return m_eventID; }

◆ getServiceSubtype()

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

Definition at line 105 of file PusServices.h.

105{ return m_serviceSubType; }

◆ getServiceType()

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

Definition at line 104 of file PusServices.h.

104{ return m_serviceType; }

◆ getSize()

std::uint16_t PusB::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 109 of file PusServices.h.

109{ return m_size; }

◆ getSourceID()

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

Definition at line 106 of file PusServices.h.

106{ return m_sourceID; }

◆ getType()

std::string PusB::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 110 of file PusServices.h.

110{ return m_type; }
const std::string m_type

◆ getVersion()

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

Definition at line 103 of file PusServices.h.

103{ return m_version; }

◆ loadFromConfig()

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

Definition at line 130 of file PusServices.cpp.

130 {
131 std::uint8_t version = 0;
132 std::uint8_t serviceType = 0;
133 std::uint8_t serviceSubType = 0;
134 std::uint8_t sourceId = 0;
135 std::uint8_t eventId = 0;
136
137 RET_IF_ERR_MSG(!cfg.isKey("pus_version"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_version");
138 RET_IF_ERR_MSG(!cfg.isKey("pus_service_type"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_service_type");
139 RET_IF_ERR_MSG(!cfg.isKey("pus_service_sub_type"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_service_sub_type");
140 RET_IF_ERR_MSG(!cfg.isKey("pus_source_id"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_source_id");
141 RET_IF_ERR_MSG(!cfg.isKey("pus_event_id"), CCSDS::ErrorCode::CONFIG_FILE_ERROR,"Config: Missing string field: pus_event_id");
142
143 ASSIGN_OR_PRINT(version, cfg.get<int>("pus_version"));
144 ASSIGN_OR_PRINT(serviceType, cfg.get<int>("pus_service_type"));
145 ASSIGN_OR_PRINT(serviceSubType,cfg.get< int>("pus_service_sub_type"));
146 ASSIGN_OR_PRINT(sourceId,cfg.get<int>("pus_source_id"));
147 ASSIGN_OR_PRINT(eventId,cfg.get<int>("pus_event_id"));
148
149 m_version = version & 0x7;
150 m_serviceType = serviceType & 0xFF;
151 m_serviceSubType = serviceSubType & 0xFF;
152 m_sourceID = sourceId & 0xFF;
153 m_eventID = eventId & 0xFFFF;
154
155 return true;
156}
#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 > PusB::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 47 of file PusServices.cpp.

47 {
48 std::vector data{
49 static_cast<std::uint8_t>(m_version & 0x7),
53 static_cast<std::uint8_t>(m_eventID >> 8 & 0xFF),
54 static_cast<std::uint8_t>(m_eventID & 0xFF),
55 static_cast<std::uint8_t>(m_dataLength >> 8 & 0xFF),
56 static_cast<std::uint8_t>(m_dataLength & 0xFF),
57 };
58
59 return data;
60}

◆ update()

void PusB::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 62 of file PusServices.cpp.

62 {
64}
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 PusB::m_dataLength {}
private

Definition at line 126 of file PusServices.h.

126{}; // Data Length 16 Length of the event data in bytes

◆ m_eventID

std::uint16_t PusB::m_eventID {}
private

Definition at line 125 of file PusServices.h.

125{}; // Event ID 16 ID of the event being reported

◆ m_serviceSubType

std::uint8_t PusB::m_serviceSubType {}
private

Definition at line 123 of file PusServices.h.

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

◆ m_serviceType

std::uint8_t PusB::m_serviceType {}
private

Definition at line 122 of file PusServices.h.

122{}; // Service Type 8 Type of service (e.g., 0x02 for event reporting)

◆ m_size

const std::uint16_t PusB::m_size = 8
private

Definition at line 129 of file PusServices.h.

◆ m_sourceID

std::uint8_t PusB::m_sourceID {}
private

Definition at line 124 of file PusServices.h.

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

◆ m_type

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

Definition at line 128 of file PusServices.h.

◆ m_version

std::uint8_t PusB::m_version {}
private

Definition at line 121 of file PusServices.h.

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

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