laymanshex-files/Sports/Concept2/PM5/pm5conv.bash

81 lines
1.8 KiB
Bash
Raw Permalink Normal View History

2020-04-28 22:44:24 +02:00
#!/bin/bash
cmd="laymanshex"
2020-04-28 22:44:24 +02:00
accTable="LogDataAccessTbl.bin"
storage="LogDataStorage.bin"
2020-04-30 16:30:26 +02:00
# uses evil eval
2020-04-30 16:07:19 +02:00
function printNonEmpty {
varname='$'"$1"
eval "val=$varname"
if [ "$val" != "" ]; then
echo "$1=$val"
fi
}
2020-04-30 19:43:31 +02:00
function printTimestamp {
timestamp="0x$1"
year="$(( ((timestamp & 0xFE000000) >> 25) + 2000 ))"
2020-04-30 20:37:33 +02:00
day="$(( (timestamp & 0x01F00000) >> 20 ))"
2020-04-30 19:43:31 +02:00
month="$(( (timestamp & 0x000F0000) >> 16 ))"
hour="$(( (timestamp & 0x0000FF00) >> 8 ))"
minute="$(( timestamp & 0x000000FF ))"
2020-04-30 19:47:22 +02:00
printf "Date=%d-%02d-%02d %02d:%02d\n" $year $month $day $hour $minute
2020-04-30 19:43:31 +02:00
}
2020-04-30 16:07:19 +02:00
function printSplit {
outputSplit="$($cmd -nopadding -fvar=offset=$1,splitNo=$2 $storage-Workout$3.layhex $storage 2> /dev/null)"
status=$?
if [ $status -eq 0 ]; then
2020-04-30 16:30:26 +02:00
eval "$outputSplit"
2020-04-30 16:07:19 +02:00
echo
echo "Split $(($2+1))"
echo "----------"
printNonEmpty "SplitDuration"
printNonEmpty "SplitDistance"
printNonEmpty "SplitHeartRate"
printNonEmpty "SplitSPM"
fi
}
function printWorkout {
echo "Workout $1"
echo "============="
outputHeader="$($cmd -nopadding -fvar=offset=$2,splitNo=0 $storage-Workout$3.layhex $storage 2> /dev/null)"
status=$?
if [ $status -eq 0 ]; then
2020-04-30 16:30:26 +02:00
eval "$outputHeader"
2020-04-30 19:43:31 +02:00
printTimestamp "$Timestamp"
2020-04-30 16:30:26 +02:00
printNonEmpty "TotalDuration"
printNonEmpty "TotalDistance"
printNonEmpty "SplitSize"
printNonEmpty "SPM"
2020-04-30 16:07:19 +02:00
j=0
while [ "$j" -lt "$NoSplits" ]; do
printSplit $2 $j $3
j=$((j+1))
done
echo
2020-04-28 22:44:24 +02:00
fi
2020-04-30 16:07:19 +02:00
}
function printAll {
i=0
while : ; do
offset=$(($i))
output="$($cmd -nopadding -fvar=offset=$offset $accTable.layhex $accTable 2>/dev/null)"
status=$?
if [ $status -ne 0 ]; then
break
else
2020-04-30 16:30:26 +02:00
eval "$output"
2020-04-30 16:07:19 +02:00
printWorkout $Index $Offset $WorkoutType
fi
i=$((i+1))
done
}
printAll