Skip to content

Commit 84fe80f

Browse files
gbcwbzmysterywolf
authored andcommitted
[DeviceDriver] Fix can infinite loop when can driver send error
- in _can_int_tx if can driver sendmsg do not return RT_EOK, it will repeat until sendmsg return RT_EOK - if error occur on can bus(wire broken or EMI), all threads that have lower priority will not be executed - we should let application layer to determine if resend is appropriate when send fail, besides in data link layer, can already implemented auto resend in hardware
1 parent 666af5e commit 84fe80f

File tree

1 file changed

+3
-2
lines changed
  • components/drivers/can

1 file changed

+3
-2
lines changed

components/drivers/can/can.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,10 @@ rt_inline int _can_int_tx(struct rt_can_device *can, const struct rt_can_msg *da
158158
{
159159
/* send failed. */
160160
level = rt_hw_interrupt_disable();
161-
rt_list_insert_after(&tx_fifo->freelist, &tx_tosnd->list);
161+
rt_list_insert_before(&tx_fifo->freelist, &tx_tosnd->list);
162162
rt_hw_interrupt_enable(level);
163163
rt_sem_release(&(tx_fifo->sem));
164-
continue;
164+
goto err_ret;
165165
}
166166

167167
can->status.sndchange = 1;
@@ -189,6 +189,7 @@ rt_inline int _can_int_tx(struct rt_can_device *can, const struct rt_can_msg *da
189189
}
190190
else
191191
{
192+
err_ret:
192193
level = rt_hw_interrupt_disable();
193194
can->status.dropedsndpkg++;
194195
rt_hw_interrupt_enable(level);

0 commit comments

Comments
 (0)