F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
Drv::TcpClientComponentImpl Class Reference

#include <Drv/TcpClient/TcpClientComponentImpl.hpp>

Inheritance diagram for Drv::TcpClientComponentImpl:
Drv::TcpClientComponentBase Drv::SocketReadTask Fw::PassiveComponentBase Fw::ObjBase

Public Member Functions

 TcpClientComponentImpl (const char *const compName)
 construct the TcpClient component. More...
 
 ~TcpClientComponentImpl ()
 Destroy the component. More...
 
SocketIpStatus configure (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 TcpClient settings but does not open the connection. More...
 
- Public Member Functions inherited from Drv::TcpClientComponentBase
void init (NATIVE_INT_TYPE instance=0)
 Initialize TcpClientComponentBase object. More...
 
Drv::InputByteStreamSendPortget_send_InputPort (NATIVE_INT_TYPE portNum)
 
void set_allocate_OutputPort (NATIVE_INT_TYPE portNum, Fw::InputBufferGetPort *port)
 Connect port to allocate[portNum]. More...
 
void set_deallocate_OutputPort (NATIVE_INT_TYPE portNum, Fw::InputBufferSendPort *port)
 Connect port to deallocate[portNum]. More...
 
void set_ready_OutputPort (NATIVE_INT_TYPE portNum, Drv::InputByteStreamReadyPort *port)
 Connect port to ready[portNum]. More...
 
void set_recv_OutputPort (NATIVE_INT_TYPE portNum, Drv::InputByteStreamRecvPort *port)
 Connect port to recv[portNum]. More...
 
- Public Member Functions inherited from Fw::PassiveComponentBase
void setIdBase (const U32)
 Set the ID base. More...
 
U32 getIdBase () const
 
- Public Member Functions inherited from Drv::SocketReadTask
 SocketReadTask ()
 constructs the socket read task More...
 
virtual ~SocketReadTask ()
 destructor of the socket read task More...
 
void startSocketTask (const Fw::StringBase &name, const bool reconnect=true, const NATIVE_UINT_TYPE priority=Os::Task::TASK_DEFAULT, const NATIVE_UINT_TYPE stack=Os::Task::TASK_DEFAULT, const NATIVE_UINT_TYPE cpuAffinity=Os::Task::TASK_DEFAULT)
 start the socket read task to start producing data More...
 
SocketIpStatus startup ()
 startup the socket for communications More...
 
SocketIpStatus open ()
 open the socket for communications More...
 
void close ()
 close the socket communications More...
 
void shutdown ()
 shutdown the socket communications More...
 
void stopSocketTask ()
 stop the socket read task and close the associated socket. More...
 
Os::Task::TaskStatus joinSocketTask (void **value_ptr)
 joins to the stopping read task to wait for it to close More...
 

Protected Member Functions

IpSocketgetSocketHandler ()
 returns a reference to the socket handler More...
 
Fw::Buffer getBuffer ()
 returns a buffer to fill with data More...
 
void sendBuffer (Fw::Buffer buffer, SocketIpStatus status)
 sends a buffer to be filled with data More...
 
void connected ()
 called when the IPv4 system has been connected More...
 
- Protected Member Functions inherited from Drv::TcpClientComponentBase
 TcpClientComponentBase (const char *compName="")
 Construct TcpClientComponentBase object. More...
 
virtual ~TcpClientComponentBase ()
 Destroy TcpClientComponentBase object. More...
 
NATIVE_INT_TYPE getNum_send_InputPorts () const
 
NATIVE_INT_TYPE getNum_allocate_OutputPorts () const
 
NATIVE_INT_TYPE getNum_deallocate_OutputPorts () const
 
NATIVE_INT_TYPE getNum_ready_OutputPorts () const
 
NATIVE_INT_TYPE getNum_recv_OutputPorts () const
 
bool isConnected_allocate_OutputPort (NATIVE_INT_TYPE portNum)
 
bool isConnected_deallocate_OutputPort (NATIVE_INT_TYPE portNum)
 
bool isConnected_ready_OutputPort (NATIVE_INT_TYPE portNum)
 
bool isConnected_recv_OutputPort (NATIVE_INT_TYPE portNum)
 
Drv::SendStatus send_handlerBase (NATIVE_INT_TYPE portNum, Fw::Buffer &sendBuffer)
 Handler base-class function for input port send. More...
 
Fw::Buffer allocate_out (NATIVE_INT_TYPE portNum, U32 size)
 Invoke output port allocate. More...
 
void deallocate_out (NATIVE_INT_TYPE portNum, Fw::Buffer &fwBuffer)
 Invoke output port deallocate. More...
 
void ready_out (NATIVE_INT_TYPE portNum)
 Invoke output port ready. More...
 
void recv_out (NATIVE_INT_TYPE portNum, Fw::Buffer &recvBuffer, const Drv::RecvStatus &recvStatus)
 Invoke output port recv. More...
 
virtual void lock ()
 Lock the guarded mutex. More...
 
virtual void unLock ()
 Unlock the guarded mutex. More...
 
- Protected Member Functions inherited from Fw::PassiveComponentBase
 PassiveComponentBase (const char *name)
 Named constructor. More...
 
virtual ~PassiveComponentBase ()
 Destructor. More...
 
void init (NATIVE_INT_TYPE instance)
 Initialization function. More...
 
NATIVE_INT_TYPE getInstance () const
 
- Protected Member Functions inherited from Fw::ObjBase
 ObjBase (const char *name)
 ObjBase constructor. More...
 
virtual ~ObjBase ()
 Destructor. More...
 
void init ()
 Object initializer. More...
 

Additional Inherited Members

- Protected Types inherited from Drv::TcpClientComponentBase
enum  { NUM_SEND_INPUT_PORTS = 1 }
 Enumerations for numbers of typed input ports. More...
 
enum  { NUM_ALLOCATE_OUTPUT_PORTS = 1 , NUM_DEALLOCATE_OUTPUT_PORTS = 1 , NUM_READY_OUTPUT_PORTS = 1 , NUM_RECV_OUTPUT_PORTS = 1 }
 Enumerations for numbers of typed output ports. More...
 
- Static Protected Member Functions inherited from Drv::SocketReadTask
static void readTask (void *pointer)
 a task designed to read from the socket and output incoming data More...
 
- Protected Attributes inherited from Drv::SocketReadTask
Os::Task m_task
 
bool m_reconnect
 Force reconnection. More...
 
bool m_stop
 Stops the task when set to true. More...
 

Detailed Description

Definition at line 23 of file TcpClientComponentImpl.hpp.

Constructor & Destructor Documentation

◆ TcpClientComponentImpl()

Drv::TcpClientComponentImpl::TcpClientComponentImpl ( const char *const  compName)

construct the TcpClient component.

Parameters
compNamename of this component

Definition at line 24 of file TcpClientComponentImpl.cpp.

◆ ~TcpClientComponentImpl()

Drv::TcpClientComponentImpl::~TcpClientComponentImpl ( )

Destroy the component.

Definition at line 35 of file TcpClientComponentImpl.cpp.

Member Function Documentation

◆ configure()

SocketIpStatus Drv::TcpClientComponentImpl::configure ( 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 TcpClient settings but does not open the connection.

The TcpClientComponent needs to connect to a remote TCP server. This call configures the hostname, port and send timeouts for that socket connection. This call should be performed on system startup before recv or send are called. Note: hostname must be a dot-notation IP address of the form "x.x.x.x". DNS translation is left up to the user.

Parameters
hostnameip address of remote tcp server in the form x.x.x.x
portport of remote tcp server
send_timeout_secondssend timeout seconds component. Defaults to: SOCKET_TIMEOUT_SECONDS
send_timeout_microsecondssend timeout microseconds component. Must be less than 1000000. Defaults to: SOCKET_TIMEOUT_MICROSECONDS
Returns
status of the configure

Definition at line 28 of file TcpClientComponentImpl.cpp.

◆ connected()

void Drv::TcpClientComponentImpl::connected ( )
protectedvirtual

called when the IPv4 system has been connected

Implements Drv::SocketReadTask.

Definition at line 54 of file TcpClientComponentImpl.cpp.

◆ getBuffer()

Fw::Buffer Drv::TcpClientComponentImpl::getBuffer ( )
protectedvirtual

returns a buffer to fill with data

Gets a reference to a buffer to fill with data. This allows the component to determine how to provide a buffer and the socket read task just fills said buffer.

Returns
Fw::Buffer to fill with data

Implements Drv::SocketReadTask.

Definition at line 45 of file TcpClientComponentImpl.cpp.

◆ getSocketHandler()

IpSocket & Drv::TcpClientComponentImpl::getSocketHandler ( )
protectedvirtual

returns a reference to the socket handler

Gets a reference to the current socket handler in order to operate generically on the IpSocket instance. Used for receive, and open calls. This socket handler will be a TcpClient.

Returns
IpSocket reference

Implements Drv::SocketReadTask.

Definition at line 41 of file TcpClientComponentImpl.cpp.

◆ sendBuffer()

void Drv::TcpClientComponentImpl::sendBuffer ( Fw::Buffer  buffer,
SocketIpStatus  status 
)
protectedvirtual

sends a buffer to be filled with data

Sends the buffer gotten by getBuffer that has now been filled with data. This is used to delegate to the component how to send back the buffer. Ignores buffers with error status error.

Returns
Fw::Buffer filled with data to send out

Implements Drv::SocketReadTask.

Definition at line 49 of file TcpClientComponentImpl.cpp.


The documentation for this class was generated from the following files: