Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: UAVCAN UAVCAN_Subscriber
Diff: libuavcan_drivers/linux/scripts/uavcan_add_vcan
- Revision:
- 0:dfe6edabb8ec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libuavcan_drivers/linux/scripts/uavcan_add_vcan Sat Apr 14 10:25:32 2018 +0000 @@ -0,0 +1,37 @@ +#!/bin/bash +# +# Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com> +# + +HELP="Initializes and brings up a virtual CAN interface. +Usage: + `basename $0` <iface-name> +Example: + `basename $0` vcan0" + +function die() { echo $@ >&2; exit 1; } + +if [ "$1" == '--help' ] || [ "$1" == '-h' ]; then echo "$HELP"; exit; fi +[ -n "$1" ] || die "Invalid usage. Use --help to get help." +[ "$(id -u)" == "0" ] || die "Must be root" + +# --------------------------------------------------------- + +IFACE="$1" + +if [ $(ifconfig -a | grep -c "^$IFACE") -eq "1" ]; then + ifconfig $IFACE up + exit +fi + +modprobe can +modprobe can_raw +modprobe can_bcm +modprobe vcan + +ip link add dev $IFACE type vcan +ip link set up $IFACE + +ifconfig $IFACE up || exit 1 + +echo "New iface $IFACE added successfully. To delete: ip link delete $IFACE"