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.
This commit is contained in:
Jef Driesen 2015-05-03 22:41:15 +02:00
parent ecd20ffb4c
commit 23acddbe08
3 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}