From 8a1d32d319eaa62a550c07349ef16f8dcb923931 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 25 Feb 2020 21:18:19 +0100 Subject: [PATCH] Pass infinite NDL values to the application When the last deco stop is cleared, the dive computer switches to NDL mode with an infinite time (0x7FFF for APOS4 and 0xFFFF for APOS3). But because libdivecomputer does not report those infinite values to the application, detecting the end of the deco phase is not very intuitive. This issue is fixed by passing those infinite NDL values as-is to the application, despite the relative large values (respectively 9.1 and 18.2 hours). For reference, the finite NDL values reported by the ratio dive computers can be large as well, with values up to 0x4000 (4.55 hours). --- src/divesystem_idive_parser.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/divesystem_idive_parser.c b/src/divesystem_idive_parser.c index 7325b0b..b8d103d 100644 --- a/src/divesystem_idive_parser.c +++ b/src/divesystem_idive_parser.c @@ -477,28 +477,20 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba decostop = array_uint16_le (data + offset + 21); decotime = array_uint16_le (data + offset + 23); tts = array_uint16_le (data + offset + 25); - if (tts == 0x7FFF) { - tts = INVALID; - } } else { decostop = array_uint16_le (data + offset + 21); tts = array_uint16_le (data + offset + 23); - if (tts == 0xFFFF) { - tts = INVALID; - } } - if (tts != INVALID) { - if (decostop) { - sample.deco.type = DC_DECO_DECOSTOP; - sample.deco.depth = decostop / 10.0; - sample.deco.time = apos4 ? decotime : tts; - } else { - sample.deco.type = DC_DECO_NDL; - sample.deco.depth = 0.0; - sample.deco.time = tts; - } - if (callback) callback (DC_SAMPLE_DECO, sample, userdata); + if (decostop) { + sample.deco.type = DC_DECO_DECOSTOP; + sample.deco.depth = decostop / 10.0; + sample.deco.time = apos4 ? decotime : tts; + } else { + sample.deco.type = DC_DECO_NDL; + sample.deco.depth = 0.0; + sample.deco.time = tts; } + if (callback) callback (DC_SAMPLE_DECO, sample, userdata); // CNS unsigned int cns = array_uint16_le (data + offset + 29);