diff --git a/opendbc b/opendbc index 0c0215516f..7456061a71 160000 --- a/opendbc +++ b/opendbc @@ -1 +1 @@ -Subproject commit 0c0215516f6a0be50fcbe7fc1e8e2fe0f47f9d86 +Subproject commit 7456061a7150911a8c186231453a337e6c73c743 diff --git a/selfdrive/car/chrysler/carcontroller.py b/selfdrive/car/chrysler/carcontroller.py index 365dec9723..c4db730368 100644 --- a/selfdrive/car/chrysler/carcontroller.py +++ b/selfdrive/car/chrysler/carcontroller.py @@ -50,7 +50,7 @@ class CarController(): if pcm_cancel_cmd: # TODO: would be better to start from frame_2b3 - new_msg = create_wheel_buttons(self.ccframe) + new_msg = create_wheel_buttons(self.packer, self.ccframe, cancel=True) can_sends.append(new_msg) # LKAS_HEARTBIT is forwarded by Panda so no need to send it here. diff --git a/selfdrive/car/chrysler/chryslercan.py b/selfdrive/car/chrysler/chryslercan.py index 7e6e320cb4..bf9f3731f6 100644 --- a/selfdrive/car/chrysler/chryslercan.py +++ b/selfdrive/car/chrysler/chryslercan.py @@ -5,34 +5,6 @@ from selfdrive.car import make_can_msg GearShifter = car.CarState.GearShifter VisualAlert = car.CarControl.HUDControl.VisualAlert -def calc_checksum(data): - """This function does not want the checksum byte in the input data. - - jeep chrysler canbus checksum from http://illmatics.com/Remote%20Car%20Hacking.pdf - """ - checksum = 0xFF - for curr in data[:-1]: - shift = 0x80 - for _ in range(0, 8): - bit_sum = curr & shift - temp_chk = checksum & 0x80 - if (bit_sum != 0): - bit_sum = 0x1C - if (temp_chk != 0): - bit_sum = 1 - checksum = checksum << 1 - temp_chk = checksum | 1 - bit_sum ^= temp_chk - else: - if (temp_chk != 0): - bit_sum = 0x1D - checksum = checksum << 1 - bit_sum ^= checksum - checksum = bit_sum - shift = shift >> 1 - return ~checksum & 0xFF - - def create_lkas_hud(packer, gear, lkas_active, hud_alert, hud_count, lkas_car_model): # LKAS_HUD 0x2a6 (678) Controls what lane-keeping icon is displayed. @@ -73,18 +45,13 @@ def create_lkas_command(packer, apply_steer, moving_fast, frame): "LKAS_HIGH_TORQUE": int(moving_fast), "COUNTER": frame % 0x10, } - - dat = packer.make_can_msg("LKAS_COMMAND", 0, values)[2] - checksum = calc_checksum(dat) - - values["CHECKSUM"] = checksum return packer.make_can_msg("LKAS_COMMAND", 0, values) -def create_wheel_buttons(frame): +def create_wheel_buttons(packer, frame, cancel=False): # 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') + b"\x00" - dat = dat[:-1] + calc_checksum(dat).to_bytes(1, 'little') - return make_can_msg(0x23b, dat, 0) + values = { + "ACC_CANCEL": cancel, + "COUNTER": frame % 10 + } + return packer.make_can_msg("WHEEL_BUTTONS", 0, values) diff --git a/selfdrive/car/chrysler/test_chryslercan.py b/selfdrive/car/chrysler/test_chryslercan.py index d4d4105760..5b15666c04 100644 --- a/selfdrive/car/chrysler/test_chryslercan.py +++ b/selfdrive/car/chrysler/test_chryslercan.py @@ -11,10 +11,6 @@ GearShifter = car.CarState.GearShifter class TestChryslerCan(unittest.TestCase): - def test_checksum(self): - 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') self.assertEqual(