F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InputSerializePort.cpp
Go to the documentation of this file.
2 #include <Fw/Types/Assert.hpp>
3 #include <cstdio>
4 
5 #if FW_PORT_SERIALIZATION == 1
6 
7 namespace Fw {
8 
9  // SerializePort has no call interface. It is to pass through serialized data
10  InputSerializePort::InputSerializePort() : InputPortBase(), m_func(nullptr) {
11  }
12  InputSerializePort::~InputSerializePort() {
13  }
14 
15  void InputSerializePort::init() {
17 
18  }
19 
20  SerializeStatus InputSerializePort::invokeSerial(SerializeBufferBase &buffer) {
21  FW_ASSERT(this->m_comp);
22  FW_ASSERT(this->m_func);
23 
24  this->m_func(this->m_comp,this->m_portNum,buffer);
25 
26  // The normal input ports perform deserialize() on the passed buffer,
27  // which is what this status is based on. This is not the case for the
28  // InputSerializePort, so just return an okay status
29  return FW_SERIALIZE_OK;
30  }
31 
32  void InputSerializePort::addCallComp(Fw::PassiveComponentBase* callComp, CompFuncPtr funcPtr) {
33  FW_ASSERT(callComp);
34  FW_ASSERT(funcPtr);
35  this->m_comp = callComp;
36  this->m_func = funcPtr;
37  }
38 
39 #if FW_OBJECT_TO_STRING == 1
40  void InputSerializePort::toString(char* buffer, NATIVE_INT_TYPE size) {
41 #if FW_OBJECT_NAMES == 1
42  FW_ASSERT(size > 0);
43  if (snprintf(buffer, size, "Input Serial Port: %s %s->(%s)", this->m_objName, this->isConnected() ? "C" : "NC",
44  this->isConnected() ? this->m_connObj->getObjName() : "None") < 0) {
45  buffer[0] = 0;
46  }
47 #else
48  (void)snprintf(buffer,size,"%s","InputSerializePort");
49 #endif
50  }
51 #endif
52 
53 }
54 #endif
Fw::SerializeStatus
SerializeStatus
forward declaration for string
Definition: Serializable.hpp:14
InputSerializePort.hpp
Fw::PassiveComponentBase
Definition: PassiveComponentBase.hpp:10
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Fw::InputPortBase::init
virtual void init()
Definition: InputPortBase.cpp:20
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::FW_SERIALIZE_OK
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
Definition: Serializable.hpp:15
Fw
Definition: SerIds.hpp:20