Add support for ppO2 samples.

When the PPO2 sample was introduced, we didn't take into account the
fact that rebreathers usually support multiple O2 sensors. The HW OSTC
supports for example three sensors. In order to support multiple values,
without having to introduce a new data structure with an additional
sensor id field, we simply relax the assumption of allowing only one
DC_SAMPLE_PPO2 value per sample. Applications that are not prepared for
multiple values, will automatically use only one of them (probably the
last one).
This commit is contained in:
Jef Driesen 2015-05-08 08:40:34 +02:00
parent a8f06c5c3c
commit 04ffc894c9

View File

@ -570,6 +570,12 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
return DC_STATUS_DATAFORMAT;
}
break;
case 3: // ppO2
if (info[i].size != 3 && info[i].size != 9) {
ERROR(abstract->context, "Unexpected sample size.");
return DC_STATUS_DATAFORMAT;
}
break;
case 5: // CNS
if (info[i].size != 1 && info[i].size != 2) {
ERROR(abstract->context, "Unexpected sample size.");
@ -779,6 +785,17 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
sample.deco.time = data[offset + 1] * 60;
if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
break;
case 3: // ppO2 (0.01 bar).
for (unsigned int j = 0; j < 3; ++j) {
if (info[i].size == 3) {
value = data[offset + j];
} else {
value = data[offset + j * 3];
}
sample.ppo2 = value / 100.0;
if (callback) callback (DC_SAMPLE_PPO2, sample, userdata);
}
break;
case 5: // CNS
if (info[i].size == 2)
sample.cns = array_uint16_le (data + offset) / 100.0;