Created
October 19, 2014 20:29
-
-
Save matt448/df7b09cbe606aab6fd73 to your computer and use it in GitHub Desktop.
Script to start can bus interface on a Beagle Bone Black
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
#!/bin/bash | |
re='^[0-9]+$' | |
if ! [[ $1 =~ $re ]] ; then | |
echo -e "ERROR: Can bus bitrate not a number or a value wasn't entered.\n\nPlease enter a speed in Kbit/s\n\n Example: canbus_start.sh 100\n Speeds: 100,125,250,500\n" >&2; exit 1 | |
fi | |
echo Bitrate: ${1}Kbit/s | |
sudo modprobe can | |
sudo modprobe can-dev | |
sudo modprobe can-raw | |
sudo ip link set can0 up type can bitrate ${1}000 | |
sudo ifconfig can0 up |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment