diff --git a/opendbc b/opendbc index fbbba94aae..a1aa3b78f7 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit fbbba94aae1e992c42f6f106c18d898905e3e39b +Subproject commit a1aa3b78f7ae9405fcb42fa8f94aa3dae8acb987 diff --git a/panda b/panda index 1b49d3e830..d7f1195d1e 160000 --- a/panda +++ b/panda @@ -1 +1 @@ -Subproject commit 1b49d3e830f6d894f9daf820f956f315fd951428 +Subproject commit d7f1195d1eef4ca3f90c17e61f07d95a566f3107 diff --git a/selfdrive/car/chrysler/chryslercan.py b/selfdrive/car/chrysler/chryslercan.py index 3c5a913fca..c06c27e964 100644 --- a/selfdrive/car/chrysler/chryslercan.py +++ b/selfdrive/car/chrysler/chryslercan.py @@ -10,19 +10,10 @@ def calc_checksum(data): jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf """ - end_index = len(data) - index = 0 checksum = 0xFF - temp_chk = 0 - bit_sum = 0 - if(end_index <= index): - return False - for index in range(0, end_index): + for curr in data[:-1]: shift = 0x80 - curr = data[index] - iterate = 8 - while(iterate > 0): - iterate -= 1 + for i in range(0, 8): bit_sum = curr & shift temp_chk = checksum & 0x80 if (bit_sum != 0): @@ -84,7 +75,6 @@ def create_lkas_command(packer, apply_steer, moving_fast, frame): } dat = packer.make_can_msg("LKAS_COMMAND", 0, values)[2] - dat = dat[:-1] checksum = calc_checksum(dat) values["CHECKSUM"] = checksum @@ -95,6 +85,6 @@ def create_wheel_buttons(frame): # WHEEL_BUTTONS (571) Message sent to cancel ACC. start = b"\x01" # acc cancel set counter = (frame % 10) << 4 - dat = start + counter.to_bytes(1, 'little') - dat = dat + calc_checksum(dat).to_bytes(1, 'little') + dat = start + counter.to_bytes(1, 'little') + b"\x00" + dat = dat[:-1] + calc_checksum(dat).to_bytes(1, 'little') return make_can_msg(0x23b, dat, 0) diff --git a/selfdrive/car/chrysler/test_chryslercan.py b/selfdrive/car/chrysler/test_chryslercan.py index 637cdc9ffa..d4d4105760 100644 --- a/selfdrive/car/chrysler/test_chryslercan.py +++ b/selfdrive/car/chrysler/test_chryslercan.py @@ -12,8 +12,8 @@ GearShifter = car.CarState.GearShifter class TestChryslerCan(unittest.TestCase): def test_checksum(self): - self.assertEqual(0x75, chryslercan.calc_checksum(b"\x01\x20")) - self.assertEqual(0xcc, chryslercan.calc_checksum(b"\x14\x00\x00\x00\x20")) + self.assertEqual(0x75, chryslercan.calc_checksum(b"\x01\x20\x00")) + self.assertEqual(0xcc, chryslercan.calc_checksum(b"\x14\x00\x00\x00\x20\x00")) def test_hud(self): packer = CANPacker('chrysler_pacifica_2017_hybrid')