F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
UdpSenderComponentImpl.hpp
Go to the documentation of this file.
1// ======================================================================
2// \title UdpSenderImpl.hpp
3// \author tcanham
4// \brief hpp file for UdpSender 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 UdpSender_HPP
14#define UdpSender_HPP
15
16#include <Svc/UdpSender/UdpSenderComponentAc.hpp>
18#include <sys/socket.h>
19#include <arpa/inet.h>
20
21
22namespace Svc {
23
25 public UdpSenderComponentBase
26 {
27
28 public:
29
30 // ----------------------------------------------------------------------
31 // Construction, initialization, and destruction
32 // ----------------------------------------------------------------------
33
37 const char *const compName
38 );
39
43
46 void open(
47 const char* addr,
48 const char* port
49 );
50
51 PRIVATE:
52
53 // ----------------------------------------------------------------------
54 // Handler implementations for user-defined typed input ports
55 // ----------------------------------------------------------------------
56
59 void Sched_handler(
60 const NATIVE_INT_TYPE portNum,
61 U32 context
62 );
63
64 PRIVATE:
65
66 // ----------------------------------------------------------------------
67 // Handler implementations for user-defined serial input ports
68 // ----------------------------------------------------------------------
69
72 void PortsIn_handler(
73 NATIVE_INT_TYPE portNum,
75 );
76
77 NATIVE_INT_TYPE m_fd;
78 NATIVE_UINT_TYPE m_packetsSent;
79 NATIVE_UINT_TYPE m_bytesSent;
80 U8 m_seq;
81
82 struct sockaddr_in m_servAddr;
83
84 class UdpSerialBuffer :
86 {
87
88 public:
89
90#ifdef BUILD_UT
91 UdpSerialBuffer& operator=(const UdpSerialBuffer& other);
92 UdpSerialBuffer(const Fw::SerializeBufferBase& other);
93 UdpSerialBuffer(const UdpSerialBuffer& other);
94 UdpSerialBuffer();
95#endif
96
97 NATIVE_UINT_TYPE getBuffCapacity() const {
98 return sizeof(m_buff);
99 }
100
101 // Get the max number of bytes that can be serialized
102 NATIVE_UINT_TYPE getBuffSerLeft() const {
103
104 const NATIVE_UINT_TYPE size = getBuffCapacity();
105 const NATIVE_UINT_TYPE loc = getBuffLength();
106
107 if (loc >= (size-1) ) {
108 return 0;
109 }
110 else {
111 return (size - loc - 1);
112 }
113 }
114
115 U8* getBuffAddr() {
116 return m_buff;
117 }
118
119 const U8* getBuffAddr() const {
120 return m_buff;
121 }
122
123 private:
124 // Should be the max of all the input ports serialized sizes...
125 U8 m_buff[UDP_SENDER_MSG_SIZE];
126
127 } m_sendBuff;
128
129 };
130
131} // end namespace Svc
132
133#endif
PlatformIntType NATIVE_INT_TYPE
Definition BasicTypes.h:55
uint8_t U8
8-bit unsigned integer
Definition BasicTypes.h:30
PlatformUIntType NATIVE_UINT_TYPE
Definition BasicTypes.h:56
Serializable::SizeType getBuffLength() const
returns current buffer size
SerializeBufferBase & operator=(const SerializeBufferBase &src)
copy assignment operator
void open(const char *addr, const char *port)
static const NATIVE_UINT_TYPE UDP_SENDER_MSG_SIZE