F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CmdSplitter.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title CmdSplitter.cpp
3 // \author watney
4 // \brief cpp file for CmdSplitter component implementation class
5 // ======================================================================
6 
7 #include <FpConfig.hpp>
8 #include <Fw/Cmd/CmdPacket.hpp>
10 #include <Fw/Types/Assert.hpp>
11 #include <FppConstantsAc.hpp>
12 
13 namespace Svc {
14 
15 // ----------------------------------------------------------------------
16 // Construction, initialization, and destruction
17 // ----------------------------------------------------------------------
18 
19 CmdSplitter ::CmdSplitter(const char* const compName) : CmdSplitterComponentBase(compName) {}
20 
22 
23 void CmdSplitter ::configure(const FwOpcodeType remoteBaseOpcode) {
24  this->m_remoteBase = remoteBaseOpcode;
25 }
26 
27 // ----------------------------------------------------------------------
28 // Handler implementations for user-defined typed input ports
29 // ----------------------------------------------------------------------
30 
31 void CmdSplitter ::CmdBuff_handler(const NATIVE_INT_TYPE portNum, Fw::ComBuffer& data, U32 context) {
32  Fw::CmdPacket cmdPkt;
33  Fw::SerializeStatus stat = cmdPkt.deserialize(data);
34 
35  FW_ASSERT(portNum < CmdSplitterPorts);
36  if (stat != Fw::FW_SERIALIZE_OK) {
37  // Let the local command dispatcher deal with it
38  this->LocalCmd_out(portNum, data, context);
39  } else {
40  // Check if local or remote
41  if (cmdPkt.getOpCode() < this->m_remoteBase) {
42  this->LocalCmd_out(portNum, data, context);
43  } else {
44  this->RemoteCmd_out(portNum, data, context);
45  }
46  }
47 }
48 
49 void CmdSplitter ::seqCmdStatus_handler(const NATIVE_INT_TYPE portNum,
50  FwOpcodeType opCode,
51  U32 cmdSeq,
52  const Fw::CmdResponse& response) {
53  FW_ASSERT(portNum < CmdSplitterPorts);
54  // Forward the command status
55  this->forwardSeqCmdStatus_out(portNum, opCode, cmdSeq, response);
56 }
57 
58 } // end namespace Svc
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:55
U32 FwOpcodeType
Definition: FpConfig.h:91
C++-compatible configuration header for fprime configuration.
@ CmdSplitterPorts
FwOpcodeType getOpCode() const
Definition: CmdPacket.cpp:55
SerializeStatus deserialize(SerializeBufferBase &buffer)
deserialize to contents
Definition: CmdPacket.cpp:29
Enum representing a command response.
Auto-generated base for CmdSplitter component.
void RemoteCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port RemoteCmd.
void forwardSeqCmdStatus_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port forwardSeqCmdStatus.
void LocalCmd_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context)
Invoke output port LocalCmd.
void configure(const FwOpcodeType remoteBaseOpcode)
Definition: CmdSplitter.cpp:23
CmdSplitter(const char *const compName)
Definition: CmdSplitter.cpp:19
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.