From: Michal Sojka Date: Wed, 6 Nov 2013 17:32:50 +0000 (+0100) Subject: Add comments about CAN frame layout in bitmap X-Git-Tag: fix-allnoconfig~126 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/can-benchmark.git/commitdiff_plain/a302d8ec061482b2bd5ad61a9e07ee4feb9aa0fa Add comments about CAN frame layout in bitmap This revealed that for EFF frames, the calculation is broken. This needs to be fixed. --- diff --git a/latester/latester.c b/latester/latester.c index a5a7c47..e19064a 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 */ /**************************************************************************/ @@ -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 |