首页 > 解决方案 > can0 监听 can-bus 但没有数据出现

问题描述

我正在尝试用覆盆子读取车辆上的 CAN-BUS(CAN 连接到覆盆子上的 DB9 连接器)。车辆也为覆盆子提供能量。

这是我的堆栈:

Bosch CAN-Bus Board PiCAN3机器的协议 CAN “ISO 15765 CAN” :Raspberry pi 4 驱动程序/总线类型:socketCAN 库:CAN utils




我遵循了这些说明

#added this in /boot/config.txt and reboot
dtparam=spi=on
dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay
#create the can interface on divice can0 with a bitrate at 500 kbps
sudo /sbin/ip link set can0 up type can bitrate 500000
#connect the PiCAN to a CAN-BUS network, and listen to it:
candump can0
#a data stream is supposed to appear here, but nothing happens...

注意 1:当我在终端中打开另一个选项卡并使用以下命令发送 can 消息时:

cansend can0 7DF#0201050000000000

2行数据确实出现在听can0的选项卡中,就像它只显示我正在发送的内容而不是车辆发送的内容。

注意 2 :这里是 can0 设备的 ifconfig 命令的结果

#ifconfig (only can0)
can0: flags=193<UP,RUNNING,NOARP>  mtu 16
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 10  (UNSPEC)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

有人知道为什么我从车辆中获得零数据吗?

这是我尝试过的教程,所有这些,问题都是一样的:
1:copperhilltech
2:打开车库
3:哈里森的盒子

标签: raspberry-pican-busifconfigsocketcancanutils

解决方案


我们显然无法远程调试您的硬件,所以这里有一些通用的 CAN 调试建议。

CAN 的典型错误是忘记启用/安装 120 欧姆终端电阻。您可以使用电压表轻松测量它(当一切都关闭时)。

此外,您应该在 中看到总线状态ip -d -s link show can0,它应该说明ERROR_ACTIVE一切是否正确或无声。(好吧,也许不是每个驱动程序都支持它。但是您应该寻找驱动程序具有的任何错误计数器,并了解它们的含义。)

当您断开 CAN 总线然后发送几帧时,您应该会看到错误计数器增加(因为总线上没有其他设备确认它们)。最终总线状态应该改变,所以它不再是ERROR_ACTIVE


推荐阅读