Browse Source

add driver_radar_4d_ars548. not complete.

yuchuli 8 tháng trước cách đây
mục cha
commit
25c8bb5db2

+ 14 - 0
autogen_lib.sh

@@ -30,6 +30,20 @@ if [ ${#qtmake} -lt 5 ]; then
   done
 fi
 
+if [ ${#qtmake} -lt 5 ]; then
+  echo "maybe qt6,find qmake in usr folder "
+  optfiles=`find /usr -name 'qmake'` 
+  for entry in $optfiles
+  do
+     x=${entry:0-14:14}
+     if [ "$x" == "/qt6/bin/qmake" ];  then
+        qtmake="$entry"
+	echo "  -----find qmake"
+	echo "$qtmake"
+     fi
+  done
+fi
+
 echo -e "\e[33m qtmake: $qtmake \e[0m"
 
 MAKEOPT=-j8

+ 2 - 2
src/common/modulecomm/inter/intercomm.cpp

@@ -209,8 +209,8 @@ void intercomm::continuecomm()
 void intercomm::listernrun()
 {
     InterListenUnit * pILU = (InterListenUnit * )mplistenunit;
-    QTime xTime;
-    xTime.start();
+//    QTime xTime;
+//    xTime.start();
     unsigned int nBufLen = 1;
     unsigned int nRead;
     char * str = new char[nBufLen];

+ 11 - 5
src/common/modulecomm/shm/procsm_if.cpp

@@ -3,6 +3,8 @@
 
 #include <iostream>
 
+#include <thread>
+#include <chrono>
 
 
 procsm_if_readthread::procsm_if_readthread(procsm *pPSM,SMCallBack pCall,const char * strsmname,void * pparent)
@@ -85,8 +87,8 @@ void procsm_if_readthread::run()
     }
     return;
 #endif
-    QTime xTime;
-    xTime.start();
+//    QTime xTime;
+//    xTime.start();
     unsigned int nBufLen = 1;
     unsigned int nRead;
     char * str = new char[nBufLen];
@@ -256,13 +258,17 @@ procsm_if::~procsm_if()
 //        mpthread->join();
 #endif
 
-        QTime xTime;
-        xTime.start();
+        int64_t nstart = std::chrono::system_clock::now().time_since_epoch().count();
+ //       QTime xTime;
+ //       xTime.start();
         bool bDel = true;
         mpReadThread->requestInterruption();
         while(!mpReadThread->isFinished())
         {
-            if(xTime.elapsed() > 1000)
+            int64_t nnow = std::chrono::system_clock::now().time_since_epoch().count();
+            int64_t ndiff = nnow - nstart;
+            if(abs(ndiff)>1e9)
+ //           if(xTime.elapsed() > 1000)
             {
                 bDel = false;
                 std::cout<<"procsm_if Thread Read not finish."<<std::endl;

+ 74 - 0
src/driver/driver_radar_4d_ars548/.gitignore

@@ -0,0 +1,74 @@
+# This file is used to ignore files which are generated
+# ----------------------------------------------------------------------------
+
+*~
+*.autosave
+*.a
+*.core
+*.moc
+*.o
+*.obj
+*.orig
+*.rej
+*.so
+*.so.*
+*_pch.h.cpp
+*_resource.rc
+*.qm
+.#*
+*.*#
+core
+!core/
+tags
+.DS_Store
+.directory
+*.debug
+Makefile*
+*.prl
+*.app
+moc_*.cpp
+ui_*.h
+qrc_*.cpp
+Thumbs.db
+*.res
+*.rc
+/.qmake.cache
+/.qmake.stash
+
+# qtcreator generated files
+*.pro.user*
+CMakeLists.txt.user*
+
+# xemacs temporary files
+*.flc
+
+# Vim temporary files
+.*.swp
+
+# Visual Studio generated files
+*.ib_pdb_index
+*.idb
+*.ilk
+*.pdb
+*.sln
+*.suo
+*.vcproj
+*vcproj.*.*.user
+*.ncb
+*.sdf
+*.opensdf
+*.vcxproj
+*vcxproj.*
+
+# MinGW generated files
+*.Debug
+*.Release
+
+# Python byte code
+*.pyc
+
+# Binaries
+# --------
+*.dll
+*.exe
+

+ 57 - 0
src/driver/driver_radar_4d_ars548/ar548pac.cpp

@@ -0,0 +1,57 @@
+#include "ar548pac.h"
+
+#include <iostream>
+#include <string.h>
+
+#define POS_ServiceID 0
+#define POS_MethodID 2
+#define POS_Length 4
+#define POS_ClientID 8
+#define POS_SessionID 10
+#define POS_ProtocolVersion 12
+#define POS_InterfaceVersion 13
+#define POS_MessageType 14
+#define POS_ReturnCode 15
+
+ars548pac::ars548pac(const char * pdata,int ndatalen)
+{
+    if(ndatalen<16)
+    {
+        std::cout<<" ARS548 Packet Len < 16, ndatalen:"<<ndatalen<<std::endl;
+        mbPacValid = false;
+        return;
+    }
+    memcpy(&mheader.ServiceID,pdata+POS_ServiceID,2);
+    memcpy(&mheader.MethodID,pdata+POS_MethodID,2);
+    memcpy(&mheader.Length,pdata+POS_Length,4);
+    memcpy(&mheader.ClientID,pdata+POS_ClientID,2);
+    memcpy(&mheader.SessionID,pdata+POS_SessionID,2);
+    memcpy(&mheader.ProtocolVersion,pdata+POS_ProtocolVersion,1);
+    memcpy(&mheader.InterfaceVersion,pdata+POS_InterfaceVersion,1);
+    memcpy(&mheader.MessageType,pdata+POS_MessageType,1);
+    memcpy(&mheader.ReturnCode,pdata+POS_ReturnCode,1);
+
+    if(mheader.Length != (unsigned short)(ndatalen-8))
+    {
+        std::cout<<" Packet Length Error. "<<"Length Told in header, "<<mheader.Length<<" ndatalen:"<<ndatalen<<std::endl;
+        mbPacValid = false;
+        return;
+    }
+
+}
+
+
+iv::ars548pac_header ars548pac::GetHeader()
+{
+    return mheader;
+}
+
+iv::ars548pac_Payload ars548pac::GetPayload()
+{
+    return mPayload;
+}
+
+bool ars548pac::IsValidPac()
+{
+    return mbPacValid;
+}

+ 49 - 0
src/driver/driver_radar_4d_ars548/ar548pac.h

@@ -0,0 +1,49 @@
+#ifndef AR548PAC_H
+#define AR548PAC_H
+
+#include <memory>
+
+namespace  iv {
+struct ars548pac_header
+{
+    unsigned short ServiceID;
+    unsigned short MethodID;
+    unsigned int Length;
+    unsigned short ClientID;
+    unsigned short  SessionID;
+    unsigned char ProtocolVersion;
+    unsigned char InterfaceVersion;
+    unsigned char MessageType;
+    unsigned char ReturnCode;
+};
+
+struct ars548pac_Payload
+{
+    unsigned char CRC[8];
+    unsigned int  Length;
+    unsigned int SOC;
+    unsigned int DataID;
+    unsigned int nDataLen;
+    std::shared_ptr<char> pPayload_ptr;
+};
+
+}
+
+class ars548pac
+{
+private:
+    iv::ars548pac_header mheader;
+    iv::ars548pac_Payload mPayload;
+    bool mbPacValid = false;
+
+public:
+    ars548pac(const char * pdata,int ndatalen);
+    ~ars548pac();
+
+    iv::ars548pac_header GetHeader();
+    iv::ars548pac_Payload GetPayload();
+    bool IsValidPac();
+
+};
+
+#endif // AR548PAC_H

+ 19 - 0
src/driver/driver_radar_4d_ars548/driver_radar_4d_ars548.pro

@@ -0,0 +1,19 @@
+QT = core network
+
+CONFIG += c++1z cmdline
+
+# You can make your code fail to compile if it uses deprecated APIs.
+# In order to do so, uncomment the following line.
+#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
+
+SOURCES += \
+        ar548pac.cpp \
+        main.cpp
+
+# Default rules for deployment.
+qnx: target.path = /tmp/$${TARGET}/bin
+else: unix:!android: target.path = /opt/$${TARGET}/bin
+!isEmpty(target.path): INSTALLS += target
+
+HEADERS += \
+    ar548pac.h

+ 8 - 0
src/driver/driver_radar_4d_ars548/main.cpp

@@ -0,0 +1,8 @@
+#include <QCoreApplication>
+
+int main(int argc, char *argv[])
+{
+    QCoreApplication a(argc, argv);
+
+    return a.exec();
+}