F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
A framework for building embedded system applications to NASA flight quality standards.
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(nullptr) {}
28 
30  FramerComponentBase::init(instance);
31 }
32 
34 
36  FW_ASSERT(m_protocol == nullptr);
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 != nullptr);
48 }
49 
50 void FramerComponentImpl ::bufferIn_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer) {
51  FW_ASSERT(m_protocol != nullptr);
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.e != Drv::SendStatus::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.e);
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:60
Fw::ComPacket::FW_PACKET_FILE
@ FW_PACKET_FILE
Definition: ComPacket.hpp:25
Svc::FramerComponentImpl::~FramerComponentImpl
~FramerComponentImpl()
Definition: FramerComponentImpl.cpp:33
Fw::Buffer
Definition: Buffer.hpp:43
Fw::ComBuffer::getBuffAddr
U8 * getBuffAddr()
gets buffer address for data filling
Definition: ComBuffer.cpp:36
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Fw::Buffer::getSize
U32 getSize() const
Definition: Buffer.cpp:64
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::init
void init(const NATIVE_INT_TYPE instance=0)
Definition: FramerComponentImpl.cpp:29
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:594
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
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: ActiveRateGroupCfg.hpp:18
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
Fw::ComBuffer
Definition: ComBuffer.hpp:21
Logger.hpp
Svc::FramingProtocolInterface
interface supplied to the framing protocol
Definition: FramingProtocolInterface.hpp:28