fix: use REQUEST (type 0) + drain response after each send
Validate and Test / validate-patches (push) Failing after 13s

RouterBridge on MCU ignores NOTIFICATION (type 2) messages.
Must use REQUEST (type 0) for draw_frame, then drain the
response to prevent router buffer buildup.
This commit is contained in:
2026-06-24 05:20:26 -07:00
parent 86facfea38
commit 88ddf740cf
+12 -2
View File
@@ -74,6 +74,8 @@ def main():
_poll.register(sock, POLLIN)
router_resp = b""
active_notes = set()
last_sent_params = None
pending_bytes = None
@@ -134,7 +136,7 @@ def main():
params = render(active_notes)
if params != last_sent_params:
msg_id = (msg_id + 1) % 65535
pending_bytes = packer.pack([2, msg_id, "draw_frame", params])
pending_bytes = packer.pack([0, msg_id, "draw_frame", params])
last_sent_params = params
# Try to send pending frame — no POLLOUT dependency
@@ -143,6 +145,14 @@ def main():
if ok:
pending_bytes = None
frames_sent += 1
# Drain exactly one response to keep router buffer clear
try:
router.settimeout(0.001)
router.recv(4096)
except (BlockingIOError, socket.timeout, OSError):
pass
finally:
router.settimeout(0.01)
else:
frames_dropped += 1
@@ -152,7 +162,7 @@ def main():
fps_sample_frames += 1
if last_sent_params is not None and pending_bytes is None:
msg_id = (msg_id + 1) % 65535
refresh_bytes = packer.pack([2, msg_id, "draw_frame", last_sent_params])
refresh_bytes = packer.pack([0, msg_id, "draw_frame", last_sent_params])
router, ok = try_send(router, refresh_bytes)
if ok:
frames_sent += 1