forked from tunwen/modebusLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_serialport.h
51 lines (44 loc) · 1.48 KB
/
c_serialport.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
#ifndef C_SERIALPORT_H
#define C_SERIALPORT_H
#include <QObject>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include "../../../WORK/HLMonitorGit/include/include.h"
class C_SerialPort : public QObject
{
Q_OBJECT
public:
explicit C_SerialPort(QObject *parent = 0);
private:
QSerialPort m_serialPort;
quint64 m_sum;
quint32 m_byte;
quint32 m_byte_s;
signals:
void sig_readData(QByteArray &array);
private slots:
void slot_readData();
public slots:
public:
bool openCOM( QString comName
,qint32 baudRate
,enum QSerialPort::DataBits dataBits
,enum QSerialPort::StopBits stopBits
,enum QSerialPort::Parity parity
,enum QSerialPort::FlowControl flowControl = QSerialPort::NoFlowControl);
bool openCOM(serialCFG cfg);
void closeCOM();
void writeData(QByteArray &array);
void get_count(quint64 &sum,quint32 &byte_s,quint32 &byte);
static QStringList comList();
static QStringList baudList();
static QStringList dataBList();
static QStringList stopBList();
static QStringList parityList();
static QStringList flowCtrlList();
static enum QSerialPort::Parity strToParity(QString str);
static QString parityToStr(enum QSerialPort::Parity parity);
static enum QSerialPort::StopBits strToStopBits(QString str);
static QString stopBitsToStr(enum QSerialPort::StopBits stopBits);
};
#endif // C_SERIALPORT_H