Report the initial gas mix.

The Suunto dive computers record gas change events in the profile data.
But because there is no gas change event stored on the first sample, the
application doesn't know which gas mix is in use, until the very first
gas change event occurs.

For the Suunto HelO2, the index of the initial gas mix is stored in the
dive header. This is most likely also the case for the other models, but
I haven't found yet where exactly it is stored. As a temporary solution,
we simply assume the initial gas mix is the first gas in the list with
available gas mixes. This should be a reasonable assumption for most
dives.

Fixes ticket #2
This commit is contained in:
Jef Driesen 2014-02-17 08:49:04 +01:00
parent d8ccfd928b
commit ede9469316

View File

@ -335,6 +335,16 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
if (rc != DC_STATUS_SUCCESS)
return rc;
// Initial gasmix.
unsigned int gasmix = 0;
if (parser->model == HELO2) {
gasmix = data[0x26];
}
if (gasmix >= parser->ngasmixes) {
ERROR (abstract->context, "Invalid initial gas mix.");
return DC_STATUS_DATAFORMAT;
}
// Number of parameters in the configuration data.
unsigned int nparams = data[parser->config];
if (nparams == 0 || nparams > MAXPARAMS)
@ -433,6 +443,23 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
}
}
// Initial gasmix.
if (time == 0) {
unsigned int he = 0;
unsigned int o2 = 0;
if (parser->mode == AIR) {
he = 0;
o2 = 21;
} else {
he = parser->helium[gasmix];
o2 = parser->oxygen[gasmix];
}
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
}
// Events
if ((nsamples + 1) == marker) {
while (offset < size) {