can接收id过滤linux,linux – 很大程度上被candump(SocketCAN)ID过滤功能搞糊涂了
时间: 2023-12-03 16:45:54 浏览: 221
Linux系统下互联网过滤功能
candump是一个用于读取CAN总线数据的工具,它可以通过设置ID过滤器来过滤接收到的数据。在Linux系统中,可以使用ip命令来设置CAN接口的过滤规则。以下是一个示例命令:
```
sudo ip link set can0 type can bitrate 500000
sudo ip link set can0 up
sudo ip link set can0 txqueuelen 1000
sudo ip link set can0 txqueuelen 1000 type can bitrate 500000 triple-sampling on
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 restart-ms 1000
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 listen-only off
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on restart-ms 1000
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on listen-only off
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on triple-sampling on
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on triple-sampling on restart-ms 1000
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on triple-sampling on listen-only off
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on triple-sampling on txqueuelen 1000
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on triple-sampling on txqueuelen 1000 restart-ms 1000
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on triple-sampling on txqueuelen 1000 listen-only off
sudo ip link set can0 up
sudo ip link set can0 type can bitrate 500000 dbitrate 2000000 berr-reporting on fd on triple-sampling on txqueuelen 1000 loopback on
sudo ip link set can0 up
```
上述命令设置了CAN接口can0的过滤规则,可以根据需要修改。其中,最后一条命令设置了CAN接口can0开启回环模式,以便测试和调试。
阅读全文