-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathserialport.h
More file actions
56 lines (48 loc) · 1.4 KB
/
serialport.h
File metadata and controls
56 lines (48 loc) · 1.4 KB
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
#ifndef SERIALPORT_H
#define SERIALPORT_H
#include <QObject>
#include <QSerialPort>
#include <QComboBox>
#include <QQueue>
#include "setup.h"
class SerialPort : public QObject
{
Q_OBJECT
public:
explicit SerialPort(QWidget *tab, Setup *setup, QObject *parent = nullptr);
~SerialPort();
QString openSerialPort();
QString closeSerialPort();
QString sendData(const QByteArray &data);
void recvData();
QString timerUpdate();
void updatePort();
signals:
void bytesSended(qint64 bytes, QString address);
void serialPortClosed();
void hasRecved(QByteArray data, QString address, int enumTunnel);
void errorOccurred(QString errorStr);
public slots:
void handleError(QSerialPort::SerialPortError error);
void onBytesSended(qint64 bytes);
private:
void initComboBox();
void initParameters();
void setupSerial();
protected:
QWidget *m_pParent = nullptr;
Setup *m_pSetup = nullptr;
QWidget *m_pTab = nullptr;
QSerialPort *m_pSerial = nullptr;
QTimer *m_pTimer = nullptr;
QByteArray m_data;
public:
QComboBox *m_pCboxPort = nullptr;
QComboBox *m_pCboxBaud = nullptr;
QComboBox *m_pCboxBit = nullptr;
QComboBox *m_pCboxParity = nullptr;
QComboBox *m_pCboxStop = nullptr;
QComboBox *m_pCboxFlow = nullptr;
QQueue<QByteArray> m_sendData;
};
#endif // SERIALPORT_H