Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CAN FD support for Virtual CAN (vcan) on SocketCAN

I have been using SocketCAN and especially the Virtual CAN vcan for quite a while now. However, I never used CAN FD (Flexible Datarate) so far.

Well, I tried it this morning using the can-utils:

cansend vcan0 123##122

However, I got the response "CAN interface is not CAN FD capable". The vcan interface has been created using the following terminal commands:

ip link add dev vcan0 type vcan
ip link set up vcan0

Does anybody know if vcan supports CAN FD? If yes, how do I set up a vcan interface supporting CAN FD?

System configuration: Ubuntu 14.04.1 on VirtualBox.

Thanks in advance, MAW

like image 895
MAW Avatar asked Jan 06 '23 06:01

MAW


2 Answers

a colleague of mine found a solution:

ip link add dev vcan0 type vcan
ip link set vcan0 mtu 72

The option "mtu 72" sets the right maximum transmission size for CAN FD. After that vcan accepts CAN FD messages.

MAW

like image 99
MAW Avatar answered Jan 16 '23 03:01

MAW


Excellent finding, MAW!

It works as a charm. Here is what I did, following your advice. Please, do note that commands are generic, and that there is a environment preparation I do NOT want to go into!

To set socketCAN framework beneath Linux kernel (I am using 4.17.2), please, as root:

lsmod | grep can
modprobe can
modprobe can_raw
modprobe can-bcm
modprobe can-dev
modprobe can-gw
modprobe vcan
lsmod | grep can

To set the socketCAN-Fd framework, the following should be done (also as root):

ip link add dev vcan0 type vcan
ip link set vcan0 mtu 72
ip link set dev vcan0 up
ifconfig

The can-utils package is required to test the socketCAN-Fd framework. Also, the following is required: https://github.com/mguentner/cannelloni

And, everything is working like Swiss Clock! :-)

On the xmit side: cangen -f vcan0 -v vcan0

2C3##0.25.5A.FF.1E.DC.BD.CB.42.25.5A.FF.1E.DC.BD.CB.42.25.5A.FF.1E.DC.BD.CB.42.25.5A.FF.1E.DC.BD.CB.42.25.5A.FF.1E.DC.BD.CB.42.25.5A.FF.1E.DC.BD.CB.42.25.5A.FF.1E.DC.BD.CB.42.25.5A.FF.1E.DC.BD.CB.42

On the receiving side: candump vcan0

vcan0 2C3 [64] 25 5A FF 1E DC BD CB 42 25 5A FF 1E DC BD CB 42 25 5A FF 1E DC BD CB 42 25 5A FF 1E DC BD CB 42 25 5A FF 1E DC BD CB 42 25 5A FF 1E DC BD CB 42 25 5A FF 1E DC BD CB 42 25 5A FF 1E DC BD CB 42

Perfect! Thank you so much!

nobody

like image 29
2 revs Avatar answered Jan 16 '23 04:01

2 revs