From adca720d6234a4108ceed8e3aedb594eb895ee1e Mon Sep 17 00:00:00 2001 From: Damien Date: Mon, 2 Dec 2013 18:02:29 +0100 Subject: [PATCH 1/2] FitRideFile: Correction for last Garmin firmware updates In last Garmin firmware there is some (unknow) fields with multiples values Fixes #724 --- src/FitRideFile.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/FitRideFile.cpp b/src/FitRideFile.cpp index 25ea7b0d6..ca65549ba 100644 --- a/src/FitRideFile.cpp +++ b/src/FitRideFile.cpp @@ -624,23 +624,28 @@ struct FitFileReaderState std::vector values; foreach(const FitField &field, def.fields) { fit_value_t v; + int size; switch (field.type) { - case 0: v = read_uint8(&count); break; - case 1: v = read_int8(&count); break; - case 2: v = read_uint8(&count); break; - case 3: v = read_int16(def.is_big_endian, &count); break; - case 4: v = read_uint16(def.is_big_endian, &count); break; - case 5: v = read_int32(def.is_big_endian, &count); break; - case 6: v = read_uint32(def.is_big_endian, &count); break; - case 10: v = read_uint8z(&count); break; - case 11: v = read_uint16z(def.is_big_endian, &count); break; - case 12: v = read_uint32z(def.is_big_endian, &count); break; + case 0: v = read_uint8(&count); size = 1; break; + case 1: v = read_int8(&count); size = 1; break; + case 2: v = read_uint8(&count); size = 1; break; + case 3: v = read_int16(def.is_big_endian, &count); size = 2; break; + case 4: v = read_uint16(def.is_big_endian, &count); size = 2; break; + case 5: v = read_int32(def.is_big_endian, &count); size = 4; break; + case 6: v = read_uint32(def.is_big_endian, &count); size = 4; break; + case 10: v = read_uint8z(&count); size = 1; break; + case 11: v = read_uint16z(def.is_big_endian, &count); size = 2; break; + case 12: v = read_uint32z(def.is_big_endian, &count); size = 4; break; // we may need to add support for float, string + byte base types here default: read_unknown( field.size, &count ); v = NA_VALUE; unknown_base_type.insert(field.num); } + // Quick fix : we need to support multivalues + if (size < field.size) + read_unknown( field.size-size, &count ); + values.push_back(v); //printf( " field: type=%d num=%d value=%lld\n", // field.type, field.num, v ); From 6c21c87a42a911800d2be4997bdf9199fc1d8ec3 Mon Sep 17 00:00:00 2001 From: Jon Escombe Date: Mon, 2 Dec 2013 23:21:19 +0000 Subject: [PATCH 2/2] Don't reset ANT channel settings on search timeout Wiping out these settings prevents a successful reconnection of the device if it comes back into range Fixes #514 --- src/ANTChannel.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ANTChannel.cpp b/src/ANTChannel.cpp index 6bd7b1635..3d4ddc73e 100644 --- a/src/ANTChannel.cpp +++ b/src/ANTChannel.cpp @@ -174,11 +174,13 @@ void ANTChannel::channelEvent(unsigned char *ant_message) { emit lostInfo(number); - channel_type=CHANNEL_TYPE_UNUSED; - channel_type_flags=0; - device_number=0; - value2=value=0; - setId(); + // Don't wipe out the channel settings when the search times out, + // else can not reconnect to the device once back in range.. + //channel_type=CHANNEL_TYPE_UNUSED; + //channel_type_flags=0; + //device_number=0; + //value2=value=0; + //setId(); parent->sendMessage(ANTMessage::unassignChannel(number)); }