forked from dihonglongxi/FactoryTestApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RailtestClient.h
39 lines (29 loc) · 1017 Bytes
/
RailtestClient.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
#ifndef __RAILTESTCLIENT_H__
#define __RAILTESTCLIENT_H__
#include <QSerialPort>
#include <QVariant>
class RailtestClient : public QObject
{
Q_OBJECT
public:
explicit RailtestClient(QObject *parent = Q_NULLPTR);
virtual ~RailtestClient();
bool open(const QString &portName);
void close();
bool waitCommandPrompt(int timeout = 1000);
QVariantList syncCommand(const QByteArray &cmd, const QByteArray &args = QByteArray(), int timeout = 5000);
private:
QSerialPort m_serial;
QByteArray
m_recvBuffer,
m_syncCommand;
QVariantList m_syncReplies;
void decodeReply(const QByteArray &reply);
private slots:
void onSerialPortReadyRead() Q_DECL_NOTHROW;
void onSerialPortErrorOccurred(QSerialPort::SerialPortError errorCode) Q_DECL_NOTHROW;
signals:
void error(QString text);
void replyReceived(QString id, QVariantMap params);
};
#endif // __RAILTESTCLIENT_H__