From 1b3c78ab372d793a98962c79fc1a49e9e3ad275b Mon Sep 17 00:00:00 2001 From: Edward Viaene Date: Sun, 8 Nov 2026 17:39:19 -0600 Subject: [PATCH] e2e: ADC sample-rate test survives a loopback that reads 0 V at the ADC's range edge test_adc_sample_rate_matches_the_host_clock failed on benchpod-c2f662 (analog module with the quad DAC) with "the ADC really samples at 4591 Hz (0.0115x the reported 400000 Hz)", on 3.10.0 and 3.10.1 alike. There the cal1 loopback reads 0 V at the top of the ADC code range: noise wraps between 65535 and 0, so 40 of 400 flat blocks had a 65535-count swing, counted as DAC bursts, and the fitted rate collapsed. The swing is now taken around each block's median, modulo 65536; the 5 kHz burst (about 1600 counts) is unchanged. A pod where the DAC never reaches the ADC skips instead of failing. On benchpod-c2f662: 3 of 3 passed. Co-Authored-By: Claude Opus 5.5 --- packages/embeddedci/tests/e2e/test_e2e_pod.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/embeddedci/tests/e2e/test_e2e_pod.py b/packages/embeddedci/tests/e2e/test_e2e_pod.py index ba6883e..e3f78f1 100644 --- a/packages/embeddedci/tests/e2e/test_e2e_pod.py +++ b/packages/embeddedci/tests/e2e/test_e2e_pod.py @@ -805,7 +805,15 @@ def toggle_dac(k): # a 5 kHz burst on even events, flat on odd ones block = 100 counts = np.asarray(cap.counts, dtype=np.int64) blocks = counts[: len(counts) // block * block].reshape(-1, block) - active = (blocks.max(axis=1) - blocks.min(axis=1)) > 800 + # Each block's swing around its own middle, modulo 65536: on the analog module with the quad + # DAC the cal1 loopback reads 0 V at the top of the ADC's code range, where noise wraps between + # 65535 and 0 and a flat block would look like a 65535-count swing. + mid = np.median(blocks, axis=1, keepdims=True) + centred = (blocks - mid + 32768) % 65536 - 32768 + swing = centred.max(axis=1) - centred.min(axis=1) + active = swing > 800 + if not active.any(): + pytest.skip("no DAC burst on the cal1 loopback: the DAC does not reach the ADC on this pod") edges = (np.flatnonzero(np.diff(active.astype(np.int8)) != 0) + 1) * block rate = host_clock_rate(edges, stamps) assert rate == pytest.approx(cap.sample_rate_hz, rel=HOST_CLOCK_REL), (