-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserialserver.h
59 lines (49 loc) · 1.43 KB
/
serialserver.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
#ifndef SERIALSERVER_H
#define SERIALSERVER_H
#include <QObject>
#include <QSerialPort>
#include <QSerialPortInfo>
#include <QIODevice>
#include <QJsonObject>
#include <QMetaEnum>
#include <QDebug>
#include "applicationsettings.h"
class SerialServer : public QObject
{
Q_OBJECT
Q_PROPERTY(QString portName READ getPortName)
public:
explicit SerialServer(const SerialServerSetting portInfo, QObject *parent = 0);
~SerialServer();
QString getPortName() const {
return m_portName;
}
signals:
void MessageAvailable(QByteArray ba, bool parseJson, bool translate, QString translateID);
void PrimaryConnectionAvailable();
void ClientConnected(void);
void Error(QString error);
public slots:
int Send(QString msg);
bool getParseJon();
bool getTranslate();
QString getTranslateID();
QString getPortName();
bool Start();
private slots:
void onClientReadyRead(void);
void onClientError(QSerialPort::SerialPortError error);
QSerialPort::StopBits getStopBitsEnum(int stopBits);
QSerialPort::Parity getParityEnum(QString parity);
QSerialPort::FlowControl getFlowControlEnum(QString flowControl);
QSerialPort::DataBits getDataBitsEnum(int dataBits);
private:
QSerialPort *m_server;
QJsonObject m_jsonObj;
bool m_parseJson;
bool m_translate;
QString m_translateID;
bool m_primaryConnection;
QString m_portName;
};
#endif // SERIALSERVER_H