From bed4d19acacdaba50a2c4d80f1c827aad0c406a9 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Tue, 18 Jun 2013 22:17:38 +0200 Subject: [PATCH] Add support for the new bailout event. The new bailout event is reported to the application as a normal gas change event. --- src/hw_ostc_parser.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 73f7fc3..b007377 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -596,13 +596,27 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call } } - // SetPoint Change - if ((events & 0x40) && (version != 0x23)) { - if (offset + 1 > size) - return DC_STATUS_DATAFORMAT; - sample.setpoint = data[offset] / 100.0; - if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); - offset++; + if (version != 0x23) { + // SetPoint Change + if (events & 0x40) { + if (offset + 1 > size) + return DC_STATUS_DATAFORMAT; + sample.setpoint = data[offset] / 100.0; + if (callback) callback (DC_SAMPLE_SETPOINT, sample, userdata); + offset++; + } + + // Bailout Event + if (events & 0x80) { + if (offset + 2 > size) + 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; + } } }