Change the default timing

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
r_frojd
Posts: 6
Joined: Wed 14. Apr 2021, 09:26

Change the default timing

Post by r_frojd » Thu 13. May 2021, 08:10

Hi guys.
I am trying to change the default timings of the pcan devices which should be persistent on each boot.

here is the settings I want to use for all my pcan devices:
d.PNG
d.PNG (4.16 KiB) Viewed 3171 times
I tried to set them with (for example)

Code: Select all

echo 10 | sudo tee /sys/class/pcan/pcanpcifd2/nom_sjw
But that gives me Permission denied.
d1.PNG
d1.PNG (48.63 KiB) Viewed 3171 times
is there any other way I can change the default timings?

I am trying to use the python-can which should work for PCAN Basic API. Problem is that I need diffrent timings then stock in order for the communication to work. This is for test purposes only.
if I use the netdev Mode I can set them like so:

Code: Select all

ip link set can0 up type can \
  tq 12 prop-seg 25 phase-seg1 25 phase-seg2 29 sjw 10 \
  dtq 12 dprop-seg 6 dphase-seg1 2 dphase-seg2 7 dsjw 12 \
  restart-ms 1000 fd on
But I dont want to use the netdev Mode :roll:

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: Change the default timing

Post by M.Heidemann » Fri 14. May 2021, 09:27

Hello,

In PCANBasic API, these values are used when initializing the device as FD:

Code: Select all

# Defines a FD Bit rate ascii string with nominal and data Bit rate set to 1 MB
#
bitrate = b"f_clock_mhz=24, nom_brp=1, nom_tseg1=17, nom_tseg2=6, nom_sjw=1, data_brp=1, data_tseg1=16, data_tseg2=7, data_sjw=1"

# The FD capable Channel (PCAN-USB Pro FD) is initialized
#
objPCAN = PCANBasic()
result = objPCAN.InitializeFD(PCAN_USBBUS1, bitrate)
if result != PCAN_ERROR_OK:
    # An error occurred, get a text describing the error and show it
    #
    result = objPCAN.GetErrorText(result)
    print (result[1])
else:
    print ("PCAN-USB Pro FD (Ch-1) was initialized")

# All initialized channels are released
#
objPCAN.Uninitialize(PCAN_NONEBUS)

As we do not support python-CAN, we are unable to tell you how that would be done when using python-CAN. PCANBasic can also be used with Python without any third party libs and frameworks.

However, as you want to work on application basis, it's easier to just initialize the device with the correct bitrate. As long as you are able to identfiy the device correctly you should also be able to just use initializeFD from PCANBasic itself to initialize the device.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

Post Reply