From aa2499ef0f74c3973e71c371191a3e0dcd91fb89 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 26 Oct 2015 19:16:19 +0100 Subject: [PATCH] Implement gas switches for the Hollis TX1. --- src/oceanic_atom2_parser.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/oceanic_atom2_parser.c b/src/oceanic_atom2_parser.c index 2503f52..6651519 100644 --- a/src/oceanic_atom2_parser.c +++ b/src/oceanic_atom2_parser.c @@ -608,6 +608,9 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ have_pressure = 0; } + // Initial gas mix. + unsigned int gasmix_previous = 0xFFFFFFFF; + unsigned int complete = 1; unsigned int offset = parser->headersize; while (offset + samplesize <= size - parser->footersize) { @@ -762,6 +765,28 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_ sample.depth = depth / 16.0 * FEET; if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); + // Gas mix + unsigned int have_gasmix = 0; + unsigned int gasmix = 0; + if (parser->model == TX1) { + gasmix = data[offset] & 0x07; + have_gasmix = 1; + } + if (have_gasmix && gasmix != gasmix_previous) { + if (gasmix < 1 || gasmix > parser->ngasmixes) { + ERROR (abstract->context, "Invalid gas mix index (%u).", gasmix); + return DC_STATUS_DATAFORMAT; + } + unsigned int o2 = parser->oxygen[gasmix - 1]; + unsigned int he = parser->helium[gasmix - 1]; + sample.event.type = SAMPLE_EVENT_GASCHANGE2; + sample.event.time = 0; + sample.event.flags = 0; + sample.event.value = o2 | (he << 16); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + gasmix_previous = gasmix; + } + // NDL / Deco unsigned int have_deco = 0; unsigned int decostop = 0, decotime = 0;