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
10
#include "
Svc/Ccsds/TmFramer/TmFramerComponentAc.hpp
"
11
#include "
Svc/Ccsds/Types/FppConstantsAc.hpp
"
12
#include "
Svc/Ccsds/Types/SpacePacketHeaderSerializableAc.hpp
"
13
#include "
Svc/Ccsds/Types/TMHeaderSerializableAc.hpp
"
14
#include "
Svc/Ccsds/Types/TMTrailerSerializableAc.hpp
"
15
16
namespace
Svc
{
17
18
namespace
Ccsds {
19
20
class
TmFramer
final :
public
TmFramerComponentBase
{
21
friend
class
TmFramerTester
;
22
23
static_assert(
ComCfg::TmFrameFixedSize
>
TMHeader::SERIALIZED_SIZE
+
TMTrailer::SERIALIZED_SIZE
,
24
"TM Frame Fixed Size must be at least large enough to hold header, trailer and data"
);
25
26
static
constexpr
FwSizeType
TmPayloadCapacity =
27
ComCfg::TmFrameFixedSize
- (
TMHeader::SERIALIZED_SIZE
+
TMTrailer::SERIALIZED_SIZE
);
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
Svc::Ccsds::TMTrailer::SERIALIZED_SIZE
The size of the serial representation.
Definition:
TMTrailerSerializableAc.hpp:32
TmFramerComponentAc.hpp
FwSizeType
PlatformSizeType FwSizeType
Definition:
FwSizeTypeAliasAc.h:15
SpacePacketHeaderSerializableAc.hpp
FppConstantsAc.hpp
Svc::Ccsds::TMHeader::SERIALIZED_SIZE
The size of the serial representation.
Definition:
TMHeaderSerializableAc.hpp:32
Svc::Ccsds::TmFramer::~TmFramer
~TmFramer()
Destroy TmFramer object.
Definition:
TmFramer.cpp:22
TMTrailerSerializableAc.hpp
FW_FILE_BUFFER_MAX_SIZE
Definition:
FppConstantsAc.hpp:254
Svc::Ccsds::TmFramer::TmFramerTester
friend class TmFramerTester
Definition:
TmFramer.hpp:21
Svc::Ccsds::TmFramer
Definition:
TmFramer.hpp:20
ComCfg::TmFrameFixedSize
Definition:
FppConstantsAc.hpp:119
U8
uint8_t U8
8-bit unsigned integer
Definition:
BasicTypes.h:53
Fw::LinearBufferBase
Definition:
Serializable.hpp:672
TMHeaderSerializableAc.hpp
Svc::Ccsds::TmFramerComponentBase
Auto-generated base for TmFramer component.
Definition:
TmFramerComponentAc.hpp:33
Svc::Ccsds::SpacePacketHeader::SERIALIZED_SIZE
The size of the serial representation.
Definition:
SpacePacketHeaderSerializableAc.hpp:32
Svc::Ccsds::TmFramer::TmFramer
TmFramer(const char *const compName)
Construct TmFramer object.
Definition:
TmFramer.cpp:19
FwIndexType
PlatformIndexType FwIndexType
Definition:
FwIndexTypeAliasAc.h:15
FW_COM_BUFFER_MAX_SIZE
Definition:
FppConstantsAc.hpp:198
ComCfg::FrameContext
Type used to pass context info between components during framing/deframing.
Definition:
FrameContextSerializableAc.hpp:20
Svc
RateGroupDivider component implementation.
Definition:
ActiveRateGroupCfg.hpp:18
Fw::Buffer
Definition:
Buffer.hpp:47
Fw::Success
Success/Failure.
Definition:
SuccessEnumAc.hpp:17
Svc
Ccsds
TmFramer
TmFramer.hpp
Generated by
1.8.14