|
@@ -5,6 +5,7 @@
|
|
#include <math.h>
|
|
#include <math.h>
|
|
#include <thread>
|
|
#include <thread>
|
|
#include <QDebug>
|
|
#include <QDebug>
|
|
|
|
+#include <QReadWriteLock>
|
|
|
|
|
|
#include <signal.h>
|
|
#include <signal.h>
|
|
#include <stdlib.h>
|
|
#include <stdlib.h>
|
|
@@ -40,12 +41,12 @@ static uint16_t Radar_to_Rear_Axle = 370;//< 0-710 cm
|
|
static uint16_t Car_Wheel_Base = 270;//< 0-710 cm
|
|
static uint16_t Car_Wheel_Base = 270;//< 0-710 cm
|
|
static uint8_t Car_Steering_Gear_Ratio = 18;//< 0-31.875
|
|
static uint8_t Car_Steering_Gear_Ratio = 18;//< 0-31.875
|
|
/******************************************/
|
|
/******************************************/
|
|
-
|
|
|
|
|
|
+QReadWriteLock *wrLock = new QReadWriteLock();
|
|
canSend4F0 canData4f0;
|
|
canSend4F0 canData4f0;
|
|
canSend4F1 canData4f1;
|
|
canSend4F1 canData4f1;
|
|
canSend5F2 canData5f2;
|
|
canSend5F2 canData5f2;
|
|
canSend5F4 canData5f4;
|
|
canSend5F4 canData5f4;
|
|
-
|
|
|
|
|
|
+int canChannel = 0;
|
|
/******************************************/
|
|
/******************************************/
|
|
|
|
|
|
iv::Ivlog * givlog;
|
|
iv::Ivlog * givlog;
|
|
@@ -69,7 +70,6 @@ void ExecSend()
|
|
{
|
|
{
|
|
iv::can::canmsg xmsg;
|
|
iv::can::canmsg xmsg;
|
|
iv::can::canraw xraw;
|
|
iv::can::canraw xraw;
|
|
-qDebug()<<QTime::currentTime();
|
|
|
|
xraw.set_id(0x4F0);
|
|
xraw.set_id(0x4F0);
|
|
xraw.set_data(canData4f0.byte,8);
|
|
xraw.set_data(canData4f0.byte,8);
|
|
xraw.set_bext(false);
|
|
xraw.set_bext(false);
|
|
@@ -136,8 +136,10 @@ void Listengpsimu(const char * strdata,const unsigned int nSize,const unsigned i
|
|
givlog->warn("detection_radar_delphi_esr_send--Listengpsimu parse errror. nSize is %d",nSize);
|
|
givlog->warn("detection_radar_delphi_esr_send--Listengpsimu parse errror. nSize is %d",nSize);
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ wrLock->lockForWrite();
|
|
Vehicle_Yaw_Rate = xgpsimu.gyro_z() * -1;
|
|
Vehicle_Yaw_Rate = xgpsimu.gyro_z() * -1;
|
|
Vehicle_Speed = sqrt(xgpsimu.vn()*xgpsimu.vn() + xgpsimu.ve()*xgpsimu.ve() + xgpsimu.vd()*xgpsimu.vd());
|
|
Vehicle_Speed = sqrt(xgpsimu.vn()*xgpsimu.vn() + xgpsimu.ve()*xgpsimu.ve() + xgpsimu.vd()*xgpsimu.vd());
|
|
|
|
+ wrLock->unlock();
|
|
}
|
|
}
|
|
|
|
|
|
void Listencancar(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
void Listencancar(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
@@ -158,10 +160,12 @@ void Listencancar(const char * strdata,const unsigned int nSize,const unsigned i
|
|
|
|
|
|
/****************timer*********************/
|
|
/****************timer*********************/
|
|
|
|
|
|
-void signalHandler(int num)
|
|
|
|
|
|
+void signalHandler()
|
|
{
|
|
{
|
|
|
|
+ wrLock->lockForRead();
|
|
unsigned int speed = (unsigned int)(Vehicle_Speed / 0.0625);
|
|
unsigned int speed = (unsigned int)(Vehicle_Speed / 0.0625);
|
|
int yawRate = (int)(Vehicle_Yaw_Rate / 0.0625);
|
|
int yawRate = (int)(Vehicle_Yaw_Rate / 0.0625);
|
|
|
|
+ wrLock->unlock();
|
|
|
|
|
|
canData4f0.bit.canVehicleSpeedH = speed >> 8;
|
|
canData4f0.bit.canVehicleSpeedH = speed >> 8;
|
|
canData4f0.bit.canVehicleSpeedL = speed & 0xFF;
|
|
canData4f0.bit.canVehicleSpeedL = speed & 0xFF;
|
|
@@ -489,7 +493,7 @@ void threadstate()
|
|
{
|
|
{
|
|
while(1)
|
|
while(1)
|
|
{
|
|
{
|
|
- std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
|
|
|
|
|
+ std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
|
if(gnRadarState > -100)gnRadarState--;
|
|
if(gnRadarState > -100)gnRadarState--;
|
|
if(gnRadarState > 0)
|
|
if(gnRadarState > 0)
|
|
{
|
|
{
|
|
@@ -506,7 +510,8 @@ void threadstate()
|
|
givfault->SetFaultState(2,2,"无CAN数据");
|
|
givfault->SetFaultState(2,2,"无CAN数据");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ signalHandler();
|
|
|
|
+ qDebug()<<QTime::currentTime();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -514,6 +519,42 @@ int main(int argc, char *argv[])
|
|
{
|
|
{
|
|
QCoreApplication a(argc, argv);
|
|
QCoreApplication a(argc, argv);
|
|
|
|
|
|
|
|
+ QString strpath = QCoreApplication::applicationDirPath();
|
|
|
|
+ if(argc < 2)
|
|
|
|
+ strpath = strpath + "/detection_radar_esr.xml";
|
|
|
|
+ else
|
|
|
|
+ strpath = argv[1];
|
|
|
|
+ std::cout<<strpath.toStdString()<<std::endl;
|
|
|
|
+
|
|
|
|
+ iv::xmlparam::Xmlparam xp(strpath.toStdString());
|
|
|
|
+
|
|
|
|
+ std::string strmemcan = xp.GetParam("canrecv","canrecv1");
|
|
|
|
+ std::string strmemsend = xp.GetParam("cansend","cansend1");
|
|
|
|
+ std::string strmemradar = xp.GetParam("radar","radar");
|
|
|
|
+ std::string strmodulename = xp.GetParam("modulename","detection_radar_delphi_esr");
|
|
|
|
+#ifdef fujiankuan
|
|
|
|
+ gstrmemgpsimu = xp.GetParam("gpsimu_name","hcp2_gpsimu");
|
|
|
|
+ gstrmemcancar = xp.GetParam("cancar","can_car");
|
|
|
|
+#endif
|
|
|
|
+ givlog = new iv::Ivlog(strmodulename.data());
|
|
|
|
+ givfault = new iv::Ivfault(strmodulename.data());
|
|
|
|
+
|
|
|
|
+ givfault->SetFaultState(1,1,"初始化");
|
|
|
|
+ givlog->info("Initialized");
|
|
|
|
+
|
|
|
|
+ if(strmemsend.compare("cansend0") == 0){
|
|
|
|
+ canChannel = 0;
|
|
|
|
+ givlog->info("ESR","set ESR can send channel to 0");
|
|
|
|
+ }
|
|
|
|
+ if(strmemsend.compare("cansend1") == 0){
|
|
|
|
+ canChannel = 1;
|
|
|
|
+ givlog->info("ESR","set ESR can send channel to 1");
|
|
|
|
+}
|
|
|
|
+ else {
|
|
|
|
+ givlog->info("ESR","Not agx can,set default ESR can send channel to 0");
|
|
|
|
+ canChannel = 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
iv::radar::radarobjectarray x;
|
|
iv::radar::radarobjectarray x;
|
|
x.set_mstime(0);
|
|
x.set_mstime(0);
|
|
int i;
|
|
int i;
|
|
@@ -542,31 +583,6 @@ int main(int argc, char *argv[])
|
|
memset(canData5f2.byte,0,8);
|
|
memset(canData5f2.byte,0,8);
|
|
memset(canData5f4.byte,0,8);
|
|
memset(canData5f4.byte,0,8);
|
|
|
|
|
|
- QString strpath = QCoreApplication::applicationDirPath();
|
|
|
|
- if(argc < 2)
|
|
|
|
- strpath = strpath + "/detection_radar_esr.xml";
|
|
|
|
- else
|
|
|
|
- strpath = argv[1];
|
|
|
|
- std::cout<<strpath.toStdString()<<std::endl;
|
|
|
|
-
|
|
|
|
- iv::xmlparam::Xmlparam xp(strpath.toStdString());
|
|
|
|
-
|
|
|
|
- std::string strmemcan = xp.GetParam("canrecv","canrecv1");
|
|
|
|
- std::string strmemsend = xp.GetParam("cansend","cansend1");
|
|
|
|
- std::string strmemradar = xp.GetParam("radar","radar");
|
|
|
|
- std::string strmodulename = xp.GetParam("modulename","detection_radar_delphi_esr");
|
|
|
|
-#ifdef fujiankuan
|
|
|
|
- gstrmemgpsimu = xp.GetParam("gpsimu_name","hcp2_gpsimu");
|
|
|
|
- gstrmemcancar = xp.GetParam("cancar","can_car");
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- givlog = new iv::Ivlog(strmodulename.data());
|
|
|
|
- givfault = new iv::Ivfault(strmodulename.data());
|
|
|
|
-
|
|
|
|
- givfault->SetFaultState(1,1,"初始化");
|
|
|
|
- givlog->info("Initialized");
|
|
|
|
-
|
|
|
|
gpa = iv::modulecomm::RegisterSend(strmemradar.data(),100000,3);
|
|
gpa = iv::modulecomm::RegisterSend(strmemradar.data(),100000,3);
|
|
gpb = iv::modulecomm::RegisterSend(strmemsend.data(),100000,1);
|
|
gpb = iv::modulecomm::RegisterSend(strmemsend.data(),100000,1);
|
|
void * pa = iv::modulecomm::RegisterRecv(strmemcan.data(),Listencan0);
|
|
void * pa = iv::modulecomm::RegisterRecv(strmemcan.data(),Listencan0);
|
|
@@ -580,13 +596,13 @@ int main(int argc, char *argv[])
|
|
// signal(SIGALRM, signalHandler);
|
|
// signal(SIGALRM, signalHandler);
|
|
// ualarm(2000,2000);
|
|
// ualarm(2000,2000);
|
|
|
|
|
|
- signal(SIGALRM, signalHandler);
|
|
|
|
|
|
+// signal(SIGALRM, signalHandler);
|
|
|
|
|
|
- struct itimerval new_value, old_value;
|
|
|
|
- new_value.it_value.tv_sec = 0;
|
|
|
|
- new_value.it_value.tv_usec = 1;
|
|
|
|
- new_value.it_interval.tv_sec = 0;
|
|
|
|
- new_value.it_interval.tv_usec = 20000;
|
|
|
|
- setitimer(ITIMER_REAL, &new_value, NULL);
|
|
|
|
|
|
+// struct itimerval new_value, old_value;
|
|
|
|
+// new_value.it_value.tv_sec = 0;
|
|
|
|
+// new_value.it_value.tv_usec = 1;
|
|
|
|
+// new_value.it_interval.tv_sec = 0;
|
|
|
|
+// new_value.it_interval.tv_usec = 20000;
|
|
|
|
+// setitimer(ITIMER_REAL, &new_value, NULL);
|
|
return a.exec();
|
|
return a.exec();
|
|
}
|
|
}
|