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"
7
8//exclude includes when building for MCU
9#ifndef CCSDS_MCU
10 #include "CCSDSConfig.h"
11#endif //CCSDS_MCU
24 class PusA final : public CCSDS::SecondaryHeaderAbstract {
25 public:
26 PusA() = default;
27
36 explicit PusA(const std::uint8_t version, const std::uint8_t serviceType, const std::uint8_t serviceSubtype,
37 const std::uint8_t sourceID, const std::uint32_t dataLength) : m_version(version & 0x7),
38 m_serviceType(serviceType),
39 m_serviceSubType(serviceSubtype),
40 m_sourceID(sourceID), m_dataLength(dataLength) {
41 }
42
43 [[nodiscard]] std::uint8_t getVersion() const { return m_version; }
44 [[nodiscard]] std::uint8_t getServiceType() const { return m_serviceType; }
45 [[nodiscard]] std::uint8_t getServiceSubtype() const { return m_serviceSubType; }
46 [[nodiscard]] std::uint8_t getSourceID() const { return m_sourceID; }
47 [[nodiscard]] std::uint16_t getDataLength() const { return m_dataLength; }
48 [[nodiscard]] std::uint16_t getSize() const override { return m_size; }
49 [[nodiscard]] std::string getType() const override { return m_type; }
50
51 [[nodiscard]] std::vector<std::uint8_t> serialize() const override;
52 [[nodiscard]] CCSDS::ResultBool deserialize( const std::vector<std::uint8_t> &data ) override;
53 void update(CCSDS::DataField* dataField) override;
54
55#ifndef CCSDS_MCU
56 CCSDS::ResultBool loadFromConfig(const ::Config &cfg) override;
57#endif
58
59
60 private: // Field Size (bits) Description
61 std::uint8_t m_version{}; // Version 3 Version of the PUS standard
62 std::uint8_t m_serviceType{}; // Service Type 8 Type of service (e.g., 0x01 for telemetry)
63 std::uint8_t m_serviceSubType{}; // Service Subtype 8 Subtype of the service (e.g., specific telemetry type)
64 std::uint8_t m_sourceID{}; // Source ID 8 ID of the source (e.g., satellite or sensor)
65 std::uint16_t m_dataLength{}; // Data Length 16 Length of the telemetry data in bytes
66
67 const std::string m_type = "PusA"; // Static registration (automatically called when the program starts)
68 const std::uint16_t m_size = 6; // bytes
69 };
70
84 class PusB final : public CCSDS::SecondaryHeaderAbstract {
85 public:
86 PusB() = default;
87
97 explicit PusB(const std::uint8_t version, const std::uint8_t serviceType, const std::uint8_t serviceSubtype,
98 const std::uint8_t sourceID, const std::uint8_t eventID, const std::uint16_t dataLength) : m_version(version & 0x7),
99 m_serviceType(serviceType), m_serviceSubType(serviceSubtype), m_sourceID(sourceID), m_eventID(eventID),
100 m_dataLength(dataLength) {
101 }
102
103 [[nodiscard]] std::uint8_t getVersion() const { return m_version; }
104 [[nodiscard]] std::uint8_t getServiceType() const { return m_serviceType; }
105 [[nodiscard]] std::uint8_t getServiceSubtype() const { return m_serviceSubType; }
106 [[nodiscard]] std::uint8_t getSourceID() const { return m_sourceID; }
107 [[nodiscard]] std::uint16_t getEventID() const { return m_eventID; }
108 [[nodiscard]] std::uint16_t getDataLength() const { return m_dataLength; }
109 [[nodiscard]] std::uint16_t getSize() const override { return m_size; }
110 [[nodiscard]] std::string getType() const override { return m_type; }
111
112 [[nodiscard]] std::vector<std::uint8_t> serialize() const override;
113 [[nodiscard]] CCSDS::ResultBool deserialize( const std::vector<std::uint8_t> &data ) override;
114 void update(CCSDS::DataField* dataField) override;
115
116#ifndef CCSDS_MCU
117 CCSDS::ResultBool loadFromConfig(const ::Config &cfg) override;
118#endif
119
120 private: // Field Size (bits) Description
121 std::uint8_t m_version{}; // Version 3 Version of the PUS standard
122 std::uint8_t m_serviceType{}; // Service Type 8 Type of service (e.g., 0x02 for event reporting)
123 std::uint8_t m_serviceSubType{}; // Service Subtype 8 Subtype of the service (e.g., specific event type)
124 std::uint8_t m_sourceID{}; // Source ID 8 ID of the source (e.g., satellite or sensor)
125 std::uint16_t m_eventID{}; // Event ID 16 ID of the event being reported
126 std::uint16_t m_dataLength{}; // Data Length 16 Length of the event data in bytes
127
128 const std::string m_type = "PusB"; // Static registration (automatically called when the program starts)
129 const std::uint16_t m_size = 8; // bytes
130 };
131
146 public:
148
158 explicit PusC(const std::uint8_t version, const std::uint8_t serviceType, const std::uint8_t serviceSubtype,
159 const std::uint8_t sourceID, const std::vector<std::uint8_t>& timeCode,
160 const std::uint16_t dataLength) : m_version(version & 0x7), m_serviceType(serviceType),
161 m_serviceSubType(serviceSubtype), m_sourceID(sourceID),
162 m_timeCode(timeCode), m_dataLength(dataLength) {
163 variableLength=true;
164 }
165
166 [[nodiscard]] std::uint8_t getVersion() const { return m_version; }
167 [[nodiscard]] std::uint8_t getServiceType() const { return m_serviceType; }
168 [[nodiscard]] std::uint8_t getServiceSubtype() const { return m_serviceSubType; }
169 [[nodiscard]] std::uint8_t getSourceID() const { return m_sourceID; }
170 [[nodiscard]] std::vector<std::uint8_t> getTimeCode() const { return m_timeCode; }
171 [[nodiscard]] std::uint16_t getDataLength() const { return m_dataLength; }
172 [[nodiscard]] std::uint16_t getSize() const override { return m_size + m_timeCode.size(); }
173 [[nodiscard]] std::string getType() const override { return m_type; }
174
175 [[nodiscard]] std::vector<std::uint8_t> serialize() const override;
176 [[nodiscard]] CCSDS::ResultBool deserialize( const std::vector<std::uint8_t> &data ) override;
177 void update(CCSDS::DataField* dataField) override;
178
179#ifndef CCSDS_MCU
180 CCSDS::ResultBool loadFromConfig(const ::Config &cfg) override;
181#endif
182
183 private: // Field Size (bits) Description
184 std::uint8_t m_version{}; // Version 3 Version of the PUS standard
185 std::uint8_t m_serviceType{}; // Service Type 8 Type of service (e.g., 0x03 for time code)
186 std::uint8_t m_serviceSubType{}; // Service Subtype 8 Subtype of the service (e.g., specific time type
187 std::uint8_t m_sourceID{}; // Source ID 8 ID of the source (e.g., satellite or sensor)
188 std::vector<std::uint8_t> m_timeCode{}; // Time Code 16 Time code value, depending on the system
189 std::uint16_t m_dataLength{}; // Data Length 16 Length of the time data in bytes
190
191 const std::string m_type = "PusC"; // Static registration (automatically called when the program starts)
192 const std::uint16_t m_size = 6; // bytes minimum size
193
194 };
195
196
197#endif //PUS_SERVICES_H
Represents the data field of a CCSDS packet.
Encapsulates a result that can hold either a value or an Error.
Definition CCSDSResult.h:82
Abstract base class for a (Packet Utilization Standard) header.
std::uint16_t getSize() const override
Gets the size of the header in bytes.
Definition PusServices.h:48
std::uint16_t getDataLength() const
Definition PusServices.h:47
std::uint8_t getServiceSubtype() const
Definition PusServices.h:45
std::uint8_t getSourceID() const
Definition PusServices.h:46
std::uint8_t getServiceType() const
Definition PusServices.h:44
PusA()=default
std::uint8_t getVersion() const
Definition PusServices.h:43
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.
Definition PusServices.h:36
std::string getType() const override
Retrieves the name of the packet.
Definition PusServices.h:49
Represents a PUS Type B (Event Reporting) header.
Definition PusServices.h:84
const std::string m_type
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.
Definition PusServices.h:97
std::uint8_t getSourceID() const
std::uint8_t m_serviceSubType
CCSDS::ResultBool deserialize(const std::vector< std::uint8_t > &data) override
takes a buffer if data (vector std::uint8) and creates the header
std::vector< std::uint8_t > serialize() const override
Retrieves the serialized representation of the header.
std::uint8_t m_serviceType
std::uint8_t m_sourceID
std::uint16_t m_eventID
std::uint16_t getEventID() const
std::uint8_t getServiceSubtype() const
std::uint16_t m_dataLength
std::string getType() const override
Retrieves the name of the packet.
std::uint8_t getVersion() const
std::uint8_t m_version
std::uint8_t getServiceType() const
const std::uint16_t m_size
void update(CCSDS::DataField *dataField) override
Defines how the packet secondary header is updated using the data field as reference.
std::uint16_t getSize() const override
Gets the size of the header in bytes.
PusB()=default
CCSDS::ResultBool loadFromConfig(const ::Config &cfg) override
std::uint16_t getDataLength() const
Represents a PUS Type C (Time Code) header.
std::uint16_t getSize() const override
Gets the size of the header in bytes.
std::uint8_t getVersion() const
std::uint16_t getDataLength() const
const std::uint16_t m_size
CCSDS::ResultBool deserialize(const std::vector< std::uint8_t > &data) override
takes a buffer if data (vector std::uint8) and creates the header
std::vector< std::uint8_t > m_timeCode
std::uint8_t m_serviceType
PusC(const std::uint8_t version, const std::uint8_t serviceType, const std::uint8_t serviceSubtype, const std::uint8_t sourceID, const std::vector< std::uint8_t > &timeCode, const std::uint16_t dataLength)
Constructs a PusC object with all fields explicitly set.
std::uint8_t m_sourceID
std::vector< std::uint8_t > serialize() const override
Retrieves the serialized representation of the header.
const std::string m_type
CCSDS::ResultBool loadFromConfig(const ::Config &cfg) override
std::vector< std::uint8_t > getTimeCode() const
std::uint8_t getSourceID() const
std::string getType() const override
Retrieves the name of the packet.
std::uint16_t m_dataLength
std::uint8_t m_serviceSubType
void update(CCSDS::DataField *dataField) override
Defines how the packet secondary header is updated using the data field as reference.
std::uint8_t getServiceSubtype() const
std::uint8_t getServiceType() const
std::uint8_t m_version