From 23acddbe08a607bf224032433650128eb6b9ca14 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 3 May 2015 22:41:15 +0200 Subject: [PATCH] Eliminate ghost events caused by unknown events. The newest Suunto models (e.g. D4i, D6i, D9tx and DX) support a few additional events (type 0x15 and higher), which are not supported yet because their interpretation isn't known. Due to a nasty bug, these unkown events result in "ghost" events. When such an unknown event is encountered, the sample type field isn't set explicitely. Therefore it simply retains the value from the previous sample, whatever that might be. If the previous sample happens to be an event as well, then the unknown event will show up as a duplicate event. But if the previous sample is not an event, then the resulting event type is undefined. This is fixed by always resetting the event type explicitely. Those unknown events are also suppressed now and no longer delivered to the application. Allthough I haven't observed this bug with the Suunto Eon and Vyper, they could be affected too. --- src/suunto_d9_parser.c | 5 ++++- src/suunto_eon_parser.c | 5 ++++- src/suunto_vyper_parser.c | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index 939dab6..e71a60f 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -502,6 +502,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca unsigned int he, o2; unsigned int length; + sample.event.type = SAMPLE_EVENT_NONE; sample.event.time = 0; sample.event.flags = 0; sample.event.value = 0; @@ -634,7 +635,9 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca else sample.event.flags = SAMPLE_FLAGS_BEGIN; sample.event.time = seconds; - if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + if (sample.event.type != SAMPLE_EVENT_NONE) { + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + } offset += 2; break; case 0x04: // Bookmark/Heading diff --git a/src/suunto_eon_parser.c b/src/suunto_eon_parser.c index f89fe2a..534b847 100644 --- a/src/suunto_eon_parser.c +++ b/src/suunto_eon_parser.c @@ -292,6 +292,7 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c complete = 1; } else { // Event. + sample.event.type = SAMPLE_EVENT_NONE; sample.event.time = 0; sample.event.flags = 0; sample.event.value = 0; @@ -313,7 +314,9 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c break; } - if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + if (sample.event.type != SAMPLE_EVENT_NONE) { + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + } } } diff --git a/src/suunto_vyper_parser.c b/src/suunto_vyper_parser.c index c0618e8..910670f 100644 --- a/src/suunto_vyper_parser.c +++ b/src/suunto_vyper_parser.c @@ -346,6 +346,7 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t complete = 1; } else { // Event. + sample.event.type = SAMPLE_EVENT_NONE; sample.event.time = 0; sample.event.flags = 0; sample.event.value = 0; @@ -382,7 +383,9 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t break; } - if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + if (sample.event.type != SAMPLE_EVENT_NONE) { + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + } } }