Created
May 3, 2015 13:29
-
-
Save mhaberler/eef30dd73aa7b326b8b3 to your computer and use it in GitHub Desktop.
making USBtin work with wheezy boot-time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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