roflcopta
Posts: 2
Joined: Tue Mar 24, 2020 9:15 am

CAN FD Bit Rate Switch on Raspberry Pi 3

Tue Mar 24, 2020 9:58 am

Hello everyone,

I am trying to get two RasPis with a CAN FD shield (MCP2517FD) to communicate via CAN FD. It actually works fine, but as soon as I set the BRS to TRUE, weird things happen and the messages are not sent out properly.

The setup I used for both Pis is pretty similiar to that one: https://github.com/GBert/misc/tree/master/RPi-MCP2517

I added the following lines to my /boot/config.txt:

Code: Select all

core_freq=250
kernel=ms7/zImage
device_tree=ms7/bcm2710-rpi-3-b.dtb
overlay_prefix=ms7/overlays/
dtoverlay=mcp2517fd-can0
dtparam=interrupt=25
dtparam=oscillator=40000000
dtparam=spimaxfrequency=20000000


The send and receive files are written and python and pretty much copied from: https://github.com/skpang/PiCAN-FD-Python-examples

If I send messages without the BRS active I receive:

Code: Select all

pi@raspberrypi:~/Desktop $ python receive.py 

CAN Tx test
Bring up CAN0....
Ready
 1585041201.788182 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.808952 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.830066 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.851458 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.872531 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.893586 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.914766 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.935900 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.957289 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.978357 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041201.999257 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041202.020625 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041202.042069 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041202.062888 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041202.083847 1 0 123 8 1 2 3 4 5 6 7 8 
 1585041202.104733 1 0 123 8 1 2 3 4 5 6 7 8 

Everythings fine so far.
Now I send the same messages but with the BRS set to True:

Code: Select all

CAN Tx test
Bring up CAN0....
Ready
 1585042868.352613 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.372650 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.372807 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.372949 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.373283 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.393287 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.393603 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.414106 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.414431 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.434750 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.435073 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.455482 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.455801 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.476293 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.476358 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.476461 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.476531 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.476863 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.497091 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.497158 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.497273 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.497595 1 1 123 8 1 2 3 4 5 6 7 8 
 1585042868.517904 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518014 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518133 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518226 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518320 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518439 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518558 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518678 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518815 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518870 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.518991 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.519087 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.519267 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.519425 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.519550 0 0 8 8 0 0 0 0 0 0 0 0 
 1585042868.519683 0 0 8 8 0 0 0 0 0 0 0 0 


The result is different most of the times. I am sending 16 messages but only receive some of them (always a different number). Furthermore, if I send more messages from the same RasPi, I am getting the following error on the sending RasPi:

Code: Select all

Traceback (most recent call last):
  File "send.py", line 32, in <module>
    bus.send(msg)
  File "/home/pi/.local/lib/python2.7/site-packages/can/interfaces/socketcan/socketcan.py", line 626, in send
    sent = self._send_once(data, msg.channel)
  File "/home/pi/.local/lib/python2.7/site-packages/can/interfaces/socketcan/socketcan.py", line 649, in _send_once
    raise can.CanError("Failed to transmit: %s" % exc)
can.CanError: Failed to transmit: [Errno 105] No buffer space available



Sometimes the RasPi freezes and I have to shut him down.

The bitrates and samplepoints of both configurations are the same.

Any ideas on how to get this running properly while the BRS is set or why this is happening?

Thank you very much in advance!

bertr2d2
Posts: 98
Joined: Wed Aug 08, 2012 10:12 pm

Re: CAN FD Bit Rate Switch on Raspberry Pi 3

Wed Mar 25, 2020 10:10 pm

Hi,
roflcopta wrote:
Tue Mar 24, 2020 9:58 am
Hello everyone,

I am trying to get two RasPis with a CAN FD shield (MCP2517FD) to communicate via CAN FD. It actually works fine, but as soon as I set the BRS to TRUE, weird things happen and the messages are not sent out properly.

The setup I used for both Pis is pretty similiar to that one: https://github.com/GBert/misc/tree/master/RPi-MCP2517
I only tested for non FD. So use a newer driver if you want CAN FD working. BTW: even the newer MCP2518FD has a serious bug.

Regards

Gerd
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie

roflcopta
Posts: 2
Joined: Tue Mar 24, 2020 9:15 am

Re: CAN FD Bit Rate Switch on Raspberry Pi 3

Thu Mar 26, 2020 2:06 pm

bertr2d2 wrote:
Wed Mar 25, 2020 10:10 pm
Hi,
roflcopta wrote:
Tue Mar 24, 2020 9:58 am
Hello everyone,

I am trying to get two RasPis with a CAN FD shield (MCP2517FD) to communicate via CAN FD. It actually works fine, but as soon as I set the BRS to TRUE, weird things happen and the messages are not sent out properly.

The setup I used for both Pis is pretty similiar to that one: https://github.com/GBert/misc/tree/master/RPi-MCP2517
I only tested for non FD. So use a newer driver if you want CAN FD working. BTW: even the newer MCP2518FD has a serious bug.

Regards

Gerd
Hey Gerd,

what exactly do you mean? I am fairly new to this...

The FD communication works if the BRS is not set, only if I set it to True, even if the databitrates are set to the same it does not work anymore.

Thanks for the answer
Rolf

Return to “Interfacing (DSI, CSI, I2C, etc.)”