From b7a5394e73804019f4d89415302c76f0fc6231be Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 4 May 2014 22:50:31 +0200 Subject: [PATCH] Add support for the new OSTC3 bailout event. With the exception of the different event mask (single byte 0x80 vs two byte 0x0100), the OSTC3 bailout event is identical to the OSTC2 variant. Just as before, the new bailout event is reported to the application as a normal gas change event. --- src/hw_ostc_parser.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 26fea22..8fb8875 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -562,16 +562,33 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call length--; } - // SetPoint Change - if ((events & 0x40) && (version == 0x23)) { - if (length < 1) { - ERROR (abstract->context, "Buffer overflow detected!"); - return DC_STATUS_DATAFORMAT; + if (version == 0x23) { + // SetPoint Change + if (events & 0x40) { + if (length < 1) { + ERROR (abstract->context, "Buffer overflow detected!"); + return DC_STATUS_DATAFORMAT; + } + sample.setpoint = data[offset] / 100.0; + if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); + offset++; + length--; + } + + // Bailout Event + if (events & 0x0100) { + if (length < 2) { + ERROR (abstract->context, "Buffer overflow detected!"); + return DC_STATUS_DATAFORMAT; + } + sample.event.type = SAMPLE_EVENT_GASCHANGE2; + sample.event.time = 0; + sample.event.flags = 0; + sample.event.value = data[offset] | (data[offset + 1] << 16); + if (callback) callback (DC_SAMPLE_EVENT, sample, userdata); + offset += 2; + length -= 2; } - sample.setpoint = data[offset] / 100.0; - if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); - offset++; - length--; } // Extended sample info.