From 7f3cea691dc64ec3d95fce8440114598d3afcce6 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Thu, 4 Jun 2015 22:24:29 +0200 Subject: [PATCH] Use a fixed id for the uwatec deco mix. The id of the uwatec deco mix is always 2, even for devices which support maximum two gas mixes. Strictly speaking, this change is more correct than commit 4fd825cdac341a2d4a1366c6deb7d4a71bbdf94d, allthough in practice they are equivalent. --- src/uwatec_smart_parser.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 163476d..ee6be1e 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -342,12 +342,17 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser) uwatec_smart_gasmix_t gasmix[NGASMIXES] = {{0}}; if (!trimix) { for (unsigned int i = 0; i < header->ngases; ++i) { + unsigned int id = i; + if (id > 0 && header->ngases == 2) { + id++; // Remap the id of the deco mix. + } + unsigned int idx = DC_GASMIX_UNKNOWN; unsigned int o2 = data[header->gasmix + i * 2]; if (o2 != 0) { idx = ngasmixes; - gasmix[ngasmixes].id = i; + gasmix[ngasmixes].id = id; gasmix[ngasmixes].oxygen = o2; ngasmixes++; } @@ -368,7 +373,7 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser) } } if (beginpressure != 0 || endpressure != 0) { - tank[ntanks].id = i; + tank[ntanks].id = id; tank[ntanks].beginpressure = beginpressure; tank[ntanks].endpressure = endpressure; tank[ntanks].gasmix = idx; @@ -881,7 +886,7 @@ uwatec_smart_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t have_alarms = 1; if (table[id].index == 1) { if (parser->model == ALADINTEC || parser->model == ALADINTEC2G) { - gasmix = (value & 0x30) >> 4; + gasmix = (value & 0x18) >> 3; } else { gasmix = (value & 0x60) >> 5; }