Skip to content

Conversation

@HedongGao
Copy link
Contributor

@HedongGao HedongGao commented Dec 25, 2025

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);

@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 :)

@github-actions github-actions bot added Area: Documentation Improvements or additions to documentation Area: Networking Effects networking subsystem Area: Memory Management Memory Management issues Area: OS Components OS Components issues Size: L The size of the change in this PR is large labels Dec 26, 2025
@github-actions github-actions bot removed Area: Documentation Improvements or additions to documentation Area: Networking Effects networking subsystem Area: Memory Management Memory Management issues Area: OS Components OS Components issues labels Dec 26, 2025
@HedongGao
Copy link
Contributor Author

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 :)

After carefully considering your suggestion, using triple backsticks is indeed not suitable. The third backticks are unnecessary, just calling can_dend_done once can trigger the sending, achieving the goal of preventing sending interruption.

Attempt to release invalid resources when sender is full.

Signed-off-by: gaohedong <gaohedong@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit 3f55399 into apache:master Dec 26, 2025
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Drivers Drivers issues Size: L The size of the change in this PR is large 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.

4 participants