-
Notifications
You must be signed in to change notification settings - Fork 2
/
serialconnect.h
88 lines (72 loc) · 2.29 KB
/
serialconnect.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef SERIALCONNECT_H
#define SERIALCONNECT_H
#include <QObject>
#include <QtSerialPort/QSerialPort>
#include <QVariant>
#include <QStringList>
#include <QBasicTimer>
class SerialConnect : public QObject
{
Q_OBJECT
public:
explicit SerialConnect(QObject *parent = 0);
Q_PROPERTY(QString newSerialData MEMBER newSerialDataString NOTIFY serialDataChanged);
Q_PROPERTY(QString serialData MEMBER serialDataString NOTIFY serialDataChanged);
Q_PROPERTY(QStringList availablePorts MEMBER availablePortsList NOTIFY availablePortsChanged)
signals:
void sendStatusText(QVariant);
void sendAvailablePort(QVariant);
void clearPortsList();
void opened();
void serialDataChanged();
void availablePortsChanged();
public slots:
void open();
void close();
void write(QString);
void write(const QByteArray&);
void read();
void reduceReads();
void getBaudSettings(qint32);
void getBitSettings(qint8);
void getParitySettings(qint8);
void getStopbitsSettings(qint8);
void getFlowcontrolSettings(qint8);
void getPortSettings(QString);
void getBaudSettings(QString);
void getBitSettings(QString);
void getParitySettings(QString);
void getStopbitsSettings(QString);
void getFlowcontrolSettings(QString);
void storeSerialSettings(qint32, QSerialPort::Directions);
void storeSerialSettings(QSerialPort::DataBits);
void storeSerialSettings(QSerialPort::Parity);
void storeSerialSettings(QSerialPort::StopBits);
void storeSerialSettings(QSerialPort::FlowControl);
void findAvailablePorts(bool);
protected:
void timerEvent(QTimerEvent *event);
private:
QSerialPort *serial;
QString serialDataString;
QString newSerialDataString;
QStringList availablePortsList;
QBasicTimer timer;
void connectSerialPort();
struct set {
QString name;
qint32 baudRate;
QString stringBaudRate;
QSerialPort::DataBits dataBits;
QString stringDataBits;
QSerialPort::Parity parity;
QString stringParity;
QSerialPort::StopBits stopBits;
QString stringStopBits;
QSerialPort::FlowControl flowControl;
QString stringFlowControl;
bool localEchoEnabled;
};
set currentSettings;
};
#endif // SERIALCONNECT_H