]> rtime.felk.cvut.cz Git - can-benchmark.git/commitdiff
Add comments about CAN frame layout in bitmap
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 6 Nov 2013 17:32:50 +0000 (18:32 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 6 Nov 2013 17:32:50 +0000 (18:32 +0100)
This revealed that for EFF frames, the calculation is broken. This needs
to be fixed.

latester/latester.c

index a5a7c474dbd837073a932e8bc9ac4fbf39d3bb1f..e19064aaa6948780d6645284a6856db84dce7e6e 100644 (file)
@@ -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 |