Skip to content

Instantly share code, notes, and snippets.

@mrworf
Created December 1, 2016 18:23
Show Gist options
  • Save mrworf/1a89b248fcd9b3b883f864d72e8f9691 to your computer and use it in GitHub Desktop.
Save mrworf/1a89b248fcd9b3b883f864d72e8f9691 to your computer and use it in GitHub Desktop.
Takes a unpacked ISY994 backup and scans it for odd Device Links. Requires Linux or OSX
#!/bin/bash
# 1 = Filename
# 2 = Record (starting from 0)
function getrecord()
{
BASE=$((180 + $2 * 8))
hexdump -v -s $BASE -n 8 -e '8/1 "%02x " "\n"' $1
}
# 1 = Device Id (XX XX XX)
function finddev()
{
DEVID="$(echo "$1" | tr '[:lower:]' '[:upper:]')"
for D in *.UND; do
ID="$(hexdump -v -s 11 -n 8 -e '"%c"' $D)"
if [ "$ID" = "$DEVID" ]; then
hexdump -v -s 31 -n 31 -e '"%c"' $D
return
fi
done
echo "NOT FOUND -$DEVID-"
}
FILE=$1
HIDE=$2
HIDE=${HIDE:=false}
I=0
TYPE=""
DEV="$(finddev "${1:0:2} ${1:2:2} ${1:4:2}")"
while [ "$TYPE" != "00" ]; do
REC=$(getrecord $FILE $I)
TYPE="${REC:0:2}"
case "$TYPE" in
e2|a2|22|02|00)
if ! $HIDE ; then
printf "%02d: %s - OK\n" $I "$REC"
fi
;;
*)
TRANSLATE=$(finddev "${REC:6:8}")
printf "%02d: %s - UNKNOWN "%s" -> "%s" (%s)\n" $I "$REC" "$DEV" "$TRANSLATE" "$FILE"
;;
esac
I=$(($I+1))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment