diff --git a/scripts/led-matrix-viz.py b/scripts/led-matrix-viz.py index d14d792..92be3d5 100755 --- a/scripts/led-matrix-viz.py +++ b/scripts/led-matrix-viz.py @@ -74,8 +74,6 @@ def main(): _poll.register(sock, POLLIN) - router_resp = b"" - active_notes = set() last_sent_params = None pending_bytes = None @@ -145,13 +143,17 @@ def main(): if ok: pending_bytes = None frames_sent += 1 - # Drain exactly one response to keep router buffer clear + # Drain pending responses so router buffer stays clear + router.setblocking(False) try: - router.settimeout(0.001) - router.recv(4096) - except (BlockingIOError, socket.timeout, OSError): + while True: + chunk = router.recv(4096) + if not chunk: + break + except (BlockingIOError, OSError): pass finally: + router.setblocking(True) router.settimeout(0.01) else: frames_dropped += 1