9 #include "../include/can.h"
12 unsigned long canmsg_id = 5;
16 char *can_dev_name = "/dev/can0";
18 #define PRT_PREFIX_SIZE 40
19 char prt_prefix[PRT_PREFIX_SIZE];
21 char *prt_prefix_in = "CAN %s : ";
27 printf("usage: sendburst\n");
28 printf(" -d, --device <name> name of CAN device [/dev/can0]\n");
29 printf(" -i, --id <num> ID of generated messages\n");
30 printf(" -f, --flags <num> CAN filter flags\n");
31 printf(" -w, --wait <num> number of seconds to wait between messages\n");
32 printf(" -p, --prefix <str> string prefix for output\n");
33 printf(" -V, --version show version\n");
34 printf(" -h, --help this usage screen\n");
37 int main(int argc, char *argv[])
39 static struct option long_opts[] = {
40 { "uldev", 1, 0, 'd' },
42 { "flags", 1, 0, 'f' },
43 { "wait", 1, 0, 'w' },
44 { "prefix",1, 0, 'p' },
45 { "version",0,0, 'V' },
46 { "help", 0, 0, 'h' },
51 struct canmsg_t sendmsg={0,0,5,0,8,{1,2,3,4,5,6,7,8}};
54 while ((opt = getopt_long(argc, argv, "d:i:f:w:p:Vh",
55 &long_opts[0], NULL)) != EOF) switch (opt) {
60 canmsg_id = strtol(optarg,NULL,0);
63 canmsg_flags = strtol(optarg,NULL,0);
66 can_wait_sec = strtol(optarg,NULL,0);
69 prt_prefix_in = optarg;
72 fputs("LinCAN utilities v0.2\n", stdout);
77 exit(opt == 'h' ? 0 : 1);
80 if ((fd=open(can_dev_name, O_RDWR)) < 0) {
82 printf("Error opening %s\n", can_dev_name);
86 snprintf(prt_prefix, PRT_PREFIX_SIZE, prt_prefix_in, can_dev_name);
91 sendmsg.flags=canmsg_flags;
95 if ((ret=write(fd,&sendmsg,sizeof(struct canmsg_t))) < 0) {
97 printf("%sError sending message\n", prt_prefix);
101 printf("%sSent block of 10 messages #: %u\n", prt_prefix, j);
103 usleep(1000000*can_wait_sec);