Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass lines to parser including line endings #15

Merged
merged 2 commits into from
Jan 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dsmr_parser/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ def data_received(self, data):

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.
Expand Down