37 lines
942 B
C
37 lines
942 B
C
|
#ifndef CSERIALPORTINTERFACE_H
|
||
|
#define CSERIALPORTINTERFACE_H
|
||
|
|
||
|
#include "ccommunicationinterface.h"
|
||
|
#include <QObject>
|
||
|
#include <QSerialPort>
|
||
|
#include <QTimer>
|
||
|
class CSerialportInterface : public CCommunicationInterface
|
||
|
{
|
||
|
public:
|
||
|
CSerialportInterface();
|
||
|
~CSerialportInterface();
|
||
|
//配置参数
|
||
|
virtual bool setConfigParam();
|
||
|
//发送数据接口
|
||
|
virtual void sendDataInterface(QByteArray);
|
||
|
//解析数据
|
||
|
virtual void analysisProtocal(QByteArray);
|
||
|
public slots:
|
||
|
//接收数据接口
|
||
|
void receiveDataInterface();
|
||
|
//通信状态变化
|
||
|
void deviceStateChanged(int);
|
||
|
//处理串口断开
|
||
|
void handleSerialError();
|
||
|
//QSerialPort::SerialPortError
|
||
|
//设备错误
|
||
|
void displayError(QSerialPort::SerialPortError error);
|
||
|
bool setConfigParamSerialError();
|
||
|
private:
|
||
|
QSerialPort *m_serialPort;
|
||
|
QByteArray receiveArray;
|
||
|
QTimer *m_blockTimer;
|
||
|
};
|
||
|
|
||
|
#endif // CSERIALPORTINTERFACE_H
|