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

supports a task to read a given socket adaptation More...

#include <Drv/Ip/SocketReadTask.hpp>

Inheritance diagram for Drv::SocketReadTask:
Drv::TcpClientComponentImpl Drv::TcpServerComponentImpl Drv::UdpComponentImpl

Public Member Functions

 SocketReadTask ()
 constructs the socket read task More...
 
virtual ~SocketReadTask ()
 destructor of the socket read task More...
 
void start (const Fw::StringBase &name, const bool reconnect=true, const Os::Task::ParamType priority=Os::Task::TASK_DEFAULT, const Os::Task::ParamType stack=Os::Task::TASK_DEFAULT, const Os::Task::ParamType 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 stop ()
 stop the socket read task and close the associated socket. More...
 
Os::Task::Status join ()
 joins to the stopping read task to wait for it to close More...
 

Protected Member Functions

virtual IpSocketgetSocketHandler ()=0
 returns a reference to the socket handler More...
 
virtual Fw::Buffer getBuffer ()=0
 returns a buffer to fill with data More...
 
virtual void sendBuffer (Fw::Buffer buffer, SocketIpStatus status)=0
 sends a buffer to be filled with data More...
 
virtual void connected ()=0
 called when the IPv4 system has been connected More...
 

Static Protected Member Functions

static void readTask (void *pointer)
 a task designed to read from the socket and output incoming data More...
 

Protected Attributes

Os::Task m_task
 
bool m_reconnect
 Force reconnection. More...
 
bool m_stop
 Stops the task when set to true. More...
 

Detailed Description

supports a task to read a given socket adaptation

Defines an Os::Task task to read a socket and send out the data. This represents the task itself, which is capable of reading the data from the socket, sending the data out, and reopening the connection should a non-retry error occur.

Definition at line 27 of file SocketReadTask.hpp.

Constructor & Destructor Documentation

◆ SocketReadTask()

Drv::SocketReadTask::SocketReadTask ( )

constructs the socket read task

Definition at line 22 of file SocketReadTask.cpp.

◆ ~SocketReadTask()

Drv::SocketReadTask::~SocketReadTask ( )
virtual

destructor of the socket read task

Definition at line 24 of file SocketReadTask.cpp.

Member Function Documentation

◆ close()

void Drv::SocketReadTask::close ( )

close the socket communications

Typically stopping the socket read task will shutdown the connection. However, in cases where the read task will not be started, this function may be used to close the socket. This calls a full close on the client socket.

Note: this just delegates to the handler

Definition at line 57 of file SocketReadTask.cpp.

◆ connected()

virtual void Drv::SocketReadTask::connected ( )
protectedpure virtual

called when the IPv4 system has been connected

Implemented in Drv::UdpComponentImpl, Drv::TcpServerComponentImpl, and Drv::TcpClientComponentImpl.

◆ getBuffer()

virtual Fw::Buffer Drv::SocketReadTask::getBuffer ( )
protectedpure virtual

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.

Note: this must be implemented by the inheritor

Returns
Fw::Buffer to fill with data

Implemented in Drv::UdpComponentImpl, Drv::TcpServerComponentImpl, and Drv::TcpClientComponentImpl.

◆ getSocketHandler()

virtual IpSocket& Drv::SocketReadTask::getSocketHandler ( )
protectedpure virtual

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.

Note: this must be implemented by the inheritor

Returns
IpSocket reference

Implemented in Drv::UdpComponentImpl, Drv::TcpServerComponentImpl, and Drv::TcpClientComponentImpl.

◆ join()

Os::Task::Status Drv::SocketReadTask::join ( )

joins to the stopping read task to wait for it to close

Called to join with the read socket task. This will block and return after the task has been stopped with a call to the stopSocketTask method.

Parameters
value_ptra pointer to fill with data. Passed to the Os::Task::join call. NULL to ignore.
Returns
: Os::Task::Status passed back from the Os::Task::join call.

Definition at line 61 of file SocketReadTask.cpp.

◆ open()

SocketIpStatus Drv::SocketReadTask::open ( )

open the socket for communications

Typically the socket read task will open the connection and keep it open. However, in cases where the read task will not be started, this function may be used to open the socket.

Note: this just delegates to the handler

Returns
status of open, SOCK_SUCCESS for success, something else on error

Definition at line 44 of file SocketReadTask.cpp.

◆ readTask()

void Drv::SocketReadTask::readTask ( void *  pointer)
staticprotected

a task designed to read from the socket and output incoming data

Parameters
pointerpointer to "this" component

Definition at line 70 of file SocketReadTask.cpp.

◆ sendBuffer()

virtual void Drv::SocketReadTask::sendBuffer ( Fw::Buffer  buffer,
SocketIpStatus  status 
)
protectedpure virtual

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.

Note: this must be implemented by the inheritor

Returns
Fw::Buffer filled with data to send out

Implemented in Drv::UdpComponentImpl, Drv::TcpServerComponentImpl, and Drv::TcpClientComponentImpl.

◆ shutdown()

void Drv::SocketReadTask::shutdown ( )

shutdown the socket communications

Typically stopping the socket read task will shutdown the connection. However, in cases where the read task will not be started, this function may be used to close the socket. This calls a full shutdown on the client socket.

Note: this just delegates to the handler

Definition at line 53 of file SocketReadTask.cpp.

◆ start()

void Drv::SocketReadTask::start ( const Fw::StringBase name,
const bool  reconnect = true,
const Os::Task::ParamType  priority = Os::Task::TASK_DEFAULT,
const Os::Task::ParamType  stack = Os::Task::TASK_DEFAULT,
const Os::Task::ParamType  cpuAffinity = Os::Task::TASK_DEFAULT 
)

start the socket read task to start producing data

Starts up the socket reading task and opens socket. This should be called before send calls are expected to work. Will connect to the previously configured port and host. priority, stack, and cpuAffinity are provided to the Os::Task::start call.

Parameters
namename of the task
reconnectautomatically reconnect socket when closed. Default: true.
prioritypriority of the started task. See: Os::Task::start. Default: TASK_DEFAULT, not prioritized
stackstack size provided to the task. See: Os::Task::start. Default: TASK_DEFAULT, posix threads default
cpuAffinitycpu affinity provided to task. See: Os::Task::start. Default: TASK_DEFAULT, don't care

Definition at line 26 of file SocketReadTask.cpp.

◆ startup()

SocketIpStatus Drv::SocketReadTask::startup ( )

startup the socket for communications

Status of the socket handler.

Note: this just delegates to the handler

Returns
status of open, SOCK_SUCCESS for success, something else on error

Definition at line 40 of file SocketReadTask.cpp.

◆ stop()

void Drv::SocketReadTask::stop ( )

stop the socket read task and close the associated socket.

Called to stop the socket read task. It is an error to call this before the thread has been started using the startSocketTask call. This will stop the read task and close the client socket.

Definition at line 65 of file SocketReadTask.cpp.

Member Data Documentation

◆ m_reconnect

bool Drv::SocketReadTask::m_reconnect
protected

Force reconnection.

Definition at line 172 of file SocketReadTask.hpp.

◆ m_stop

bool Drv::SocketReadTask::m_stop
protected

Stops the task when set to true.

Definition at line 173 of file SocketReadTask.hpp.

◆ m_task

Os::Task Drv::SocketReadTask::m_task
protected

Definition at line 171 of file SocketReadTask.hpp.


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