From b1574848b2c3ffcf7f0a8080c853453f5750ce2c Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Mon, 17 Jun 2013 22:09:28 +0200 Subject: [PATCH] Interpret the 7th bit of the event byte correctly. In the OSTC3 data format, the 7th bit of the event byte is used to indicate whether another event byte is present or not. For the OSTC2, this 7th bit remained unused, and I assumed it would eventually get used in the same way as the OSTC3 does. But that assumption turns out to be wrong. Starting with firmware v2.66 the 7th bit is used for a new bailout event. This patch leaves the existing logic intact, but except for the OSTC3 format (version 0x23), the maximum number of events bytes is now limited to just one byte. --- src/hw_ostc_parser.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hw_ostc_parser.c b/src/hw_ostc_parser.c index 576afdf..73f7fc3 100644 --- a/src/hw_ostc_parser.c +++ b/src/hw_ostc_parser.c @@ -482,6 +482,8 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call unsigned int nbits = 0; unsigned int events = 0; while (data[offset - 1] & 0x80) { + if (nbits && version != 0x23) + break; if (offset + 1 > size) return DC_STATUS_DATAFORMAT; events |= data[offset] << nbits;