canbcm.cpp
Go to the documentation of this file.
00001 #include <socketcan_interface/bcm.h>
00002 #include <socketcan_interface/string.h>
00003 
00004 using namespace can;
00005 
00006 #include <iostream>
00007 
00008 int main(int argc, char *argv[]){
00009     BCMsocket bcm;
00010 
00011     int extra_frames = argc - 4; 
00012 
00013     if(extra_frames < 0){
00014         std::cout << "usage: "<< argv[0] << " DEVICE PERIOD HEADER#DATA [DATA*]" << std::endl;
00015         return 1;
00016     }
00017 
00018     if(!bcm.init(argv[1])){
00019         return 2;
00020     }
00021 
00022     int num_frames = extra_frames+1;
00023     Frame *frames = new Frame[num_frames];
00024     Header header = frames[0] = toframe(argv[3]);
00025 
00026     if(extra_frames > 0){
00027         for(int i=0; i< extra_frames; ++i){
00028             frames[1+i] = toframe(tostring(header,true)+"#"+argv[4+i]);
00029         }
00030     }
00031     for(int i = 0; i < num_frames; ++i){
00032         std::cout << frames[i] << std::endl;
00033     }
00034     if(bcm.startTX(boost::chrono::duration<double>(atof(argv[2])), header, num_frames, frames)){
00035         pause();
00036         return 0;
00037     }
00038     return 4;
00039 }


socketcan_interface
Author(s): Mathias Lüdtke
autogenerated on Sun Sep 3 2017 03:10:37