fix: use REQUEST (type 0) + drain response after each send
Validate and Test / validate-patches (push) Failing after 13s
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:
@@ -74,6 +74,8 @@ def main():
|
|||||||
|
|
||||||
_poll.register(sock, POLLIN)
|
_poll.register(sock, POLLIN)
|
||||||
|
|
||||||
|
router_resp = b""
|
||||||
|
|
||||||
active_notes = set()
|
active_notes = set()
|
||||||
last_sent_params = None
|
last_sent_params = None
|
||||||
pending_bytes = None
|
pending_bytes = None
|
||||||
@@ -134,7 +136,7 @@ def main():
|
|||||||
params = render(active_notes)
|
params = render(active_notes)
|
||||||
if params != last_sent_params:
|
if params != last_sent_params:
|
||||||
msg_id = (msg_id + 1) % 65535
|
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
|
last_sent_params = params
|
||||||
|
|
||||||
# Try to send pending frame — no POLLOUT dependency
|
# Try to send pending frame — no POLLOUT dependency
|
||||||
@@ -143,6 +145,14 @@ def main():
|
|||||||
if ok:
|
if ok:
|
||||||
pending_bytes = None
|
pending_bytes = None
|
||||||
frames_sent += 1
|
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:
|
else:
|
||||||
frames_dropped += 1
|
frames_dropped += 1
|
||||||
|
|
||||||
@@ -152,7 +162,7 @@ def main():
|
|||||||
fps_sample_frames += 1
|
fps_sample_frames += 1
|
||||||
if last_sent_params is not None and pending_bytes is None:
|
if last_sent_params is not None and pending_bytes is None:
|
||||||
msg_id = (msg_id + 1) % 65535
|
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)
|
router, ok = try_send(router, refresh_bytes)
|
||||||
if ok:
|
if ok:
|
||||||
frames_sent += 1
|
frames_sent += 1
|
||||||
|
|||||||
Reference in New Issue
Block a user