canbcm.cpp
Go to the documentation of this file.
3 
4 using namespace can;
5 
6 #include <iostream>
7 
8 int main(int argc, char *argv[]){
9  BCMsocket bcm;
10 
11  int extra_frames = argc - 4;
12 
13  if(extra_frames < 0){
14  std::cout << "usage: "<< argv[0] << " DEVICE PERIOD HEADER#DATA [DATA*]" << std::endl;
15  return 1;
16  }
17 
18  if(!bcm.init(argv[1])){
19  return 2;
20  }
21 
22  int num_frames = extra_frames+1;
23  Frame *frames = new Frame[num_frames];
24  Header header = frames[0] = toframe(argv[3]);
25 
26  if(extra_frames > 0){
27  for(int i=0; i< extra_frames; ++i){
28  frames[1+i] = toframe(tostring(header,true)+"#"+argv[4+i]);
29  }
30  }
31  for(int i = 0; i < num_frames; ++i){
32  std::cout << frames[i] << std::endl;
33  }
34  if(bcm.startTX(boost::chrono::duration<double>(atof(argv[2])), header, num_frames, frames)){
35  pause();
36  return 0;
37  }
38  return 4;
39 }
std::string tostring(const Header &h, bool lc)
Definition: string.cpp:78
Definition: asio_base.h:11
Frame toframe(const std::string &s)
Definition: string.cpp:119
int main(int argc, char *argv[])
Definition: canbcm.cpp:8
bool init(const std::string &device)
Definition: bcm.h:56
bool startTX(DurationType period, Header header, size_t num, Frame *frames)
Definition: bcm.h:81


socketcan_interface
Author(s): Mathias Lüdtke
autogenerated on Mon Feb 28 2022 23:28:00