Reputation: 104
I'm trying to read a CAN-BUS on a vehicle with a raspberry (CAN is connected to DB9 connector on the raspberry). The vehicle provides energy to the raspberry also.
Here's my stack:
Protocol CAN "ISO 15765 CAN" by Bosch
CAN-Bus Board PiCAN3
machine : Raspberry pi 4
Driver/Bus Type : socketCAN
Library : CAN utils
I followed these instructions
#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...
Note1 : When i open an other tab in my terminal and sending a can message with the command :
cansend can0 7DF#0201050000000000
2 lines of data does appear in the tab that listen to can0, like it only shows what i'm sending but not what the vehicle send.
Note2 : here is the result of the command ifconfig for can0 device
#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
Does someone knows why i get zero data from the vehicle ?
here's the tutorials that i tried, with all these, the problem stays the same :
1: copperhilltech
2: Open Garage
3: Harrison's Box
Upvotes: 3
Views: 4188
Reputation: 104
After changing the cable, everything started working fine. It was a hardware problem. Thanks everyone.
Upvotes: 0
Reputation: 5467
We obviously cannot remote-debug your hardware, so here is some generic CAN debugging advice.
The classical mistake with CAN is to forget to enable/mount the 120 ohm termination resistors. You can easily measure it with a volt-meter (while everything is turned off).
Also, you should see the bus state in ip -d -s link show can0
, it should say ERROR_ACTIVE
if everything is either correct or silent. (Well, maybe not every driver supports it. But you should go hunting for any error counters your driver has, and learn their meaning.)
When you disconnect the CAN bus and then send a few frames, you should see the error counters increase (because no other device on the bus ACKs them). And eventually the bus state should change, so it is no longer ERROR_ACTIVE
.
Upvotes: 1