F´ Flight Software - C/C++ Documentation  NASA-v2.0.1
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FramerComponentImpl.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title FramerComponentImpl.cpp
3 // \author mstarch
4 // \brief cpp file for Framer component implementation class
5 //
6 // \copyright
7 // Copyright 2009-2015, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
14 #include "Fw/Logger/Logger.hpp"
15 #include "Fw/Types/BasicTypes.hpp"
16 #include "Utils/Hash/Hash.hpp"
17 
18 namespace Svc {
19 
20 
21 
22 // ----------------------------------------------------------------------
23 // Construction, initialization, and destruction
24 // ----------------------------------------------------------------------
25 
26 FramerComponentImpl ::FramerComponentImpl(const char* const compName) : FramerComponentBase(compName), FramingProtocolInterface(),
27 m_protocol(NULL) {}
28 
30  FramerComponentBase::init(instance);
31 }
32 
34 
36  FW_ASSERT(m_protocol == NULL);
37  m_protocol = &protocol;
38  protocol.setup(*this);
39 }
40 
41 // ----------------------------------------------------------------------
42 // Handler implementations for user-defined typed input ports
43 // ----------------------------------------------------------------------
44 
45 void FramerComponentImpl ::comIn_handler(const NATIVE_INT_TYPE portNum, Fw::ComBuffer& data, U32 context) {
46  FW_ASSERT(m_protocol != NULL);
48 }
49 
50 void FramerComponentImpl ::bufferIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer) {
51  FW_ASSERT(m_protocol != NULL);
52  m_protocol->frame(fwBuffer.getData(), fwBuffer.getSize(), Fw::ComPacket::FW_PACKET_FILE);
53  bufferDeallocate_out(0, fwBuffer);
54 }
55 
56 void FramerComponentImpl ::send(Fw::Buffer& outgoing) {
57  Drv::SendStatus sendStatus = framedOut_out(0, outgoing);
58  if (sendStatus != Drv::SEND_OK) {
59  // Note: if there is a data sending problem, an EVR likely wouldn't make it down. Log the issue in hopes that
60  // someone will see it.
61  Fw::Logger::logMsg("[ERROR] Failed to send framed data: %d\n", sendStatus);
62  }
63 }
64 
66  this->getTime();
67  return framedAllocate_out(0, size);
68 }
69 
70 } // end namespace Svc
FramerComponentImpl.hpp
Svc::FramerComponentImpl::setup
void setup(FramingProtocol &protocol)
Setup this component with a supplied framing protocol.
Definition: FramerComponentImpl.cpp:35
Fw::ComPacket::FW_PACKET_UNKNOWN
@ FW_PACKET_UNKNOWN
Definition: ComPacket.hpp:28
Fw::Buffer::getData
U8 * getData() const
Definition: Buffer.cpp:56
Fw::ComBuffer::getBuffAddr
U8 * getBuffAddr(void)
gets buffer address for data filling
Definition: ComBuffer.cpp:36
Fw::ComPacket::FW_PACKET_FILE
@ FW_PACKET_FILE
Definition: ComPacket.hpp:25
FramingProtocolInterface
interface supplied to the framing protocol
Definition: FramingProtocolInterface.hpp:26
Fw::Buffer
Definition: Buffer.hpp:43
Fw::Buffer::getSize
U32 getSize() const
Definition: Buffer.cpp:60
Hash.hpp
Svc::FramingProtocol::frame
virtual void frame(const U8 *const data, const U32 size, Fw::ComPacket::ComPacketType packet_type)=0
frame a given set of bytes
Svc::FramingProtocol::setup
void setup(FramingProtocolInterface &interface)
setup function called to supply the interface used for allocation and sending
Definition: FramingProtocol.cpp:21
Svc::FramerComponentImpl::~FramerComponentImpl
~FramerComponentImpl(void)
Definition: FramerComponentImpl.cpp:33
Svc::FramerComponentImpl::init
void init(const NATIVE_INT_TYPE instance=0)
Definition: FramerComponentImpl.cpp:29
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:587
Fw::Logger::logMsg
static void logMsg(const char *fmt, POINTER_CAST a0=0, POINTER_CAST a1=0, POINTER_CAST a2=0, POINTER_CAST a3=0, POINTER_CAST a4=0, POINTER_CAST a5=0, POINTER_CAST a6=0, POINTER_CAST a7=0, POINTER_CAST a8=0, POINTER_CAST a9=0)
Definition: Logger.cpp:18
Svc::FramingProtocol
abstract class representing a framing protocol
Definition: FramingProtocol.hpp:31
Svc
Definition: ActiveRateGroupImplCfg.hpp:18
BasicTypes.hpp
Declares ISF basic types.
Svc::FramerComponentImpl::FramerComponentImpl
FramerComponentImpl(const char *const compName)
Definition: FramerComponentImpl.cpp:26
Svc::FramerComponentImpl::allocate
Fw::Buffer allocate(const U32 size)
Allocation callback used to request memory for the framer.
Definition: FramerComponentImpl.cpp:65
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Fw::ComBuffer
Definition: ComBuffer.hpp:21
NULL
#define NULL
NULL.
Definition: BasicTypes.hpp:100
Logger.hpp