From 399f3574967a619b2b5de8f12a9894cbe96772d9 Mon Sep 17 00:00:00 2001 From: weetmuts Date: Tue, 4 Feb 2020 14:46:48 +0100 Subject: [PATCH] Fix cul. --- src/wmbus_cul.cc | 9 +-------- src/wmbus_im871a.cc | 1 + utils/Analyze.java | 14 +++++++++----- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/wmbus_cul.cc b/src/wmbus_cul.cc index fe950b7..6d00981 100644 --- a/src/wmbus_cul.cc +++ b/src/wmbus_cul.cc @@ -144,13 +144,10 @@ void WMBusCUL::setLinkModes(LinkModeSet lms) msg[3] = 0xa; msg[4] = 0xd; - serial()->send(msg); - usleep(1000*100); - verbose("(cul) set link mode %c\n", msg[2]); - bool sent = serial()->send(msg); sent_command_ = string(&msg[0], &msg[3]); received_response_ = ""; + bool sent = serial()->send(msg); if (sent) waitForResponse(); @@ -298,10 +295,6 @@ FrameStatus WMBusCUL::checkCULFrame(vector &data, } if (eolp >= data.size()) return PartialFrame; - // We got a full line, but if it is too short, then - // there is something wrong. Discard the data. - if (data.size() < 10) return ErrorInFrame; - if (data[0] != 'b') { // C1 and T1 telegrams should start with a 'b' diff --git a/src/wmbus_im871a.cc b/src/wmbus_im871a.cc index 6494952..f4d49ec 100644 --- a/src/wmbus_im871a.cc +++ b/src/wmbus_im871a.cc @@ -394,6 +394,7 @@ FrameStatus WMBusIM871A::checkIM871AFrame(vector &data, { if (data.size() == 0) return PartialFrame; if (data[0] != 0xa5) return ErrorInFrame; + if (data.size() < 4) return PartialFrame; int ctrlbits = (data[1] & 0xf0) >> 4; if (ctrlbits & 1) return ErrorInFrame; // Bit 1 is reserved, we do not expect it.... diff --git a/utils/Analyze.java b/utils/Analyze.java index 33b9536..9acb909 100644 --- a/utils/Analyze.java +++ b/utils/Analyze.java @@ -13,22 +13,26 @@ public class Analyze { args[0])); String prevline = reader.readLine(); String line = reader.readLine(); - while (line != null) { - if (line.indexOf(match) >= 0) { + while (line != null) + { + if (line.indexOf(match) >= 0) + { boolean space = false; - for (int i=0; i