|
@@ -3,23 +3,87 @@
|
|
|
#include <iostream>
|
|
|
#include <QDateTime>
|
|
|
#include <math.h>
|
|
|
+#include <QTimer>
|
|
|
+#include <sys/time.h>
|
|
|
+#include <signal.h>
|
|
|
+#include <QThread>
|
|
|
|
|
|
#include "modulecomm.h"
|
|
|
#include "xmlparam.h"
|
|
|
+#include "ivlog.h"
|
|
|
+#include "ivfault.h"
|
|
|
|
|
|
#include "canmsg.pb.h"
|
|
|
#include "radarobjectarray.pb.h"
|
|
|
+#include "gpsimu.pb.h"
|
|
|
+
|
|
|
+/*Vcan send data*/
|
|
|
+std::string gstrmemgpsimu;
|
|
|
+std::string gstrmemcancar;
|
|
|
+double g_gyro_z; //
|
|
|
+double g_v; //
|
|
|
|
|
|
iv::radar::radarobjectarray gobj;
|
|
|
+iv::Ivlog *givlog;
|
|
|
|
|
|
iv::radar::radarobjectarray gobjright;
|
|
|
int gntemp = 0;
|
|
|
int gntmpright=0;
|
|
|
|
|
|
-void * gpa , * gpb,*gpc;
|
|
|
+void * gpa , * gpb, *gpc, *gpcanSend;
|
|
|
|
|
|
QTime gTime;
|
|
|
|
|
|
+/*vcan send begin*/
|
|
|
+int gnIndex = 0;
|
|
|
+
|
|
|
+void ExecSend(uint16_t id, unsigned char _data[8])
|
|
|
+{
|
|
|
+ iv::can::canmsg xmsg;
|
|
|
+ iv::can::canraw xraw;
|
|
|
+
|
|
|
+ unsigned char canbyte[8];
|
|
|
+
|
|
|
+ memcpy(canbyte,_data,sizeof(_data));
|
|
|
+
|
|
|
+ xraw.set_id(id);
|
|
|
+ xraw.set_data(canbyte,8);
|
|
|
+ xraw.set_bext(false);
|
|
|
+ xraw.set_bremote(false);
|
|
|
+ xraw.set_len(8);
|
|
|
+ iv::can::canraw * pxraw = xmsg.add_rawmsg();
|
|
|
+ pxraw->CopyFrom(xraw);
|
|
|
+ xmsg.set_channel(0);
|
|
|
+ xmsg.set_index(gnIndex);
|
|
|
+ gnIndex++;
|
|
|
+ xmsg.set_mstime(QDateTime::currentMSecsSinceEpoch());
|
|
|
+ int ndatasize = xmsg.ByteSize();
|
|
|
+ char * strser = new char[ndatasize];
|
|
|
+ std::shared_ptr<char> pstrser;
|
|
|
+ pstrser.reset(strser);
|
|
|
+ if(xmsg.SerializePartialToArray(strser,ndatasize))
|
|
|
+ {
|
|
|
+ iv::modulecomm::ModuleSendMsg(gpcanSend,strser,ndatasize);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ std::cout<<"MainWindow::onTimer serialize error."<<std::endl;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void Listengpsimu(const char * strdata,const unsigned int nSize,const unsigned int index,const QDateTime * dt,const char * strmemname)
|
|
|
+{
|
|
|
+ if(nSize<1)return;
|
|
|
+ iv::gps::gpsimu xgpsimu;
|
|
|
+ if(false == xgpsimu.ParseFromArray(strdata,nSize))
|
|
|
+ {
|
|
|
+ givlog->warn("detection_radar_delphi_esr_send--Listengpsimu parse errror. nSize is %d",nSize);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ g_gyro_z = xgpsimu.gyro_z();
|
|
|
+ g_v = sqrt(pow(xgpsimu.vn(),2) + pow(xgpsimu.ve(),2));
|
|
|
+}
|
|
|
+/*vcan end*/
|
|
|
void ShareResult()
|
|
|
{
|
|
|
char * str = new char[gobj.ByteSize()];
|
|
@@ -232,6 +296,37 @@ void Listencan0(const char * strdata,const unsigned int nSize,const unsigned int
|
|
|
// qDebug("latence = %ld ",xt-pic.time());
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+void signalHandler(int sig)
|
|
|
+{
|
|
|
+ unsigned char dataYaw[8] = {0,0,0,0,0,0,0,0};
|
|
|
+ unsigned char dataSpeed[8] = {0,0,0,0,0,0,0,0};
|
|
|
+ uint16_t id;
|
|
|
+ int32_t value = 0;
|
|
|
+ id = 0x278;
|
|
|
+ value = int32_t(g_gyro_z * 100);
|
|
|
+ dataYaw[5] = value & 0xFF;
|
|
|
+ dataYaw[4] = (value >> 8) & 0x3F;
|
|
|
+ dataYaw[6] = 0x00;//0x80
|
|
|
+ ExecSend(id, dataYaw);
|
|
|
+ QThread::msleep(2);
|
|
|
+ id = 0x218;
|
|
|
+ value = int32_t(g_v * 20);
|
|
|
+ dataYaw[5] = value & 0xFF;
|
|
|
+ dataSpeed[4] = ((value >> 8) & 0x0F) | 0x00;//0x30
|
|
|
+ QThread::msleep(2);
|
|
|
+ ExecSend(id,dataSpeed);
|
|
|
+// id = 0x180;
|
|
|
+// unsigned char a[8] = {0,0,0,0,0,0,0,0};
|
|
|
+// QThread::msleep(2);
|
|
|
+// ExecSend(id,a);
|
|
|
+ id = 0x270;
|
|
|
+// unsigned char b[8] = {0,0,0,0x80,0x15,0xFF,0,0x2};
|
|
|
+ unsigned char b[8] = {0,0,0,0,0x05,0,0,0};
|
|
|
+ QThread::msleep(2);
|
|
|
+ ExecSend(id,b);
|
|
|
+}
|
|
|
+
|
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
|
QCoreApplication a(argc, argv);
|
|
@@ -271,17 +366,38 @@ int main(int argc, char *argv[])
|
|
|
iv::xmlparam::Xmlparam xp(strpath.toStdString());
|
|
|
|
|
|
std::string strmemcan = xp.GetParam("canrecv","canrecv0");
|
|
|
+ std::string strmemsend = xp.GetParam("cansend","cansend0");
|
|
|
|
|
|
std::string strmemradarleft = xp.GetParam("radarleft","corner_radar_left");
|
|
|
std::string strmemradaright = xp.GetParam("radaright","corner_radar_right");
|
|
|
+ gstrmemgpsimu = xp.GetParam("gpsimu_name","hcp2_gpsimu");
|
|
|
|
|
|
gpa = iv::modulecomm::RegisterSend(strmemradarleft.data(),100000,3);
|
|
|
gpb = iv::modulecomm::RegisterSend(strmemradaright.data(),100000,3);
|
|
|
+ gpcanSend = iv::modulecomm::RegisterSend(strmemsend.data(),100000,3);
|
|
|
|
|
|
void * pa = iv::modulecomm::RegisterRecv(strmemcan.data(),Listencan0);
|
|
|
+ void * pb = iv::modulecomm::RegisterRecv(gstrmemgpsimu.data(),Listengpsimu);
|
|
|
+
|
|
|
+ givlog = new iv::Ivlog("detection_radar_delphi_srr");
|
|
|
|
|
|
+// QWidget *mwidget = new QWidget(nullptr);
|
|
|
|
|
|
+// QTimer * timer = new QTimer(); //car数据发送定时器,每隔30ms发送一次
|
|
|
+// mwidget->connect(timer,SIGNAL(timeout()),mwidget,SLOT(onTimer()));
|
|
|
+// timer->setTimerType(Qt::PreciseTimer);
|
|
|
+// timer->start(100);
|
|
|
|
|
|
+ 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 = 100000;
|
|
|
+ setitimer(ITIMER_REAL, &new_value, NULL);
|
|
|
|
|
|
return a.exec();
|
|
|
}
|
|
|
+
|
|
|
+
|