F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
CmdPortAc.cpp
Go to the documentation of this file.
1
// ======================================================================
2
// \title CmdPortAc.cpp
3
// \author Generated by fpp-to-cpp
4
// \brief cpp file for Cmd port
5
// ======================================================================
6
7
#include "
F-Prime/Fw/Cmd/CmdPortAc.hpp
"
8
#include "
Fw/Types/Assert.hpp
"
9
#include "
Fw/Types/ExternalString.hpp
"
10
11
namespace
Fw
{
12
13
namespace
{
14
15
// ----------------------------------------------------------------------
16
// Port buffer class
17
// ----------------------------------------------------------------------
18
19
class
CmdPortBuffer :
public
Fw::SerializeBufferBase
{
20
21
public
:
22
23
Fw::Serializable::SizeType
getBuffCapacity()
const
{
24
return
InputCmdPort::SERIALIZED_SIZE
;
25
}
26
27
U8
* getBuffAddr() {
28
return
m_buff;
29
}
30
31
const
U8
* getBuffAddr()
const
{
32
return
m_buff;
33
}
34
35
private
:
36
37
U8
m_buff[
InputCmdPort::SERIALIZED_SIZE
];
38
39
};
40
41
}
42
43
// ----------------------------------------------------------------------
44
// Input Port Member functions
45
// ----------------------------------------------------------------------
46
47
InputCmdPort ::
48
InputCmdPort() :
49
Fw
::
InputPortBase
(),
50
m_func(nullptr)
51
{
52
53
}
54
55
void
InputCmdPort ::
56
init()
57
{
58
Fw::InputPortBase::init
();
59
}
60
61
void
InputCmdPort ::
62
addCallComp(
63
Fw::PassiveComponentBase
* callComp,
64
CompFuncPtr funcPtr
65
)
66
{
67
FW_ASSERT
(callComp !=
nullptr
);
68
FW_ASSERT
(funcPtr !=
nullptr
);
69
70
this->m_comp = callComp;
71
this->m_func = funcPtr;
72
this->m_connObj = callComp;
73
}
74
75
void
InputCmdPort ::
76
invoke(
77
FwOpcodeType
opCode,
78
U32 cmdSeq,
79
Fw::CmdArgBuffer
& args
80
)
81
{
82
#if FW_PORT_TRACING == 1
83
this->trace();
84
#endif
85
86
FW_ASSERT
(this->m_comp !=
nullptr
);
87
FW_ASSERT
(this->m_func !=
nullptr
);
88
89
return
this->m_func(this->m_comp, this->m_portNum, opCode, cmdSeq, args);
90
}
91
92
#if FW_PORT_SERIALIZATION == 1
93
94
Fw::SerializeStatus
InputCmdPort ::
95
invokeSerial(
Fw::SerializeBufferBase
& _buffer)
96
{
97
Fw::SerializeStatus
_status;
98
99
#if FW_PORT_TRACING == 1
100
this->trace();
101
#endif
102
103
FW_ASSERT
(this->m_comp !=
nullptr
);
104
FW_ASSERT
(this->m_func !=
nullptr
);
105
106
FwOpcodeType
opCode;
107
_status = _buffer.
deserialize
(opCode);
108
if
(_status !=
Fw::FW_SERIALIZE_OK
) {
109
return
_status;
110
}
111
112
U32 cmdSeq;
113
_status = _buffer.
deserialize
(cmdSeq);
114
if
(_status !=
Fw::FW_SERIALIZE_OK
) {
115
return
_status;
116
}
117
118
Fw::CmdArgBuffer
args;
119
_status = _buffer.
deserialize
(args);
120
if
(_status !=
Fw::FW_SERIALIZE_OK
) {
121
return
_status;
122
}
123
124
this->m_func(this->m_comp, this->m_portNum, opCode, cmdSeq, args);
125
126
return
Fw::FW_SERIALIZE_OK
;
127
}
128
129
#endif
130
131
// ----------------------------------------------------------------------
132
// Output Port Member functions
133
// ----------------------------------------------------------------------
134
135
OutputCmdPort ::
136
OutputCmdPort() :
137
Fw
::
OutputPortBase
(),
138
m_port(nullptr)
139
{
140
141
}
142
143
void
OutputCmdPort ::
144
init()
145
{
146
Fw::OutputPortBase::init
();
147
}
148
149
void
OutputCmdPort ::
150
addCallPort(
InputCmdPort
* callPort)
151
{
152
FW_ASSERT
(callPort !=
nullptr
);
153
154
this->m_port = callPort;
155
this->m_connObj = callPort;
156
157
#if FW_PORT_SERIALIZATION == 1
158
this->m_serPort =
nullptr
;
159
#endif
160
}
161
162
void
OutputCmdPort ::
163
invoke(
164
FwOpcodeType
opCode,
165
U32 cmdSeq,
166
Fw::CmdArgBuffer
& args
167
)
const
168
{
169
#if FW_PORT_TRACING == 1
170
this->trace();
171
#endif
172
173
#if FW_PORT_SERIALIZATION
174
FW_ASSERT
((this->m_port !=
nullptr
) || (this->m_serPort !=
nullptr
));
175
176
if
(this->m_port !=
nullptr
) {
177
this->m_port->invoke(opCode, cmdSeq, args);
178
}
179
else
{
180
Fw::SerializeStatus
_status;
181
CmdPortBuffer _buffer;
182
183
_status = _buffer.serialize(opCode);
184
FW_ASSERT
(_status ==
Fw::FW_SERIALIZE_OK
,
static_cast<
FwAssertArgType
>
(_status));
185
186
_status = _buffer.serialize(cmdSeq);
187
FW_ASSERT
(_status ==
Fw::FW_SERIALIZE_OK
,
static_cast<
FwAssertArgType
>
(_status));
188
189
_status = _buffer.serialize(args);
190
FW_ASSERT
(_status ==
Fw::FW_SERIALIZE_OK
,
static_cast<
FwAssertArgType
>
(_status));
191
192
_status = this->m_serPort->invokeSerial(_buffer);
193
FW_ASSERT
(_status ==
Fw::FW_SERIALIZE_OK
,
static_cast<
FwAssertArgType
>
(_status));
194
}
195
#else
196
FW_ASSERT
(this->m_port !=
nullptr
);
197
this->m_port->invoke(opCode, cmdSeq, args);
198
#endif
199
}
200
201
}
Assert.hpp
FW_ASSERT
#define FW_ASSERT(...)
Definition
Assert.hpp:14
U8
uint8_t U8
8-bit unsigned integer
Definition
BasicTypes.h:30
CmdPortAc.hpp
ExternalString.hpp
FwAssertArgType
PlatformAssertArgType FwAssertArgType
Definition
FpConfig.h:39
FwOpcodeType
U32 FwOpcodeType
Definition
FpConfig.h:91
Fw::CmdArgBuffer
Definition
CmdArgBuffer.hpp:21
Fw::InputCmdPort
Definition
CmdPortAc.hpp:27
Fw::InputCmdPort::SERIALIZED_SIZE
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition
CmdPortAc.hpp:37
Fw::InputPortBase
Definition
InputPortBase.hpp:12
Fw::InputPortBase::init
virtual void init()
Definition
InputPortBase.cpp:18
Fw::OutputPortBase
Definition
OutputPortBase.hpp:11
Fw::OutputPortBase::init
virtual void init()
Definition
OutputPortBase.cpp:21
Fw::PassiveComponentBase
Definition
PassiveComponentBase.hpp:10
Fw::Serializable::SizeType
NATIVE_UINT_TYPE SizeType
Definition
Serializable.hpp:28
Fw::SerializeBufferBase
Definition
Serializable.hpp:54
Fw::SerializeBufferBase::deserialize
SerializeStatus deserialize(U8 &val)
deserialize 8-bit unsigned int
Definition
Serializable.cpp:300
Fw
Definition
FppConstantsAc.hpp:121
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition
Serializable.hpp:14
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition
Serializable.hpp:15
Fw
Cmd
CmdPortAc.cpp
Generated by
1.9.8