From 10edb943fffe8495d4e39a5f980b469168dbcae7 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 23 Feb 2010 13:43:57 +0000 Subject: [PATCH] Fix the HelO2 fingerprint, datetime and sample interval offsets. --- src/suunto_common2.c | 8 ++++++-- src/suunto_d9_parser.c | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/suunto_common2.c b/src/suunto_common2.c index 058091e..18c55f1 100644 --- a/src/suunto_common2.c +++ b/src/suunto_common2.c @@ -377,10 +377,14 @@ suunto_common2_device_foreach (device_t *abstract, dive_callback_t callback, voi previous = current; current = prev; - if (memcmp (p + FP_OFFSET, device->fingerprint, sizeof (device->fingerprint)) == 0) + unsigned int fp_offset = FP_OFFSET; + if (devinfo.model == 0x15) + fp_offset += 6; // HelO2 + + if (memcmp (p + fp_offset, device->fingerprint, sizeof (device->fingerprint)) == 0) return DEVICE_STATUS_SUCCESS; - if (callback && !callback (p + 4, size - 4, p + FP_OFFSET, sizeof (device->fingerprint), userdata)) + if (callback && !callback (p + 4, size - 4, p + fp_offset, sizeof (device->fingerprint), userdata)) return DEVICE_STATUS_SUCCESS; } diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index 9918cdf..e6b620b 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -112,10 +112,16 @@ suunto_d9_parser_set_data (parser_t *abstract, const unsigned char *data, unsign static parser_status_t suunto_d9_parser_get_datetime (parser_t *abstract, dc_datetime_t *datetime) { - if (abstract->size < 0x15 - 4 + 7) + suunto_d9_parser_t *parser = (suunto_d9_parser_t*) abstract; + + unsigned int offset = 0x15 - 4; + if (parser->model == 0x15) + offset += 6; // HelO2 + + if (abstract->size < offset + 7) return PARSER_STATUS_ERROR; - const unsigned char *p = abstract->data + 0x15 - 4; + const unsigned char *p = abstract->data + offset; if (datetime) { datetime->hour = p[0]; @@ -159,7 +165,10 @@ suunto_d9_parser_samples_foreach (parser_t *abstract, sample_callback_t callback assert (profile + 5 <= size); // Sample recording interval. - unsigned int interval_sample = data[0x1C - SKIP]; + unsigned int interval_sample_offset = 0x1C - SKIP; + if (parser->model == 0x15) + interval_sample_offset += 6; // HelO2 + unsigned int interval_sample = data[interval_sample_offset]; assert (interval_sample > 0); // Temperature recording interval.