Skip to content

Fix frame ACK being discarded by flush_input after write#28

Merged
widgetii merged 1 commit intomasterfrom
fix-frame-flush-order
Apr 3, 2026
Merged

Fix frame ACK being discarded by flush_input after write#28
widgetii merged 1 commit intomasterfrom
fix-frame-flush-order

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented Apr 3, 2026

Problem

The frame retry loop did write(frame) → flush_input() → read(ACK). The device responds fast enough that the ACK arrives during or right after the write. flush_input() then discards it, forcing a retry. Every frame needed 4-5 attempts, wasting ~80% of transfer time.

Note: burn (the reference tool) has the same bug in sendframe().

Fix

One-line change: move flush_input() before write() instead of after.

flush_input()  →  clear stale data
write(frame)   →  send frame
read(ACK)      →  ACK arrives immediately, not discarded

Benchmarks (real hardware)

Camera Firmware Before After Speedup
IVGHP203Y-AF (CV300) 131 KB 259s (0.9 KB/s) 40s (3.3 KB/s) 6.5x
IVG85HG50PYA-S (EV300) 236 KB 263s (0.9 KB/s) 66s (3.5 KB/s) 4.0x

🤖 Generated with Claude Code

The retry loop did write() → flush_input() → read(ACK), which discarded
ACKs the device sent during/right after the write. Every frame needed
4-5 attempts, wasting ~80% of transfer time.

Fix: flush_input() → write() → read(ACK). Clear stale data before
sending, not after.

Before: CV300 131KB in 259s (0.9 KB/s), EV300 236KB in 263s (0.9 KB/s)
After:  CV300 131KB in 40s (3.3 KB/s), EV300 236KB in 66s (3.5 KB/s)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit d9b31a8 into master Apr 3, 2026
13 checks passed
@widgetii widgetii deleted the fix-frame-flush-order branch April 3, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant