fix(#710): flserial never overwrites incoming serial bytes
flserial's reader thread copied every byte into an 8 KB ring that overwrote the oldest bytes when full, and told Dart about data only once the port went idle. The RK4 sends its 350-contact list (about 52 KB) in about 0.17 s, so most of it was overwritten before the app read it: the app saw 106-154 contacts and #660's contacts were lost. The thread now reads only as much as the ring has room for. When the ring is full it leaves the bytes in the OS driver, and USB flow control holds the radio, so nothing is dropped. The ring is 256 KB (the size the header already declared as MAX_PORT_FIFO_LEN, and a power of two as the ring's mask needs); the per-read chunk stays 8 KB on the thread stack. Dart is called back during a burst (4 KB waiting or 10 ms) and whenever the ring fills, not only when the port goes idle. Same change in the macOS copy of the source (macos/Classes), which was identical. (std::min) is parenthesised because the Windows headers define a min macro. Verified on the owner's RK4 (read-only harness driving the DLL): new DLL 350/350 in every mode, including a reader 2 s late, zero bytes skipped; the old DLL, as the control, got 345 app-like and 54 (8191 bytes, the old ring's capacity) when 300 ms or 2 s late. Epic #702. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>pull/753/head
parent
3f4bd23f08
commit
03266e709e
Loading…
Reference in new issue