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 
64  SocketIpStatus configureSend(const char* const ipv4_address,
65  const U16 port,
66  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
67  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS);
68 
85  SocketIpStatus configureRecv(const char* const ipv4_address, const U16 port, FwSizeType buffer_size = 1024);
86 
95  U16 getRecvPort();
96 
97  protected:
98  // ----------------------------------------------------------------------
99  // Implementations for socket read task virtual methods
100  // ----------------------------------------------------------------------
101 
110  IpSocket& getSocketHandler() override;
111 
120  Fw::Buffer getBuffer() override;
121 
130  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status) override;
131 
135  void connected() override;
136 
137  private:
138  // ----------------------------------------------------------------------
139  // Handler implementations for user-defined typed input ports
140  // ----------------------------------------------------------------------
141 
156  Drv::ByteStreamStatus send_handler(const FwIndexType portNum, Fw::Buffer& fwBuffer) override;
157 
161  void recvReturnIn_handler(FwIndexType portNum,
162  Fw::Buffer& fwBuffer
163  ) override;
164 
165  Drv::UdpSocket m_socket;
166 
167  FwSizeType m_allocation_size;
168 };
169 
170 } // end namespace Drv
171 
172 #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:44
UdpComponentImpl(const char *const compName)
construct the TcpClient component.
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.
SocketIpStatus configureSend(const char *const ipv4_address, 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.
Fw::Buffer getBuffer() override
returns a buffer to fill with data
IpSocket & getSocketHandler() override
returns a reference to the socket handler
SocketIpStatus configureRecv(const char *const ipv4_address, const U16 port, FwSizeType buffer_size=1024)
Configures the Udp receive settings but does not open the connection.
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