| 130 | |
| 131 | |
| 132 | def evaluate(case: BenchCase, parsed: dict[str, int]) -> tuple[bool, str]: |
| 133 | edges = parsed.get("edges", 0) |
| 134 | periods = parsed.get("periods", 0) |
| 135 | mean_ns = parsed.get("mean_ns", 0) |
| 136 | sigma_ns = parsed.get("sigma_ns", 0) |
| 137 | min_ns = parsed.get("min_ns", 0) |
| 138 | max_ns = parsed.get("max_ns", 0) |
| 139 | success = parsed.get("success", 0) |
| 140 | if not success: |
| 141 | return False, ( |
| 142 | f"firmware reported success=0 (edges={edges}, periods={periods}) — " |
| 143 | "SCT capture likely returned no edges; verify TX↔RX jumper" |
| 144 | ) |
| 145 | if periods < 5: |
| 146 | return False, ( |
| 147 | f"only {periods} periods captured in {case.duration_ms} ms " |
| 148 | f"(edges={edges}) — capture path likely not working yet" |
| 149 | ) |
| 150 | mean_low = case.expected_period_ns * (1.0 - case.mean_tolerance_pct / 100.0) |
| 151 | mean_high = case.expected_period_ns * (1.0 + case.mean_tolerance_pct / 100.0) |
| 152 | if not (mean_low <= mean_ns <= mean_high): |
| 153 | return False, ( |
| 154 | f"mean {mean_ns} ns outside ±{case.mean_tolerance_pct}% of " |
| 155 | f"{case.expected_period_ns} ns (range {mean_low:.0f}..{mean_high:.0f})" |
| 156 | ) |
| 157 | if sigma_ns > case.sigma_max_ns: |
| 158 | return False, f"sigma {sigma_ns} ns exceeds {case.sigma_max_ns} ns" |
| 159 | return True, ( |
| 160 | f"edges={edges}, periods={periods}, mean={mean_ns} ns, " |
| 161 | f"sigma={sigma_ns} ns, min={min_ns} ns, max={max_ns} ns" |
| 162 | ) |
| 163 | |
| 164 | |
| 165 | def main() -> int: |