Skip to content

Instantly share code, notes, and snippets.

@mhaberler
Created May 3, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhaberler/eef30dd73aa7b326b8b3 to your computer and use it in GitHub Desktop.
Save mhaberler/eef30dd73aa7b326b8b3 to your computer and use it in GitHub Desktop.
making USBtin work with wheezy boot-time
# add this file to /etc/udev/rules.d:
# 04d8:000a USBtin
KERNEL=="ttyACM*", ATTRS{idVendor}=="04d8", ATTRS{idProduct}=="000a",SYMLINK+="USBtin%n" ,RUN+="/usr/local/bin/slcan.sh /dev/%k can%n"
# store this file in /usr/local/bin and chmod 755 it
#!/bin/sh
DEVICE=$1
CANIF=$2
PATH=/bin:/usr/bin:/sbin:/usr/sbin
ATTACH=/usr/local/bin/slcan_attach
DAEMON=/usr/local/bin/slcand
PIDFILE=/var/run/slcand.${CANIF}.pid
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
case "$ACTION" in
add)
log_daemon_msg "Starting CAN interface $CANIF on $DEVICE"
#$ATTACH -f -o -c -s8 $DEVICE
start_daemon -p $PIDFILE $DAEMON -f -o -c -s8 $DEVICE $CANIF
sleep 1
ip link set $CANIF up type can
sleep 1
ifconfig $CANIF up
log_end_msg $?
;;
remove)
log_daemon_msg "Stopping CAN interface $CANIF on $DEVICE" "can"
#ip link set $CANIF down type can
ifconfig $CANIF down
kill `ps ax|grep slcand|grep $CANIF|awk '{print $1}'`
log_end_msg $?
;;
*)
echo "Usage: /etc/init.d/slcan {add|remove} device interface"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment