mirror of
https://github.com/apache/nuttx.git
synced 2025-12-06 17:23:49 +08:00
This adds ability for read and write operations to work with messages aligned to configured number of bytes. This has few different use cases. The alignment is specified as unsigned integer and can be changed with ioctl command CANIOC_SET_MSGALIGN. The current value can be queried by CANIOC_GET_MSGALIGN command. The default value for the message alignment is 1. This will provide behavior consistent with current one. Thus messages are placed to the buffer right after data of the previous one. The same applies for writes. The special alignment value 0 disables read and write of multiple frames. Thus read will always return at most one message and write will always write only one message even if larger buffer size is provided. Another use case is if message alignment is set to exactly message representation size (`sizeof(struct can_msg_s)`). This allows writing and reading arrays of messages. Other values provide even more advanced and specialized use cases, such as optimizations if architecture has to emulate some non-aligned accesses, there alignment of for example 4 bytes could provide performance boost. The original motivation behind this is was compatibility with socket CAN. It is easier to port applications to NuttX's CAN driver if only one frame is provided at the time. This solution was suggested by Pavel Pisa <pisa@fel.cvut.cz> as a more versatile variant of plain boolean disabling the multiple frame retrieval. Signed-off-by: Karel Kočí <kkoci@elektroline.cz>