From: Oliver Hartkopp Date: Thu, 10 Jul 2008 10:59:37 +0000 (+0000) Subject: Added -f option to filter only on the CAN-ID and not on the content. X-Git-Tag: 0.1~177 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f33075946d9eddd6b4f329c4aaaab078821d96bf;p=profile%2Fivi%2Fcan-utils.git Added -f option to filter only on the CAN-ID and not on the content. This can be useful when the timestamp cyle needs to be displayed. --- diff --git a/cansniffer.c b/cansniffer.c index c2b5930..bedaf5c 100644 --- a/cansniffer.c +++ b/cansniffer.c @@ -118,13 +118,14 @@ extern int optind, opterr, optopt; static int running = 1; static int clearscreen = 1; -static int notch = 0; +static int notch; +static int filter_id_only; static long timeout = TIMEOUT; static long hold = HOLD; static long loop = LOOP; -static unsigned char binary = 0; -static unsigned char binary_gap = 0; -static unsigned char color = 0; +static unsigned char binary; +static unsigned char binary_gap; +static unsigned char color; void rx_setup (int fd, int id); void rx_delete (int fd, int id); @@ -195,7 +196,6 @@ int main(int argc, char **argv) long currcms = 0; long lastcms = 0; unsigned char quiet = 0; - int opt, ret; struct timeval timeo, start_tv, tv; struct sockaddr_can addr; @@ -210,7 +210,7 @@ int main(int argc, char **argv) for (i=0; i < 2048 ;i++) /* default: check all CAN-IDs */ do_set(i, ENABLE); - while ((opt = getopt(argc, argv, "m:v:r:t:h:l:qbBc")) != -1) { + while ((opt = getopt(argc, argv, "m:v:r:t:h:l:qbBcf")) != -1) { switch (opt) { case 'm': sscanf(optarg, "%x", &mask); @@ -254,6 +254,10 @@ int main(int argc, char **argv) color = 1; break; + case 'f': + filter_id_only = 1; + break; + case '?': break; @@ -371,6 +375,9 @@ void rx_setup (int fd, int id){ txmsg.msg_head.nframes = 1; U64_DATA(&txmsg.frame) = (__u64) 0xFFFFFFFFFFFFFFFFULL; + if (filter_id_only) + txmsg.msg_head.flags |= RX_FILTER_ID; + if (write(fd, &txmsg, sizeof(txmsg)) < 0) perror("write"); };