| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #include <QCoreApplication>
- #include <QObject>
- #include <signal.h>
- #include "canctrl.h"
- #include <QDebug>
- #include <unistd.h>
- #include <thread>
- #include <iostream>
- #include <xmlparam.h>
- #include "ivversion.h"
- iv::Ivfault *gfault = nullptr;
- iv::Ivlog *givlog = nullptr;
- //void func()
- //{
- // int i;
- // i = 0;
- // while(1)
- // {
- // std::this_thread::sleep_for(std::chrono::milliseconds(1000));
- // i++;
- // qDebug("pid is ",getpid());
- // if(i == 10)break;
- // }
- // qDebug("pid is %d ",getpid());
- // kill(getpid(),SIGINT);
- //}
- int main(int argc, char *argv[])
- {
- showversion("driver_can_kvaser");
- QCoreApplication a(argc, argv);
- gfault = new iv::Ivfault("kvaser_can");
- givlog = new iv::Ivlog("kvaser_can");
- QString strpath = QCoreApplication::applicationDirPath();
- if(argc < 2){
- givlog->info("read param form driver_can_vci.xml");
- strpath = strpath + "/driver_can_kvaser.xml";
- }
- else{
- strpath = argv[1];
- givlog->info("set param by default value");
- }
- std::cout<<strpath.toStdString()<<std::endl;
- iv::xmlparam::Xmlparam xp(strpath.toStdString());
- std::string strmemsend0 = xp.GetParam("cansend0_kvaser","cansend0");
- std::string strmemsend1 = xp.GetParam("cansend1_kvaser","cansend1");
- std::string strmemrecv0 = xp.GetParam("canrecv0_kvaser","canrecv0");
- std::string strmemrecv1 = xp.GetParam("canrecv1_kvaser","canrecv1");
- std::string strmemsend_canstate = xp.GetParam("canstate","canstate");
- std::string strmemdevnum = xp.GetParam("devnum","0");
- std::string strmembaud0 = xp.GetParam("baud0","500k");
- std::string strmembaud1 = xp.GetParam("baud0","500k");
- canctrl * pcanctrl = new canctrl(strmemsend0.data(),strmemsend1.data(),strmemrecv0.data(),strmemrecv1.data(),
- strmemsend_canstate.data(),strmemdevnum.data(),strmembaud0.data(),strmembaud1.data());
- pcanctrl->start();
- // std::thread b(func);
- return a.exec();
- }
|