From d91e913953e51d55fdbff806e5be9bcf8ebc1968 Mon Sep 17 00:00:00 2001 From: Frogger900 Date: Sat, 21 Nov 2026 17:11:53 -0500 Subject: [PATCH] subaru: fix subaru_avh_count MISRA width and Legacy 2025 startup dash test assertions --- opendbc_repo/opendbc/safety/modes/subaru_avh.h | 2 +- openpilot/starpilot/car/subaru/tests/test_avh_callers.py | 8 +++++++- .../starpilot/car/subaru/tests/test_stop_start_callers.py | 8 +++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/opendbc_repo/opendbc/safety/modes/subaru_avh.h b/opendbc_repo/opendbc/safety/modes/subaru_avh.h index d0cee01cee..38065d5431 100644 --- a/opendbc_repo/opendbc/safety/modes/subaru_avh.h +++ b/opendbc_repo/opendbc/safety/modes/subaru_avh.h @@ -7,7 +7,7 @@ static bool subaru_avh_seen[7]; static bool subaru_avh_seq[7]; static bool subaru_avh_enabled; static bool subaru_avh_done; -static unsigned int subaru_avh_count; +static uint8_t subaru_avh_count; static uint32_t subaru_avh_start; static uint32_t subaru_avh_sent; static uint32_t subaru_avh_template_ts; diff --git a/openpilot/starpilot/car/subaru/tests/test_avh_callers.py b/openpilot/starpilot/car/subaru/tests/test_avh_callers.py index fa45281277..694c6bbaf3 100644 --- a/openpilot/starpilot/car/subaru/tests/test_avh_callers.py +++ b/openpilot/starpilot/car/subaru/tests/test_avh_callers.py @@ -192,7 +192,13 @@ def test_actual_startup_factory_card_controls_native(enabled, combined, aol, sub expected = ci.CC.angle_was_active if steering_name == 'ES_LKAS_ANGLE' else card.sm['carControl'].latActive if candidate == 'SUBARU_LEGACY_2025': assert bool(dash['LKAS_ACTIVE']), (candidate, tick, expected, dash) - assert dash['LKAS_Dash_State'] == (2 if expected else (1 if cs.cruiseState.available else 0)), (candidate, tick, expected, dash) + if not cs.cruiseState.available or cs.steerFaultTemporary or cs.steerFaultPermanent: + assert not ci.CC.aol_dash_green_last, (candidate, tick, dash) + if expected: + assert ci.CC.aol_dash_green_last, (candidate, tick, dash) + ready_wheel = cs.cruiseState.available and bool(getattr(ci.CS, 'aol_enabled', True)) + expected_dash = 2 if ci.CC.aol_dash_green_last else (1 if ready_wheel else 0) + assert dash['LKAS_Dash_State'] == expected_dash, (candidate, tick, expected, expected_dash, dash) else: assert bool(dash['LKAS_ACTIVE']) == expected, (candidate, tick, expected, dash) assert dash['LKAS_Dash_State'] == (2 if expected else 0), (candidate, tick, expected, dash) diff --git a/openpilot/starpilot/car/subaru/tests/test_stop_start_callers.py b/openpilot/starpilot/car/subaru/tests/test_stop_start_callers.py index cb09d9d64c..464a0ab69f 100644 --- a/openpilot/starpilot/car/subaru/tests/test_stop_start_callers.py +++ b/openpilot/starpilot/car/subaru/tests/test_stop_start_callers.py @@ -177,7 +177,13 @@ def test_actual_startup_factory_card_controls_native(enabled, manual, aol, subar expected = ci.CC.angle_was_active if steering_name == 'ES_LKAS_ANGLE' else card.sm['carControl'].latActive if candidate == 'SUBARU_LEGACY_2025': assert bool(dash['LKAS_ACTIVE']), (candidate, tick, expected, dash) - assert dash['LKAS_Dash_State'] == (2 if expected else (1 if cs.cruiseState.available else 0)), (candidate, tick, expected, dash) + if not cs.cruiseState.available or cs.steerFaultTemporary or cs.steerFaultPermanent: + assert not ci.CC.aol_dash_green_last, (candidate, tick, dash) + if expected: + assert ci.CC.aol_dash_green_last, (candidate, tick, dash) + ready_wheel = cs.cruiseState.available and bool(getattr(ci.CS, 'aol_enabled', True)) + expected_dash = 2 if ci.CC.aol_dash_green_last else (1 if ready_wheel else 0) + assert dash['LKAS_Dash_State'] == expected_dash, (candidate, tick, expected, expected_dash, dash) else: assert bool(dash['LKAS_ACTIVE']) == expected, (candidate, tick, expected, dash) assert dash['LKAS_Dash_State'] == (2 if expected else 0), (candidate, tick, expected, dash)