proto-debuger/protoDebuger/serialcontroller.h

48 lines
994 B
C
Raw Normal View History

2021-04-10 14:22:41 +00:00
#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