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 <glance@acc.umu.se>
This commit is contained in:
Jef Driesen 2015-09-04 08:32:52 +02:00
parent c72bdfe4e4
commit ddbcdeecbb

View File

@ -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