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: 5352006cbd
taco
Greg Hogan 3 years ago committed by GitHub
parent 5c99e4ca39
commit 937ca9a946
  1. 2
      opendbc
  2. 10
      selfdrive/car/hyundai/hyundaican.py

@ -1 +1 @@
Subproject commit eaac172af9cb342204e69ec52339cdf3c6a8ac4e
Subproject commit 9ddcdb22c4929baf310295e832668e6e7fcfa602

@ -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

Loading…
Cancel
Save