Hello, with appended patch, I could run e.g ./cangen can0 -g 1 -e -I 0x06042008 -L 0 -n 20
to send 20 frames. Bye -- Uwe Bonnes [email protected] Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 162516 -------- Fax. 06151 164321 ---------- Index: cangen.c =================================================================== --- cangen.c (Revision 1215) +++ cangen.c (Arbeitskopie) @@ -95,6 +95,8 @@ " generation mode - see below)\n"); fprintf(stderr, " -p <timeout> (poll on -ENOBUFS to write frames" " with <timeout> ms)\n"); + fprintf(stderr, " -n <count> (write count frames )" + "- default: infinite\n"); fprintf(stderr, " -i (ignore -ENOBUFS return values on" " write() syscalls)\n"); fprintf(stderr, " -x (disable local loopback of " @@ -149,6 +151,7 @@ static struct can_frame frame; int nbytes; int i; + int runs = 0, count = 0; struct ifreq ifr; struct timespec ts; @@ -157,7 +160,7 @@ signal(SIGHUP, sigterm); signal(SIGINT, sigterm); - while ((opt = getopt(argc, argv, "ig:eI:L:D:xp:vh?")) != -1) { + while ((opt = getopt(argc, argv, "ig:eI:L:D:xp:vn:h?")) != -1) { switch (opt) { case 'i': @@ -220,6 +223,10 @@ polltimeout = strtoul(optarg, NULL, 10); break; + case 'n': + count = strtoul(optarg, NULL, 10); + break; + case '?': case 'h': default: @@ -398,6 +405,9 @@ for (i=0; i<8 ;i++) frame.data[i] = (incdata >> i*8) & 0xFFULL; } + runs++; + if (count && (runs >= count)) + running = 0; } if (enobufs_count) _______________________________________________ Socketcan-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/socketcan-users
