Re: correct length of bcm message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Oliver,

Am 04.02.21 um 21:14 schrieb Oliver Hartkopp:
> struct can_frames[0] is used in this struct definition to point out,
> that this struct is followed by a number (0..257) struct can_frame's.
> 
> This creates a padding at the end of struct bcm_head, so that the struct
> can_frame (which is always 64 bit aligned) can be directly concatenated.

so this behavior is caused by this alignment

struct can_frame {
    ...
    __u8    data[8] __attribute__((aligned(8)));
}

and walks back upwards to

nframes (end at 36 bytes)
...
< 4 bytes gap >
...
frames (start at 40 bytes)

Should the alignment not be defined on structure instead?

struct can_frame __attribute__((aligned(8))) {
...
}


Interesting to know, apparently native alignment is 8 on X86_64 linux
and 4 on armhf linux. That's why it worked on X86_64.

Regarding python ctypes module, setting _pack_=8 has no remedy effect on
armhf platform, so I'll move to struct module.

Thanks again.

Regards,
Patrick



[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux