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 little endian
: byte[offset] : byte[offset*32]
Magic : byte[1] Magic : byte[1]
WorkoutType : uint8 WorkoutType : uint8
: byte[10] : 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 HeaderSPM : uint8
: byte[1] : byte[1]
HeaderSplitSize : uint16 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" accTable="LogDataAccessTbl.bin"
storage="LogDataStorage.bin" storage="LogDataStorage.bin"
function assignVariables { assignVariables='while read -r line; do typeset -x "$line"; done <<< '
while read -r line; do
typeset -g "$line" function printNonEmpty {
done <<< "$1" varname='$'"$1"
eval "val=$varname"
if [ "$val" != "" ]; then
echo "$1=$val"
fi
} }
i=0 function printSplit {
while : ; do outputSplit="$($cmd -nopadding -fvar=offset=$1,splitNo=$2 $storage-Workout$3.layhex $storage 2> /dev/null)"
offset=$(($i*32)) status=$?
if [ $status -eq 0 ]; then
eval "$assignVariables $outputSplit"
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
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)" output="$($cmd -nopadding -fvar=offset=$offset $accTable.layhex $accTable 2>/dev/null)"
status=$? status=$?
if [ $status -ne 0 ]; then if [ $status -ne 0 ]; then
break break
else else
assignVariables "$output" eval "$assignVariables $output"
echo "Workout $Index" printWorkout $Index $Offset $WorkoutType
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
fi fi
i=$((i+1)) i=$((i+1))
done done
}
printAll