From ddbcdeecbb803ba7ed33cf58dc03bae25207f706 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 4 Sep 2015 08:32:52 +0200 Subject: [PATCH] Ignore disconnected O2 sensors. Even if there are no O2 sensors connected (for example in auto or fixed setpoint mode), the device records a ppO2 sample with all three values set to zero. Such samples are now ignored, as if there was no ppO2 sample present. Reported-by: Anton Lundin --- src/hw_ostc_parser.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index b3ef2fb..394291f 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -767,6 +767,8 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call return DC_STATUS_DATAFORMAT; } + unsigned int ppo2[3] = {0}; + unsigned int count = 0; unsigned int value = 0; switch (info[i].type) { case 0: // Temperature (0.1 °C). @@ -788,12 +790,18 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call case 3: // ppO2 (0.01 bar). for (unsigned int j = 0; j < 3; ++j) { if (info[i].size == 3) { - value = data[offset + j]; + ppo2[j] = data[offset + j]; } else { - value = data[offset + j * 3]; + ppo2[j] = data[offset + j * 3]; + } + if (ppo2[j] != 0) + count++; + } + if (count) { + for (unsigned int j = 0; j < 3; ++j) { + sample.ppo2 = ppo2[j] / 100.0; + if (callback) callback (DC_SAMPLE_PPO2, sample, userdata); } - sample.ppo2 = value / 100.0; - if (callback) callback (DC_SAMPLE_PPO2, sample, userdata); } break; case 5: // CNS