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.

Revisions

  1. matt448 created this gist Oct 19, 2014.
    14 changes: 14 additions & 0 deletions canbus_start.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    #!/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