From 3fa606a8a292c26dcb76250a87c05e7186ad6528 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 15 Sep 2015 21:43:50 +0200 Subject: [PATCH] Fix the gas switches for Galileo Trimix. The Galileo Trimix supports up to 10 tanks and gas mixes. However, the existing alarm based gas switch events have only 2 bits available, and can support at most 4 gas mixes. Therefore, the trimix variant stores another 4 bit value in the second alarm byte. For the first three gas mixes (and possibly also the fourth), both alarm bytes appear to be always set to the same value. For the higher mixes, the value in the first alarm byte is always zero. This doesn't cause any problems, because in the data stream the second alarm byte is stored after the first one, and our final value is always the last one. The non-trimix variant also has the second alarm byte, but the gas mix bits appear to be always zero. In order to avoid taking this zero as the final value, a separate table is used for the trimix variant. --- src/uwatec_smart_parser.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index ab4e7e1..138b196 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -374,6 +374,12 @@ uwatec_smart_event_info_t uwatec_smart_galileo_events_2[] = { {EV_UNKNOWN, 0xFF, 0}, }; +static const +uwatec_smart_event_info_t uwatec_smart_trimix_events_2[] = { + {EV_UNKNOWN, 0x0F, 0}, + {EV_GASMIX, 0xF0, 4}, +}; + static unsigned int uwatec_smart_find_gasmix (uwatec_smart_parser_t *parser, unsigned int id) { @@ -419,6 +425,14 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser) if (data[43] & 0x80) { trimix = 1; } + + if (trimix) { + parser->events[2] = uwatec_smart_trimix_events_2; + parser->nevents[2] = C_ARRAY_SIZE (uwatec_smart_trimix_events_2); + } else { + parser->events[2] = uwatec_smart_galileo_events_2; + parser->nevents[2] = C_ARRAY_SIZE (uwatec_smart_galileo_events_2); + } } // Get the gas mixes and tanks.