#include #include #include #include "nvcan.h" #include "canctrl.h" #include #include #include #include #include "ivversion.h" #include "ivexit.h" #include static canctrl * gpcanctrl; void exitfunc() { qDebug("enter exit func."); gpcanctrl->requestInterruption(); QTime xTime; xTime.start(); while(xTime.elapsed()<1000) { if(gpcanctrl->isFinished()) { qDebug("canctrl complete."); delete gpcanctrl; break; } } } void signal_handler(int sig) { if(sig == SIGINT) { exitfunc(); } } #ifdef TEST_PROG void threadtest() { QTimer xTimer; xTimer.setTimerType(Qt::PreciseTimer); void * pa = iv::modulecomm::RegisterSend("cansend0",100000,100); while(true) { iv::can::canmsg xmsg; xmsg.set_channel(0); xmsg.set_mstime(QDateTime::currentMSecsSinceEpoch()); xmsg.set_index(0); int i; for(i=0;i<10;i++) { iv::can::canraw * pcanraw = xmsg.add_rawmsg(); pcanraw->set_bext(false); pcanraw->set_id(11); pcanraw->set_bremote(false); char xdata[8]; xdata[0] = 11; pcanraw->set_data(xdata,8); pcanraw->set_len(8); } int nbytesize = xmsg.ByteSize(); std::shared_ptr str_ptr = std::shared_ptr(new char[nbytesize]); if(xmsg.SerializeToArray(str_ptr.get(),nbytesize)) iv::modulecomm::ModuleSendMsg(pa,str_ptr.get(),nbytesize); // std::this_thread::sleep_for(std::chrono::milliseconds(1)); std::this_thread::sleep_for(std::chrono::microseconds(5000)); } } #endif int main(int argc, char *argv[]) { showversion("driver_can_nvidia_agx"); QCoreApplication a(argc, argv); QString strpath = QCoreApplication::applicationDirPath(); if(argc < 2) strpath = strpath + "/driver_can_socket.xml"; else strpath = argv[1]; std::cout<start(); iv::ivexit::RegIVExitCall(exitfunc); signal(SIGINT,signal_handler); #ifdef TEST_PROG std::thread * pthread = new std::thread(threadtest); #endif // std::thread b(func); return a.exec(); }