I have set up a CAN bus between 2 STM32 Nucleo's, where one is only sending messages and the other one is only reading them. This works, I have also validated this by connecting them to another CAN Bus to receive messages.
Now I also want to read CAN messages on a Raspberry Pi. I have bought the Waveshare RS485 CAN HAT for Raspberry Pi (https://www.waveshare.com/rs485-can-hat.htm) and followed their instructions to get started.
I have connected the CAN H and L to my STM32 Nucleo CAN Bus to read the messages, however I cannot get this to work. I tried their demo code to send and receive messages (https://www.waveshare.com/wiki/File:RS485_CAN_HAT_Code.7z) and I have installed can-utils
to use candump can0
. Both methods don't seem to work, because I am not receiving any message from the Pi and the receiving Nucleo is also not receiving any message from the Pi.
When I run ifconfig can0
to check the CAN connection the Pi gives me the following:
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: 1 dropped 1 overruns 0 carrier 1 collisions 0
I am not really familiar how to read this, but I guess no messages have been sent or received and there is a transmission error (don't know why that is, maybe because it cannot connect to a CAN Bus?).
Can anyone help me to setup the CAN Bus on Raspberry Pi with the RS485 CAN HAT correctly? Thanks in advance!
P.S. I would like to add the tag rs485-can-hat to this question for users with the same problem, but of course this is not a 'popular' tag and I don't have enough reputation to create a new tag. Can anyone do this for me?