diff options
Diffstat (limited to 'tools/rtt.zig')
| -rw-r--r-- | tools/rtt.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/rtt.zig b/tools/rtt.zig index 6ab0d87..d971c74 100644 --- a/tools/rtt.zig +++ b/tools/rtt.zig @@ -62,9 +62,14 @@ pub fn roundTrip( if (now - t0 > timeout_us) return null; } else if (now - last > quiet_us) break; - // Poll in millisecond units because that is what poll(2) takes; the TIMING above is - // microseconds and independent of this granularity. - const n = try port.readTimeout(&buf, 1); + // NON-BLOCKING, and that matters. `poll(2)` takes a timeout in MILLISECONDS, so waiting + // even 1 ms quantises this measurement into 1 ms buckets: a response that arrived just after + // a poll returned empty is reported up to a millisecond late. Against a round trip of a few + // milliseconds that is not a rounding error, it is a large fraction of the answer - measured + // as ~0.75 ms of unexplained gap between this figure and the sum of the board's own stage + // timings. A spin costs a busy host CPU for a few milliseconds per sample, which is the + // right trade for an instrument. + const n = try port.readTimeout(&buf, 0); if (n == 0) continue; if (first < 0) first = nowUs(port); bytes += n; |
