From 3d2294a90c7f264335ace784c08142ed431b0297 Mon Sep 17 00:00:00 2001 From: linuswck Date: Mon, 26 Aug 2024 11:33:48 +0800 Subject: [PATCH] driver: fix incorrect recv_response behavior --- pykirdy/driver/kirdy.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pykirdy/driver/kirdy.py b/pykirdy/driver/kirdy.py index b516792..26f75b1 100644 --- a/pykirdy/driver/kirdy.py +++ b/pykirdy/driver/kirdy.py @@ -835,11 +835,15 @@ class Kirdy: self._connected_sig.emit(True) async def _read_response(self, buffer_size=16384): - raw_response = await self._reader.read(buffer_size) + raw_response = b'' + while len(raw_response) == 0: + # Ignore 0 size packet + raw_response = await self._reader.read(buffer_size) response = raw_response.decode('utf-8', errors='ignore').split("\n") - response.reverse() + response = response[:-1] + items = [] - for item in response[1:]: + for item in response: items.append(json.loads(item)) return items