Explorar o código

fix(detection_chassis):add yuhesen chassis

孙嘉城 %!s(int64=3) %!d(string=hai) anos
pai
achega
2aca775610

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

@@ -66,6 +66,10 @@ static bool  ghave0x14= false;
 static bool  ghave0x15= false;
 static bool  ghave0x28b= false;
 static bool  ghave0x255= false;
+static bool  ghave0x16= false;
+static bool  ghave0x17= false;
+static bool  ghave0x18= false;
+
 
 int ProcJSRunlegs(void * pa, iv::can::canmsg * pmsg)
 {
@@ -155,3 +159,91 @@ int ProcJSRunlegs(void * pa, iv::can::canmsg * pmsg)
     }
     return nRtn;
 }
+
+int ProcJSGuide(void * pa, iv::can::canmsg * pmsg)
+{
+    int i;
+    int nRtn = 0;
+    static iv::chassis xchassis;
+    for(i=0;i<pmsg->rawmsg_size();i++)
+    {
+        const iv::can::canraw * praw = &(pmsg->rawmsg(i));
+        unsigned char data[8];
+        memcpy(data,praw->data().data(),8);
+        if(praw->id() == 0x13)
+        {
+            xchassis.set_angle_feedback(gettwomotovalue(data+0,0.1,-870));
+            xchassis.set_torque(getonevalue(data+2,0.4,0));
+            xchassis.set_brake_feedback(getonevalue(data+3,0.4,0));
+            xchassis.set_vel(gettwomotovalue(data+4,0.05625,0));
+            xchassis.set_epb_feedback(data[6]&0x03);
+            xchassis.set_shift((data[6]&0xf0)>>4);
+            xchassis.set_drivemode(data[7]&0x01);
+            xchassis.set_emergencystop_feedback((data[7]&06)>>1);
+            xchassis.set_brakelight_feedback((data[7]&0x08)>>3);
+
+            std::cout<<"torque is "<<xchassis.torque()<<std::endl;
+            ghave0x13 = true;
+        }
+        if(praw->id() == 0x14)
+        {
+            xchassis.set_range_feedback(data[0]);
+            xchassis.set_soc(getonevalue(data+1,0.4,0));
+            xchassis.set_drivectrltype_feedback(data[5]&0x0f);
+            xchassis.set_brakectrltype_feedback((data[5]&0xf0)>>4);
+            xchassis.set_epsctrltype_feedback(data[6]&0x0f);
+            ghave0x14 = true;
+        }
+        if(praw->id() == 0x15)
+        {
+
+            xchassis.set_frontleftwheel_feedback(gettwomotovalue(data,0.05625,0));
+            xchassis.set_frontrightwheel_feedback(gettwomotovalue(data+2,0.05625,0));
+            xchassis.set_rearleftwheel_feedback(gettwomotovalue(data+4,0.05625,0));
+            xchassis.set_rearrightwheel_feedback(gettwomotovalue(data+6,0.05625,0));
+            ghave0x15 = true;
+        }
+        // Mileage--YuHeSen--0x18C4DEEF
+        if(praw->id() == 0x16)
+        {
+            uint32_t mileage = 0;
+            mileage = (data[3] << 24) | (data[2] << 16) | (data[1] << 8) | data[0];
+            xchassis.set_totalmileage(mileage);
+            ghave0x16 = true;
+        }
+        // BMS error code--YuHeSen--0x18C4E2EF
+        if(praw->id() == 0x17)
+        {
+            uint32_t BMSStatusCode = 0;
+            BMSStatusCode = (data[4] << 24) | (data[3] << 16) | (data[2] << 8) | data[1];
+            xchassis.set_hivolbatteryerr(BMSStatusCode);
+            ghave0x17 = true;
+        }
+        // vehicle error code--YuHeSen--0x18C4EAEF
+        if(praw->id() == 0x18)
+        {
+            uint32_t vehicleErr = 0;
+            vehicleErr = data[0] & 0x3F;
+            xchassis.set_veherrind(vehicleErr);
+            vehicleErr = data[1] & 0x3F;
+            xchassis.set_epserr(vehicleErr);
+            vehicleErr = ((data[5] & 0x01) << 8) | data[4];
+            xchassis.set_motorerr(vehicleErr);
+            vehicleErr = (data[5] >> 4) & 0x0F;
+            xchassis.set_othererrcode(vehicleErr);
+            ghave0x18 = true;
+        }
+        if(ghave0x13 && ghave0x14 && ghave0x15 && ghave0x16 && ghave0x17 && ghave0x18)
+        {
+            ghave0x13 = false;
+            ghave0x14 = false;
+            ghave0x15 = false;
+            ghave0x16 = false;
+            ghave0x17 = false;
+            ghave0x18 = false;
+            ShareChassis(pa,&xchassis);
+            nRtn = 1;
+        }
+    }
+    return nRtn;
+}

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

