#include <stdlib.h>
#include <stdio.h>
#include <time.h>
+#include <stdbool.h>
#define CHECK(cmd) do { if ((cmd) == -1) { perror(#cmd); exit(1); } } while (0)
char *dev = "vcan0";
int count = 10000;
enum { READ, RECVMMSG } recv_method = READ;
+bool quiet = false;
/* Subtract the `struct timespec' values X and Y,
storing the result in RESULT (result = x - y).
memset(&cf, 0, sizeof(cf));
cf.can_dlc = 8;
- fprintf(stderr, "Sending %d frames\n", count);
+ if (!quiet) fprintf(stderr, "Sending %d frames\n", count);
for (i = 0; i < count; i++) {
ret = write(ss, &cf, sizeof(cf));
if (ret != sizeof(cf)) {
switch (recv_method) {
case READ: {
- fprintf(stderr, "Receiving %d frames with read()\n", count);
+ if (!quiet) fprintf(stderr, "Receiving %d frames with read()\n", count);
clock_gettime(CLOCK_MONOTONIC, &t1);
for (i = 0; i < count; i++) {
//fprintf(stderr, "Receiving frame %d\r", i);
break;
}
case RECVMMSG: {
- fprintf(stderr, "Receiving %d frames with recvmmsg()\n", count);
+ if (!quiet) fprintf(stderr, "Receiving %d frames with recvmmsg()\n", count);
struct mmsghdr msgs[count];
struct iovec iovecs[count];
char bufs[count][sizeof(struct can_frame)];
{
int opt;
- while ((opt = getopt(argc, argv, "c:mr")) != -1) {
+ while ((opt = getopt(argc, argv, "c:mrq")) != -1) {
switch (opt) {
case 'c':
count = atoi(optarg);
case 'r':
recv_method = READ;
break;
+ case 'q':
+ quiet = true;
+ break;
default: /* '?' */
fprintf(stderr, "Usage: %s [-c <count>] [-r] [-m] [interface]\n",
argv[0]);