48 lines
994 B
C
48 lines
994 B
C
|
#ifndef SERIALCONTROLLER_H
|
||
|
#define SERIALCONTROLLER_H
|
||
|
|
||
|
#include <QObject>
|
||
|
#include <qextserialenumerator.h>
|
||
|
#include <qextserialport.h>
|
||
|
#include <QList>
|
||
|
#include "qserialproto.h"
|
||
|
#include <vector>
|
||
|
#include <QDebug>
|
||
|
|
||
|
#define OK 0
|
||
|
#define NULLPOINTER -1
|
||
|
|
||
|
/*
|
||
|
data -> controler -> proto -> listener
|
||
|
*/
|
||
|
using namespace std;
|
||
|
class SerialController : public QObject
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public slots:
|
||
|
void ReadyRead();
|
||
|
void AboutClose();
|
||
|
public:
|
||
|
typedef enum {
|
||
|
ERROR_OPEN = -1,
|
||
|
ERROR_SEND = -2,
|
||
|
}SerialError;
|
||
|
explicit SerialController(QObject *parent = nullptr);
|
||
|
int OpenSerial(QString port,PortSettings setting);
|
||
|
int CloseSerial();
|
||
|
void FlushPorts();
|
||
|
QList<QextPortInfo> GetPorts();
|
||
|
int SetProto(QSerialProto *);
|
||
|
int SendData(uint8_t *,uint8_t len);
|
||
|
|
||
|
signals:
|
||
|
private:
|
||
|
QList<QextPortInfo> mPorts;
|
||
|
bool mConnected;
|
||
|
PortSettings mSetting;
|
||
|
QextSerialPort *mCurrentPort;
|
||
|
QSerialProto *mProto;
|
||
|
};
|
||
|
|
||
|
#endif // SERIALCONTROLLER_H
|