From df77a0b33ef225c1dc7b2ddd7564c44228416f05 Mon Sep 17 00:00:00 2001 From: gutmet Date: Thu, 30 Apr 2020 16:30:26 +0200 Subject: [PATCH] if hackish then hackish --- .../PM5/LogDataStorage.bin-Workout1.layhex | 18 +++++++++--------- Sports/Concept2/PM5/pm5conv.bash | 17 ++++++++--------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Sports/Concept2/PM5/LogDataStorage.bin-Workout1.layhex b/Sports/Concept2/PM5/LogDataStorage.bin-Workout1.layhex index 7579087..71184aa 100644 --- a/Sports/Concept2/PM5/LogDataStorage.bin-Workout1.layhex +++ b/Sports/Concept2/PM5/LogDataStorage.bin-Workout1.layhex @@ -1,19 +1,19 @@ big endian : byte[offset] -HeaderMagic : byte[1] + : byte[1] : byte[1] : byte[2] : byte[4] -HeaderTimestamp : byte[4] -HeaderUserID : uint16 +Timestamp : byte[4] +UserID : uint16 : byte[4] -HeaderRecordID : uint8 -HeaderMagic2 : byte[3] -HeaderTotalDuration : uint16 -HeaderTotalDistance : uint32 -HeaderSPM : uint8 +RecordID : uint8 + : byte[3] +TotalDuration : uint16 +TotalDistance : uint32 +SPM : uint8 : byte[1] -HeaderSplitSize : uint16 +SplitSize : uint16 : byte[18] : byte[splitNo*32] SplitDistance : uint16 diff --git a/Sports/Concept2/PM5/pm5conv.bash b/Sports/Concept2/PM5/pm5conv.bash index 63fde14..cf23261 100755 --- a/Sports/Concept2/PM5/pm5conv.bash +++ b/Sports/Concept2/PM5/pm5conv.bash @@ -5,7 +5,7 @@ cmd="laymanshex" accTable="LogDataAccessTbl.bin" storage="LogDataStorage.bin" -assignVariables='while read -r line; do typeset -x "$line"; done <<< ' +# uses evil eval function printNonEmpty { varname='$'"$1" @@ -19,7 +19,7 @@ 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" + eval "$outputSplit" echo echo "Split $(($2+1))" echo "----------" @@ -36,11 +36,11 @@ function printWorkout { 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" + eval "$outputHeader" + printNonEmpty "TotalDuration" + printNonEmpty "TotalDistance" + printNonEmpty "SplitSize" + printNonEmpty "SPM" j=0 while [ "$j" -lt "$NoSplits" ]; do printSplit $2 $j $3 @@ -50,7 +50,6 @@ function printWorkout { fi } - function printAll { i=0 while : ; do @@ -60,7 +59,7 @@ function printAll { if [ $status -ne 0 ]; then break else - eval "$assignVariables $output" + eval "$output" printWorkout $Index $Offset $WorkoutType fi i=$((i+1))