Added option '-x' to disable local loopback for sent CAN frames.

pull/7/head
Oliver Hartkopp 2007-06-22 08:33:18 +00:00
parent a121452698
commit 404bf3b1bd
1 changed files with 15 additions and 1 deletions

View File

@ -87,6 +87,8 @@ void print_usage(char *prg)
"send frames immediately)\n");
fprintf(stderr, " -g <ms> (gap in milli "
"seconds - default: %d ms)\n", DEFAULT_GAP);
fprintf(stderr, " -x (disable local "
"loopback of sent CAN frames)\n");
fprintf(stderr, " -v (verbose: print "
"sent CAN frames)\n\n");
fprintf(stderr, "Interface assignment: 0..n assignments like "
@ -219,13 +221,14 @@ int main(int argc, char **argv)
unsigned long gap = DEFAULT_GAP;
int use_timestamps = 1;
static int verbose, opt, delay_loops;
static int loopback_disable = 0;
static int infinite_loops = 0;
static int loops = DEFAULT_LOOPS;
int assignments; /* assignments defined on the commandline */
int txidx; /* sendto() interface index */
int eof, nbytes, i, j;
while ((opt = getopt(argc, argv, "I:l:tg:v")) != -1) {
while ((opt = getopt(argc, argv, "I:l:tg:xv")) != -1) {
switch (opt) {
case 'I':
infile = fopen(optarg, "r");
@ -253,6 +256,10 @@ int main(int argc, char **argv)
gap = strtoul(optarg, NULL, 10);
break;
case 'x':
loopback_disable = 1;
break;
case 'v':
verbose++;
break;
@ -292,6 +299,13 @@ int main(int argc, char **argv)
/* disable unneeded default receive filter on this RAW socket */
setsockopt(s, SOL_CAN_RAW, CAN_RAW_FILTER, NULL, 0);
if (loopback_disable) {
int loopback = 0;
setsockopt(s, SOL_CAN_RAW, CAN_RAW_LOOPBACK,
&loopback, sizeof(loopback));
}
if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("bind");
return 1;