From 04ffc894c935da74ca5e85ef8b8f856f33e08fea Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Fri, 8 May 2015 08:40:34 +0200 Subject: [PATCH] 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). --- src/hw_ostc_parser.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index a0e9002..b3ef2fb 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -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;