Class TcpTransport
Defined in File tcp_transport.h
Inheritance Relationships
Base Type
public flir_ptu_driver::Transport(Class Transport)
Class Documentation
-
class TcpTransport : public flir_ptu_driver::Transport
TCP/IP implementation of the PTU Transport interface.
Establishes a blocking IPv4 TCP connection to a FLIR PTU’s network port (typically 4000) and exposes the line-oriented byte stream expected by PTU. Intended as a drop-in replacement for SerialTransport when the unit is reached over Ethernet rather than RS-232.
Public Functions
-
TcpTransport(const std::string &host, int port)
Construct a TCP transport for a PTU at
host:port.The socket is not opened until open() is called.
-
~TcpTransport() override
Closes the socket if still open and releases any resources.
-
virtual bool open() override
Resolve the host and open a TCP connection to the PTU.
- Returns:
trueif the connection was established,falseon error.
-
virtual void close() override
Close the socket. Safe to call when already closed.
-
virtual bool isOpen() const override
- Returns:
truewhile the underlying socket is connected.
-
virtual void write(const std::string &data) override
Send raw bytes to the PTU.
- Parameters:
data – Bytes to write; sent as-is with no framing or escaping.
-
virtual std::string readline(size_t max_len = 255, char eol = '\n') override
Read a single line terminated by
eolfrom the PTU.Blocks until either a terminator is seen,
max_lenbytes have been accumulated, or the socket reports an error. The returned string includes the terminator when one was received.- Parameters:
max_len – Maximum number of bytes to accumulate before returning.
eol – Byte that delimits a line.
-
virtual std::string read(size_t size) override
Read exactly
sizebytes from the socket.Blocks until the requested count has been read or the socket is closed.
-
virtual size_t available() override
- Returns:
Number of bytes currently buffered and immediately readable.
-
virtual void flush() override
Discard any bytes pending in the receive buffer.
-
TcpTransport(const std::string &host, int port)