diff --git a/Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex b/Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex index 661d8c2..69df2a6 100644 --- a/Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex +++ b/Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex @@ -1,5 +1,5 @@ little endian - : byte[offset] + : byte[offset*32] Magic : byte[1] WorkoutType : uint8 : byte[10] diff --git a/Sports/Concept2/PM5/LogDataStorage.bin-FrameWorkout1.layhex b/Sports/Concept2/PM5/LogDataStorage.bin-FrameWorkout1.layhex deleted file mode 100644 index 61e7144..0000000 --- a/Sports/Concept2/PM5/LogDataStorage.bin-FrameWorkout1.layhex +++ /dev/null @@ -1,6 +0,0 @@ -big endian - : byte[offset] -SplitDistance : uint16 -SplitHeartRate : uint8 -SplitSPM : uint8 - : byte[28] diff --git a/Sports/Concept2/PM5/LogDataStorage.bin-HeaderWorkout1.layhex b/Sports/Concept2/PM5/LogDataStorage.bin-Workout1.layhex similarity index 71% rename from Sports/Concept2/PM5/LogDataStorage.bin-HeaderWorkout1.layhex rename to Sports/Concept2/PM5/LogDataStorage.bin-Workout1.layhex index 9ae73e2..7579087 100644 --- a/Sports/Concept2/PM5/LogDataStorage.bin-HeaderWorkout1.layhex +++ b/Sports/Concept2/PM5/LogDataStorage.bin-Workout1.layhex @@ -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] diff --git a/Sports/Concept2/PM5/pm5conv.bash b/Sports/Concept2/PM5/pm5conv.bash index d53c0f6..63fde14 100755 --- a/Sports/Concept2/PM5/pm5conv.bash +++ b/Sports/Concept2/PM5/pm5conv.bash @@ -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