Skip to content

[Bug] drv_can: RT_CAN_FILTER_STD_INIT和RT_CAN_FILTER_EXT_INIT的mask赋值疑问 #11576

Todo

Description

@RCSN

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. 这里使用全 1 的 mask 是有意为之吗?如果是,这样设计是出于什么考虑(比如后续会被裁剪、或者硬件会自动忽略高位、或者作为"不过滤"的默认值)?
  2. 实际生效时,是否由底层驱动或硬件自动将超出位宽的 mask 位截断/忽略?
  3. 若不会自动截断,这里是否考虑限定为对应帧格式的有效位宽?

感谢!

Other additional context

No response

Activity

  1. CYFS3 commented on Jul 6, 2026

    @CYFS3
    Contributor

    这一块应该要看具体的bsp是怎么实现的。这个mask确实应该是需要精确的去限定的。

  2. ymj0440 commented on Nov 25, 2026

    @ymj0440
    Contributor

    /claim

  3. added
    in progress
    on Nov 25, 2026
  4. github-actions commented on Nov 25, 2026

    @github-actions

    @ymj0440 has claimed this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in progress

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions