Browse Source

change driver_lidar_bk. complete.

yuchuli 2 months ago
parent
commit
89bddc0675
1 changed files with 30 additions and 1 deletions
  1. 30 1
      src/driver/driver_lidar_bk_16z/lidar_bkdriver.cpp

+ 30 - 1
src/driver/driver_lidar_bk_16z/lidar_bkdriver.cpp

@@ -319,7 +319,10 @@ int lidar_bkdriver::setState(lidarAPi::DEB_PROGRM_S &program)
 
 int lidar_bkdriver::RecvRawThread()
 {
-    const int MAXPACLEN = 60000;
+    const int MAXPACLEN = 90000;
+    std::shared_ptr<unsigned char> plast_ptr;
+    int nlast = 0;
+
     while(mbRun)
     {
         std::shared_ptr<unsigned char> pread = std::shared_ptr<unsigned char>(new unsigned  char[MAXPACLEN]);
@@ -333,6 +336,32 @@ int lidar_bkdriver::RecvRawThread()
             continue;
         }
 
+        if(ret%1184 != 0)
+        {
+            std::cout<<" read a not complete packet. size: "<<ret<<std::endl;
+            if((nlast + ret )%1184 == 0)
+            {
+                std::cout<<" now add last is ok."<<std::endl;
+                std::shared_ptr<unsigned char> pt1 = pread;
+                pread = std::shared_ptr<unsigned char>(new unsigned  char[nlast + ret]);
+                memcpy(pread.get(),plast_ptr.get(),nlast);
+                memcpy(pread.get()+nlast,pt1.get(),ret);
+                ret = ret + nlast;
+            }
+
+        }
+
+        if(ret%1184 != 0)
+        {
+            plast_ptr = pread;
+            nlast = ret;
+            continue;
+        }
+        else
+        {
+            nlast = 0;
+        }
+
         mmutexrawdata.lock();
         if(mvecterraw.size()>100)
         {