cancel
Showing results for 
Search instead for 
Did you mean: 

modify a CAN sample point

MaHa
Associate II

I using a STM32MP-157F-EV1 eval board with linux Version 4.0.1-openstlinux-5.15-yocto-kirkstone-mp1-v22.06.15.

CAN receive 500kBit/s fails, if I modify the sample point via an console command it works well. All other Bitrates 125kBit / 250kBit 1MBit are ok with the default values.

How could I set the sample point permant, is there a linux config-File, to get the modyfied value even after a reboot?

5 REPLIES 5

Hi,

if you are using the systemd, you can create a service that will run the command for you.

[Unit]
Description=Reconfigure CAN interface
BindsTo=dev-can0.device
After=dev-can0.device
 
[Service]
Type=simple
ExecStart=/sbin/ip link set can0 up type can bitrate 500000 sample-point 0.5
 
[Install]
WantedBy=multi-user.target

Or you can create a network file. Unfortunately, I can't test it but perhaps tomorrow.

[Match]
Name=can0
 
[CAN]
BitRate=500000
SamplePoint=50%

Hope this helps.

MaHa
Associate II

Hi Tomas,

thank you very much for your support. I tried your first proposal,using systemd and it works well.:smiling_face_with_smiling_eyes:

Our Customer uses fix 500kBit, so we have actually a solution.

Now I looking for a possibility to modify the default values, because some other customer tried different Bitrates after power on. Maybe you have still an idea .

Again, thank you for your good and fast support.

Best wishes

Manfred

Hello,

if you want to easily modify the bitrate and do not change the systemd service, you can create a configuration file with the desired values and load it into the service.

The service could look like this

[Unit]
Description=Reconfigure CAN interface
BindsTo=dev-can0.device
After=dev-can0.device
 
[Service]
Type=simple
EnvironmentFile=-/etc/default/can_config
ExecStart=/sbin/ip link set can0 up type can bitrate $CAN_CFG_BR sample-point $CAN_CFG_SP $CAN_CFG_EXTRA
 
[Install]
WantedBy=multi-user.target

And the content of the /etc/default/can_config

CAN_CFG_BR=500000
CAN_CFG_SP="0.5"
CAN_CFG_EXTRA=""

Hope this helps.

Tomas

Hi,

today I had time to test the second solution; it works fine and is a cleaner solution for me.

The drawback can be that you are not using the systemd-networkd to manage the network interfaces and that the systemd version 250 is required (fine for ST 4.0.2), but it is easy to modify the configuration as you also need.

Best regards,

Tomas

Hi Tomas,

thank you for testing the second proposal. I will try it as well in my system.

Best regards

Manfred