-/**************************************************************************/
-/* CAN latency tester */
-/* Copyright (C) 2010 Michal Sojka, DCE FEE CTU Prague */
-/* License: GPLv2 */
-/**************************************************************************/
+/*******************************************************************************/
+/* CAN latency tester */
+/* Copyright (C) 2010, 2011, 2012, 2013, 2014 Michal Sojka, DCE FEE CTU Prague */
+/* License: GPLv2 */
+/*******************************************************************************/
struct timespec ts_rx_onwire, ts_rx_onwire_kern;
struct timespec ts_rx_final, ts_rx_final_kern;
struct can_frame sent, received;
struct timespec ts_rx_onwire, ts_rx_onwire_kern;
struct timespec ts_rx_final, ts_rx_final_kern;
struct can_frame sent, received;
sprint_canframe(sent, &mi->sent, true);
sprint_canframe(received, &mi->received, true);
sprint_canframe(sent, &mi->sent, true);
sprint_canframe(received, &mi->received, true);
num, S(mi->ts_sent), sent, S(mi->ts_rx_final_kern), S(mi->ts_rx_final), received,
num, S(mi->ts_sent), sent, S(mi->ts_rx_final_kern), S(mi->ts_rx_final), received,
- DIFF(mi->ts_sent, mi->ts_rx_final_kern),
- DIFF(mi->ts_sent, mi->ts_rx_final));
+ DIFF(mi->ts_sent, mi->ts_rx_final_kern),
+ DIFF(mi->ts_sent, mi->ts_rx_final),
+ mi->tx_time_us);
num, S(mi->ts_sent), sent,
S(mi->ts_rx_onwire_kern), S(mi->ts_rx_onwire),
S(mi->ts_rx_final_kern), S(mi->ts_rx_final), received,
DIFF(mi->ts_sent, mi->ts_rx_onwire_kern),
DIFF(mi->ts_sent, mi->ts_rx_onwire),
DIFF(mi->ts_rx_onwire_kern, mi->ts_rx_final_kern),
num, S(mi->ts_sent), sent,
S(mi->ts_rx_onwire_kern), S(mi->ts_rx_onwire),
S(mi->ts_rx_final_kern), S(mi->ts_rx_final), received,
DIFF(mi->ts_sent, mi->ts_rx_onwire_kern),
DIFF(mi->ts_sent, mi->ts_rx_onwire),
DIFF(mi->ts_rx_onwire_kern, mi->ts_rx_final_kern),
opt.f_hist = fopen(f, "w");
if (!opt.f_hist)
error(1, errno, "fopen: %s", f);
}
opt.f_hist = fopen(f, "w");
if (!opt.f_hist)
error(1, errno, "fopen: %s", f);
}
if (opt.name) {
char *f = talloc_asprintf(local, "%s-stat.txt", opt.name);
opt.f_stat = fopen(f, "w");
if (opt.name) {
char *f = talloc_asprintf(local, "%s-stat.txt", opt.name);
opt.f_stat = fopen(f, "w");
close(completion_pipe[0]);
close(completion_pipe[1]);
histogram_fprint(&histogram, opt.f_hist);
close(completion_pipe[0]);
close(completion_pipe[1]);
histogram_fprint(&histogram, opt.f_hist);
- fclose(opt.f_hist);
- fclose(opt.f_msgs);
-
-
- fprintf(opt.f_stat, "cmdline='");
- for (i=0; i<argc; i++)
- fprintf(opt.f_stat, "%s%s", argv[i], i < argc-1 ? " " : "");
- fprintf(opt.f_stat, "'\n");
-
- timespec_subtract(&diff, &stats.tac, &stats.tic);
- fprintf(opt.f_stat, "duration=%s # seconds\n", tstamp_str(NULL, &diff));
+ histogram_fprint(&histogram_gw, opt.f_hist_gw);
+ if (opt.f_hist)
+ fclose(opt.f_hist);
+ if (opt.f_hist_gw)
+ fclose(opt.f_hist_gw);
+ if (opt.f_msgs)
+ fclose(opt.f_msgs);
+
+ if (opt.f_stat) {
+ fprintf(opt.f_stat, "cmdline='");
+ for (i=0; i<argc; i++)
+ fprintf(opt.f_stat, "%s%s", argv[i], i < argc-1 ? " " : "");
+ fprintf(opt.f_stat, "'\n");
+
+ timespec_subtract(&diff, &stats.tac, &stats.tic);
+ fprintf(opt.f_stat, "duration=%s # seconds\n", tstamp_str(NULL, &diff));
- fprintf(opt.f_stat, "sent=%d\n", count);
- fprintf(opt.f_stat, "overrun=%d\n", stats.overrun);
- if (stats.overrun && !opt.quiet)
- printf("overrun=%d\n", stats.overrun);
- fprintf(opt.f_stat, "enobufs=%d\n", stats.enobufs);
- if (stats.enobufs && !opt.quiet)
- printf("enobufs=%d\n", stats.enobufs);
- fprintf(opt.f_stat, "lost=%d\n", stats.lost);
- if (stats.lost && !opt.quiet)
- printf("lost=%d\n", stats.lost);
- 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);
+ fprintf(opt.f_stat, "sent=%d\n", count);
+ fprintf(opt.f_stat, "overrun=%d\n", stats.overrun);
+ if (stats.overrun && !opt.quiet)
+ printf("overrun=%d\n", stats.overrun);
+ fprintf(opt.f_stat, "enobufs=%d\n", stats.enobufs);
+ if (stats.enobufs && !opt.quiet)
+ printf("enobufs=%d\n", stats.enobufs);
+ fprintf(opt.f_stat, "lost=%d\n", stats.lost);
+ if (stats.lost && !opt.quiet)
+ printf("lost=%d\n", stats.lost);
+ 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);
+ }