hlp:荆州版本
This commit is contained in:
+1017
-1017
File diff suppressed because it is too large
Load Diff
+136
-136
@@ -1,136 +1,136 @@
|
||||
#ifndef SERIAL_H
|
||||
#define SERIAL_H
|
||||
#include <QSerialPort>
|
||||
#include <QObject>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <QQueue>
|
||||
#include <QTimer>
|
||||
#include <QSet>
|
||||
#include <QMutex>
|
||||
|
||||
typedef struct{
|
||||
int cmd;
|
||||
int addr;
|
||||
unsigned char* data;
|
||||
int len;
|
||||
int type;
|
||||
}send_Data;
|
||||
|
||||
class Serial : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Serial(QObject *parent = nullptr);
|
||||
Serial(const QString);
|
||||
~Serial();
|
||||
|
||||
QString com;
|
||||
QSerialPort *serial = nullptr;
|
||||
QByteArray recDataFromFPGA;
|
||||
QByteArray recDataFromSTM32;
|
||||
unsigned char *STM32RecDataSavePtr;
|
||||
int STM32RecDataLen;
|
||||
unsigned char *FPGARecDataSavePtr;
|
||||
int FPGARecDataLen;
|
||||
QSet<int> set;
|
||||
|
||||
QQueue<send_Data> queue;
|
||||
QQueue<send_Data> queueFPGA;
|
||||
int curLen;
|
||||
bool flagOfReadFinished;
|
||||
bool isCommunication;
|
||||
int STM32ReadCnt;
|
||||
int STM32WriteCnt;
|
||||
int FPGAReadCnt;
|
||||
int FPGAWriteCnt;
|
||||
bool RecFlag;
|
||||
int waitTime;
|
||||
bool flagOfUpgradeSTM32;
|
||||
bool UpgradeACK;
|
||||
|
||||
QByteArray recData;
|
||||
QTimer *timerSend;
|
||||
QTimer *timerRead;
|
||||
bool flagOfsendEmit;
|
||||
void enQueue(int cmd,int addr, unsigned char* data, int len,int type,bool flag);
|
||||
void getDataFromQueue(int &cmd,int &addr,unsigned char*& data,int &len,int &type,bool flag);
|
||||
|
||||
|
||||
void initSerialPort(const QString);
|
||||
quint16 calCRC16CodeOut(QByteArray data, int length);
|
||||
bool calCRC16CodeIn(QByteArray data);
|
||||
void showData( QByteArray dat,int type);
|
||||
bool getSerialStatus(int);
|
||||
|
||||
void getReceivedFromFPGAData(QByteArray);
|
||||
|
||||
void readFPGAData(QByteArray);
|
||||
void readSTM32Data(QByteArray);
|
||||
void updateSet();
|
||||
void close();
|
||||
|
||||
public slots:
|
||||
void readData();
|
||||
|
||||
void startInitSlot();
|
||||
|
||||
void sendSerialData(int cmd,int addr, unsigned char* data, int len,int type);
|
||||
void sendSerialDataFromTimer();
|
||||
void readTimeOut();
|
||||
void upgradeSTM32File(QString);
|
||||
|
||||
signals:
|
||||
void receivedFromFPGA(QByteArray);
|
||||
void receivedFromSTM32(QByteArray);
|
||||
void getFPGAStatus(unsigned char *);
|
||||
void getFPGAPhaseDetectHighTm(unsigned char *);
|
||||
void getFPGAVersion(unsigned int);
|
||||
void getSTM32Status(unsigned char *);
|
||||
void getGearPumpVal(unsigned char *);
|
||||
void getPulseCnt(unsigned char *);
|
||||
void getFPGACalandarAndDat(unsigned char *);
|
||||
void getFPGACnt3CurrValue(unsigned char *);
|
||||
void getFPGAXXXDay(unsigned char *);
|
||||
void getSTM32Version(unsigned char *);
|
||||
void getSTM32Time(unsigned char *);
|
||||
void powerOffReady();
|
||||
|
||||
void stopSendData(bool);
|
||||
void queueSizeFPGA(int);
|
||||
void queueSizeSTM32(int);
|
||||
void queueFPGASizeSIG(int);
|
||||
void resendFPGAData(int,int,unsigned char *,int,int);
|
||||
void sendQueueData(int,int,unsigned char *,int,int);
|
||||
void progress(int,int);
|
||||
void FPGABuildDat(int buildTime);
|
||||
|
||||
void STM32Connected(bool ok, QString errorMsg);
|
||||
|
||||
private:
|
||||
void sendDataToFPGA(int,int,unsigned char*,int);
|
||||
void sendDataToSTM32(int,int,unsigned char*,int);
|
||||
void handleFPGAVersion(unsigned char *);
|
||||
// void handleFPGAStatus(unsigned char *data);
|
||||
void handleSTM32Status(unsigned char *dataPtr);
|
||||
void handleGearPumpVal(unsigned char *dataPtr);
|
||||
void handlePulseCnt(unsigned char *dataPtr);
|
||||
int STM32CRCErrorCNt;
|
||||
int FPGACRCErrorCNt;
|
||||
QMutex Mutex;
|
||||
|
||||
void UpgradeSTM32(QString);
|
||||
bool sync(); // 发送 0x7F 等待 0x79
|
||||
bool getCMD();
|
||||
bool eraseChip(); // Extended Erase 全片
|
||||
bool writeBin(QByteArray bin, uint32_t addr = 0x08000000);
|
||||
bool go(uint32_t addr = 0x08000000);
|
||||
bool sendCmd(uint8_t cmd);
|
||||
bool waitForAck(int);
|
||||
unsigned char checkSumForUpgrade(unsigned char *data,int len);
|
||||
bool sendDataToUART2(QByteArray,int);
|
||||
|
||||
};
|
||||
|
||||
#endif // SERIAL_H
|
||||
#ifndef SERIAL_H
|
||||
#define SERIAL_H
|
||||
#include <QSerialPort>
|
||||
#include <QObject>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
#include <QQueue>
|
||||
#include <QTimer>
|
||||
#include <QSet>
|
||||
#include <QMutex>
|
||||
|
||||
typedef struct{
|
||||
int cmd;
|
||||
int addr;
|
||||
unsigned char* data;
|
||||
int len;
|
||||
int type;
|
||||
}send_Data;
|
||||
|
||||
class Serial : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Serial(QObject *parent = nullptr);
|
||||
Serial(const QString);
|
||||
~Serial();
|
||||
|
||||
QString com;
|
||||
QSerialPort *serial = nullptr;
|
||||
QByteArray recDataFromFPGA;
|
||||
QByteArray recDataFromSTM32;
|
||||
unsigned char *STM32RecDataSavePtr;
|
||||
int STM32RecDataLen;
|
||||
unsigned char *FPGARecDataSavePtr;
|
||||
int FPGARecDataLen;
|
||||
QSet<int> set;
|
||||
|
||||
QQueue<send_Data> queue;
|
||||
QQueue<send_Data> queueFPGA;
|
||||
int curLen;
|
||||
bool flagOfReadFinished;
|
||||
bool isCommunication;
|
||||
int STM32ReadCnt;
|
||||
int STM32WriteCnt;
|
||||
int FPGAReadCnt;
|
||||
int FPGAWriteCnt;
|
||||
bool RecFlag;
|
||||
int waitTime;
|
||||
bool flagOfUpgradeSTM32;
|
||||
bool UpgradeACK;
|
||||
|
||||
QByteArray recData;
|
||||
QTimer *timerSend;
|
||||
QTimer *timerRead;
|
||||
bool flagOfsendEmit;
|
||||
void enQueue(int cmd,int addr, unsigned char* data, int len,int type,bool flag);
|
||||
void getDataFromQueue(int &cmd,int &addr,unsigned char*& data,int &len,int &type,bool flag);
|
||||
|
||||
|
||||
void initSerialPort(const QString);
|
||||
quint16 calCRC16CodeOut(QByteArray data, int length);
|
||||
bool calCRC16CodeIn(QByteArray data);
|
||||
void showData( QByteArray dat,int type);
|
||||
bool getSerialStatus(int);
|
||||
|
||||
void getReceivedFromFPGAData(QByteArray);
|
||||
|
||||
void readFPGAData(QByteArray);
|
||||
void readSTM32Data(QByteArray);
|
||||
void updateSet();
|
||||
void close();
|
||||
|
||||
public slots:
|
||||
void readData();
|
||||
|
||||
void startInitSlot();
|
||||
|
||||
void sendSerialData(int cmd,int addr, unsigned char* data, int len,int type);
|
||||
void sendSerialDataFromTimer();
|
||||
void readTimeOut();
|
||||
void upgradeSTM32File(QString);
|
||||
|
||||
signals:
|
||||
void receivedFromFPGA(QByteArray);
|
||||
void receivedFromSTM32(QByteArray);
|
||||
void getFPGAStatus(unsigned char *);
|
||||
void getFPGAPhaseDetectHighTm(unsigned char *);
|
||||
void getFPGAVersion(unsigned int);
|
||||
void getSTM32Status(unsigned char *);
|
||||
void getGearPumpVal(unsigned char *);
|
||||
void getPulseCnt(unsigned char *);
|
||||
void getFPGACalandarAndDat(unsigned char *);
|
||||
void getFPGACnt3CurrValue(unsigned char *);
|
||||
void getFPGAXXXDay(unsigned char *);
|
||||
void getSTM32Version(unsigned char *);
|
||||
void getSTM32Time(unsigned char *);
|
||||
void powerOffReady();
|
||||
|
||||
void stopSendData(bool);
|
||||
void queueSizeFPGA(int);
|
||||
void queueSizeSTM32(int);
|
||||
void queueFPGASizeSIG(int);
|
||||
void resendFPGAData(int,int,unsigned char *,int,int);
|
||||
void sendQueueData(int,int,unsigned char *,int,int);
|
||||
void progress(int,int);
|
||||
void FPGABuildDat(int buildTime);
|
||||
|
||||
void STM32Connected(bool ok, QString errorMsg);
|
||||
|
||||
private:
|
||||
void sendDataToFPGA(int,int,unsigned char*,int);
|
||||
void sendDataToSTM32(int,int,unsigned char*,int);
|
||||
void handleFPGAVersion(unsigned char *);
|
||||
// void handleFPGAStatus(unsigned char *data);
|
||||
void handleSTM32Status(unsigned char *dataPtr);
|
||||
void handleGearPumpVal(unsigned char *dataPtr);
|
||||
void handlePulseCnt(unsigned char *dataPtr);
|
||||
int STM32CRCErrorCNt;
|
||||
int FPGACRCErrorCNt;
|
||||
QMutex Mutex;
|
||||
|
||||
void UpgradeSTM32(QString);
|
||||
bool sync(); // 发送 0x7F 等待 0x79
|
||||
bool getCMD();
|
||||
bool eraseChip(); // Extended Erase 全片
|
||||
bool writeBin(QByteArray bin, uint32_t addr = 0x08000000);
|
||||
bool go(uint32_t addr = 0x08000000);
|
||||
bool sendCmd(uint8_t cmd);
|
||||
bool waitForAck(int);
|
||||
unsigned char checkSumForUpgrade(unsigned char *data,int len);
|
||||
bool sendDataToUART2(QByteArray,int);
|
||||
|
||||
};
|
||||
|
||||
#endif // SERIAL_H
|
||||
|
||||
Reference in New Issue
Block a user