GM: add checksum to button message (#26014)

* Add GM button msg checksum

* checksum that works for both, fix missing bit

* bump opendbc

* update comment

Co-authored-by: Shane Smiskol <shane@smiskol.com>
pull/26776/head
Jason Shuler 2 years ago committed by GitHub
parent e1c739f709
commit 2f83b9872f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      opendbc
  2. 9
      selfdrive/car/gm/gmcan.py

@ -1 +1 @@
Subproject commit 1f8aa057bc1c96fcf8a2b612a9897ce91e627381 Subproject commit bb7182902847b84aa572733edfd8e7073bb02aeb

@ -6,7 +6,16 @@ def create_buttons(packer, bus, idx, button):
values = { values = {
"ACCButtons": button, "ACCButtons": button,
"RollingCounter": idx, "RollingCounter": idx,
"ACCAlwaysOne": 1,
"DistanceButton": 0,
} }
checksum = 240 + int(values["ACCAlwaysOne"] * 0xf)
checksum += values["RollingCounter"] * (0x4ef if values["ACCAlwaysOne"] != 0 else 0x3f0)
checksum -= int(values["ACCButtons"] - 1) << 4 # not correct if value is 0
checksum -= 2 * values["DistanceButton"]
values["SteeringButtonChecksum"] = checksum
return packer.make_can_msg("ASCMSteeringButton", bus, values) return packer.make_can_msg("ASCMSteeringButton", bus, values)

Loading…
Cancel
Save