driver: fix incorrect recv_response behavior

This commit is contained in:
linuswck 2024-08-26 11:33:48 +08:00
parent 3ba8b99084
commit 3d2294a90c
1 changed files with 7 additions and 3 deletions

View File

@ -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