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 uint8_t version, const uint8_t serviceType, const uint8_t serviceSubtype, const uint8_t sourceID, const uint8_t eventID, const uint16_t dataLength)
 Constructs a PusB object with all fields explicitly set.
 
void setDataLength (const uint16_t dataLength) override
 Sets the length of the data associated with the packet.
 
uint8_t getVersion () const
 
uint8_t getServiceType () const
 
uint8_t getServiceSubtype () const
 
uint8_t getSourceID () const
 
uint16_t getEventID () const
 
uint16_t getDataLength () const override
 Gets the length of the data associated with the packet if applicable.
 
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< uint8_t > serialize () const override
 Retrieves the serialized representation of the header.
 
CCSDS::ResultBool deserialize (const std::vector< uint8_t > &data) override
 takes a buffer if data (vector uint8) and creates the header
 
- Public Member Functions inherited from CCSDS::SecondaryHeaderAbstract
virtual ~SecondaryHeaderAbstract ()=default
 

Private Attributes

uint8_t m_version {}
 
uint8_t m_serviceType {}
 
uint8_t m_serviceSubType {}
 
uint8_t m_sourceID {}
 
uint16_t m_eventID {}
 
uint16_t m_dataLength {}
 
const std::string m_type = "PusB"
 
const uint16_t m_size = 8
 

Detailed Description

Represents a PUS Type B (Event Reporting) header.

Contains fields used for event reporting.

Field Summary:

Definition at line 75 of file PusServices.h.

Constructor & Destructor Documentation

◆ PusB() [1/2]

PusB::PusB ( )
default

◆ PusB() [2/2]

PusB::PusB ( const uint8_t  version,
const uint8_t  serviceType,
const uint8_t  serviceSubtype,
const uint8_t  sourceID,
const uint8_t  eventID,
const 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 88 of file PusServices.h.

89 : m_version(version & 0x7),
90 m_serviceType(serviceType), m_serviceSubType(serviceSubtype), m_sourceID(sourceID), m_eventID(eventID),
91 m_dataLength(dataLength) {
92 }
uint8_t m_serviceType
uint16_t m_dataLength
uint8_t m_version
uint16_t m_eventID
uint8_t m_sourceID
uint8_t m_serviceSubType

Member Function Documentation

◆ deserialize()

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

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

Returns
Boolean true on success or Error.

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 29 of file PusServices.cpp.

29 {
31 "PUS-B header not correct size (size != 8 bytes)");
32 m_version = data[0] & 0x7;
33 m_serviceType = data[1];
34 m_serviceSubType = data[2];
35 m_sourceID = data[3];
36 m_eventID = data[4] << 8 | data[5];
37 m_dataLength = data[6] << 8 | data[7];
38 return true;
39}
#define RET_IF_ERR_MSG(condition, errorCode, message)
Macro to return an error with an error message if a condition is met.
const uint16_t m_size
@ INVALID_SECONDARY_HEADER_DATA
Secondary header data is invalid.
Definition CCSDSResult.h:25

◆ getDataLength()

uint16_t PusB::getDataLength ( ) const
inlineoverridevirtual

Gets the length of the data associated with the packet if applicable.

Returns
The length of the data in bytes set in the header.

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 101 of file PusServices.h.

101{ return m_dataLength; }

◆ getEventID()

uint16_t PusB::getEventID ( ) const
inline

Definition at line 100 of file PusServices.h.

100{ return m_eventID; }

◆ getServiceSubtype()

uint8_t PusB::getServiceSubtype ( ) const
inline

Definition at line 98 of file PusServices.h.

98{ return m_serviceSubType; }

◆ getServiceType()

uint8_t PusB::getServiceType ( ) const
inline

Definition at line 97 of file PusServices.h.

97{ return m_serviceType; }

◆ getSize()

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

102{ return m_size; }

◆ getSourceID()

uint8_t PusB::getSourceID ( ) const
inline

Definition at line 99 of file PusServices.h.

99{ 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 103 of file PusServices.h.

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

◆ getVersion()

uint8_t PusB::getVersion ( ) const
inline

Definition at line 96 of file PusServices.h.

96{ return m_version; }

◆ serialize()

std::vector< 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 41 of file PusServices.cpp.

41 {
42 std::vector data{
43 static_cast<uint8_t>(m_version & 0x7),
47 static_cast<uint8_t>(m_eventID >> 8 & 0xFF),
48 static_cast<uint8_t>(m_eventID & 0xFF),
49 static_cast<uint8_t>(m_dataLength >> 8 & 0xFF),
50 static_cast<uint8_t>(m_dataLength & 0xFF),
51 };
52
53 return data;
54}

◆ setDataLength()

void PusB::setDataLength ( const uint16_t  dataLength)
inlineoverridevirtual

Sets the length of the data associated with the packet.

Parameters
dataLengthLength of the data in bytes.

Implements CCSDS::SecondaryHeaderAbstract.

Definition at line 94 of file PusServices.h.

94{ m_dataLength = dataLength; }

Member Data Documentation

◆ m_dataLength

uint16_t PusB::m_dataLength {}
private

Definition at line 114 of file PusServices.h.

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

◆ m_eventID

uint16_t PusB::m_eventID {}
private

Definition at line 113 of file PusServices.h.

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

◆ m_serviceSubType

uint8_t PusB::m_serviceSubType {}
private

Definition at line 111 of file PusServices.h.

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

◆ m_serviceType

uint8_t PusB::m_serviceType {}
private

Definition at line 110 of file PusServices.h.

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

◆ m_size

const uint16_t PusB::m_size = 8
private

Definition at line 117 of file PusServices.h.

◆ m_sourceID

uint8_t PusB::m_sourceID {}
private

Definition at line 112 of file PusServices.h.

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

◆ m_version

uint8_t PusB::m_version {}
private

Definition at line 109 of file PusServices.h.

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

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