]> 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 23bdf9883fcf3b6dea9b5666f5caa745e91e9ca4..4859ebe038046f5d44ebd96c9b5a18b0c208d9f9 100644 (file)
@@ -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);