F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
AosDeframer.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title AosDeframer.hpp
3 // \author Auto-generated
4 // \brief hpp file for AosDeframer component implementation class
5 //
6 // Deframer for the AOS Space Data Link Protocol per CCSDS 732.0-B-5.
7 // Supports M_PDU data field service with:
8 // - Frame Error Control Field (FECF) validation
9 // - Space Packet Protocol (SPP) extraction
10 // - Encapsulation Packet Protocol (EPP) extraction per CCSDS 133.1-B-3
11 // ======================================================================
12 
13 #ifndef Svc_Ccsds_AosDeframer_HPP
14 #define Svc_Ccsds_AosDeframer_HPP
15 
23 #include "config/PvnEnumAc.hpp"
24 
25 namespace Svc {
26 namespace Ccsds {
27 
29  public:
30  // ----------------------------------------------------------------------
31  // Component construction and destruction
32  // ----------------------------------------------------------------------
33 
35  AosDeframer(const char* const compName
36  );
37 
39  ~AosDeframer();
40 
52  void configure(U32 fixedFrameSize,
53  bool frameErrorControlField,
54  U16 spacecraftId = ComCfg::SpacecraftId,
55  U8 vcId = 0,
57 
58  private:
59  // Forward declaration for helper method signatures that reference the nested VC state type
60  struct AosDeframerVc;
61 
62  // ----------------------------------------------------------------------
63  // Handler implementations for user-defined typed input ports
64  // ----------------------------------------------------------------------
65 
72  void dataIn_handler(FwIndexType portNum,
73  Fw::Buffer& data,
74  const ComCfg::FrameContext& context) override;
75 
79  void dataReturnIn_handler(FwIndexType portNum,
80  Fw::Buffer& data,
81  const ComCfg::FrameContext& context) override;
82 
83  // ----------------------------------------------------------------------
84  // Private helper methods
85  // ----------------------------------------------------------------------
86 
91  AosDeframerVc* parseAndValidateHeader(Fw::Buffer& data, ComCfg::FrameContext& context);
92 
97  bool validateFecf(Fw::Buffer& data);
98 
100  void notifyErrorIfConnected(Ccsds::FrameError error);
101 
103  void abandonSpanningPacket(AosDeframerVc& vc);
104 
108  void extractPackets(AosDeframerVc& vc, Fw::Buffer& data);
109 
115  FwSizeType sizePacket(AosDeframerVc& vc, U8* packetStart, FwSizeType remainingBytes);
116 
121  FwSizeType sizeSppPacket(U8* payloadStart, FwSizeType payloadSize);
122 
127  FwSizeType sizeEppPacket(const U8* const payloadStart, FwSizeType payloadSize);
128 
132  static U8 getPacketVersion(U8 firstByte);
133 
139  FwSizeType appendToSpanningPacket(AosDeframerVc& vc, U8* data, FwSizeType size);
140 
145  AosDeframerVc* getVcStruct(const U8 vcId);
146 
148  struct AosDeframerVc {
149  U8 vcStructIndex = 0xFF;
150  U8 virtualChannelId = 0;
152 
153  // Telemetry counters (per-VC)
154  U32 framesProcessed = 0;
155  U32 packetsExtracted = 0;
156  U32 vcFrameCount = 0;
157 
158  // Spanning packet state (for packets that span multiple frames)
159  // Per CCSDS 732.0-B-5 Section 4.1.4.2.2.3
161  static constexpr FwSizeType HEADER_BUF_SIZE =
162  8;
164 
166 
168  // Context to be sent w/ the spanning packet
170  } spanningPacket;
171  };
172 
173  private:
174  // ----------------------------------------------------------------------
175  // Member variables
176  // ----------------------------------------------------------------------
177 
178  // Frame-level configuration parameters (set via configure())
179  U32 m_fixedFrameSize = 0;
180  bool m_fecfEnabled = true;
181  U16 m_spacecraftId = 0;
182 
184  U32 m_crcErrorCount = 0;
185 
187  AosDeframerVc m_vcs[AosDeframer_NumVcs];
188 };
189 
190 } // namespace Ccsds
191 } // namespace Svc
192 
193 #endif
PlatformSizeType FwSizeType
~AosDeframer()
Destroy AosDeframer object.
Definition: AosDeframer.cpp:40
void configure(U32 fixedFrameSize, bool frameErrorControlField, U16 spacecraftId=ComCfg::SpacecraftId, U8 vcId=0, U8 pvnMask=PvnBitfield::SPP_MASK|PvnBitfield::EPP_MASK)
Configure the AosDeframer with mission-specific parameters.
Definition: AosDeframer.cpp:42
Auto-generated base for AosDeframer component.
static constexpr FwSizeType HEADER_BUF_SIZE
Max header bytes needed to determine size (8 bytes is largest EPP Header)
U8 headerBuf[HEADER_BUF_SIZE]
Header bytes accumulated before allocation.
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
AosDeframer(const char *const compName)
Construct AosDeframer object.
Definition: AosDeframer.cpp:28
Fw::Buffer buffer
Dynamically-allocated packet buffer.
PlatformIndexType FwIndexType
Type used to pass context info between components during framing/deframing.
RateGroupDivider component implementation.