]> rtime.felk.cvut.cz Git - canping.git/blobdiff - src/vca_canping.c
Portability enhancements.
[canping.git] / src / vca_canping.c
index b29f465270efa2207d897623f50f7c221f26f929..348d641e4163862ae57a7866d5477801358c419d 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      */
@@ -28,6 +28,7 @@
 #include <signal.h>
 #include <sys/types.h>
 #include <sys/time.h>
+#include <sys/select.h>
 #include <ul_list.h>
 #include <errno.h>
 #include <semaphore.h>
@@ -88,7 +89,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 +249,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 +468,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);