From 5116ee8f2d0ab5550566b18e0a36da9a6856b54e Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 2 Apr 2019 21:01:21 +0200 Subject: [PATCH] Get the gas mix index directly from the event data There is no need to lookup the gas mix index, because the number is stored directly in the event data, right next to the oxygen and helium values. This actually removes an ambiguity in cases where the user has configured two or more identical gas mixes. In that case, the lookup would always find the first gas mix. --- src/suunto_d9_parser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/suunto_d9_parser.c b/src/suunto_d9_parser.c index 10a7590..362f0d7 100644 --- a/src/suunto_d9_parser.c +++ b/src/suunto_d9_parser.c @@ -729,7 +729,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca ERROR (abstract->context, "Buffer overflow detected!"); return DC_STATUS_DATAFORMAT; } - unknown = data[offset + 0]; + type = data[offset + 0]; he = data[offset + 1]; o2 = data[offset + 2]; if (parser->model == DX || parser->model == VYPERNOVO || @@ -738,7 +738,7 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca } else { seconds = data[offset + 3]; } - idx = suunto_d9_parser_find_gasmix(parser, o2, he); + idx = type & 0x0F; if (idx >= parser->ngasmixes) { ERROR (abstract->context, "Invalid gas mix."); return DC_STATUS_DATAFORMAT;