From aebb6d04c8374547bdbe3990385f802ff4381b09 Mon Sep 17 00:00:00 2001 From: gutmet Date: Tue, 28 Apr 2020 22:44:24 +0200 Subject: [PATCH] Concept2 PM5 definitions and bash glue --- .../Concept2/PM5/LogDataAccessTbl.bin.layhex | 13 +++++ .../LogDataStorage.bin-FrameWorkout1.layhex | 6 +++ .../LogDataStorage.bin-HeaderWorkout1.layhex | 16 +++++++ Sports/Concept2/PM5/pm5conv.bash | 48 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex create mode 100644 Sports/Concept2/PM5/LogDataStorage.bin-FrameWorkout1.layhex create mode 100644 Sports/Concept2/PM5/LogDataStorage.bin-HeaderWorkout1.layhex create mode 100755 Sports/Concept2/PM5/pm5conv.bash diff --git a/Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex b/Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex new file mode 100644 index 0000000..661d8c2 --- /dev/null +++ b/Sports/Concept2/PM5/LogDataAccessTbl.bin.layhex @@ -0,0 +1,13 @@ +little endian + : byte[offset] +Magic : byte[1] +WorkoutType : uint8 + : byte[10] +NoSplits : uint16 + : byte[2] +Offset : uint16 + : byte[6] +Size : uint16 +Index : uint16 + : byte[4] +Marker : byte[32] diff --git a/Sports/Concept2/PM5/LogDataStorage.bin-FrameWorkout1.layhex b/Sports/Concept2/PM5/LogDataStorage.bin-FrameWorkout1.layhex new file mode 100644 index 0000000..61e7144 --- /dev/null +++ b/Sports/Concept2/PM5/LogDataStorage.bin-FrameWorkout1.layhex @@ -0,0 +1,6 @@ +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-HeaderWorkout1.layhex new file mode 100644 index 0000000..9ae73e2 --- /dev/null +++ b/Sports/Concept2/PM5/LogDataStorage.bin-HeaderWorkout1.layhex @@ -0,0 +1,16 @@ +big endian + : byte[offset] +HeaderMagic : byte[1] + : byte[1] + : byte[2] + : byte[4] +HeaderTimestamp : byte[4] +HeaderUserID : uint16 + : byte[4] +HeaderRecordID : uint8 +HeaderMagic2 : byte[3] +HeaderTotalDuration : uint16 +HeaderTotalDistance : uint32 +HeaderSPM : uint8 + : byte[1] +HeaderSplitSize : uint16 diff --git a/Sports/Concept2/PM5/pm5conv.bash b/Sports/Concept2/PM5/pm5conv.bash new file mode 100755 index 0000000..72c362d --- /dev/null +++ b/Sports/Concept2/PM5/pm5conv.bash @@ -0,0 +1,48 @@ +#!/bin/bash + +cmd="/home/alexander/Spielewiese/laymanshex/laymanshex" + +accTable="LogDataAccessTbl.bin" +storage="LogDataStorage.bin" + +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 + while read -r line; do + typeset -x "$line" + done <<< "$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 + while read -r line; do + typeset -x "$line" + done <<< $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 + i=$((i+1)) +done