From 2ba99047574d707680fdef8f0f64a3d53aedcf74 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 15 Feb 2023 21:29:17 +0100 Subject: [PATCH] Fix the OSTC4 diluent changes The hwos devices support 5 gas mixes for open-circuit and 5 diluents for CCR dives. Internally, both sets are stored separately, but depending on the dive mode only one of both sets gets stored in the dive header. The gas change event contains the index of the corresponding gas mix or diluent, and should always be in the range 1 to 5. The OSTC4 behaves a bit different from the other hwOS models and uses index 6 to 10 for the diluents. That means the index needs to be adjusted to refer to the correct mix in the dive header. Reported-by: Michael Keller --- src/hw_ostc_parser.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index aff1b8c..2d93fcd 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -953,6 +953,10 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call return DC_STATUS_DATAFORMAT; } unsigned int idx = data[offset]; + if (parser->model == OSTC4 && ccr && idx > parser->nfixed) { + // Fix the OSTC4 diluent index. + idx -= parser->nfixed; + } if (idx < 1 || idx > parser->nfixed) { ERROR(abstract->context, "Invalid gas mix (%u).", idx); return DC_STATUS_DATAFORMAT;