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 
26  static constexpr FwSizeType TmPayloadCapacity =
28  static constexpr FwSizeType SppOverhead = (2 * SpacePacketHeader::SERIALIZED_SIZE) + 1;
29 
30  // These are to ensure the frame can hold the packet buffer, its SP header and an idle packet of 1 byte
31  // This is because TM specifies a frame to be padded with an idle packet of at least 1 byte of idle data
32  static_assert(TmPayloadCapacity >= FW_COM_BUFFER_MAX_SIZE + SppOverhead,
33  "TM Frame Fixed Size must be at least large enough to hold Tm Header + Footer, a full com buffer, 2 "
34  "SP headers, and 1 idle byte");
35  static_assert(TmPayloadCapacity >= FW_FILE_BUFFER_MAX_SIZE + SppOverhead,
36  "TM Frame Fixed Size must be at least large enough to hold Tm Header + Footer, a full file buffer, 2 "
37  "SP headers, and 1 idle byte");
38 
39  static constexpr U8 IDLE_DATA_PATTERN = 0x44;
40 
41  enum class BufferOwnershipState {
42  NOT_OWNED,
43  OWNED,
44  };
45 
46  public:
47  // ----------------------------------------------------------------------
48  // Component construction and destruction
49  // ----------------------------------------------------------------------
50 
52  TmFramer(const char* const compName
53  );
54 
56  ~TmFramer();
57 
58  private:
59  // ----------------------------------------------------------------------
60  // Handler implementations for typed input ports
61  // ----------------------------------------------------------------------
62 
67  void comStatusIn_handler(FwIndexType portNum,
68  Fw::Success& condition
69  ) override;
70 
77  void dataIn_handler(FwIndexType portNum,
78  Fw::Buffer& data,
79  const ComCfg::FrameContext& context) override;
80 
84  void dataReturnIn_handler(FwIndexType portNum,
85  Fw::Buffer& data,
86  const ComCfg::FrameContext& context) override;
87 
88  // ----------------------------------------------------------------------
89  // Helpers
90  // ----------------------------------------------------------------------
91  private:
95  void fill_with_idle_packet(Fw::SerializeBufferBase& serializer);
96 
97  // ----------------------------------------------------------------------
98  // Members
99  // ----------------------------------------------------------------------
100  private:
101  // Because the TM protocol use fixed width frames, and only one frame is in transit between ComQueue and
102  // ComInterface at a time, we can use a member fixed-size buffer to hold the frame data
103  U8 m_frameBuffer[ComCfg::TmFrameFixedSize];
104  BufferOwnershipState m_bufferState = BufferOwnershipState::OWNED;
105 
106  // Current implementation uses a single virtual channel, so we can use a single virtual frame count
107  U8 m_masterFrameCount;
108  U8 m_virtualFrameCount;
109 };
110 
111 } // namespace Ccsds
112 } // namespace Svc
113 
114 #endif
The size of the serial representation.
PlatformSizeType FwSizeType
The size of the serial representation.
~TmFramer()
Destroy TmFramer object.
Definition: TmFramer.cpp:22
friend class TmFramerTester
Definition: TmFramer.hpp:21
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
Auto-generated base for TmFramer component.
TmFramer(const char *const compName)
Construct TmFramer object.
Definition: TmFramer.cpp:19
PlatformIndexType FwIndexType
Type used to pass context info between components during framing/deframing.
RateGroupDivider component implementation.
Success/Failure.