Skip to content

Hyundai: cover ALT_LIMITS_2 in test_alternate_limits#3523

Open
johnnathanwood wants to merge 1 commit into
commaai:masterfrom
johnnathanwood:hyundai-alt-limits-2-test-coverage
Open

Hyundai: cover ALT_LIMITS_2 in test_alternate_limits#3523
johnnathanwood wants to merge 1 commit into
commaai:masterfrom
johnnathanwood:hyundai-alt-limits-2-test-coverage

Conversation

@johnnathanwood

Copy link
Copy Markdown
Contributor

Summary

test_alternate_limits verifies that the car-side ALT_LIMITS (270 Nm) flag is propagated to the
panda safetyParam, but the sibling ALT_LIMITS_2 (170 Nm) tier — added for the Kona 2022 in #2072
has no equivalent assertion. This adds the missing symmetric check.

Why it matters

The panda steer-torque tier is selected fail-open: with no flag set, opendbc/safety/modes/hyundai.h
falls back to the 384 Nm default. The car cap (CarControllerParams.STEER_MAX) and the panda tier are
derived independently, and panda cannot re-derive the per-car limit from the bus. So if the
ALT_LIMITS_2 flag is set on the car but not propagated into safetyParam (interface.py), panda
silently enforces 384 for a car that intends 170 — with no RX/TX/controls_allowed symptom. That is
the "a simple bug can silently allow more torque than expected" failure mode noted in #1137, and the
dropped-flag regression seen in #2072. The 270 tier is guarded against this today; the 170 tier was not.

Change

Test-only. One added assertion in test_alternate_limits, mirroring the existing ALT_LIMITS line for
ALT_LIMITS_2.

Test plan

  • pytest opendbc/car/hyundai/tests/test_hyundai.py -k test_alternate_limits — passes on master.
  • Verified it fails when the ALT_LIMITS_2 → safetyParam mapping in interface.py is removed: the Kona
    then reports a safetyParam missing the bit, so the assertion catches the silent fall-back to 384.

Scope / non-goals

  • No behavior change; no generated code touched — the car_diff replay should report 0 changed.
  • Guards the flag→safetyParam propagation only. It intentionally does not assert a per-platform
    expected cap: STEER_MAX is also set to non-default values by the CAN-FD and 255 Nm branches ahead of
    the ALT_LIMITS branches, so a blanket per-CAR "car cap == panda tier" assertion would false-fail on
    those cars.

@github-actions github-actions Bot added car related to opendbc/car/ hyundai labels Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Car behavior report

Replays driving segments through this PR and compares the behavior to master.
Please review any changes carefully to ensure they are expected.

Testing 260 segments for: HYUNDAI_AZERA_HEV_6TH_GEN, HYUNDAI_ELANTRA_GT_I30, HYUNDAI_ELANTRA_2021, HYUNDAI_ELANTRA_HEV_2021, HYUNDAI_GENESIS, HYUNDAI_IONIQ, HYUNDAI_IONIQ_HEV_2022, HYUNDAI_IONIQ_EV_2020, HYUNDAI_IONIQ_PHEV_2019, HYUNDAI_IONIQ_PHEV, HYUNDAI_KONA_2022, HYUNDAI_KONA_EV, HYUNDAI_KONA_EV_2022, HYUNDAI_KONA_EV_2ND_GEN, HYUNDAI_SANTA_FE, HYUNDAI_SANTA_FE_2022, HYUNDAI_SANTA_FE_HEV_2022, HYUNDAI_SANTA_FE_PHEV_2022, HYUNDAI_SONATA, HYUNDAI_SONATA_LF, HYUNDAI_STARIA_4TH_GEN, HYUNDAI_PALISADE, HYUNDAI_SONATA_HYBRID, HYUNDAI_IONIQ_5, HYUNDAI_IONIQ_6, HYUNDAI_TUCSON_4TH_GEN, HYUNDAI_SANTA_CRUZ_1ST_GEN, HYUNDAI_CUSTIN_1ST_GEN

✅ 0 changed, 256 passed, 4 errors

Show errors

Traceback (most recent call last):
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 86, in process_segment
    can_msgs = load_can_messages(seg)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 57, in load_can_messages
    msgs = LogReader(url, only_union_types=True, sort_by_time=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/logreader.py", line 31, in __init__
    dat = f.read()
          ^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 500, in read
    s = self._safe_read(self.length)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 650, in _safe_read
    raise IncompleteRead(data, amt - len(data))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 2581970 more expected)


Traceback (most recent call last):
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 86, in process_segment
    can_msgs = load_can_messages(seg)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 57, in load_can_messages
    msgs = LogReader(url, only_union_types=True, sort_by_time=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/logreader.py", line 31, in __init__
    dat = f.read()
          ^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 500, in read
    s = self._safe_read(self.length)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 650, in _safe_read
    raise IncompleteRead(data, amt - len(data))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 3601038 more expected)


Traceback (most recent call last):
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 86, in process_segment
    can_msgs = load_can_messages(seg)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 57, in load_can_messages
    msgs = LogReader(url, only_union_types=True, sort_by_time=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/logreader.py", line 31, in __init__
    dat = f.read()
          ^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 500, in read
    s = self._safe_read(self.length)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 650, in _safe_read
    raise IncompleteRead(data, amt - len(data))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 1882216 more expected)


Traceback (most recent call last):
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 86, in process_segment
    can_msgs = load_can_messages(seg)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/tests/car_diff.py", line 57, in load_can_messages
    msgs = LogReader(url, only_union_types=True, sort_by_time=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/opendbc/opendbc/opendbc/car/logreader.py", line 31, in __init__
    dat = f.read()
          ^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 500, in read
    s = self._safe_read(self.length)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/http/client.py", line 650, in _safe_read
    raise IncompleteRead(data, amt - len(data))
http.client.IncompleteRead: IncompleteRead(0 bytes read, 1865472 more expected)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

car related to opendbc/car/ hyundai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant