Skip to content

Instantly share code, notes, and snippets.

@alepez
Created July 31, 2019 08:53
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 alepez/c43a3498447dbce9e4b084a645ccc639 to your computer and use it in GitHub Desktop.
Save alepez/c43a3498447dbce9e4b084a645ccc639 to your computer and use it in GitHub Desktop.
nmea2kutils
#!/bin/bash
init() {
ip link set can0 type can bitrate 250000
ip link set can0 up
}
rawdump() {
candump can0
}
dump() {
rawdump | candump2analyzer
}
live_analyze() {
dump | analyzer
}
live_json() {
dump | analyzer -json
}
dump_write() {
socketcan-writer can0
}
help() {
cat <<EOF
help: show this help
init: initialize network (needs root permissions)
rawdump: print canbus raw data
dump: print canbus partially analyzed data with timestamp
analyze: convert dump format (from stdin) to human readable data
live_analyze: show human readable data directly from network
live_json: show json data directly from network
EOF
}
case $1 in
init) init;;
rawdump) rawdump;;
dump) dump;;
analyze) analyzer;;
live_analyze) live_analyze;;
live_json) live_json;;
dump_write) dump_write;;
*) help;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment