Browse Source

change detection_chasis. add printraw.

yuchuli 1 year ago
parent
commit
da90e292ce

+ 21 - 0
src/detection/detection_chassis/decodechassis.cpp

@@ -12,6 +12,27 @@ extern "C"
 iv::Ivlog * mygivlog;
 iv::Ivfault * mygivfault;
 
+
+void PrintCANRaw(const iv::can::canraw * praw )
+{
+    char strout[512];
+    int ndatalen = praw->len();
+    int i;
+    snprintf(strout,512,"id: %02X data: ",praw->id());
+    char * pdata = new char[8];
+    if(ndatalen>0)pdata = new char[ndatalen];
+    memcpy(pdata,praw->data().data(),ndatalen);
+    for(i=0;i<ndatalen;i++)
+    {
+        char strtem[10];
+        snprintf(strtem,10,"%02X ",pdata[i]);
+        strncat(strout,strtem,512);
+    }
+    std::cout<<strout<<std::endl;
+    delete  pdata;
+
+}
+
 /**
   * @brief ShareChassis
   * Share Chassis State

+ 2 - 0
src/detection/detection_chassis/decodechassis.h

@@ -28,4 +28,6 @@ int ProcShenLanCANFDChassis(void *pa, iv::can::canmsg *pmsg);
 
 int ProcHunterChassis(void *pa, iv::can::canmsg *pmsg);
 
+void PrintCANRaw(const iv::can::canraw * praw );
+
 #endif // DECODECHASSIS_H

+ 13 - 0
src/detection/detection_chassis/main.cpp

@@ -24,6 +24,8 @@ void * gpa ;
 
 QTime gTime;
 
+bool gbPrintRaw = false;
+
 
 namespace  iv {
 
@@ -61,6 +63,16 @@ void Listencan0(const char * strdata,const unsigned int nSize,const unsigned int
         return;
     }
 
+    if(gbPrintRaw)
+    {
+        int i;
+        for(i=0;i<xmsg.rawmsg_size();i++)
+        {
+            const iv::can::canraw * praw = &(xmsg.rawmsg(i));
+            PrintCANRaw(praw);
+        }
+    }
+
     int nRtn = 0;
     switch (iv::gVehicleType) {
     case iv::GE3:
@@ -157,6 +169,7 @@ int main(int argc, char *argv[])
     std::string strvehicletype = xp.GetParam("vehicletype","GE3");
     std::string strmodulename = xp.GetParam("modulename","chassis"); //chassismsgname
     std::string strchassismsgname = xp.GetParam("chassismsgname","chassis");
+    gbPrintRaw = xp.GetParam("PrintRaw",false);
 
     iv::gVehicleType = iv::UNKNOWN;
     if(strncmp(strvehicletype.data(),"GE3",255) == 0)