| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -5,34 +5,6 @@ from selfdrive.car import make_can_msg | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					GearShifter = car.CarState.GearShifter | 
					 | 
					 | 
					 | 
					GearShifter = car.CarState.GearShifter | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					VisualAlert = car.CarControl.HUDControl.VisualAlert | 
					 | 
					 | 
					 | 
					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): | 
					 | 
					 | 
					 | 
					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. | 
					 | 
					 | 
					 | 
					  # 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), | 
					 | 
					 | 
					 | 
					    "LKAS_HIGH_TORQUE": int(moving_fast), | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    "COUNTER": frame % 0x10, | 
					 | 
					 | 
					 | 
					    "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) | 
					 | 
					 | 
					 | 
					  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. | 
					 | 
					 | 
					 | 
					  # WHEEL_BUTTONS (571) Message sent to cancel ACC. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  start = b"\x01"  # acc cancel set | 
					 | 
					 | 
					 | 
					  values = { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  counter = (frame % 10) << 4 | 
					 | 
					 | 
					 | 
					    "ACC_CANCEL": cancel, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  dat = start + counter.to_bytes(1, 'little') + b"\x00" | 
					 | 
					 | 
					 | 
					    "COUNTER": frame % 10 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  dat = dat[:-1] + calc_checksum(dat).to_bytes(1, 'little') | 
					 | 
					 | 
					 | 
					  } | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  return make_can_msg(0x23b, dat, 0) | 
					 | 
					 | 
					 | 
					  return packer.make_can_msg("WHEEL_BUTTONS", 0, values) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
	
		
		
			
				
					| 
						
						
						
					 | 
					 | 
					
  |