Skip to content

Conversation

@HedongGao
Copy link
Contributor

Summary

Due to bus reasons, the can sender may be full. However, after the bus is restored and the hardware has sent the message, in some scenarios, due to hardware bugs, the TXconfirm interrupt is lost, which can lead to packet interruption.
To enhance the robustness of the Nuttx CAN protocol stack and address the potential issues mentioned above. Improved the CAN protocol stack.

Impact

This modification will not have an impact on normal packet sending, but it will only trigger message sending through can_dend.done when the sender is already full and there is no external data in the driver.

Testing

Perform functional validation on the development board. Modify the driver layer code so that the first 10 frames of messages sent do not handle TXconfirmation interrupts, and subsequent TXconfirmation interrupts are handled normally, indicating a hardware issue. Before powering on the development board, disconnect the CAN bus connection. There are no CAN messages on the other end device. After the bus connection, CAN messages appear.

`
int fd;
int count = 0;
struct can_msg_s txmsg;

txmsg.cm_hdr.ch_id = 0x69;
txmsg.cm_hdr.ch_dlc = 8;
txmsg.cm_hdr.ch_edl = 1;

fd = open("/dev/can0", O_RDWR | O_NONBLOCK);
while (1)
{
count = (++count)%256;
txmsg.cm_data[0] = count;
write(fd, &txmsg, sizeof(struct can_msg_s ));
}
close(fd);
`

Attempt to release invalid resources when sender is full.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
@github-actions github-actions bot added Area: Drivers Drivers issues Size: S The size of the change in this PR is small labels Dec 25, 2025
@linguini1
Copy link
Contributor

If you use triple backticks instead of single ones, it will make the code block! Also, you can put 'c' after the first three backticks and GitHub will highlight the code according to C syntax :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants