F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
TmFramer.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title TmFramer.hpp
3 // \author thomas-bc
4 // \brief hpp file for TmFramer component implementation class
5 // ======================================================================
6 
7 #ifndef Svc_CCSDS_TmFramer_HPP
8 #define Svc_CCSDS_TmFramer_HPP
9 
15 
16 namespace Svc {
17 
18 namespace CCSDS {
19 
20 class TmFramer final : public TmFramerComponentBase {
21  friend class TmFramerTester;
22 
24  "TM Frame Fixed Size must be at least large enough to hold header, trailer and data");
25  // These are to ensure the frame can hold the packet buffer, its SP header and an idle packet of 1 byte
26  // This is because TM specifies a frame to be padded with an idle packet of at least 1 byte of idle data
27  static_assert(
29  "TM Frame Fixed Size must be at least large enough to hold a full com buffer, 2 SP headers and 1 byte");
30  static_assert(
32  "TM Frame Fixed Size must be at least large enough to hold a full com buffer, 2 SP headers and 1 byte");
33 
34  static constexpr U8 IDLE_DATA_PATTERN = 0x44;
35 
36  enum class BufferOwnershipState {
37  NOT_OWNED,
38  OWNED,
39  };
40 
41  public:
42  // ----------------------------------------------------------------------
43  // Component construction and destruction
44  // ----------------------------------------------------------------------
45 
47  TmFramer(const char* const compName
48  );
49 
51  ~TmFramer();
52 
53  private:
54  // ----------------------------------------------------------------------
55  // Handler implementations for typed input ports
56  // ----------------------------------------------------------------------
57 
62  void comStatusIn_handler(FwIndexType portNum,
63  Fw::Success& condition
64  ) override;
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  // Helpers
85  // ----------------------------------------------------------------------
86  private:
90  void fill_with_idle_packet(Fw::SerializeBufferBase& serializer);
91 
92  // ----------------------------------------------------------------------
93  // Members
94  // ----------------------------------------------------------------------
95  private:
96  // Because the TM protocol use fixed width frames, and only one frame is in transit between ComQueue and
97  // ComInterface at a time, we can use a member fixed-size buffer to hold the frame data
98  U8 m_frameBuffer[ComCfg::TmFrameFixedSize];
99  BufferOwnershipState m_bufferState = BufferOwnershipState::OWNED;
100 
101  // Current implementation uses a single virtual channel, so we can use a single virtual frame count
102  U8 m_masterFrameCount;
103  U8 m_virtualFrameCount;
104 };
105 
106 } // namespace CCSDS
107 } // namespace Svc
108 
109 #endif
The size of the serial representation.
~TmFramer()
Destroy TmFramer object.
Definition: TmFramer.cpp:22
friend class TmFramerTester
Definition: TmFramer.hpp:21
The size of the serial representation.
#define FW_COM_BUFFER_MAX_SIZE
Definition: FpConfig.h:182
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:56
PlatformIndexType FwIndexType
Type used to pass context info between components during framing/deframing.
RateGroupDivider component implementation.
Auto-generated base for TmFramer component.
TmFramer(const char *const compName)
Construct TmFramer object.
Definition: TmFramer.cpp:19
#define FW_FILE_BUFFER_MAX_SIZE
Max size of file buffer (i.e. chunk of file)
Definition: FpConfig.h:249
Success/Failure.