mirror of
https://github.com/apache/nuttx.git
synced 2025-12-10 12:14:36 +08:00
drivers/can: fix sending of RTR frames with nonzero DLC
The message passed to the write can have `cm.hdr.ch_rtr` set and if nonzero DLC is specified in the frame then invalid number of bytes is removed from the buffer as RTR frames do not have any data even when DLC is nonzero. This was tested on SAMv7 (mcan). With this change a custom RTR can be sent. Signed-off-by: Karel Kočí <cynerd@email.cz>
This commit is contained in:
@@ -675,8 +675,16 @@ static ssize_t can_write(FAR struct file *filep, FAR const char *buffer,
|
||||
* CAN message at sutibal.
|
||||
*/
|
||||
|
||||
msg = (FAR struct can_msg_s *)&buffer[nsent];
|
||||
nbytes = can_dlc2bytes(msg->cm_hdr.ch_dlc);
|
||||
msg = (FAR struct can_msg_s *)&buffer[nsent];
|
||||
if (msg->cm_hdr.ch_rtr)
|
||||
{
|
||||
nbytes = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
nbytes = can_dlc2bytes(msg->cm_hdr.ch_dlc);
|
||||
}
|
||||
|
||||
msglen = CAN_MSGLEN(nbytes);
|
||||
|
||||
if (nsent + msglen > buflen)
|
||||
|
||||
Reference in New Issue
Block a user