F´ Flight Software - C/C++ Documentation  NASA-v1.6.0
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 class
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>
19 #include "Drv/ByteStreamDriverModel/ByteStreamDriverModelComponentAc.hpp"
20 
21 namespace Drv {
22 
23 class UdpComponentImpl : public ByteStreamDriverModelComponentBase, public SocketReadTask {
24  public:
25  // ----------------------------------------------------------------------
26  // Construction, initialization, and destruction
27  // ----------------------------------------------------------------------
28 
33  UdpComponentImpl(const char* const compName);
34 
35 
40  void init(const NATIVE_INT_TYPE instance = 0);
41 
46 
47  // ----------------------------------------------------------------------
48  // Helper methods to start and stop socket
49  // ----------------------------------------------------------------------
50 
66  SocketIpStatus configureSend(const char* hostname,
67  const U16 port,
68  const U32 send_timeout_seconds = SOCKET_SEND_TIMEOUT_SECONDS,
69  const U32 send_timeout_microseconds = SOCKET_SEND_TIMEOUT_MICROSECONDS);
70 
82  SocketIpStatus configureRecv(const char* hostname, const U16 port);
83 
89  Drv::PollStatus poll_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
90 
91  PROTECTED:
92  // ----------------------------------------------------------------------
93  // Implementations for socket read task virtual methods
94  // ----------------------------------------------------------------------
95 
105 
115 
124  void sendBuffer(Fw::Buffer buffer, SocketIpStatus status);
125 
129  void connected();
130 
131  PRIVATE:
132 
133  // ----------------------------------------------------------------------
134  // Handler implementations for user-defined typed input ports
135  // ----------------------------------------------------------------------
136 
152  Drv::SendStatus send_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer& fwBuffer);
153 
154  Drv::UdpSocket m_socket;
155 };
156 
157 } // end namespace Drv
158 
159 #endif // end UdpComponentImpl
Drv::UdpComponentImpl::getSocketHandler
IpSocket & getSocketHandler()
returns a reference to the socket handler
Definition: UdpComponentImpl.cpp:50
Drv::UdpComponentImpl::configureRecv
SocketIpStatus configureRecv(const char *hostname, const U16 port)
Configures the Udp receive settings but does not open the connection.
Definition: UdpComponentImpl.cpp:40
SocketReadTask.hpp
Drv::UdpComponentImpl
Definition: UdpComponentImpl.hpp:23
Drv::UdpSocket
Helper for setting up Udp using Berkley sockets as a client.
Definition: UdpSocket.hpp:32
Drv::IpSocket
Helper base-class for setting up Berkley sockets.
Definition: IpSocket.hpp:45
Drv
Definition: BlockDriver.hpp:11
SOCKET_SEND_TIMEOUT_MICROSECONDS
@ SOCKET_SEND_TIMEOUT_MICROSECONDS
Definition: IpCfg.hpp:18
Drv::UdpComponentImpl::sendBuffer
void sendBuffer(Fw::Buffer buffer, SocketIpStatus status)
sends a buffer to be filled with data
Definition: UdpComponentImpl.cpp:58
Fw::Buffer
Definition: Buffer.hpp:43
SOCKET_SEND_TIMEOUT_SECONDS
@ SOCKET_SEND_TIMEOUT_SECONDS
Definition: IpCfg.hpp:17
NATIVE_INT_TYPE
int NATIVE_INT_TYPE
native integer type declaration
Definition: BasicTypes.hpp:27
Drv::SocketReadTask
supports a task to read a given socket adaptation
Definition: SocketReadTask.hpp:27
Drv::UdpComponentImpl::~UdpComponentImpl
~UdpComponentImpl()
Destroy the component.
Definition: UdpComponentImpl.cpp:44
Drv::UdpComponentImpl::connected
void connected()
called when the IPv4 system has been connected
Definition: UdpComponentImpl.cpp:63
Drv::UdpComponentImpl::init
void init(const NATIVE_INT_TYPE instance=0)
Initialize this component.
Definition: UdpComponentImpl.cpp:29
Drv::SocketIpStatus
SocketIpStatus
Status enumeration for socket return values.
Definition: IpSocket.hpp:23
Drv::UdpComponentImpl::UdpComponentImpl
UdpComponentImpl(const char *const compName)
construct the TcpClient component.
Definition: UdpComponentImpl.cpp:25
IpSocket.hpp
Drv::UdpComponentImpl::configureSend
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.
Definition: UdpComponentImpl.cpp:33
Drv::UdpComponentImpl::poll_handler
Drv::PollStatus poll_handler(const NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
not supported
Definition: UdpComponentImpl.cpp:85
Drv::UdpComponentImpl::getBuffer
Fw::Buffer getBuffer()
returns a buffer to fill with data
Definition: UdpComponentImpl.cpp:54
UdpSocket.hpp