Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure alignment #107

Open
netlcod opened this issue Feb 7, 2024 · 0 comments
Open

Structure alignment #107

netlcod opened this issue Feb 7, 2024 · 0 comments

Comments

@netlcod
Copy link

netlcod commented Feb 7, 2024

I think the can_frame structure needs alignment added. This is necessary for cases when CAN commands are sent streaming (Serial, for example).

#pragma pack(push,1)
struct can_frame {
    canid_t can_id;  /* 32 bit CAN_ID + EFF/RTR/ERR flags */
    __u8    can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
    __u8    data[CAN_MAX_DLEN] __attribute__((aligned(8)));
};
#pragma pack(pop)

Field sizes are 4b + 1b + 8b = 13b.
Struct size is 16b without alignment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant