]> rtime.felk.cvut.cz Git - canping.git/blobdiff - src/vca_canping.c
Unify selection of CAN interface to open if no option is provided.
[canping.git] / src / vca_canping.c
index b29f465270efa2207d897623f50f7c221f26f929..4859ebe038046f5d44ebd96c9b5a18b0c208d9f9 100644 (file)
@@ -2,7 +2,7 @@
 /* File: vca_canping.c - utility to test CAN functionality and throughput */
 /*                                                                        */
 /* LibVCA - Versatile CAN/CANopen API library                             */
-/* Copyright (C) 2005-2006 Michal Sojka, DCE FEE CTU Prague               */
+/* Copyright (C) 2005-2009 Michal Sojka, DCE FEE CTU Prague               */
 /* Copyright (C) 2006-2009 Pavel Pisa <pisa@cmp.felk.cvut.cz>             */
 /*                                                                        */
 /* LibVCA is free software; you can redistribute it and/or modify it      */
@@ -88,7 +88,7 @@ sem_t ready_sem;              /* Thread is ready for execution */
 
 
 /* Command line options */
-char *option_device = "/dev/can0";
+char *option_device = VCA_DEV_NAME;
 int option_masters = 0;
 long int option_first_id = 1000;
 int option_slaves = 0;
@@ -248,8 +248,9 @@ void *master_thread(void *arg)
        struct canfilt_t canfilt; /* filter for received messages */
 
        if (!option_open_once) {
-               /* Open can driver */
-               if(vca_open_handle(&vcah, option_device, NULL, 0) < 0) {
+               /* Open the CAN driver and disable (D) reception of
+                * all messages until we setup a filter below. */
+               if(vca_open_handle(&vcah, option_device, "D", 0) < 0) {
                        perror("open");
                        fprintf(stderr, "Error opening %s (for id %d)\n", option_device, ping_id);
                        exit(EXIT_CANNOT_OPEN); 
@@ -466,8 +467,9 @@ void *slave_thread(void *arg)
        struct canfilt_t canfilt; /* filter for received messages */
 
        if (!option_open_once) {
-               /* Open the CAN driver */
-               if(vca_open_handle(&vcah, option_device, NULL, 0) < 0) {
+               /* Open the CAN driver and disable (D) reception of
+                * all messages until we setup a filter below. */
+               if(vca_open_handle(&vcah, option_device, "D", 0) < 0) {
                        perror("open");
                        printf("Error opening %s (for id %d)\n", option_device, ping_id);
                        exit(EXIT_CANNOT_OPEN);