F´ Flight Software - C/C++ Documentation  NASA-v1.5.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
UdpReceiverComponentImpl.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title UdpReceiverImpl.hpp
3 // \author tcanham
4 // \brief hpp file for UdpReceiver 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 
13 #ifndef UdpReceiver_HPP
14 #define UdpReceiver_HPP
15 
16 #include "Svc/UdpReceiver/UdpReceiverComponentAc.hpp"
18 
19 namespace Svc {
20 
22  public UdpReceiverComponentBase
23  {
24 
25  public:
26 
27  // ----------------------------------------------------------------------
28  // Construction, initialization, and destruction
29  // ----------------------------------------------------------------------
30 
34  const char *const compName
35  );
36 
39  void init(
40  const NATIVE_INT_TYPE instance = 0
41  );
42 
46 
48  void open(
49  const char* port
50  );
51 
53  void startThread(
54  NATIVE_UINT_TYPE priority,
55  NATIVE_UINT_TYPE stackSize,
56  NATIVE_UINT_TYPE affinity
57  );
58 
59 
61 
62  // ----------------------------------------------------------------------
63  // Handler implementations for user-defined typed input ports
64  // ----------------------------------------------------------------------
65 
68  void Sched_handler(
69  const NATIVE_INT_TYPE portNum,
71  );
72 
73  static void workerTask(void* ptr);
74  void doRecv(void);
76 
78 
81  {
82 
83  public:
84 
85 #ifdef BUILD_UT
86  void operator=(const UdpSerialBuffer& other);
88  UdpSerialBuffer(const UdpSerialBuffer& other);
90 #endif
91 
93  return sizeof(m_buff);
94  }
95 
96  // Get the max number of bytes that can be serialized
98 
99  const NATIVE_UINT_TYPE size = getBuffCapacity();
100  const NATIVE_UINT_TYPE loc = getBuffLength();
101 
102  if (loc >= (size-1) ) {
103  return 0;
104  }
105  else {
106  return (size - loc - 1);
107  }
108  }
109 
110  U8* getBuffAddr(void) {
111  return m_buff;
112  }
113 
114  const U8* getBuffAddr(void) const {
115  return m_buff;
116  }
117 
118  private:
119  // Should be the max of all the input ports serialized sizes...
120  U8 m_buff[UDP_RECEIVER_MSG_SIZE];
121 
123 
125 
130 
131  bool m_firstSeq;
133 
134 
135  };
136 
137 } // end namespace Svc
138 
139 #endif
Svc::UdpReceiverComponentImpl::UdpSerialBuffer::getBuffAddr
U8 * getBuffAddr(void)
gets buffer address for data filling
Definition: UdpReceiverComponentImpl.hpp:110
Svc::UdpReceiverComponentImpl::m_packetsReceived
U32 m_packetsReceived
number of packets received
Definition: UdpReceiverComponentImpl.hpp:126
PRIVATE
#define PRIVATE
overridable private for unit testing
Definition: BasicTypes.hpp:118
Fw::SerializeBufferBase
Definition: Serializable.hpp:43
Svc::UdpReceiverComponentImpl
Definition: UdpReceiverComponentImpl.hpp:23
Svc::UdpReceiverComponentImpl::UdpSerialBuffer::getBuffAddr
const U8 * getBuffAddr(void) const
gets buffer address for data reading, const version
Definition: UdpReceiverComponentImpl.hpp:114
Svc::UdpReceiverComponentImpl::m_currSeq
U8 m_currSeq
current tracked sequence number
Definition: UdpReceiverComponentImpl.hpp:132
U8
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.hpp:76
Svc::UdpReceiverComponentImpl::doRecv
void doRecv(void)
receives a single packet (helps unit testing)
Definition: UdpReceiverComponentImpl.cpp:136
Svc::UdpReceiverComponentImpl::m_decodeErrors
U32 m_decodeErrors
deserialization errors
Definition: UdpReceiverComponentImpl.hpp:129
Svc::UdpReceiverComponentImpl::m_recvBuff
Svc::UdpReceiverComponentImpl::UdpSerialBuffer m_recvBuff
Svc::UdpReceiverComponentImpl::m_fd
NATIVE_INT_TYPE m_fd
socket file descriptor
Definition: UdpReceiverComponentImpl.hpp:77
Svc::UdpReceiverComponentImpl::init
void init(const NATIVE_INT_TYPE instance=0)
Definition: UdpReceiverComponentImpl.cpp:50
Svc::UdpReceiverComponentImpl::context
PRIVATE NATIVE_UINT_TYPE context
Definition: UdpReceiverComponentImpl.hpp:71
Svc::UdpReceiverComponentImpl::m_firstSeq
bool m_firstSeq
first sequence number detected
Definition: UdpReceiverComponentImpl.hpp:131
Svc::UdpReceiverComponentImpl::UdpSerialBuffer
Definition: UdpReceiverComponentImpl.hpp:81
Svc::UdpReceiverComponentImpl::UdpSerialBuffer::getBuffSerLeft
NATIVE_UINT_TYPE getBuffSerLeft(void) const
Definition: UdpReceiverComponentImpl.hpp:97
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
Svc::UdpReceiverComponentImpl::~UdpReceiverComponentImpl
~UdpReceiverComponentImpl(void)
Definition: UdpReceiverComponentImpl.cpp:58
Svc::UdpReceiverComponentImpl::UdpSerialBuffer::getBuffCapacity
NATIVE_UINT_TYPE getBuffCapacity(void) const
returns capacity, not current size, of buffer
Definition: UdpReceiverComponentImpl.hpp:92
Svc::UdpReceiverComponentImpl::open
void open(const char *port)
Open the connection.
Definition: UdpReceiverComponentImpl.cpp:65
Fw::SerializeBufferBase::getBuffLength
NATIVE_UINT_TYPE getBuffLength() const
returns current buffer size
Definition: Serializable.cpp:592
Svc::UdpReceiverComponentImpl::startThread
void startThread(NATIVE_UINT_TYPE priority, NATIVE_UINT_TYPE stackSize, NATIVE_UINT_TYPE affinity)
start worker thread
Definition: UdpReceiverComponentImpl.cpp:96
Svc::UdpReceiverComponentImpl::UdpReceiverComponentImpl
UdpReceiverComponentImpl(const char *const compName)
Definition: UdpReceiverComponentImpl.cpp:35
Os::Task
forward declaration
Definition: Task.hpp:15
Fw::SerializeBufferBase::operator=
const SerializeBufferBase & operator=(const SerializeBufferBase &src)
equal operator
Definition: Serializable.cpp:60
Svc::UdpReceiverComponentImpl::m_portBuff
UdpSerialBuffer m_portBuff
working buffer for decoding packets
Definition: UdpReceiverComponentImpl.hpp:124
Svc
Definition: ActiveLoggerComponentAc.cpp:22
UdpReceiverComponentImplCfg.hpp
Svc::UdpReceiverComponentImpl::m_bytesReceived
U32 m_bytesReceived
number of bytes received
Definition: UdpReceiverComponentImpl.hpp:127
Svc::UDP_RECEIVER_MSG_SIZE
static const NATIVE_UINT_TYPE UDP_RECEIVER_MSG_SIZE
Definition: UdpReceiverComponentImplCfg.hpp:12
Svc::UdpReceiverComponentImpl::m_packetsDropped
U32 m_packetsDropped
number of detected packets dropped
Definition: UdpReceiverComponentImpl.hpp:128
Svc::UdpReceiverComponentImpl::m_socketTask
Os::Task m_socketTask
Definition: UdpReceiverComponentImpl.hpp:75
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:29
Svc::UdpReceiverComponentImpl::workerTask
static void workerTask(void *ptr)
worker task entry point
Definition: UdpReceiverComponentImpl.cpp:129