Skip to content

Instantly share code, notes, and snippets.

@matt448
Created October 19, 2014 20:29
Show Gist options
  • Save matt448/df7b09cbe606aab6fd73 to your computer and use it in GitHub Desktop.
Save matt448/df7b09cbe606aab6fd73 to your computer and use it in GitHub Desktop.
Script to start can bus interface on a Beagle Bone Black
#!/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