CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
Loading...
Searching...
No Matches
PusServices.h
Go to the documentation of this file.
1#ifndef PUS_SERVICES_H
2#define PUS_SERVICES_H
3
6#include "CCSDSResult.h"
19 class PusA final : public CCSDS::SecondaryHeaderAbstract {
20 public:
21 PusA() = default;
22
31 explicit PusA(const uint8_t version, const uint8_t serviceType, const uint8_t serviceSubtype,
32 const uint8_t sourceID, const uint32_t dataLength) : m_version(version & 0x7),
33 m_serviceType(serviceType),
34 m_serviceSubType(serviceSubtype),
35 m_sourceID(sourceID), m_dataLength(dataLength) {
36 }
37
38 void setDataLength(const uint16_t dataLength) override { m_dataLength = dataLength; }
39
40 [[nodiscard]] uint8_t getVersion() const { return m_version; }
41 [[nodiscard]] uint8_t getServiceType() const { return m_serviceType; }
42 [[nodiscard]] uint8_t getServiceSubtype() const { return m_serviceSubType; }
43 [[nodiscard]] uint8_t getSourceID() const { return m_sourceID; }
44 [[nodiscard]] uint16_t getDataLength() const override { return m_dataLength; }
45 [[nodiscard]] uint16_t getSize() const override { return m_size; }
46 [[nodiscard]] std::string getType() const override { return m_type; }
47
48 [[nodiscard]] std::vector<uint8_t> serialize() const override;
49 [[nodiscard]] CCSDS::ResultBool deserialize( const std::vector<uint8_t> &data ) override;
50
51 private: // Field Size (bits) Description
52 uint8_t m_version{}; // Version 3 Version of the PUS standard
53 uint8_t m_serviceType{}; // Service Type 8 Type of service (e.g., 0x01 for telemetry)
54 uint8_t m_serviceSubType{}; // Service Subtype 8 Subtype of the service (e.g., specific telemetry type)
55 uint8_t m_sourceID{}; // Source ID 8 ID of the source (e.g., satellite or sensor)
56 uint16_t m_dataLength{}; // Data Length 16 Length of the telemetry data in bytes
57
58 const std::string m_type = "PusA"; // Static registration (automatically called when the program starts)
59 const uint16_t m_size = 6; // bytes
60 };
61
75 class PusB final : public CCSDS::SecondaryHeaderAbstract {
76 public:
77 PusB() = default;
78
88 explicit PusB(const uint8_t version, const uint8_t serviceType, const uint8_t serviceSubtype,
89 const uint8_t sourceID, const uint8_t eventID, const uint16_t dataLength) : m_version(version & 0x7),
90 m_serviceType(serviceType), m_serviceSubType(serviceSubtype), m_sourceID(sourceID), m_eventID(eventID),
91 m_dataLength(dataLength) {
92 }
93
94 void setDataLength(const uint16_t dataLength) override { m_dataLength = dataLength; }
95
96 [[nodiscard]] uint8_t getVersion() const { return m_version; }
97 [[nodiscard]] uint8_t getServiceType() const { return m_serviceType; }
98 [[nodiscard]] uint8_t getServiceSubtype() const { return m_serviceSubType; }
99 [[nodiscard]] uint8_t getSourceID() const { return m_sourceID; }
100 [[nodiscard]] uint16_t getEventID() const { return m_eventID; }
101 [[nodiscard]] uint16_t getDataLength() const override { return m_dataLength; }
102 [[nodiscard]] uint16_t getSize() const override { return m_size; }
103 [[nodiscard]] std::string getType() const override { return m_type; }
104
105 [[nodiscard]] std::vector<uint8_t> serialize() const override;
106 [[nodiscard]] CCSDS::ResultBool deserialize( const std::vector<uint8_t> &data ) override;
107
108 private: // Field Size (bits) Description
109 uint8_t m_version{}; // Version 3 Version of the PUS standard
110 uint8_t m_serviceType{}; // Service Type 8 Type of service (e.g., 0x02 for event reporting)
111 uint8_t m_serviceSubType{}; // Service Subtype 8 Subtype of the service (e.g., specific event type)
112 uint8_t m_sourceID{}; // Source ID 8 ID of the source (e.g., satellite or sensor)
113 uint16_t m_eventID{}; // Event ID 16 ID of the event being reported
114 uint16_t m_dataLength{}; // Data Length 16 Length of the event data in bytes
115
116 const std::string m_type = "PusB"; // Static registration (automatically called when the program starts)
117 const uint16_t m_size = 8; // bytes
118 };
119
134 public:
135 PusC() = default;
136
146 explicit PusC(const uint8_t version, const uint8_t serviceType, const uint8_t serviceSubtype,
147 const uint8_t sourceID, const uint16_t timeCode,
148 const uint16_t dataLength) : m_version(version & 0x7), m_serviceType(serviceType),
149 m_serviceSubType(serviceSubtype), m_sourceID(sourceID),
150 m_timeCode(timeCode), m_dataLength(dataLength) {
151 }
152
153 void setDataLength(const uint16_t dataLength) override { m_dataLength = dataLength; }
154
155 [[nodiscard]] uint8_t getVersion() const { return m_version; }
156 [[nodiscard]] uint8_t getServiceType() const { return m_serviceType; }
157 [[nodiscard]] uint8_t getServiceSubtype() const { return m_serviceSubType; }
158 [[nodiscard]] uint8_t getSourceID() const { return m_sourceID; }
159 [[nodiscard]] uint16_t getTimeCode() const { return m_timeCode; }
160 [[nodiscard]] uint16_t getDataLength() const override { return m_dataLength; }
161 [[nodiscard]] uint16_t getSize() const override { return m_size; }
162 [[nodiscard]] std::string getType() const override { return m_type; }
163
164 [[nodiscard]] std::vector<uint8_t> serialize() const override;
165 [[nodiscard]] CCSDS::ResultBool deserialize( const std::vector<uint8_t> &data ) override;
166
167 private: // Field Size (bits) Description
168 uint8_t m_version{}; // Version 3 Version of the PUS standard
169 uint8_t m_serviceType{}; // Service Type 8 Type of service (e.g., 0x03 for time code)
170 uint8_t m_serviceSubType{}; // Service Subtype 8 Subtype of the service (e.g., specific time type
171 uint8_t m_sourceID{}; // Source ID 8 ID of the source (e.g., satellite or sensor)
172 uint16_t m_timeCode{}; // Time Code 16 Time code value, depending on the system
173 uint16_t m_dataLength{}; // Data Length 16 Length of the time data in bytes
174
175 const std::string m_type = "PusC"; // Static registration (automatically called when the program starts)
176 const uint16_t m_size = 8; // bytes
177 };
178
179
180#endif //PUS_SERVICES_H
Encapsulates a result that can hold either a value or an Error.
Definition CCSDSResult.h:81
Abstract base class for a (Packet Utilization Standard) header.
Represents a PUS Type A (Telemetry) header.
Definition PusServices.h:19
uint8_t getSourceID() const
Definition PusServices.h:43
std::vector< uint8_t > serialize() const override
Retrieves the serialized representation of the header.
void setDataLength(const uint16_t dataLength) override
Sets the length of the data associated with the packet.
Definition PusServices.h:38
const std::string m_type
Definition PusServices.h:58
uint16_t m_dataLength
Definition PusServices.h:56
uint8_t m_serviceSubType
Definition PusServices.h:54
CCSDS::ResultBool deserialize(const std::vector< uint8_t > &data) override
takes a buffer if data (vector uint8) and creates the header
PusA(const uint8_t version, const uint8_t serviceType, const uint8_t serviceSubtype, const uint8_t sourceID, const uint32_t dataLength)
Constructs a PusA object with all fields explicitly set.
Definition PusServices.h:31
uint8_t m_sourceID
Definition PusServices.h:55
uint8_t m_version
Definition PusServices.h:52
uint8_t m_serviceType
Definition PusServices.h:53
uint16_t getDataLength() const override
Gets the length of the data associated with the packet if applicable.
Definition PusServices.h:44
PusA()=default
uint8_t getVersion() const
Definition PusServices.h:40
uint8_t getServiceSubtype() const
Definition PusServices.h:42
uint8_t getServiceType() const
Definition PusServices.h:41
uint16_t getSize() const override
Gets the size of the header in bytes.
Definition PusServices.h:45
const uint16_t m_size
Definition PusServices.h:59
std::string getType() const override
Retrieves the name of the packet.
Definition PusServices.h:46
Represents a PUS Type B (Event Reporting) header.
Definition PusServices.h:75
uint8_t m_serviceType
const std::string m_type
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.
Definition PusServices.h:88
uint16_t getDataLength() const override
Gets the length of the data associated with the packet if applicable.
uint16_t m_dataLength
uint8_t m_version
std::vector< uint8_t > serialize() const override
Retrieves the serialized representation of the header.
uint16_t m_eventID
uint8_t m_sourceID
uint8_t getSourceID() const
Definition PusServices.h:99
uint16_t getEventID() const
uint16_t getSize() const override
Gets the size of the header in bytes.
const uint16_t m_size
CCSDS::ResultBool deserialize(const std::vector< uint8_t > &data) override
takes a buffer if data (vector uint8) and creates the header
std::string getType() const override
Retrieves the name of the packet.
uint8_t getServiceType() const
Definition PusServices.h:97
void setDataLength(const uint16_t dataLength) override
Sets the length of the data associated with the packet.
Definition PusServices.h:94
uint8_t getServiceSubtype() const
Definition PusServices.h:98
PusB()=default
uint8_t m_serviceSubType
uint8_t getVersion() const
Definition PusServices.h:96
Represents a PUS Type C (Time Code) header.
uint8_t getServiceSubtype() const
uint8_t m_version
uint16_t m_timeCode
uint16_t getTimeCode() const
const uint16_t m_size
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.
const std::string m_type
uint8_t getSourceID() const
uint8_t getServiceType() const
CCSDS::ResultBool deserialize(const std::vector< uint8_t > &data) override
takes a buffer if data (vector uint8) and creates the header
void setDataLength(const uint16_t dataLength) override
Sets the length of the data associated with the packet.
uint16_t getDataLength() const override
Gets the length of the data associated with the packet if applicable.
std::string getType() const override
Retrieves the name of the packet.
uint16_t m_dataLength
uint8_t m_serviceSubType
std::vector< uint8_t > serialize() const override
Retrieves the serialized representation of the header.
PusC()=default
uint8_t m_sourceID
uint8_t getVersion() const
uint16_t getSize() const override
Gets the size of the header in bytes.
uint8_t m_serviceType