F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Deframer.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title Deframer.hpp
3 // \author mstarch, bocchino
4 // \brief hpp file for Deframer component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2022, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef Svc_Deframer_HPP
14 #define Svc_Deframer_HPP
15 
20 #include "config/DeframerCfg.hpp"
21 
22 namespace Svc {
23 
37 class Deframer :
38  public DeframerComponentBase,
40 {
41  public:
42 
43  // ----------------------------------------------------------------------
44  // Construction, initialization, and destruction
45  // ----------------------------------------------------------------------
46 
48  Deframer(
49  const char* const compName
50  );
51 
53  void init(
54  const NATIVE_INT_TYPE instance = 0
55  );
56 
58  ~Deframer();
59 
61  void setup(
62  DeframingProtocol& protocol
63  );
64 
65  PRIVATE:
66 
67  // ----------------------------------------------------------------------
68  // Handler implementations for user-defined typed input ports
69  // ----------------------------------------------------------------------
70 
72  void cmdResponseIn_handler(
73  NATIVE_INT_TYPE portNum,
74  FwOpcodeType opcode,
75  U32 cmdSeq,
76  const Fw::CmdResponse& response
77  );
78 
80  void framedIn_handler(
81  const NATIVE_INT_TYPE portNum,
82  Fw::Buffer& recvBuffer,
83  const Drv::RecvStatus& recvStatus
84  );
85 
87  void schedIn_handler(
88  const NATIVE_INT_TYPE portNum,
89  NATIVE_UINT_TYPE context
90  );
91 
92  // ----------------------------------------------------------------------
93  // Implementation of DeframingProtocolInterface
94  // ----------------------------------------------------------------------
95 
98  void route(
99  Fw::Buffer& packetBuffer
100  );
101 
105  Fw::Buffer allocate(
106  const U32 size
107  );
108 
109  // ----------------------------------------------------------------------
110  // Helper methods
111  // ----------------------------------------------------------------------
112 
115  void processBuffer(
116  Fw::Buffer& buffer
117  );
118 
120  void processRing();
121 
122  // ----------------------------------------------------------------------
123  // Member variables
124  // ----------------------------------------------------------------------
125 
127  DeframingProtocol* m_protocol;
128 
130  Types::CircularBuffer m_inRing;
131 
133  U8 m_ringBuffer[DeframerCfg::RING_BUFFER_SIZE];
134 
136  U8 m_pollBuffer[DeframerCfg::POLL_BUFFER_SIZE];
137 
138 };
139 
140 } // end namespace Svc
141 
142 #endif
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:51
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:26
PlatformUIntType NATIVE_UINT_TYPE
Definition: BasicTypes.h:52
U32 FwOpcodeType
Definition: FpConfig.h:56
Status associated with the received data.
Enum representing a command response.
void init()
Object initializer.
Definition: ObjBase.cpp:27
Auto-generated base for Deframer component.
Generic deframing component using DeframingProtocol implementation for actual deframing.
Definition: Deframer.hpp:40
~Deframer()
Destroy Deframer instance.
Definition: Deframer.cpp:52
void setup(DeframingProtocol &protocol)
Set up the instance.
Definition: Deframer.cpp:54
Deframer(const char *const compName)
Construct Deframer instance.
Definition: Deframer.cpp:39
Abstract base class representing a deframing protocol.
interface supplied to the deframing protocol
static const U32 POLL_BUFFER_SIZE
The size of the polling buffer in bytes.
Definition: DeframerCfg.hpp:17
static const U32 RING_BUFFER_SIZE
The size of the circular buffer in bytes.
Definition: DeframerCfg.hpp:15