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>
old-commit-hash: 2f83b9872fe991d21e07a95cc518f91f140a856a
This commit is contained in:
Jason Shuler
2022-12-12 20:26:30 -05:00
committed by GitHub
parent c5cbd60a34
commit fc38509523
2 changed files with 10 additions and 1 deletions

Submodule opendbc updated: 1f8aa057bc...bb71829028

View File

@@ -6,7 +6,16 @@ def create_buttons(packer, bus, idx, button):
values = {
"ACCButtons": button,
"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)