Browse Source

change driver_can_nvidia_agx, fix a big bug , memory leak. change controller_tju_vv7, close engine control.

yuchuli 3 years ago
parent
commit
438e7d5eae

+ 9 - 2
src/controller/controller_tju_vv7/main.cpp

@@ -13,6 +13,7 @@
 #include "canmsg.pb.h"
 #include "decition.pb.h"
 #include <thread>
+#include <QMutex>
 
 void * gpacansend;
 void * gpadecition;
@@ -24,6 +25,8 @@ bool gbSendRun = true;
 iv::brain::decition gdecition_def;
 iv::brain::decition gdecition;
 
+QMutex gMutexDecision;
+
 
 QTime gTime;
 int gnLastSendTime = 0;
@@ -87,8 +90,8 @@ void executeDecition(const iv::brain::decition decition)
         rightlampSig = decition.rightlamp();
     gcontroller->control_turnsignals(leftlampSig,rightlampSig);
 
-    if(decition.has_engine())
-        gcontroller->control_engine(decition.engine());
+//    if(decition.has_engine())
+//        gcontroller->control_engine(decition.engine());
     if(decition.has_speak())
         gcontroller->control_speaker(decition.speak());
 
@@ -106,7 +109,9 @@ void ListenDeciton(const char * strdata,const unsigned int nSize,const unsigned
         return;
     }
 
+    gMutexDecision.lock();
     gdecition.CopyFrom(xdecition);
+    gMutexDecision.unlock();
     gnDecitionNum = gnDecitionNumMax;
 
 
@@ -155,7 +160,9 @@ void sendthread()
         }
         else
         {
+            gMutexDecision.lock();
             xdecition.CopyFrom(gdecition);
+            gMutexDecision.unlock();
             gnDecitionNum--;
         }
         executeDecition(xdecition);

+ 2 - 0
src/driver/driver_can_nvidia_agx/canctrl.cpp

@@ -110,6 +110,7 @@ void canctrl::run()
             {
                 iv::modulecomm::ModuleSendMsg(mpcanState,strdata,nsize);
             }
+            delete strdata;
             msleep(1);
             mpcan->mivlog->error("%s open can card fail",__func__);
         }
@@ -218,4 +219,5 @@ void canctrl::sharecanmsg(void *xpa, basecan_msg * pxmsg,int ncount,int nch)
         mpcan->mivlog->error("canctrl::sharecanmsg serialize error");
         mpcan->mfault->SetFaultState(1, 0, "sharecanmsg serialize error");
     }
+    delete strdata;
 }