From 26ac27c347c39d473c7f034eab2bdb295927d2df Mon Sep 17 00:00:00 2001 From: Gunnar Klauberg Date: Sun, 14 Nov 2021 22:29:37 +0000 Subject: [PATCH] re-adding ascii decoding at telegram level --- dsmr_parser/clients/protocol.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dsmr_parser/clients/protocol.py b/dsmr_parser/clients/protocol.py index a9a9205..c2d032f 100644 --- a/dsmr_parser/clients/protocol.py +++ b/dsmr_parser/clients/protocol.py @@ -134,7 +134,10 @@ class DSMRProtocol(asyncio.Protocol): self.log.debug('got telegram: %s', telegram) try: - telegram = telegram.decode("ascii") + # we accepted 8-bit at transport level (e.g. tcp) + telegram_data = telegram.encode("latin1") + # we need to ensure 7-bit at telegram level (IEC 646 required in section 5.4 of IEC 62056-21) + telegram = telegram_data.decode("ascii") parsed_telegram = self.telegram_parser.parse(telegram) except InvalidChecksumError as e: self.log.warning(str(e))