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;
+/* Functions and types for CRC checks.
+ *
+ * Generated on Wed Sep 21 22:30:11 2011,
+ * by pycrc v0.7.8, http://www.tty1.net/pycrc/
+ * using the configuration:
+ * Width = 15
+ * Poly = 0x4599
+ * XorIn = 0x0000
+ * ReflectIn = False
+ * XorOut = 0x0000
+ * ReflectOut = False
+ * Algorithm = table-driven
+ *****************************************************************************/
+typedef uint16_t crc_t;
+
+static const crc_t crc_table[2] = {
+ 0x0000, 0x4599
+};
+
+crc_t crc_update(crc_t crc, uint32_t data, size_t bit_len)
+{
+ unsigned int tbl_idx;
+/* crc_t bc = crc; */
+/* uint32_t bd = data; */
+/* size_t bl = bit_len; */
+
+ while (bit_len--) {
+ tbl_idx = (crc >> 14) ^ (data >> 31);
+ crc = crc_table[tbl_idx & 0x01] ^ (crc << 1);
+ data <<= 1;
+ }
+ crc = crc & 0x7fff;
+/* printf("crc: 0x%04x -> 0x%04x data: 0x%08x len: %d\n", */
+/* bc, crc, bd, bl); */
+ return crc;
+}
+
- (frame->can_id >> 18) << 25 |
- 3 << 23 |
- (frame->can_id & 0x3ffff) << 7 |
- (!!(frame->can_id & CAN_RTR_FLAG)) << 6 |
- 0 << 4 |
+ ((frame->can_id & CAN_EFF_MASK) >> 18) << 25 |
+ 3 << 23 |
+ ((frame->can_id & CAN_EFF_MASK) & 0x3ffff) << 7 |
+ (!!(frame->can_id & CAN_RTR_FLAG)) << 6 |
+ 0 << 4 |
+ crc = crc_update(crc, bitmap[0] << start, 32-start);
+ crc = crc_update(crc, bitmap[1], 32);
+ crc = crc_update(crc, bitmap[2], end - 64 > 32 ? 32 : end - 64);
+ crc = crc_update(crc, bitmap[3], end > 96 ? end - 96 : 0);
+ crcx = (uint32_t)htons(crc) << 17;
+ if (frame->can_dlc < 4)
+ bitmap[2] |= crcx >> (frame->can_dlc*8);
+ if (frame->can_dlc = 3)
+ bitmap[3] |= crcx << 8;
+ if (frame->can_dlc >= 4)
+ bitmap[3] |= crcx >> (frame->can_dlc*8);
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,
DIFF(mi->ts_sent, mi->ts_rx_final_kern),
DIFF(mi->ts_sent, mi->ts_rx_final),
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_onwire),
DIFF(mi->ts_rx_onwire_kern, mi->ts_rx_final_kern),
DIFF(mi->ts_rx_onwire, mi->ts_rx_final),
DIFF(mi->ts_sent, mi->ts_rx_onwire),
DIFF(mi->ts_rx_onwire_kern, mi->ts_rx_final_kern),
DIFF(mi->ts_rx_onwire, mi->ts_rx_final),
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);
+ }