RT-Thread / RT-Thread/rt-thread

[Bug] CAN总线发送(_can_int_tx)在链路波动时会阻塞

Open
#10,341 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
12.2k
Forks
5.4k
Avg merge
4d 12h
Merged PRs (30d)
40

Description

RT-Thread Version

5.1.0

Hardware Type/Architectures

STM32F407VET6

Develop Toolchain

RT-Thread Studio

Describe the bug

在CAN总线上设备掉电时发送CAN报文,STM32F407会产生SCE中断(错误码并非RT_CAN_BUS_ACK_ERR),drv_can中没有调用rt_hw_can_isr来执行

rt_completion_done(&(tx_fifo->buffer[no].completion));

这会导致 _can_int_tx 中

rt_completion_wait(&(tx_tosnd->completion), RT_WAITING_FOREVER)

永远不会返回。我尝试将他改成

if(RT_EOK != rt_completion_wait(&(tx_tosnd->completion), 100))
        {
            /* send timeout. */
            
            level = rt_hw_interrupt_disable();
            rt_list_insert_before(&tx_fifo->freelist, &tx_tosnd->list);
            rt_hw_interrupt_enable(level);
            rt_sem_release(&(tx_fifo->sem));

            // rt_kprintf("CAN send timeout, no %d\n", no);
            goto err_ret;
        }

来解决,不知道是否正确

Other additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect drv_can and the _can_int_tx path, then trace how SCE interrupts are handled compared with rt_hw_can_isr and RT_CAN_BUS_ACK_ERR. Reproduce transmission with the CAN bus device powered down on STM32F407VET6 and verify that the completion is handled so the sender does not wait forever; validate the behavior against the proposed timeout path.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.