From 404bf3b1bda7cf8b483ecef7f53e3acee7e5cd89 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Fri, 22 Jun 2007 08:33:18 +0000 Subject: [PATCH] Added option '-x' to disable local loopback for sent CAN frames. --- canplayer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/canplayer.c b/canplayer.c index 5e04f77..dc428f6 100644 --- a/canplayer.c +++ b/canplayer.c @@ -87,6 +87,8 @@ void print_usage(char *prg) "send frames immediately)\n"); fprintf(stderr, " -g (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; -- 2.39.2