From dd6d26670eb703a0f5db70033c79a374f6432ce0 Mon Sep 17 00:00:00 2001 From: Ronald Pijnacker Date: Tue, 4 Jan 2022 09:49:11 +0100 Subject: [PATCH] Rewrite for compatibility with python 3.6 --- dsmr_parser/clients/rfxtrx_protocol.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dsmr_parser/clients/rfxtrx_protocol.py b/dsmr_parser/clients/rfxtrx_protocol.py index e4080a2..848de71 100644 --- a/dsmr_parser/clients/rfxtrx_protocol.py +++ b/dsmr_parser/clients/rfxtrx_protocol.py @@ -49,12 +49,14 @@ class RFXtrxDSMRProtocol(DSMRProtocol): data = self.remaining_data + data - while len(data) > 0 and (packetlength := data[0] + 1) <= len(data): + packetlength = data[0] + 1 if len(data) > 0 else 1 + while packetlength <= len(data): packettype = data[1] subtype = data[2] if (packettype == PACKETTYPE_DSMR and subtype == SUBTYPE_P1): dsmr_data = data[4:packetlength] super().data_received(dsmr_data) data = data[packetlength:] + packetlength = data[0] + 1 if len(data) > 0 else 1 self.remaining_data = data