F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
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 
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, static_cast<size_t>(size), "Input Serial Port: %s %s->(%s)", this->m_objName.toChar(), 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
#define FW_ASSERT(...)
Definition: Assert.hpp:14
PlatformIntType NATIVE_INT_TYPE
Definition: BasicTypes.h:55
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
void init()
Initialize the OS Abstraction Layer (OSAL)
Definition: Os.cpp:15