33 Os::Task::State::NOT_STARTED);
38 stackReconnect, cpuAffinityReconnect);
44 Os::Task::State::NOT_STARTED);
58 if (this->
m_open == OpenState::NOT_OPEN) {
59 this->
m_open = OpenState::OPENING;
62 local_open = OpenState::SKIP;
65 if (local_open == OpenState::OPENING) {
72 this->
m_open = OpenState::OPEN;
74 this->
m_open = OpenState::NOT_OPEN;
89 bool is_open = this->
m_open == OpenState::OPEN;
112 status = this->
open();
127 if (descriptor.
fd == -1) {
136 return reconnectStat;
155 this->
m_open = OpenState::NOT_OPEN;
164 return reconnectStat;
191 if (descriptor.
fd == -1) {
220 status = this->
recv(data, size);
223 Fw::Logger::log(
"[WARNING] %s failed to recv from port with status %d and errno %d\n",
268 bool reconnect =
false;
284 status = this->reopen();
301 Fw::Logger::log(
"[WARNING] %s failed to open port with status %d and errno %d\n",
334 while (elapsed < timeout) {
SocketComponentHelper()
constructs the socket read task
static Status delay(Fw::TimeInterval interval)
delay the current task
bool m_reopen
Force reopen on disconnect.
bool m_stop
Stops the task when set to true.
Failed to read socket with disconnect.
void shutdown()
shutdown the socket communications
Interrupted status for retries.
PlatformSizeType FwSizeType
SocketIpStatus recv(const SocketDescriptor &fd, U8 *const data, FwSizeType &size)
receive data from the IP socket from the given buffer
bool isOpened()
check if IP socket has previously been opened
void setSize(FwSizeType size)
const char * toChar() const
Convert to a C-style char*.
SocketIpStatus send(const U8 *const data, const FwSizeType size)
send data to the IP socket from the given buffer
State getState()
get the task's state
static void log(const char *format,...)
log a formated string with supplied arguments
Automatic connections are disabled.
Fw::TimeInterval m_reconnectCheckInterval
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
void setAutomaticOpen(bool auto_open)
set socket to automatically open connections when true, or not when false
SocketIpStatus waitForReconnect(Fw::TimeInterval timeout=Fw::TimeInterval(1, 0))
wait method for a task to wait for a reconnect request to complete
int fd
Used for all sockets to track the communication file descriptor.
Status start(const Arguments &arguments) override
start the task
SocketIpStatus recv(U8 *data, FwSizeType &size)
receive data from the IP socket from the given buffer
virtual SocketIpStatus send(const SocketDescriptor &socketDescriptor, const U8 *const data, const FwSizeType size)
send data out the IP socket from the given buffer
Os::Task::Status joinReconnect()
static void reconnectTask(void *pointer)
a task designed for socket reconnection
virtual Fw::Buffer getBuffer()=0
returns a buffer to fill with data
Another thread is opening.
void requestReconnect()
signal to reconnect task that a reconnect is needed
void shutdown(const SocketDescriptor &socketDescriptor)
shutdown the socket
void unlock()
alias for unLock to meet BasicLockable requirements
supports a task to read a given socket adaptation
OpenState m_open
Have we successfully opened.
Socket operation successful.
Os::Mutex m_reconnectLock
bool getAutomaticOpen()
get socket automatically open connections status
message sent/received okay
ReconnectState m_reconnectState
Status join() override
block until the task has ended
void add(U32 seconds, U32 mseconds)
TaskString getName()
get the task name
void close()
close the socket communications
virtual void connected()=0
called when the IPv4 system has been connected
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
PlatformTaskPriorityType FwTaskPriorityType
The type of task priorities used.
virtual IpSocket & getSocketHandler()=0
returns a reference to the socket handler
uint8_t U8
8-bit unsigned integer
FwSizeType ParamType
backwards-compatible parameter type
FwSizeType getSize() const
virtual ~SocketComponentHelper()
destructor of the socket read task
static void readTask(void *pointer)
a task designed to read from the socket and output incoming data
void stop()
stop the socket read task and close the associated socket.
void close(const SocketDescriptor &socketDescriptor)
closes the socket
Fw::TimeInterval m_reconnectWaitInterval
A read-only abstract superclass for StringBase.
locks a mutex within the current scope
virtual void reconnectLoop()
reconnect TCP socket
static const Fw::TimeInterval SOCKET_RETRY_INTERVAL
virtual void readLoop()
receive off the TCP socket
SocketIpStatus open(SocketDescriptor &socketDescriptor)
open the IP socket for communications
SocketDescriptor m_descriptor
Os::Task::Status join()
joins to the stopping read task to wait for it to close
SocketIpStatus
Status enumeration for socket return values.
void start(const Fw::ConstStringBase &name, const FwTaskPriorityType priority=Os::Task::TASK_PRIORITY_DEFAULT, const Os::Task::ParamType stack=Os::Task::TASK_DEFAULT, const Os::Task::ParamType cpuAffinity=Os::Task::TASK_DEFAULT, const FwTaskPriorityType priorityReconnect=Os::Task::TASK_PRIORITY_DEFAULT, const Os::Task::ParamType stackReconnect=Os::Task::TASK_DEFAULT, const Os::Task::ParamType cpuAffinityReconnect=Os::Task::TASK_DEFAULT)
start the socket read task to start producing data
SocketIpStatus open()
open the socket for communications
No data available or read operation would block.
virtual void sendBuffer(Fw::Buffer buffer, SocketIpStatus status)=0
sends a buffer to be filled with data
bool running()
is the read loop running
void lock()
lock the mutex and assert success