F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
UdpComponentImpl.hpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title UdpComponentImpl.hpp
3 // \author mstarch
4 // \brief hpp file for UdpComponentImpl component implementation
5 //
6 // \copyright
7 // Copyright 2009-2020, by the California Institute of Technology.
8 // ALL RIGHTS RESERVED. United States Government Sponsorship
9 // acknowledged.
10 //
11 // ======================================================================
12 
13 #ifndef UdpComponentImpl_HPP
14 #define UdpComponentImpl_HPP
15 
16 #include <Drv/Ip/IpSocket.hpp>
18 #include <Drv/Ip/UdpSocket.hpp>
20 
21 namespace Drv {
22 
24 
25  friend class UdpTester;
26 
27  public:
28  // ----------------------------------------------------------------------
29  // Construction, initialization, and destruction
30  // ----------------------------------------------------------------------
31 
36  UdpComponentImpl(const char* const compName);
37 
42 
43  // ----------------------------------------------------------------------
44  // Helper methods to start and stop socket
45  // ----------------------------------------------------------------------
46 
62  SocketIpStatus configureSend(const char* hostname,
63  const U16 port,
64  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
65  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS);
66 
79  SocketIpStatus configureRecv(const char* hostname, const U16 port, FwSizeType buffer_size = 1024);
80 
89  U16 getRecvPort();
90 
91 
92 protected:
93  // ----------------------------------------------------------------------
94  // Implementations for socket read task virtual methods
95  // ----------------------------------------------------------------------
96 
105  IpSocket& getSocketHandler() override;
106 
115  Fw::Buffer getBuffer() override;
116 
125  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override;
126 
130  void connected() override;
131 
132  private:
133 
134  // ----------------------------------------------------------------------
135  // Handler implementations for user-defined typed input ports
136  // ----------------------------------------------------------------------
137 
152  void send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) override;
153 
154 
158  void recvReturnIn_handler(FwIndexType portNum,
159  Fw::Buffer& fwBuffer
160  ) override;
161 
162  Drv::UdpSocket m_socket;
163 
164  FwSizeType m_allocation_size;
165 };
166 
167 } // end namespace Drv
168 
169 #endif // end UdpComponentImpl
U16 getRecvPort()
get the port being received on
PlatformSizeType FwSizeType
Helper for setting up Udp using Berkeley sockets as a client.
Definition: UdpSocket.hpp:29
UdpComponentImpl(const char *const compName)
construct the TcpClient component.
SocketIpStatus configureRecv(const char *hostname, const U16 port, FwSizeType buffer_size=1024)
Configures the Udp receive settings but does not open the connection.
void connected() override
called when the IPv4 system has been connected
supports a task to read a given socket adaptation
Fw::Buffer getBuffer() override
returns a buffer to fill with data
SocketIpStatus configureSend(const char *hostname, const U16 port, const U32 send_timeout_seconds=SOCKET_SEND_TIMEOUT_SECONDS, const U32 send_timeout_microseconds=SOCKET_SEND_TIMEOUT_MICROSECONDS)
Configures the Udp send settings but does not open the connection.
IpSocket & getSocketHandler() override
returns a reference to the socket handler
PlatformIndexType FwIndexType
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override
sends a buffer to be filled with data
Auto-generated base for Udp component.
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:29
~UdpComponentImpl()
Destroy the component.
Helper base-class for setting up Berkeley sockets.
Definition: IpSocket.hpp:57