@@ -7,4 +7,5 @@
 #include "canmsg.pb.h"
 #include "chassis.pb.h"
 int ProcJSRunlegs(void * pa, iv::can::canmsg * pmsg);
+int ProcJSGuide(void * pa, iv::can::canmsg * pmsg);
 #endif // DECODECHASSIS_H

+ 8 - 1
src/detection/detection_chassis/main.cpp

@@ -26,7 +26,7 @@ QTime gTime;
 
 namespace  iv {
 
-enum VehicleTypeDef {GE3,VV7,MIDCAR,PROBLUE,MIDBUS,HAPO,UNKNOWN, YUHESEN, JSRunlegs} gVehicleType;  //车辆类型
+enum VehicleTypeDef {GE3,VV7,MIDCAR,PROBLUE,MIDBUS,HAPO,UNKNOWN, YUHESEN, JSRunlegs,JSGuide} gVehicleType;  //车辆类型
 
 
 }
@@ -62,6 +62,9 @@ void Listencan0(const char * strdata,const unsigned int nSize,const unsigned int
     case iv::JSRunlegs:
         nRtn = ProcJSRunlegs(gpa,&xmsg);
         break;
+    case iv::JSGuide:
+        nRtn = ProcJSGuide(gpa,&xmsg);
+        break;
     default:
         break;
     }
@@ -135,6 +138,10 @@ int main(int argc, char *argv[])
     {
         iv::gVehicleType = iv::JSRunlegs;
     }
+    if(strncmp(strvehicletype.data(),"JSGuide",255) == 0)
+    {
+        iv::gVehicleType = iv::JSGuide;
+    }
 
     givlog = new iv::Ivlog(strmodulename.data());
     givfault = new iv::Ivfault(strmodulename.data());

+ 9 - 8
src/include/proto/chassis.proto

@@ -29,12 +29,13 @@ message chassis
   optional float rearleftwheel_feedback = 23;
   optional float rearrightwheel_feedback = 24;
   optional float engine_speed = 25;
-  optional int32 vehErrInd = 26;	//整车线控故障状态
-  optional int32 brakeSysErr = 27;	//制动系统故障状态
-  optional int32 EPSErr = 28;		//转向系统故障状态
-  optional int32 motorErr = 29;		//驱动电机故障状态
-  optional int32 EPBErr = 30;		//电子驻车系统故障状态
-  optional int32 hiVolBatteryErr = 31;	//高压电池系统故障状态
-  optional int32 subMileage = 32;	//小计行驶里程
-  optional int32 totalMileage = 33;	//总行驶里程
+  optional int32 vehErrInd = 26; //整车线控故障状态或故障等级
+  optional int32 brakeSysErr = 27; //制动系统故障状态或故障码
+  optional int32 EPSErr = 28; //转向系统故障状态或故障码
+  optional int32 motorErr = 29; //驱动电机故障状态或故障码
+  optional int32 EPBErr = 30; //电子驻车系统故障状态或故障码
+  optional int32 hiVolBatteryErr = 31; //高压电池系统故障状态或故障码
+  optional int32 subMileage = 32; //小计行驶里程
+  optional int32 totalMileage = 33; //总行驶里程
+  optional int64 otherErrCode = 34; //其他故障码 总线通信 急停 遥控等故障
 };