Data bytes must not be converted to big endian
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 6 Nov 2013 17:46:23 +0000 (18:46 +0100)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 6 Nov 2013 17:46:23 +0000 (18:46 +0100)
I don't know why I did that before :-o

latester/latester.c

index b0937ba..a2f4f18 100644 (file)
@@ -251,8 +251,7 @@ unsigned calc_stuff_bits(struct can_frame *frame) {
                        (!!(frame->can_id & CAN_RTR_FLAG)) << 6         |
                        0 << 4                                          |
                        frame->can_dlc & 0xf;
-               bitmap[2] = htonl(((uint32_t*)frame->data)[0]);
-               bitmap[3] = htonl(((uint32_t*)frame->data)[1]);
+               memcpy(&bitmap[2], &frame->data, frame->can_dlc);
                start = 27;
                end = 64 + 8*frame->can_dlc;
        } else {
@@ -265,8 +264,7 @@ unsigned calc_stuff_bits(struct can_frame *frame) {
                        (!!(frame->can_id & CAN_RTR_FLAG)) << 6 |
                        0 << 4                                  |
                        frame->can_dlc & 0xf;
-               bitmap[1] = htonl(((uint32_t*)frame->data)[0]);
-               bitmap[2] = htonl(((uint32_t*)frame->data)[1]);
+               memcpy(&bitmap[1], &frame->data, frame->can_dlc);
                start = 13;
                end = 32 + 8*frame->can_dlc;
        }