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 
24 #include "config/PvnEnumAc.hpp"
25 
26 namespace Svc {
27 namespace Ccsds {
28 
30  public:
31  // ----------------------------------------------------------------------
32  // Component construction and destruction
33  // ----------------------------------------------------------------------
34 
36  AosDeframer(const char* const compName
37  );
38 
40  ~AosDeframer();
41 
53  void configure(U32 fixedFrameSize,
54  bool frameErrorControlField,
55  U16 spacecraftId = ComCfg::SpacecraftId,
56  U8 vcId = 0,
58 
59  private:
60  // Forward declaration for helper method signatures that reference the nested VC state type
61  struct AosDeframerVc;
62 
63  // ----------------------------------------------------------------------
64  // Handler implementations for user-defined typed input ports
65  // ----------------------------------------------------------------------
66 
73  void dataIn_handler(FwIndexType portNum,
74  Fw::Buffer& data,
75  const ComCfg::FrameContext& context) override;
76 
80  void dataReturnIn_handler(FwIndexType portNum,
81  Fw::Buffer& data,
82  const ComCfg::FrameContext& context) override;
83 
84  // ----------------------------------------------------------------------
85  // Private helper methods
86  // ----------------------------------------------------------------------
87 
92  AosDeframerVc* parseAndValidateHeader(Fw::Buffer& data, ComCfg::FrameContext& context);
93 
98  bool validateFecf(Fw::Buffer& data);
99 
101  void notifyErrorIfConnected(Ccsds::FrameError error);
102 
104  void abandonSpanningPacket(AosDeframerVc& vc);
105 
109  void extractPackets(AosDeframerVc& vc, Fw::Buffer& data);
110 
116  FwSizeType sizePacket(AosDeframerVc& vc, U8* packetStart, FwSizeType remainingBytes);
117 
122  FwSizeType sizeSppPacket(U8* payloadStart, FwSizeType payloadSize);
123 
128  FwSizeType sizeEppPacket(const U8* const payloadStart, FwSizeType payloadSize);
129 
133  static U8 getPacketVersion(U8 firstByte);
134 
140  FwSizeType appendToSpanningPacket(AosDeframerVc& vc, U8* data, FwSizeType size);
141 
146  AosDeframerVc* getVcStruct(const U8 vcId);
147 
149  struct AosDeframerVc {
150  U8 vcStructIndex = 0xFF;
151  U8 virtualChannelId = 0;
153 
154  // Telemetry counters (per-VC)
155  U32 framesProcessed = 0;
156  U32 packetsExtracted = 0;
157  U32 vcFrameCount = 0;
158 
159  // Spanning packet state (for packets that span multiple frames)
160  // Per CCSDS 732.0-B-5 Section 4.1.4.2.2.3
162  static constexpr FwSizeType HEADER_BUF_SIZE =
163  8;
165 
167 
169  // Context to be sent w/ the spanning packet
171  } spanningPacket;
172  };
173 
174  private:
175  // ----------------------------------------------------------------------
176  // Member variables
177  // ----------------------------------------------------------------------
178 
179  // Frame-level configuration parameters (set via configure())
180  U32 m_fixedFrameSize = 0;
181  bool m_fecfEnabled = true;
182  U16 m_spacecraftId = 0;
183 
185  U32 m_crcErrorCount = 0;
186 
188  AosDeframerVc m_vcs[AosDeframer_NumVcs];
189 };
190 
191 } // namespace Ccsds
192 } // namespace Svc
193 
194 #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:54
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.