关于candump 命令中 filter 过滤的解释

Filters:
  Comma separated filters can be specified for each given CAN interface:
    <can_id>:<can_mask>
         (matches when <received_can_id> & mask == can_id & mask)
    <can_id>~<can_mask>
         (matches when <received_can_id> & mask != can_id & mask)
    #
         (set error frame filter, see include/linux/can/error.h)
    [j|J]
         (join the given CAN filters - logical AND semantic)

CAN IDs, masks and data content are given and expected in hexadecimal values.
When the can_id is 8 digits long the CAN_EFF_FLAG is set for 29 bit EFF format.
Without any given filter all data frames are received ('0:0' default filter).

Use interface name 'any' to receive from all CAN interfaces.

Examples:
candump -c -c -ta can0,123:7FF,400:700,#000000FF can2,400~7F0 can3 can8

candump -l any,0~0,#FFFFFFFF
         (log only error frames but no(!) data frames)
candump -l any,0:0,#FFFFFFFF
         (log error frames and also all data frames)
candump vcan2,12345678:DFFFFFFF
         (match only for extended CAN ID 12345678)
candump vcan2,123:7FF
         (matches CAN ID 123 - including EFF and RTR frames)
candump vcan2,123:C00007FF
         (matches CAN ID 123 - only SFF and non-RTR frames)

1、关于 canid 是标准 11位 还是 扩展 29位
例如 candump vcan2,123:C00007FF (matches CAN ID 123 - only SFF and non-RTR frames)
因为 mask 掩码 是 C00007FF 说明 只支持11位(7FF),其他位与的时候都清零了,所以
“only SFF and non-RTR frames” 表示只包括标准帧(Standard Frame Format,SFF)和非远程帧(non-RTR frames)。

再例如 candump vcan2,123:7FF
candump 命令将监听名为 vcan2 的虚拟 CAN 接口,并只捕获 CAN ID 为 123 的消息,包括扩展帧(EFF)和远程帧(RTR)消息。

2、看下 canid 是 扩展29位
candump vcan2,12345678:DFFFFFFF
(match only for extended CAN ID 12345678) 只支持扩展帧,且can id 是 12345678。

3、can 标准帧
标准帧(Standard Frame Format,SFF)

4、can 扩展帧
扩展帧(Extended Frame Format)

5、can 远程帧
远程帧(Remote Frame)

6、can 数据帧
数据帧(Data Frame)

7、数据过滤的公式 是

:
(matches when & mask == can_id & mask)
~
(matches when & mask != can_id & mask)

你可能感兴趣的:(linux开发,c,c++,linux,网络)