X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/b55ca3688e84d51f68d5d0270f962b041b96f065..3ea7fae8477eb1f8a65e07a2e5f8c139110a2a81:/latester/latester.c diff --git a/latester/latester.c b/latester/latester.c index e4185b2..61b2b43 100644 --- a/latester/latester.c +++ b/latester/latester.c @@ -83,6 +83,7 @@ struct { unsigned lost; struct timespec tic, tac; unsigned timeouts; + unsigned invalid_frame; } stats; int num_interfaces = 0; @@ -339,11 +340,16 @@ static inline void trace_off(int ret) write(trace_fd, "0", 1); } -void msg_info_free(struct msg_info *mi) +static inline void msg_info_free(struct msg_info *mi) { mi->id = -1; } +static inline bool msg_info_used(struct msg_info *mi) +{ + return mi->id != -1; +} + int send_frame(int socket) { struct can_frame frame; @@ -355,7 +361,7 @@ int send_frame(int socket) MEMSET_ZERO(frame); i = curr_msg+1; - while (msg_infos[i].id != -1 && i != curr_msg) { + while (msg_info_used(&msg_infos[i]) && i != curr_msg) { i++; if (i >= MAX_INFOS) i = 0; @@ -484,8 +490,11 @@ void process_on_wire_rx(int s) struct msg_info *mi; receive(s, &frame, &ts_kern, &ts_user); mi = frame2info(&frame); - mi->ts_rx_onwire_kern = ts_kern; - mi->ts_rx_onwire = ts_user; + if (msg_info_used(mi)) { + mi->ts_rx_onwire_kern = ts_kern; + mi->ts_rx_onwire = ts_user; + } else + stats.invalid_frame++; } @@ -818,6 +827,9 @@ int main(int argc, const char *argv[]) fprintf(opt.f_stat, "timeouts=%d\n", stats.timeouts); if (stats.timeouts && !opt.quiet) printf("timeouts=%d\n", stats.timeouts); + fprintf(opt.f_stat, "invalid_frame=%d\n", stats.timeouts); + if (stats.timeouts && !opt.quiet) + printf("invalid_frame=%d\n", stats.timeouts); fclose(opt.f_stat);