Page 1 of 1

FD transmit from Linux

Posted: Thu 21. Oct 2021, 16:24
by brynw
I am using the PCAN-USB FD (firmware version 3.2.0) with an Ubuntu (kenel version 4.9.253-tegra). With the device's settings configured with the following command:

Code: Select all

nvidia@xavier:~$ sudo ip link set can0 type can bitrate 1000000 sjw 20 sample-point 0.75 dbitrate 5000000 dsample-point 0.75 dsjw 1 fd on restart-ms 1
candump sees incoming FD messages but transmitted messages are not FD (as indicated by the B column in candump).

Code: Select all

nvidia@xavier:~$ candump -ex -td can0
 (000.000001)  can0  RX B -  22B  [04]  C1 00 00 00
 (000.100002)  can0  RX B -  18B  [02]  00 00
 (000.000002)  can0  RX B -  17B  [02]  00 00
 (000.000000)  can0  TX - -  23B   [5]  3F 3F 7F 3F 08
Are my settings correct? What am I missing?

Re: FD transmit from Linux

Posted: Thu 21. Oct 2021, 17:28
by M.Maidhof
Hi,

we don't see how and with which applicaton you send those frames. Will be helpfull to understand your problem.

regards

Michael

Re: FD transmit from Linux

Posted: Thu 21. Oct 2021, 17:37
by brynw
After a bit more research, I realized that not only do you have to set up the PCAN-USB FD device parameters for communicating FD using the

Code: Select all

ip link set
command, you also have to explicitly specify for each message whether you want to send an FD message frame and whether to use brs (bit rate shifting) for the higher data rate. This is evident in the cansend man page

Code: Select all

Usage: cansend - simple command line tool to send CAN-frames via CAN_RAW sockets.
Usage: cansend <device> <can_frame>.
<can_frame>:
 <can_id>#{R|data}          for CAN 2.0 frames
 <can_id>##<flags>{data}    for CAN FD frames

<can_id>:
 can have 3 (SFF) or 8 (EFF) hex chars
{data}:
 has 0..8 (0..64 CAN FD) ASCII hex-values (optionally separated by '.')
<flags>:
 a single ASCII Hex value (0 .. F) which defines canfd_frame.flags
The extra # tells cansend to send and FD frame, and the <flags> character needs to be a 1 to force BRS for the data bytes.

Still have to figure out how to have an application, say, in C++, tell the interface to use FD with BRS.

Re: FD transmit from Linux

Posted: Thu 21. Oct 2021, 17:48
by M.Maidhof
yes, correct. You can also have a look in the code of the can_utils tools to understand how SocketCAN works.

regards

Michael