RT-Thread / RT-Thread/rt-thread
[Bug] drv_can: RT_CAN_FILTER_STD_INIT和RT_CAN_FILTER_EXT_INIT的mask赋值疑问
Open
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
master
Hardware Type/Architectures
all
Develop Toolchain
Other
Describe the bug
背景
我在阅读 RT_CAN_FILTER_STD_INIT / RT_CAN_FILTER_EXT_INIT 的实现时,注意到 filter 的 mask 被初始化为 0xFFFFFFFF。
我的疑惑
根据 CAN 协议规范:
- 标准帧(STD)ID 为 11 位,有效 mask 应不超过
0x7FF - 扩展帧(EXT)ID 为 29 位,有效 mask 应不超过
0x1FFFFFFF
因此我对 mask 使用 0xFFFFFFFF 有些困惑,想请教一下:
- 这里使用全 1 的 mask 是有意为之吗?如果是,这样设计是出于什么考虑(比如后续会被裁剪、或者硬件会自动忽略高位、或者作为"不过滤"的默认值)?
- 实际生效时,是否由底层驱动或硬件自动将超出位宽的 mask 位截断/忽略?
- 若不会自动截断,这里是否考虑限定为对应帧格式的有效位宽?
感谢!
Other additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the definitions of RT_CAN_FILTER_STD_INIT and RT_CAN_FILTER_EXT_INIT, then inspect how their mask fields are consumed by CAN drivers or hardware backends. Determine whether high bits are intentionally ignored or need limiting to the frame width; done means the behavior is confirmed and the issue's requested clarification or correction is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100