diff --git a/Plx/include/LowLevel/HonaLowLevelAPI.h b/Plx/include/LowLevel/HonaLowLevelAPI.h index 767bc59..43f2523 100755 --- a/Plx/include/LowLevel/HonaLowLevelAPI.h +++ b/Plx/include/LowLevel/HonaLowLevelAPI.h @@ -3,6 +3,7 @@ #include #include #include +#include #include "LowLevel/Setting/Setting.h" #include "LowLevel/HonaPacket.h" @@ -118,6 +119,7 @@ private: public: + signals: void lowLevelHonaData(QList honaPacketList, quint32 hsruLoss, quint32 Doa); diff --git a/Plx/src/LowLevel/HonaLowLevelAPI.cpp b/Plx/src/LowLevel/HonaLowLevelAPI.cpp index ee51055..2f7cdd2 100755 --- a/Plx/src/LowLevel/HonaLowLevelAPI.cpp +++ b/Plx/src/LowLevel/HonaLowLevelAPI.cpp @@ -3,7 +3,8 @@ #include "include/LowLevel/HonaLowLevelAPI.h" #include "include/Wrapper/PlxWrapper.h" #include -#include +#include + quint32 HonaLowLevelAPI::packetLenInt4; quint32 HonaLowLevelAPI::packetLenRes4; quint32 HonaLowLevelAPI::packetLenSinglePulse; @@ -185,12 +186,16 @@ void HonaLowLevelAPI::hsruMainThread() throw HonaException(); } + _isHsruReaderThreadFree = false; + _isHsruUpdateThreadFree = false; + QtConcurrent::run(this, &HonaLowLevelAPI::hsruReadThread); QtConcurrent::run(this, &HonaLowLevelAPI::hsruUpdateThread); _mutex.lock(); _hsruStopEvent.wait(&_mutex); _mutex.unlock(); + _isHsruReaderThreadFree = true; _isHsruUpdateThreadFree = true; @@ -258,6 +263,9 @@ void HonaLowLevelAPI::hsruUpdateThread() quint32 Doa = 0; Doa = hiruGetDOA(); emit lowLevelHonaData(honaPacketList, _hsruLoss, Doa); + QThread::msleep(200); + // QDateTime time = QDateTime :: currentDateTime ();//Get the current time of the system + // QString str = time.toString ("yyyy-MM-dd hh: mm: ss: zzz ddd");//Set the display format _hsruUpdateAck.wakeAll(); } } @@ -306,7 +314,6 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector& honaData, { if((honaData[Ind] & 0xFF000000) == 0x0F000000) { - HonaPacket tempHonaPacketInt123C; tempHonaPacketInt123C.setPacketType(honaPacketType::interrogationMode123C); packetLenInt123C = 6; tempHonaPacketInt123C.setPacketNumber(honaData[Ind] & 0x0000FFFF); @@ -357,6 +364,10 @@ quint32 HonaLowLevelAPI::hsruParserInt123C(const QVector& honaData, tempHonaPacketInt123C.setCodeL(0); nextInt123C = 6; } + else if(honaData[Ind] == 0xEEEEEEEE) + { + break; + } if(nextInt123C == packetLenInt123C) { @@ -432,6 +443,10 @@ quint32 HonaLowLevelAPI::hsruParserRes123C(const QVector& honaData, nextRes123C = 6; } + else if(honaData[Ind] == 0xEEEEEEEE) + { + break; + } if(nextRes123C == packetLenRes123C) { @@ -513,8 +528,7 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector& honaData, else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextIntS == 6)) { tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); + ((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 36)); tempHonaPacketIntS.setCodeL(0); nextIntS = 7; } @@ -527,10 +541,13 @@ quint32 HonaLowLevelAPI::hsruParserIntS(const QVector& honaData, else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextIntS == 8)) { tempHonaPacketIntS.setCodeM(tempHonaPacketIntS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); + ((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 36)); nextIntS = 9; } + else if(honaData[Ind] == 0xEEEEEEEE) + { + break; + } if(nextIntS == packetLenIntS) { @@ -613,8 +630,7 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector& honaData, else if(((honaData[Ind] & 0xF0000000) == 0x60000000) && (nextResS == 6)) { tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); + ((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 36)); tempHonaPacketResS.setCodeL(0); nextResS = 7; } @@ -627,10 +643,14 @@ quint32 HonaLowLevelAPI::hsruParserResS(const QVector& honaData, else if(((honaData[Ind] & 0xF0000000) == 0x80000000) && (nextResS == 8)) { tempHonaPacketResS.setCodeM(tempHonaPacketResS.getCodeM() + - (static_cast(honaData[Ind] & 0x0FFFFFFF)) << - 36); + ((static_cast(honaData[Ind] & 0x0FFFFFFF)) << 36)); nextResS = 9; } + else if(honaData[Ind] == 0xEEEEEEEE) + { + break; + } + if(nextResS == packetLenResS) { if(isValid(tempHonaPacketResS)) @@ -710,6 +730,10 @@ quint32 HonaLowLevelAPI::hsruParserInt4(const QVector& honaData, tempHonaPacketInt4.setm4Status(static_cast((honaData[Ind] & 0x0F000000) >> 20)); nextInt4 = 7; } + else if(honaData[Ind] == 0xEEEEEEEE) + { + break; + } if(nextInt4 == packetLenInt4) { @@ -775,6 +799,10 @@ quint32 HonaLowLevelAPI::hsruParserRes4(const QVector& honaData, ((honaData[Ind] & 0x00F00000) >> 8)); nextRes4 = 5; } + else if(honaData[Ind] == 0xEEEEEEEE) + { + break; + } if(nextRes4 == packetLenRes4) { @@ -818,14 +846,14 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector& honaData, else if(((honaData[Ind] & 0xF0000000) == 0x10000000) && (nextSinglePulse == 1)) { tempHonaPacketSinglePulse.setToa(static_cast(honaData[Ind] & - 0x0FFFFFFF)); + 0x0FFFFFFF)); nextSinglePulse = 2; } else if(((honaData[Ind] & 0xF0000000) == 0x20000000) && (nextSinglePulse == 2)) { tempHonaPacketSinglePulse.setToa(tempHonaPacketSinglePulse.getToa() + ((static_cast(honaData[Ind] & - 0x0000FFFF)) << 28)); + 0x0000FFFF)) << 28)); tempHonaPacketSinglePulse.setPa2((honaData[Ind] & 0x0FFF0000) >> 16); nextSinglePulse = 3; } @@ -844,6 +872,10 @@ quint32 HonaLowLevelAPI::hsruParserSinglePulse(const QVector& honaData, ((honaData[Ind] & 0x00F00000) >> 8)); nextSinglePulse = 5; } + else if(honaData[Ind] == 0xEEEEEEEE) + { + break; + } if(nextSinglePulse == packetLenSinglePulse) { @@ -889,10 +921,10 @@ QVector HonaLowLevelAPI::hsruReadHonaBuffer(honaReceivers receiver) throw HonaException(); } -// qDebug() << " hsruReadHonaBuffer receiver "<< receiver; -// for(auto i = 0 ; i < 10; i++) -// qDebug() << "[" << i << "] " << "0x" << QString::number(honaData[i], 16); -// qDebug() << "------------------------------------------------------------"; + qDebug() << " hsruReadHonaBuffer receiver "<< receiver; + for(auto i = 0 ; i < 10; i++) + qDebug() << "[" << i << "] " << "0x" << QString::number(honaData[i], 16); + qDebug() << "------------------------------------------------------------"; return honaData; } diff --git a/Test/MainWindow.cpp b/Test/MainWindow.cpp index 8f0085a..f32db8d 100755 --- a/Test/MainWindow.cpp +++ b/Test/MainWindow.cpp @@ -7,6 +7,10 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { +// system("sudo PlxSdk/Bin/Plx_load 9054 d"); +// system("echo jangal28 | sudo -S gedit"); + + ui->setupUi(this); connect(&_honaAPI, &HonaAPI::honaDataResult, this, &MainWindow::honaDataResultUi); }