Take the CCR diluents into account
The Suunto DX supports 3 CCR diluents and 8 OC gas mixes. Since the gas mix index in the data is relative to either the set of CCR diluents or OC gas mixes (depending on the dive mode) and libdivecomputer reports both sets, the index needs to be adjusted.
This commit is contained in:
parent
6867ffb143
commit
8a70885f89
@ -77,6 +77,7 @@ struct suunto_d9_parser_t {
|
|||||||
unsigned int id;
|
unsigned int id;
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
unsigned int ngasmixes;
|
unsigned int ngasmixes;
|
||||||
|
unsigned int nccr;
|
||||||
unsigned int oxygen[NGASMIXES];
|
unsigned int oxygen[NGASMIXES];
|
||||||
unsigned int helium[NGASMIXES];
|
unsigned int helium[NGASMIXES];
|
||||||
unsigned int gasmix;
|
unsigned int gasmix;
|
||||||
@ -109,7 +110,7 @@ static unsigned int
|
|||||||
suunto_d9_parser_find_gasmix (suunto_d9_parser_t *parser, unsigned int o2, unsigned int he)
|
suunto_d9_parser_find_gasmix (suunto_d9_parser_t *parser, unsigned int o2, unsigned int he)
|
||||||
{
|
{
|
||||||
// Find the gasmix in the list.
|
// Find the gasmix in the list.
|
||||||
unsigned int i = 0;
|
unsigned int i = parser->nccr;
|
||||||
while (i < parser->ngasmixes) {
|
while (i < parser->ngasmixes) {
|
||||||
if (o2 == parser->oxygen[i] && he == parser->helium[i])
|
if (o2 == parser->oxygen[i] && he == parser->helium[i])
|
||||||
break;
|
break;
|
||||||
@ -136,6 +137,7 @@ suunto_d9_parser_cache (suunto_d9_parser_t *parser)
|
|||||||
unsigned int gasmode_offset = 0x19;
|
unsigned int gasmode_offset = 0x19;
|
||||||
unsigned int gasmix_offset = 0x21;
|
unsigned int gasmix_offset = 0x21;
|
||||||
unsigned int gasmix_count = 3;
|
unsigned int gasmix_count = 3;
|
||||||
|
unsigned int ccr_count = 0;
|
||||||
if (parser->model == HELO2) {
|
if (parser->model == HELO2) {
|
||||||
gasmode_offset = 0x1F;
|
gasmode_offset = 0x1F;
|
||||||
gasmix_offset = 0x54;
|
gasmix_offset = 0x54;
|
||||||
@ -169,6 +171,7 @@ suunto_d9_parser_cache (suunto_d9_parser_t *parser)
|
|||||||
else
|
else
|
||||||
gasmix_offset = 0xC1;
|
gasmix_offset = 0xC1;
|
||||||
gasmix_count = 11;
|
gasmix_count = 11;
|
||||||
|
ccr_count = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offset to the configuration data.
|
// Offset to the configuration data.
|
||||||
@ -189,12 +192,15 @@ suunto_d9_parser_cache (suunto_d9_parser_t *parser)
|
|||||||
parser->gasmix = 0;
|
parser->gasmix = 0;
|
||||||
if (parser->mode == GAUGE || parser->mode == FREEDIVE) {
|
if (parser->mode == GAUGE || parser->mode == FREEDIVE) {
|
||||||
parser->ngasmixes = 0;
|
parser->ngasmixes = 0;
|
||||||
|
parser->nccr = 0;
|
||||||
} else if (parser->mode == AIR) {
|
} else if (parser->mode == AIR) {
|
||||||
parser->oxygen[0] = 21;
|
parser->oxygen[0] = 21;
|
||||||
parser->helium[0] = 0;
|
parser->helium[0] = 0;
|
||||||
parser->ngasmixes = 1;
|
parser->ngasmixes = 1;
|
||||||
|
parser->nccr = 0;
|
||||||
} else {
|
} else {
|
||||||
parser->ngasmixes = 0;
|
parser->ngasmixes = 0;
|
||||||
|
parser->nccr = ccr_count;
|
||||||
for (unsigned int i = 0; i < gasmix_count; ++i) {
|
for (unsigned int i = 0; i < gasmix_count; ++i) {
|
||||||
if (parser->model == HELO2 || parser->model == D4i ||
|
if (parser->model == HELO2 || parser->model == D4i ||
|
||||||
parser->model == D6i || parser->model == D9tx ||
|
parser->model == D6i || parser->model == D9tx ||
|
||||||
@ -225,6 +231,9 @@ suunto_d9_parser_cache (suunto_d9_parser_t *parser)
|
|||||||
}
|
}
|
||||||
} else if (parser->model == DX) {
|
} else if (parser->model == DX) {
|
||||||
parser->gasmix = data[0x31] & 0x7F;
|
parser->gasmix = data[0x31] & 0x7F;
|
||||||
|
if ((data[0x31] & 0x80) == 0) {
|
||||||
|
parser->gasmix += parser->nccr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parser->config = config;
|
parser->config = config;
|
||||||
@ -255,6 +264,7 @@ suunto_d9_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int
|
|||||||
parser->id = 0;
|
parser->id = 0;
|
||||||
parser->mode = AIR;
|
parser->mode = AIR;
|
||||||
parser->ngasmixes = 0;
|
parser->ngasmixes = 0;
|
||||||
|
parser->nccr = 0;
|
||||||
for (unsigned int i = 0; i < NGASMIXES; ++i) {
|
for (unsigned int i = 0; i < NGASMIXES; ++i) {
|
||||||
parser->oxygen[i] = 0;
|
parser->oxygen[i] = 0;
|
||||||
parser->helium[i] = 0;
|
parser->helium[i] = 0;
|
||||||
@ -278,6 +288,7 @@ suunto_d9_parser_set_data (dc_parser_t *abstract, const unsigned char *data, uns
|
|||||||
parser->id = 0;
|
parser->id = 0;
|
||||||
parser->mode = AIR;
|
parser->mode = AIR;
|
||||||
parser->ngasmixes = 0;
|
parser->ngasmixes = 0;
|
||||||
|
parser->nccr = 0;
|
||||||
for (unsigned int i = 0; i < NGASMIXES; ++i) {
|
for (unsigned int i = 0; i < NGASMIXES; ++i) {
|
||||||
parser->oxygen[i] = 0;
|
parser->oxygen[i] = 0;
|
||||||
parser->helium[i] = 0;
|
parser->helium[i] = 0;
|
||||||
@ -741,6 +752,9 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
|
|||||||
seconds = data[offset + 3];
|
seconds = data[offset + 3];
|
||||||
}
|
}
|
||||||
idx = type & 0x0F;
|
idx = type & 0x0F;
|
||||||
|
if ((type & 0x80) == 0) {
|
||||||
|
idx += parser->nccr;
|
||||||
|
}
|
||||||
if (idx >= parser->ngasmixes) {
|
if (idx >= parser->ngasmixes) {
|
||||||
ERROR (abstract->context, "Invalid gas mix.");
|
ERROR (abstract->context, "Invalid gas mix.");
|
||||||
return DC_STATUS_DATAFORMAT;
|
return DC_STATUS_DATAFORMAT;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user