Skip to content

Instantly share code, notes, and snippets.

@alepez
Created March 3, 2021 11:17
Show Gist options
  • Save alepez/5873a3ee57dbb977ff414d7cec666ac4 to your computer and use it in GitHub Desktop.
Save alepez/5873a3ee57dbb977ff414d7cec666ac4 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 2>/dev/null
}
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