From 8b470c200bad294282a0177b3ee7e0213df43004 Mon Sep 17 00:00:00 2001 From: Kevin Weiss Date: Tue, 24 Sep 2024 11:21:11 +0200 Subject: [PATCH] fix: handle reconnect After updating the firmware on my PPK2 to v4.2.0 I noticed that connecting, disconnected then trying to reconnect failed. It seems like the updated firmware has some 0x80 byte that gets send and as a result an exception gets thrown. This commit allows those bytes to be replaced, thus the check is still valid but we do not get this exception. --- src/ppk2_api/ppk2_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ppk2_api/ppk2_api.py b/src/ppk2_api/ppk2_api.py index c291cdc..85a1c30 100644 --- a/src/ppk2_api/ppk2_api.py +++ b/src/ppk2_api/ppk2_api.py @@ -158,8 +158,8 @@ def _read_metadata(self): time.sleep(0.1) # TODO add a read_until serial read function with a timeout - if read != b'' and "END" in read.decode("utf-8"): - return read.decode("utf-8") + if read != b'' and "END" in read.decode("utf-8", errors="replace"): + return read.decode("utf-8", errors="replace") def _parse_metadata(self, metadata): """Parse metadata and store it to modifiers"""