From 937ca9a946e6e8570e30c06ca9bc4c32102d5e79 Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Mon, 3 Oct 2022 19:19:39 -0700 Subject: [PATCH] hyundai: fix FCA11 checksum and counter (#25027) * hyundai: fix FCA11 checksum and counter * update refs and comment about alt DBC definition we do not support old-commit-hash: 5352006cbd00dc84262a4789b66cba47669d6d75 --- opendbc | 2 +- selfdrive/car/hyundai/hyundaican.py | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/opendbc b/opendbc index eaac172af9..9ddcdb22c4 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit eaac172af9cb342204e69ec52339cdf3c6a8ac4e +Subproject commit 9ddcdb22c4929baf310295e832668e6e7fcfa602 diff --git a/selfdrive/car/hyundai/hyundaican.py b/selfdrive/car/hyundai/hyundaican.py index b3e1aa6b66..139a14d5e8 100644 --- a/selfdrive/car/hyundai/hyundaican.py +++ b/selfdrive/car/hyundai/hyundaican.py @@ -132,18 +132,16 @@ def create_acc_commands(packer, enabled, accel, upper_jerk, idx, lead_visible, s } commands.append(packer.make_can_msg("SCC14", 0, scc14_values)) + # note that some vehicles most likely have an alternate checksum/counter definition + # https://github.com/commaai/opendbc/commit/9ddcdb22c4929baf310295e832668e6e7fcfa602 fca11_values = { - # seems to count 2,1,0,3,2,1,0,3,2,1,0,3,2,1,0,repeat... - # (where first value is aligned to Supplemental_Counter == 0) - # test: [(idx % 0xF, -((idx % 0xF) + 2) % 4) for idx in range(0x14)] - "CR_FCA_Alive": ((-((idx % 0xF) + 2) % 4) << 2) + 1, - "Supplemental_Counter": idx % 0xF, + "CR_FCA_Alive": idx % 0xF, "PAINT1_Status": 1, "FCA_DrvSetStatus": 1, "FCA_Status": 1, # AEB disabled } fca11_dat = packer.make_can_msg("FCA11", 0, fca11_values)[2] - fca11_values["CR_FCA_ChkSum"] = 0x10 - sum(sum(divmod(i, 16)) for i in fca11_dat) % 0x10 + fca11_values["CR_FCA_ChkSum"] = hyundai_checksum(fca11_dat[:7]) commands.append(packer.make_can_msg("FCA11", 0, fca11_values)) return commands