Measure cable length from hardware transmit and receive timestamps

This commit is contained in:
flamingcow
2026-07-25 22:38:52 -07:00
parent 09411aebdf
commit 1b322bb32b
6 changed files with 454 additions and 18 deletions
+9 -4
View File
@@ -216,7 +216,7 @@ func rateColor(gb, target float64) rgb {
}
}
func (d *display) render(dirs []*direction, views []view, elapsed time.Duration, target float64) {
func (d *display) render(dirs []*direction, views []view, elapsed time.Duration, target float64, cable string) {
fb := d.fb
fb.fill(uiBg)
@@ -248,7 +248,7 @@ func (d *display) render(dirs []*direction, views []view, elapsed time.Duration,
avail := fb.h - (bandY + bandH) - btnH - 2*uiMargin
y := bandY + bandH + 8 + (avail-2*sectionH-gap)/2
y = d.section(y, "RATE")
y = d.section(y, "RATE", "")
d.rightAt(colTxGbEnd, y, "TX Gb/s", uiDim)
d.rightAt(colTxPPSEnd, y, "TX pps", uiDim)
d.rightAt(colRxGbEnd, y, "RX Gb/s", uiDim)
@@ -265,7 +265,7 @@ func (d *display) render(dirs []*direction, views []view, elapsed time.Duration,
}
y += gap
y = d.section(y, "OVERALL")
y = d.section(y, "OVERALL", cable)
d.rightAt(colFramesEnd, y, "frames", uiDim)
d.rightAt(colDataEnd, y, "data", uiDim)
d.rightAt(colLostEnd, y, "lost", uiDim)
@@ -289,8 +289,13 @@ func (d *display) render(dirs []*direction, views []view, elapsed time.Duration,
fb.flush()
}
func (d *display) section(y int, title string) int {
// The right-hand annotation sits above the table's last column so it lines up
// with the numbers under it rather than with the rule.
func (d *display) section(y int, title, right string) int {
d.small.draw(d.fb, uiMargin, y, title, uiFg)
if right != "" {
d.right(d.small, d.cellX(colKdropEnd), y, right, uiCyan)
}
ruleY := y + d.small.cellH + 3
d.fb.rect(uiMargin, ruleY, d.fb.w-2*uiMargin, 1, uiRule)
return ruleY + 7