[PATCH] Skip unconnected ppo2 sensors

Anton Lundin glance at acc.umu.se
Mon Aug 31 14:06:03 PDT 2015


The HwOS devices logs ppo2 sensor values even in Auto / Fixed SP mode,
but they log them as reading zero, if there are no sensors there.

This skips us reporting those zero values.

Signed-off-by: Anton Lundin <glance at acc.umu.se>
---

This shows one of the flaws with re-using the DC_SAMPLE_PPO2 value.

Should we report unconnected sensors? how should a application actually
handle them?


Maybee we should look at the ppO2 value too, but for now this POC only
looked at the mV values.

 src/hw_ostc_parser.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c
index 6db9d27..954f6f7 100644
--- a/src/hw_ostc_parser.c
+++ b/src/hw_ostc_parser.c
@@ -885,6 +885,9 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
 							value = data[offset + j];
 						} else {
 							value = data[offset + j * 3];
+							// Skip zero mV sensors, as they are most likely unconnected
+							if (array_uint16_le (data + offset + j * 3 + 1) == 0)
+								continue;
 						}
 						sample.ppo2 = value / 100.0;
 						if (callback) callback (DC_SAMPLE_PPO2, sample, userdata);
-- 
2.1.4



More information about the devel mailing list