pm5: simplified and structured

This commit is contained in:
gutmet 2020-04-30 16:07:19 +02:00
parent a80bd12e4a
commit 1b339ae6d0
4 changed files with 67 additions and 47 deletions

View File

@ -1,5 +1,5 @@
little endian
: byte[offset]
: byte[offset*32]
Magic : byte[1]
WorkoutType : uint8
: byte[10]

View File

@ -1,6 +0,0 @@
big endian
: byte[offset]
SplitDistance : uint16
SplitHeartRate : uint8
SplitSPM : uint8
: byte[28]

View File

@ -14,3 +14,9 @@ HeaderTotalDistance : uint32
HeaderSPM : uint8
: byte[1]
HeaderSplitSize : uint16
: byte[18]
: byte[splitNo*32]
SplitDistance : uint16
SplitHeartRate : uint8
SplitSPM : uint8
: byte[28]

View File

@ -5,46 +5,66 @@ cmd="laymanshex"
accTable="LogDataAccessTbl.bin"
storage="LogDataStorage.bin"
function assignVariables {
while read -r line; do
typeset -g "$line"
done <<< "$1"
assignVariables='while read -r line; do typeset -x "$line"; done <<< '
function printNonEmpty {
varname='$'"$1"
eval "val=$varname"
if [ "$val" != "" ]; then
echo "$1=$val"
fi
}
i=0
while : ; do
offset=$(($i*32))
output="$($cmd -nopadding -fvar=offset=$offset $accTable.layhex $accTable 2>/dev/null)"
status=$?
if [ $status -ne 0 ]; then
break
else
assignVariables "$output"
echo "Workout $Index"
echo "============="
outputHeader="$($cmd -nopadding -fvar=offset=$Offset $storage-HeaderWorkout$WorkoutType.layhex $storage 2>/dev/null)"
status=$?
if [ $status -eq 0 ]; then
assignVariables "$outputHeader"
echo "TotalDuration=$HeaderTotalDuration"
echo "TotalDistance=$HeaderTotalDistance"
echo "SplitSize=$HeaderSplitSize"
echo "SPM=$HeaderSPM"
j=0
while [ "$j" -lt "$NoSplits" ]; do
splitOffset=$((Offset+50+j*32))
outputSplit="$($cmd -nopadding -fvar=offset=$splitOffset $storage-FrameWorkout$WorkoutType.layhex $storage 2>/dev/null)"
status=$?
if [ $status -eq 0 ]; then
echo
echo "Split $((j+1))"
echo "----------"
echo "$outputSplit"
fi
j=$((j+1))
done
echo
fi
function printSplit {
outputSplit="$($cmd -nopadding -fvar=offset=$1,splitNo=$2 $storage-Workout$3.layhex $storage 2> /dev/null)"
status=$?
if [ $status -eq 0 ]; then
eval "$assignVariables $outputSplit"
echo
echo "Split $(($2+1))"
echo "----------"
printNonEmpty "SplitDuration"
printNonEmpty "SplitDistance"
printNonEmpty "SplitHeartRate"
printNonEmpty "SplitSPM"
fi
i=$((i+1))
done
}
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
eval "$assignVariables $outputHeader"
printNonEmpty "HeaderTotalDuration"
printNonEmpty "HeaderTotalDistance"
printNonEmpty "HeaderSplitSize"
printNonEmpty "HeaderSPM"
j=0
while [ "$j" -lt "$NoSplits" ]; do
printSplit $2 $j $3
j=$((j+1))
done
echo
fi
}
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
eval "$assignVariables $output"
printWorkout $Index $Offset $WorkoutType
fi
i=$((i+1))
done
}
printAll