diff options
Diffstat (limited to 'recipes-connectivity/kuksa-val/can-dev-helper')
-rw-r--r-- | recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.service | 10 | ||||
-rw-r--r-- | recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.sh | 33 |
2 files changed, 43 insertions, 0 deletions
diff --git a/recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.service b/recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.service new file mode 100644 index 000000000..04e6a9c35 --- /dev/null +++ b/recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.service @@ -0,0 +1,10 @@ +[Unit] +Description=CAN interface helper +Before=kuksa-dbc-feeder.service + +[Service] +ExecStart=/usr/sbin/can-dev-helper.sh +Type=oneshot + +[Install] +WantedBy=multi-user.target diff --git a/recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.sh b/recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.sh new file mode 100644 index 000000000..de9894d76 --- /dev/null +++ b/recipes-connectivity/kuksa-val/can-dev-helper/can-dev-helper.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# +# Script to bring up CAN interface configured for the kuksa.val +# CAN feeder in /etc/kuksa-dbc-feeder/dbc_feeder.ini as vcan +# interfaces if no physical interface is present. +# + +vcan_up() { + if [ -n "$1" ]; then + echo "Bringing up $1 as virtual CAN device" + ip link add dev $1 type vcan + ip link set up $1 + fi +} + +CONF=/etc/kuksa-dbc-feeder/config.ini + +if [ ! -f $CONF ]; then + exit 0 +fi + +# Ideally the parsing would take the "[can]" section into +# account, but this should work for now. +interface=$(grep ^port= $CONF |cut -d= -f2 |tr -d '"') +if [ -n "$interface" ]; then + echo "Checking $interface" + if ! ifconfig $interface >/dev/null 2>&1; then + vcan_up $interface + fi +fi + +exit 0 |