From 3ff890b3e23b78038dc05d6933488097268dc7eb Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 26 Aug 2015 07:51:53 +0200 Subject: [PATCH] Improve the detection of unused tanks. The begin/end pressure for unused tanks is normally zero. But I noticed that in some cases both pressure values are stored as 0xFFFF. Since that corresponds to a pressure of 511.99 bar, this is most likely some special magic value, and not a valid pressure. Tanks where either the begin or end pressure is 0xFFFF are now ignored too. --- src/uwatec_smart_parser.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 3bf7d2b..ab4e7e1 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -459,7 +459,8 @@ uwatec_smart_parser_cache (uwatec_smart_parser_t *parser) endpressure = array_uint16_le(data + offset + 2); } } - if (beginpressure != 0 || endpressure != 0) { + if ((beginpressure != 0 || endpressure != 0) && + (beginpressure != 0xFFFF) && (endpressure != 0xFFFF)) { tank[ntanks].id = id; tank[ntanks].beginpressure = beginpressure; tank[ntanks].endpressure = endpressure; @@ -1068,7 +1069,8 @@ uwatec_smart_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t mixidx = idx; } - if (beginpressure != 0 || endpressure != 0) { + if ((beginpressure != 0 || endpressure != 0) && + (beginpressure != 0xFFFF) && (endpressure != 0xFFFF)) { idx = uwatec_smart_find_tank (parser, mixid); if (idx >= parser->ntanks) { if (idx >= NGASMIXES) {