API Documentation
Loading...
Searching...
No Matches
SerialPortConnection.h
Go to the documentation of this file.
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/Connection.h>
4class QSerialPort;
5namespace NDEVR
6{
7 /**--------------------------------------------------------------------------------------------------
8 \brief A structure containing information needed to establish a SerialPortConnection.
9 **/
19 /**--------------------------------------------------------------------------------------------------
20 \brief A ConnectionBackend that allows the software to interface with QSerialPort for communicating
21 with SerialPort devices.
22 **/
24 {
25 public:
28 virtual uint04 peek(char* s, uint04 size) const override;
29 virtual uint04 rx(char*, uint04 size = Constant<uint04>::Max) override;
30 virtual void tx(const String& command) override;
31 virtual bool open(const ConnectionInfo& request) override;
32 virtual void close() override;
33 virtual bool isOpen() const override;
34 virtual uint04 bytesAvailable() const override;
35 virtual TranslatedString lastError() const override;
36 bool setSerialPort(QSerialPort* serial_port, ConnectionOpenType connection_type = ConnectionOpenType::e_read_write, ProgressInfo* log = nullptr);
37 virtual bool waitForReadyRead(const TimeSpan& span) override;
38 void handleSerialPortError(int error, ProgressInfo* log);
39 static void ToString(const QSerialPort& value, String& string);
40 static void FromString(const String& string, QSerialPort& value);
41 static ConnectionInfo CreateInfo(const QSerialPortInfo& value);
42 static ConnectionInfo CreateInfo(const QSerialPort& value);
43 String threadID() const override;
44 protected:
45 QSerialPort* m_serial_port = nullptr;
47 };
48 /**--------------------------------------------------------------------------------------------------
49 \brief A ConnectionFactory that enables the creation of a SerialPortConnection for interfacing with
50 a QSerialPort
51 **/
61}
#define NDEVR_SERIAL_PORT_API
Definition DLLInfo.h:55
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides the unseen backend logic for setting up, tearing down, and sending data over a specific type...
Definition Connection.h:153
Stores factories that can be registered for creating Connections of various types.
Definition Connection.h:177
A light-weight base class for Log that allows processes to update, without the need for additional in...
Definition ProgressInfo.hpp:48
A ConnectionFactory that enables the creation of a SerialPortConnection for interfacing with a QSeria...
Definition SerialPortConnection.h:53
virtual Buffer< ConnectionInfo > availableConnections(const ConnectionSearchParamaters &params) override
virtual Buffer< ConnectionCategory > availableConnectionCatagories() override
virtual bool handlesType(const String &request) const override
virtual Buffer< QSerialPortInfo, uint04, ObjectAllocator< false > > availablePortInfo()
virtual ConnectionBackend * createConnection(const ConnectionInfo &request) override
A ConnectionBackend that allows the software to interface with QSerialPort for communicating with Ser...
Definition SerialPortConnection.h:24
static void FromString(const String &string, QSerialPort &value)
virtual void tx(const String &command) override
bool setSerialPort(QSerialPort *serial_port, ConnectionOpenType connection_type=ConnectionOpenType::e_read_write, ProgressInfo *log=nullptr)
TranslatedString m_last_error
Definition SerialPortConnection.h:46
SerialPortConnection(ProgressInfo *log)
virtual void close() override
void handleSerialPortError(int error, ProgressInfo *log)
static ConnectionInfo CreateInfo(const QSerialPortInfo &value)
virtual bool isOpen() const override
static void ToString(const QSerialPort &value, String &string)
static ConnectionInfo CreateInfo(const QSerialPort &value)
virtual uint04 rx(char *, uint04 size=Constant< uint04 >::Max) override
virtual TranslatedString lastError() const override
virtual bool waitForReadyRead(const TimeSpan &span) override
virtual uint04 peek(char *s, uint04 size) const override
virtual uint04 bytesAvailable() const override
String threadID() const override
virtual bool open(const ConnectionInfo &request) override
The core String class for the NDEVR API.
Definition String.h:69
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
Definition TranslatedString.h:13
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
ConnectionOpenType
Describes how to open a connection.
Definition Connection.h:76
A structure designed to store information about a specific Connection.
Definition Connection.h:97
Describes settings for performing a Connection search.
Definition Connection.h:136
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233
A structure containing information needed to establish a SerialPortConnection.
Definition SerialPortConnection.h:11
uint04 parity
Definition SerialPortConnection.h:15
uint04 flow_control
Definition SerialPortConnection.h:17
uint04 stop_bits
Definition SerialPortConnection.h:16
String port_name
Definition SerialPortConnection.h:12
uint04 baud_rate
Definition SerialPortConnection.h:13
uint04 data_bits
Definition SerialPortConnection.h:14