]> rtime.felk.cvut.cz Git - can-utils.git/commitdiff
Added option '-x' to disable local loopback for sent CAN frames.
authorOliver Hartkopp <socketcan@hartkopp.net>
Fri, 22 Jun 2007 08:33:18 +0000 (08:33 +0000)
committerOliver Hartkopp <socketcan@hartkopp.net>
Fri, 22 Jun 2007 08:33:18 +0000 (08:33 +0000)
canplayer.c

index 5e04f775f1ad17a811e3baca1d060da3ea5fdf3c..dc428f6a5f2b50d76749a86a68305586beeef215 100644 (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;