From 03b761e15b20a378d2279e7041574359cf37dfdf Mon Sep 17 00:00:00 2001 From: Alex Mekkering Date: Wed, 4 Jan 2017 14:49:18 +0100 Subject: [PATCH 1/2] Pass lines to parser including line endings --- dsmr_parser/protocol.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dsmr_parser/protocol.py b/dsmr_parser/protocol.py index d2270e0..0712189 100644 --- a/dsmr_parser/protocol.py +++ b/dsmr_parser/protocol.py @@ -73,9 +73,11 @@ class DSMRProtocol(asyncio.Protocol): def handle_lines(self): """Assemble incoming data into single lines.""" - while "\r\n" in self.buffer: - line, self.buffer = self.buffer.split("\r\n", 1) + crlf = "\r\n" + while crlf in self.buffer: + line, self.buffer = self.buffer.split(crlf, 1) self.log.debug('got line: %s', line) + line += crlf # add the trailing crlf again # Telegrams need to be complete because the values belong to a # particular reading and can also be related to eachother. From 8b60d48edd8fccf584243874875f0c6e21da26ce Mon Sep 17 00:00:00 2001 From: Alex Mekkering Date: Wed, 4 Jan 2017 15:01:20 +0100 Subject: [PATCH 2/2] pycodestyle fixes --- dsmr_parser/protocol.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dsmr_parser/protocol.py b/dsmr_parser/protocol.py index 0712189..60c2cc8 100644 --- a/dsmr_parser/protocol.py +++ b/dsmr_parser/protocol.py @@ -77,7 +77,7 @@ class DSMRProtocol(asyncio.Protocol): while crlf in self.buffer: line, self.buffer = self.buffer.split(crlf, 1) self.log.debug('got line: %s', line) - line += crlf # add the trailing crlf again + line += crlf # add the trailing crlf again # Telegrams need to be complete because the values belong to a # particular reading and can also be related to eachother.