CAN BMS with slcan, CANable V2

Hi,

unfortunately I got me a CANable V2 (instead of V1) which turned out to have a STM32G431 chip and accordingly is not (yet) suitable for candlelight.

This device operates as slcan and I found slcand as a possibility to ‘make’ it appear as socketCAN:

 sudo slcand -o -c -s6 /dev/ttyACM0 can0

now I wonder where to place this (without the sudo…)?

I found no services in /etc/systemd/system/ - where are the systemd start scripts in Venus OS? {edit: ok -sh: systemctl: command not found so this seems to be no option…}

What I found is /run/service/can-bus-bms.can0/run:

#!/bin/sh
echo "*** starting can-bus-bms ***"
exec 2>&1
exec softlimit -d 100000000 -s 1000000 -a 100000000 /opt/victronenergy/can-bus-bms/can-bus-bms --log-before 25 --log-after 25 -vv -c socketcan:can0 --banner

should I insert the slcand start command there?

any better way? any further advice?!

thank you & greetings!
Phil

Hi,

Anthing that it’s placed in /opt/victronenergy/service is copied at boot to /service and run.

Or maybe I didn’t understand what you need?..

hi Alex, happy new year! :slight_smile:

the slcand is a program that emulates a socketCAN and bidirectionally forwards the slcan ‘data’. To operate a slcan adapter/device with Venus OS, this is required since Venus assumes a socketCAN can0.

So I need to start that program before the can-bus-bms gets executed.

but (I just realized that) this requires also the slcan kernel module. This can get loaded by mudprobe, but I’m afraid it doesn’t get loaded by default? So another thing I would need to ‘manipulate’. I think the better solution is to take 8€ and buy a CANable V1 adapter… This works with Venus ‘out of the box’, doesn’t it?

Happy New Year!

Probably it’s better to stick with working and documented things… :slight_smile:

hm, I can’t keep my finger of… :wink:

@alexpescaru could you please explain “Anthing that it’s placed in /opt/victronenergy/service is copied at boot to /service and run.”?!

In /opt/victronenergy/service there is nothing regarding can-bus-bms. in /opt/victronenergy there is a folder /can-bus-bms containing (obviously) a binary ‘run’.

Starting the system with my ‘old expensive’ socketCAN adapter, the folder /run/service/can-bus-bms.can0/ gets created, containing the run bash script (see above) and 2 sub-folders /log and /supervise.

How does the start mechanism work in detail?

What do I have to do to modprobe slcan and exec slcand -o -c -s6 /dev/ttyACM0 can0 at boot before the can-bus-bms gets ‘executed’?

I believe for CAN ports the run files/scripts are taken from /opt/victronenergy/service-templates
As per your other questions, I don’t have a definitive answer for you as at this moment I am quite rookie on linux too… :blush:

ok, thank you!

just adding the two lines

exec modprobe slcan
exec slcand -o -c -s6 /dev/ttyACM0 can0

to the template did not work. If I do them ‘manually’ after boot, the can0 receives the packages from the bms. But Venus does not answer and accordingly the BMS doesn’t show up in the console…

Unfortunately this startup-at-boot mechanism is not really Linux-like. On my bookworm raspi I managed to get the adapter running using systemctl script etc…

ok, got it running :slight_smile:

solution is to create /data/rc.local and add slcand -o -c -s6 /dev/ttyACM0 can0 to it.
That’s it. In fact this is quite Linux-like.

1 Like