main.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <QCoreApplication>
  2. #include <QObject>
  3. #include <signal.h>
  4. #include "canctrl.h"
  5. #include <unistd.h>
  6. #include <thread>
  7. #include <iostream>
  8. #include <xmlparam.h>
  9. #include "ivversion.h"
  10. //void func()
  11. //{
  12. // int i;
  13. // i = 0;
  14. // while(1)
  15. // {
  16. // std::this_thread::sleep_for(std::chrono::milliseconds(1000));
  17. // i++;
  18. // qDebug("pid is ",getpid());
  19. // if(i == 10)break;
  20. // }
  21. // qDebug("pid is %d ",getpid());
  22. // kill(getpid(),SIGINT);
  23. //}
  24. int main(int argc, char *argv[])
  25. {
  26. showversion("driver_can_vci");
  27. QCoreApplication a(argc, argv);
  28. QString strpath = QCoreApplication::applicationDirPath();
  29. if(argc < 2)
  30. strpath = strpath + "/driver_can_vci.xml";
  31. else
  32. strpath = argv[1];
  33. std::cout<<strpath.toStdString()<<std::endl;
  34. iv::xmlparam::Xmlparam xp(strpath.toStdString());
  35. std::string strmemsend0 = xp.GetParam("cansend0_vci","cansend0");//31510000E80
  36. std::string strmemsend1 = xp.GetParam("cansend1_vci","cansend1");
  37. std::string strmemrecv0 = xp.GetParam("canrecv0_vci","canrecv0");
  38. std::string strmemrecv1 = xp.GetParam("canrecv1_vci","canrecv1");
  39. std::string strmemdevnum = xp.GetParam("devnum","0");
  40. std::string strmembaud0 = xp.GetParam("baud0","500k");
  41. std::string strmembaud1 = xp.GetParam("baud0","500k");
  42. canctrl * pcanctrl = new canctrl(strmemsend0.data(),strmemsend1.data(),strmemrecv0.data(),strmemrecv1.data(),strmemdevnum.data(),
  43. strmembaud0.data(),strmembaud1.data());
  44. pcanctrl->start();
  45. // std::thread b(func);
  46. return a.exec();
  47. }