From 6f89e445e31f8a090c0d323b30c5309145687c19 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 20 Oct 2015 20:30:37 +0100 Subject: [PATCH] Convert the internal tank id to an index. The internal Uwatec tank id should be converted to the libdivecomputer tank index. If there is no corresponding tank, the tank pressure samples are dropped for the following reasons: Some models appear to record an absolute tank pressure sample, even if there is no pressure sensor attached to the corresponding tank. In this case only the tank index changes. The sample value simply retains the last pressure of the previous tank. Since we don't have any real pressure data, dropping those samples is fine. --- src/uwatec_smart_parser.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/uwatec_smart_parser.c b/src/uwatec_smart_parser.c index 138b196..7a6a35f 100644 --- a/src/uwatec_smart_parser.c +++ b/src/uwatec_smart_parser.c @@ -1146,9 +1146,12 @@ uwatec_smart_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t } if (have_pressure) { - sample.pressure.tank = tank; - sample.pressure.value = pressure; - if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); + idx = uwatec_smart_find_tank(parser, tank); + if (idx < parser->ntanks) { + sample.pressure.tank = idx; + sample.pressure.value = pressure; + if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); + } } if (have_heartrate) {