3#include <NDEVR/Connection.h>
4#include <QSerialPortInfo.h>
72 virtual bool isOpen()
const override;
The equivelent of std::vector but with a bit more control.
Provides the unseen backend logic for setting up, tearing down, and sending data over a specific type...
ConnectionBackend(LogPtr log)
Constructs a ConnectionBackend with the given log.
Stores factories that can be registered for creating Connections of various types by instantiating a ...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
A ConnectionFactory that enables the creation of a SerialPortConnection for interfacing with a QSeria...
virtual Buffer< QSerialPortInfo > availablePortInfo()
Returns information about all available serial ports on the system.
virtual ConnectionBackend * createConnection(const ConnectionInfo &request) override
Creates a new SerialPortConnection backend for the given connection information.
virtual Buffer< ConnectionCategory > availableConnectionCategories() override
Returns the connection categories supported by this factory.
virtual Buffer< ConnectionInfo > availableConnections(const ConnectionSearchParameters ¶ms) override
Returns connection information for all available serial port connections.
virtual bool handlesType(const StringView &request) const override
Checks whether this factory handles the given connection type string.
virtual uint04 bytesAvailable() const override
Returns the number of bytes available for reading from the serial port.
QSerialPort * m_serial_port
The underlying Qt serial port instance.
SerialPortConnection(LogPtr log)
Constructs a SerialPortConnection with the given log.
static void ToString(const QSerialPort &value, String &string)
Serializes a QSerialPort configuration to a string representation.
virtual bool open(const ConnectionInfo &request) override
Opens the serial port connection using the given connection information.
static ConnectionInfo CreateInfo(const QSerialPortInfo &value)
Creates a ConnectionInfo from a QSerialPortInfo descriptor.
virtual TranslatedString lastError() const override
Returns the last error message from the serial port.
virtual void close() override
Closes the serial port connection.
TranslatedString m_last_error
The most recent error message from the serial port.
virtual bool isOpen() const override
Checks whether the serial port is currently open.
void handleSerialPortError(int error, LogPtr log)
Handles a QSerialPort error code and logs the corresponding message.
virtual uint04 rx(char *s, uint04 size=Constant< uint04 >::Max) override
Receives data from the serial port.
static void FromString(const String &string, QSerialPort &value)
Deserializes a string representation into a QSerialPort configuration.
virtual bool waitForReadyRead(const TimeSpan &span) override
Blocks until data is ready to read or the timeout expires.
static ConnectionInfo CreateInfo(const QSerialPort &value)
Creates a ConnectionInfo from an existing QSerialPort.
bool setSerialPort(QSerialPort *serial_port, ConnectionOpenType connection_type=ConnectionOpenType::e_read_write, LogPtr log=LogPtr())
Sets the underlying QSerialPort and configures it with the given open type.
String threadID() const override
Returns a string identifying the thread this connection operates on.
void txInThread(const StringView &command)
Transmits a command over the serial port from within the connection thread.
virtual void tx(const StringView &command) override
Transmits a command over the serial port.
virtual uint04 peek(char *s, uint04 size) const override
Reads data from the serial port without consuming it.
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Stores a time span, or difference between two times, with an optional start time.
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
ConnectionOpenType
Describes how to open a connection.
@ e_read_write
Open for both reading and writing.
A structure designed to store information about a specific Connection.
Describes settings for performing a Connection search.
A structure containing information needed to establish a SerialPortConnection.
uint04 baud_rate
The communication baud rate.
uint04 data_bits
The number of data bits per frame.
uint04 flow_control
The flow control mode.
uint04 stop_bits
The number of stop bits per frame.
uint04 parity
The parity checking mode.
String port_name
The system name of the serial port (e.g., "COM3").