|
@@ -527,3 +527,123 @@ int ProcShenLanCANFDChassis(void *pa, iv::can::canmsg *pmsg)
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+int ProcHunterChassis(void *pa, iv::can::canmsg *pmsg)
|
|
|
+{
|
|
|
+ int i;
|
|
|
+ static iv::chassis xchassis;
|
|
|
+ static bool bHave0x221 = false;
|
|
|
+ static bool bHave0x361 = false;
|
|
|
+ float fsoc = 0.0;
|
|
|
+ float fsoh = 0.0;
|
|
|
+ float fbatv = 0.0;
|
|
|
+ float fbati = 0.0;
|
|
|
+ float fbatt = 0.0;
|
|
|
+ float fmileage_left = 0.0;
|
|
|
+ float fmileage_right = 0.0;
|
|
|
+ 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() == 0x221)
|
|
|
+ {
|
|
|
+ unsigned char vdata[2];
|
|
|
+ memcpy(&vdata,praw->data().data(),2);
|
|
|
+ double fvh = vdata[0];
|
|
|
+ double fvl = vdata[1];
|
|
|
+ double vehspeed = (fvh * 256 + fvl) * 0.001;
|
|
|
+ xchassis.set_vel(static_cast<float>(vehspeed));
|
|
|
+ bHave0x221 = true;
|
|
|
+ }
|
|
|
+ if(praw->id() == 0x361)
|
|
|
+ {
|
|
|
+ unsigned char vdata[2];
|
|
|
+ memcpy(&vdata,praw->data().data(),1);
|
|
|
+ fsoc = vdata[0];
|
|
|
+ memcpy(&vdata,praw->data().data() + 1,1);
|
|
|
+ fsoh = vdata[0];
|
|
|
+ memcpy(&vdata,praw->data().data()+2,2);
|
|
|
+ double fvh = vdata[0];
|
|
|
+ double fvl = vdata[1];
|
|
|
+ fbatv = (fvh * 256 + fvl) * 0.01f;
|
|
|
+
|
|
|
+ memcpy(&vdata,praw->data().data()+4,2);
|
|
|
+ unsigned char vswap[2];
|
|
|
+ vswap[0] = vdata[1];
|
|
|
+ vswap[1] = vdata[0];
|
|
|
+ unsigned short svalue;
|
|
|
+ memcpy(&svalue,vswap,2);
|
|
|
+ fbati = svalue;
|
|
|
+ fbati = fbati * 0.1f;
|
|
|
+
|
|
|
+ memcpy(&vdata,praw->data().data()+6,2);
|
|
|
+ vswap[0] = vdata[1];
|
|
|
+ vswap[1] = vdata[0];
|
|
|
+ memcpy(&svalue,vswap,2);
|
|
|
+ fbatt = svalue;
|
|
|
+ fbatt = fbatt * 0.1f;
|
|
|
+
|
|
|
+ bHave0x361 = true;
|
|
|
+ }
|
|
|
+ if(praw->id() == 0x311)
|
|
|
+ {
|
|
|
+ unsigned char vdata[4];
|
|
|
+ memcpy(&vdata,praw->data().data(),4);
|
|
|
+ unsigned char vswap[4];
|
|
|
+ vswap[0] = vdata[3];
|
|
|
+ vswap[1] = vdata[2];
|
|
|
+ vswap[2] = vdata[1];
|
|
|
+ vswap[3] = vdata[0];
|
|
|
+ int mil_left;
|
|
|
+ memcpy(&mil_left,vswap,4);
|
|
|
+ fmileage_left = mil_left;
|
|
|
+ fmileage_left = fmileage_left * 0.001f;
|
|
|
+
|
|
|
+ memcpy(&vdata,praw->data().data(),4);
|
|
|
+ vswap[0] = vdata[3];
|
|
|
+ vswap[1] = vdata[2];
|
|
|
+ vswap[2] = vdata[1];
|
|
|
+ vswap[3] = vdata[0];
|
|
|
+ int mil_right;
|
|
|
+ memcpy(&mil_right,vswap,4);
|
|
|
+ fmileage_right = mil_right;
|
|
|
+ fmileage_right = fmileage_right * 0.001f;
|
|
|
+ }
|
|
|
+ if(praw->id() == 0x358)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ if(praw->id() == 0x3AA)
|
|
|
+ {
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bHave0x221 && bHave0x361)
|
|
|
+ {
|
|
|
+ bHave0x221 = false;
|
|
|
+ bHave0x361 = false;
|
|
|
+ ShareChassis(pa,&xchassis);
|
|
|
+
|
|
|
+ std::cout<<"veh: "<<xchassis.vel()<<" soc: "<<fsoc<<" soh:"<<fsoh<< std::endl;
|
|
|
+ std::cout<<"bat v:"<<fbatv<<" i: "<<fbati<<" Temp:"<<fbatt<<" mil left:"<<fmileage_left<<" right: "<<fmileage_right<<std::endl;
|
|
|
+ }
|
|
|
+
|
|
|
+// if(ghave0x13&&ghave0x14&&ghave0x15)
|
|
|
+// {
|
|
|
+// ghave0x13 = false;
|
|
|
+// ghave0x14 = false;
|
|
|
+// ghave0x15 = false;
|
|
|
+// ShareChassis(pa,&xchassis);
|
|
|
+// nRtn = 1;
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|