Repository navigation
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
Summary
Extend the lifecycle model from PR #10 to cover safe close/reconfigure and explicit CAN bus state/recovery.
This PR adds:
rt_can_bus_statemodel (ERROR_ACTIVE/WARNING/PASSIVE/BUS_OFF);rt_hw_can_bus_state()reporting for drivers with precise state events;RT_CAN_CAP_MANUAL_RECOVERYandRT_CAN_CMD_RECOVER;rt_can_recover()lifecycle transition throughRECOVERING;QUIESCED -> RECONFIGURING -> RUNNING;Lifecycle vs bus state
Lifecycle and CAN protocol state are intentionally separate. For example a device can be
RUNNING + ERROR_PASSIVE, orRECOVERING + BUS_OFF.Close safety
Final close now performs
ABORT_ALLquiesce first. CAN runtime resources are not detached/freed unless accepted TX ownership has been retired. This prevents a late TX ISR from touching already-freed request/mailbox state.Reconfiguration
RT_DEVICE_CTRL_CONFIG, mode changes and baud-rate changes are performed from an explicit quiesced boundary. Baud changes use the destructiveABORT_ALLpolicy; normal configuration/mode changes useDRAIN.Recovery
Drivers may advertise manual recovery.
rt_can_recover()serializes recovery with lifecycle operations, invokes the driver recovery command, restoresERROR_ACTIVEon success, and restarts the existing scheduler without a deferred worker.Compatibility
rt_hw_can_isr()sites remain source-compatible.rt_hw_can_bus_state()is additive/optional.Tests
The fake-controller tests now cover BUS_OFF TX rejection and successful manual recovery before TX admission resumes.
No target-board/hardware validation has been performed in this PR.
Stack
PR 6/7. Base: PR #10 (
refactor/can-quiesce-flush).