Class Transport
Defined in File transport.h
Inheritance Relationships
Derived Types
public flir_ptu_driver::SerialTransport(Class SerialTransport)public flir_ptu_driver::TcpTransport(Class TcpTransport)
Class Documentation
-
class Transport
Abstract byte-stream link between PTU and the physical unit.
Concrete implementations (SerialTransport, TcpTransport) wrap a file descriptor and expose a minimal blocking read/write interface that the driver uses to issue ASCII commands and parse responses.
Subclassed by flir_ptu_driver::SerialTransport, flir_ptu_driver::TcpTransport
Public Functions
-
virtual ~Transport() = default
-
virtual bool open() = 0
Open the underlying connection.
- Returns:
trueif the link is ready for I/O,falseon failure.
-
virtual void close() = 0
Close the underlying connection. Safe to call when already closed.
-
virtual bool isOpen() const = 0
- Returns:
truewhile the underlying connection is open.
-
virtual void write(const std::string &data) = 0
Send raw bytes to the device with no framing or escaping.
- Parameters:
data – Bytes to write.
-
virtual std::string readline(size_t max_len = 255, char eol = '\n') = 0
Read a single line terminated by
eolfrom the device.Blocks until a terminator is seen,
max_lenbytes have accumulated, or the link reports an error. The terminator is included in the result when one was received.- Parameters:
max_len – Maximum number of bytes to accumulate before returning.
eol – Line-terminator byte.
-
virtual std::string read(size_t size) = 0
Read exactly
sizebytes from the device.Blocks until the requested count has been read or the link is closed.
-
virtual size_t available() = 0
- Returns:
Number of bytes currently buffered and immediately readable.
-
virtual void flush() = 0
Discard any bytes pending in the receive buffer.
-
virtual ~Transport() = default