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

Represents a PUS Type C (Time Code) header. More...

#include <PusServices.h>

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

Public Member Functions

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

Detailed Description

Represents a PUS Type C (Time Code) header.

Contains fields used for time synchronization.

Field Summary:

Definition at line 133 of file PusServices.h.

Constructor & Destructor Documentation

◆ PusC() [1/2]

PusC::PusC ( )
default

◆ PusC() [2/2]

PusC::PusC ( const uint8_t  version,
const uint8_t  serviceType,
const uint8_t  serviceSubtype,
const uint8_t  sourceID,
const uint16_t  timeCode,
const uint16_t  dataLength 
)
inlineexplicit

Constructs a PusC object with all fields explicitly set.

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

Definition at line 146 of file PusServices.h.

148 : m_version(version & 0x7), m_serviceType(serviceType),
149 m_serviceSubType(serviceSubtype), m_sourceID(sourceID),
150 m_timeCode(timeCode), m_dataLength(dataLength) {
151 }
uint8_t m_version
uint16_t m_timeCode
uint16_t m_dataLength
uint8_t m_serviceSubType
uint8_t m_sourceID
uint8_t m_serviceType

Member Function Documentation

◆ deserialize()

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

56 {
58 "PUS-C header not correct size (size != 8 bytes)");
59
60 m_version = data[0] & 0x7;
61 m_serviceType = data[1];
62 m_serviceSubType = data[2];
63 m_sourceID = data[3];
64 m_timeCode = data[4] << 8 | data[5];
65 m_dataLength = data[6] << 8 | data[7];
66 return true;
67}
#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 PusC::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 160 of file PusServices.h.

160{ return m_dataLength; }

◆ getServiceSubtype()

uint8_t PusC::getServiceSubtype ( ) const
inline

Definition at line 157 of file PusServices.h.

157{ return m_serviceSubType; }

◆ getServiceType()

uint8_t PusC::getServiceType ( ) const
inline

Definition at line 156 of file PusServices.h.

156{ return m_serviceType; }

◆ getSize()

uint16_t PusC::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 161 of file PusServices.h.

161{ return m_size; }

◆ getSourceID()

uint8_t PusC::getSourceID ( ) const
inline

Definition at line 158 of file PusServices.h.

158{ return m_sourceID; }

◆ getTimeCode()

uint16_t PusC::getTimeCode ( ) const
inline

Definition at line 159 of file PusServices.h.

159{ return m_timeCode; }

◆ getType()

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

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

◆ getVersion()

uint8_t PusC::getVersion ( ) const
inline

Definition at line 155 of file PusServices.h.

155{ return m_version; }

◆ serialize()

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

69 {
70 std::vector data{
71 static_cast<uint8_t>(m_version & 0x7),
75 static_cast<uint8_t>(m_timeCode >> 8 & 0xFF),
76 static_cast<uint8_t>(m_timeCode & 0xFF),
77 static_cast<uint8_t>(m_dataLength >> 8 & 0xFF),
78 static_cast<uint8_t>(m_dataLength & 0xFF),
79 };
80
81 return data;
82}

◆ setDataLength()

void PusC::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 153 of file PusServices.h.

153{ m_dataLength = dataLength; }

Member Data Documentation

◆ m_dataLength

uint16_t PusC::m_dataLength {}
private

Definition at line 173 of file PusServices.h.

173{}; // Data Length 16 Length of the time data in bytes

◆ m_serviceSubType

uint8_t PusC::m_serviceSubType {}
private

Definition at line 170 of file PusServices.h.

170{}; // Service Subtype 8 Subtype of the service (e.g., specific time type

◆ m_serviceType

uint8_t PusC::m_serviceType {}
private

Definition at line 169 of file PusServices.h.

169{}; // Service Type 8 Type of service (e.g., 0x03 for time code)

◆ m_size

const uint16_t PusC::m_size = 8
private

Definition at line 176 of file PusServices.h.

◆ m_sourceID

uint8_t PusC::m_sourceID {}
private

Definition at line 171 of file PusServices.h.

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

◆ m_timeCode

uint16_t PusC::m_timeCode {}
private

Definition at line 172 of file PusServices.h.

172{}; // Time Code 16 Time code value, depending on the system

◆ m_type

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

Definition at line 175 of file PusServices.h.

◆ m_version

uint8_t PusC::m_version {}
private

Definition at line 168 of file PusServices.h.

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

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