Class Transport

Inheritance Relationships

Derived Types

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:

true if the link is ready for I/O, false on failure.

virtual void close() = 0

Close the underlying connection. Safe to call when already closed.

virtual bool isOpen() const = 0
Returns:

true while 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 eol from the device.

Blocks until a terminator is seen, max_len bytes 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 size bytes 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.