X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/blobdiff_plain/85663f7d1d874b065a93fc451bacd43bca9fa73c..d2073a52c1ba52749c1c9522c42ccbfc83b70b1d:/latester/latester.c diff --git a/latester/latester.c b/latester/latester.c index a5a7c47..b0937ba 100644 --- a/latester/latester.c +++ b/latester/latester.c @@ -1,6 +1,6 @@ /**************************************************************************/ /* CAN latency tester */ -/* Copyright (C) 2010, 2011, 2012 Michal Sojka, DCE FEE CTU Prague */ +/* Copyright (C) 2010, 2011, 2012, 2013 Michal Sojka, DCE FEE CTU Prague */ /* License: GPLv2 */ /**************************************************************************/ @@ -204,7 +204,7 @@ uint32_t calc_bitmap_crc(uint32_t *bitmap, unsigned start, unsigned end) 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); - return (uint32_t)htons(crc) << 17; + return (uint32_t)htons(crc << 17); } void write_crc_to_bitmap(uint32_t crc, uint32_t *bitmap, struct can_frame *frame) @@ -237,6 +237,11 @@ unsigned calc_stuff_bits(struct can_frame *frame) { /* printf("Frame: %s\n", received); */ if (frame->can_id & CAN_EFF_FLAG) { + // bit 31 0 + // [0] |...........................sBBBB| s = SOF, B = Base ID (11 bits) + // [1] |BBBBBBBSIEEEEEEEEEEEEEEEEEER10DLC4| S = SRR, I = IDE, E = Extended ID (18 bits), DLC4 = DLC + // [2] |00000000111111112222222233333333| Data bytes, MSB first + // [3] |44444444555555556666666677777777| bitmap[0] = ((frame->can_id & CAN_EFF_MASK) >> 25); bitmap[1] = @@ -251,6 +256,10 @@ unsigned calc_stuff_bits(struct can_frame *frame) { start = 27; end = 64 + 8*frame->can_dlc; } else { + // bit 31 0 + // [0] |.............sIIIIIIIIIIIRE0DLC4| s = SOF, I = ID (11 bits), R = RTR, E = IDE, DLC4 = DLC + // [1] |00000000111111112222222233333333| Data bytes, MSB first + // [2] |44444444555555556666666677777777| bitmap[0] = (frame->can_id << 7) | (!!(frame->can_id & CAN_RTR_FLAG)) << 6 |