SocketCan with Macchina m2


Does anyone know if you can use the macchina m2 with Socketcan and can-utils?


Well, in theory, yes. If you have M2RET installed then slcan ought to work if you point it at the M2’s serial port. But, I’m not sure if anyone has tried it. You see, the base for M2RET was GVRET and that code did support lawicel / slcan. But, when things were ported over for the M2 I never checked whether this still works or if it has broken. I suppose one of these days I ought to verify that it still works.

 sudo modprobe can
 sudo modprobe vcan
 sudo modprobe slcan
 sudo slcand -o -c -s6 /dev/ttyACM0 can0
 sudo ifconfig can0 up

That basic set of commands should cause it to work. However, in there is -s6 which would have selected a CAN speed but if I remember correctly long ago I messed that up and you can’t set the speed on the command line. It’ll use whatever you have set in the serial console of M2RET so set the speed first then connect with slcand and it ought to work.


Yes it works!
I don’t think you need to modprobe vcan or slcan.

I got it to work with just

sudo modprobe can
sudo slcand -o -c -s6 /dev/ttyACM0 can0
sudo ifconfig can0 up

Is this output to can0 all the buses on the device?


Yes, all CAN frames will appear on the same socketcan interface. That’s fine for capturing but obviously means if you try sending it will instead end up always sending on the M2 CAN0 port. Technically Lawicel 2.0 is implemented in the M2RET codebase so that ought to allow for sending on any of the three CAN ports and would show which bus a given frame came in on. But, obviously this is still problematic as nothing else supports this LAWICEL2.0 we made up, certainly not the slcan tools.