42 if (this->
m_open == OpenState::NOT_OPEN) {
43 this->
m_open = OpenState::OPENING;
46 local_open = OpenState::SKIP;
50 if (local_open == OpenState::OPENING) {
57 this->
m_open = OpenState::OPEN;
59 this->
m_open = OpenState::NOT_OPEN;
74 bool is_open = this->
m_open == OpenState::OPEN;
96 status = this->
open();
111 if (descriptor.
fd == -1) {
112 status = this->reopen();
138 this->
m_open = OpenState::NOT_OPEN;
166 if (descriptor.
fd == -1) {
181 status = this->reopen();
188 Fw::Logger::log(
"[WARNING] Failed to open port with status %d and errno %d\n", status, errno);
200 status = this->
recv(data, size);
202 Fw::Logger::log(
"[WARNING] Failed to recv from port with status %d and errno %d\n",
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.
SocketIpStatus send(const SocketDescriptor &socketDescriptor, const U8 *const data, const U32 size)
send data out the IP socket from the given buffer
SocketIpStatus send(const U8 *const data, const U32 size)
send data to the IP socket from the given buffer
bool isOpened()
check if IP socket has previously been opened
State getState()
get the task's state
static void log(const char *format,...)
log a formated string with supplied arguments
Automatic connections are disabled.
void setAutomaticOpen(bool auto_open)
set socket to automatically open connections when true, or not when false
Status start(const Arguments &arguments) override
start the task
SocketIpStatus recv(const SocketDescriptor &fd, U8 *const data, U32 &size)
receive data from the IP socket from the given buffer
virtual Fw::Buffer getBuffer()=0
returns a buffer to fill with data
Another thread is opening.
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.
message sent/received okay
Status join() override
block until the task has ended
void close()
close the socket communications
virtual void connected()=0
called when the IPv4 system has been connected
virtual IpSocket & getSocketHandler()=0
returns a reference to the socket handler
uint8_t U8
8-bit unsigned integer
FwSizeType ParamType
backwards-compatible parameter type
SocketIpStatus recv(U8 *data, U32 &size)
receive data from the IP socket from the given buffer
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.
PlatformIntType fd
Used for all sockets to track the communication file descriptor.
void close(const SocketDescriptor &socketDescriptor)
closes the socket
locks a mutex within the current scope
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.
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
void start(const Fw::StringBase &name, 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
bool running()
is the read loop running
void lock()
lock the mutex and assert success
static const Fw::TimeInterval SOCKET_RETRY_INTERVAL