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  friend class UdpTester;
25 
26  public:
27  // ----------------------------------------------------------------------
28  // Construction, initialization, and destruction
29  // ----------------------------------------------------------------------
30 
35  UdpComponentImpl(const char* const compName);
36 
41 
42  // ----------------------------------------------------------------------
43  // Helper methods to start and stop socket
44  // ----------------------------------------------------------------------
45 
61  SocketIpStatus configureSend(const char* hostname,
62  const U16 port,
63  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
64  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS);
65 
78  SocketIpStatus configureRecv(const char* hostname, const U16 port, FwSizeType buffer_size = 1024);
79 
88  U16 getRecvPort();
89 
90  protected:
91  // ----------------------------------------------------------------------
92  // Implementations for socket read task virtual methods
93  // ----------------------------------------------------------------------
94 
103  IpSocket& getSocketHandler() override;
104 
113  Fw::Buffer getBuffer() override;
114 
123  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override;
124 
128  void connected() override;
129 
130  private:
131  // ----------------------------------------------------------------------
132  // Handler implementations for user-defined typed input ports
133  // ----------------------------------------------------------------------
134 
149  Drv::ByteStreamStatus send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) override;
150 
154  void recvReturnIn_handler(FwIndexType portNum,
155  Fw::Buffer& fwBuffer
156  ) override;
157 
158  Drv::UdpSocket m_socket;
159 
160  FwSizeType m_allocation_size;
161 };
162 
163 } // end namespace Drv
164 
165 #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:36
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
Status returned by the send call.
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