OpenCurves  0.9
realtimeserialconnection.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef REALTIMESERIALCONNECTION_H_
7 #define REALTIMESERIALCONNECTION_H_
8 
9 #include "ocurvesconfig.h"
10 
11 #include "realtimeconnection.h"
12 
13 #include <QHostAddress>
14 #include <vector>
15 
16 class QSerialPort;
17 
21 {
22 public:
25 
28 
31  virtual QString name() const override;
32 
38  bool open(const QString &name, quint32 baudRate, bool readOnly);
39 
42  bool isConnected() const override;
43 
45  void disconnect() override;
46 
49  int send(const QByteArray &buffer) override;
50 
53  int read(QByteArray &buffer) override;
54 
55 private:
56  QSerialPort *_port;
57 };
58 
59 #endif // REALTIMESERIALCONNECTION_H_
RealTimeSerialConnection()
Create an unconnected serial connection.
bool isConnected() const override
Is the port open and connected?
bool open(const QString &name, quint32 baudRate, bool readOnly)
Open a serial connection, first disconnecting any existing connection.
void disconnect() override
Disconnect if connected.
int read(QByteArray &buffer) override
Read data into the given buffer.
A RealTimeConnection which reads from a serial port.
Definition: realtimeserialconnection.h:20
int send(const QByteArray &buffer) override
Send the given buffer to the source.
This is the base class for data source which provides data in real time.
Definition: realtimeconnection.h:16
virtual QString name() const override
The name of the serial port being used.
~RealTimeSerialConnection()
Destructor, ensures disconnect() is called.