From 7be2e53ec18645f2549e0f401627c3d239614f87 Mon Sep 17 00:00:00 2001 From: BHAY-3DiTex Date: Wed, 19 Jun 2024 14:39:23 +0200 Subject: [PATCH 1/2] fix pyluos limitation to send messages --- pyluos/io/serial_io.py | 6 +++++- pyluos/io/ws.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pyluos/io/serial_io.py b/pyluos/io/serial_io.py index 3baccc1..7a6fcfe 100644 --- a/pyluos/io/serial_io.py +++ b/pyluos/io/serial_io.py @@ -75,7 +75,7 @@ def write(self, data): def close(self): self._running = False - self._poll_loop.join() + self._poll_loop.join(timeout = 1) self._serial.close() @@ -121,6 +121,10 @@ def extract_line(s): while self._running: to_read = self._serial.in_waiting + if to_read == 0: + time.sleep(self.period) + continue + s = self._serial.read(to_read) buff = buff + s diff --git a/pyluos/io/ws.py b/pyluos/io/ws.py index e5dd4a4..9a7f916 100644 --- a/pyluos/io/ws.py +++ b/pyluos/io/ws.py @@ -63,7 +63,7 @@ def is_ready(self): def recv(self): try: - data = self._msg.get(block = False) + data = self._msg.get(True, 1) except queue.Empty: data = None return data @@ -73,7 +73,7 @@ def write(self, data): def close(self): self._running = False - self._poll_loop.join(timeout = 1) + self._poll_loop.join(timeout = 2) self._ws.close() def _poll(self): From ad423bcad7255796c1432c51779e45731319950b Mon Sep 17 00:00:00 2001 From: BHAY-3DiTex Date: Thu, 20 Jun 2024 14:23:01 +0200 Subject: [PATCH 2/2] modification of timeout value in websocket recv --- pyluos/io/ws.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyluos/io/ws.py b/pyluos/io/ws.py index 9a7f916..b2d93b8 100644 --- a/pyluos/io/ws.py +++ b/pyluos/io/ws.py @@ -63,7 +63,7 @@ def is_ready(self): def recv(self): try: - data = self._msg.get(True, 1) + data = self._msg.get(True, 0.01) except queue.Empty: data = None return data