| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -44,18 +44,9 @@ class CarInterface(CarInterfaceBase): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    stop_and_go = candidate in TSS2_CAR | 
					 | 
					 | 
					 | 
					    stop_and_go = candidate in TSS2_CAR | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Detect smartDSU, which intercepts ACC_CMD from the DSU (or radar) allowing openpilot to send it | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # 0x2AA is sent by a similar device which intercepts the radar instead of DSU on NO_DSU_CARs | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if 0x2FF in fingerprint[0] or (0x2AA in fingerprint[0] and candidate in NO_DSU_CAR): | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ret.flags |= ToyotaFlags.SMART_DSU.value | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if 0x2AA in fingerprint[0] and candidate in NO_DSU_CAR: | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ret.flags |= ToyotaFlags.RADAR_CAN_FILTER.value | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # In TSS2 cars, the camera does long control | 
					 | 
					 | 
					 | 
					    # In TSS2 cars, the camera does long control | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    found_ecus = [fw.ecu for fw in car_fw] | 
					 | 
					 | 
					 | 
					    found_ecus = [fw.ecu for fw in car_fw] | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ret.enableDsu = len(found_ecus) > 0 and Ecu.dsu not in found_ecus and candidate not in (NO_DSU_CAR | UNSUPPORTED_DSU_CAR) \ | 
					 | 
					 | 
					 | 
					    ret.enableDsu = len(found_ecus) > 0 and Ecu.dsu not in found_ecus and candidate not in (NO_DSU_CAR | UNSUPPORTED_DSU_CAR) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					                                        and not (ret.flags & ToyotaFlags.SMART_DSU) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if candidate == CAR.TOYOTA_PRIUS: | 
					 | 
					 | 
					 | 
					    if candidate == CAR.TOYOTA_PRIUS: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      stop_and_go = True | 
					 | 
					 | 
					 | 
					      stop_and_go = True | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -98,7 +89,7 @@ class CarInterface(CarInterfaceBase): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # TODO: these models can do stop and go, but unclear if it requires sDSU or unplugging DSU. | 
					 | 
					 | 
					 | 
					    # TODO: these models can do stop and go, but unclear if it requires sDSU or unplugging DSU. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    #  For now, don't list stop and go functionality in the docs | 
					 | 
					 | 
					 | 
					    #  For now, don't list stop and go functionality in the docs | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if ret.flags & ToyotaFlags.SNG_WITHOUT_DSU: | 
					 | 
					 | 
					 | 
					    if ret.flags & ToyotaFlags.SNG_WITHOUT_DSU: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      stop_and_go = stop_and_go or bool(ret.flags & ToyotaFlags.SMART_DSU.value) or (ret.enableDsu and not docs) | 
					 | 
					 | 
					 | 
					      stop_and_go = stop_and_go or (ret.enableDsu and not docs) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ret.centerToFront = ret.wheelbase * 0.44 | 
					 | 
					 | 
					 | 
					    ret.centerToFront = ret.wheelbase * 0.44 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -110,28 +101,20 @@ class CarInterface(CarInterfaceBase): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # TODO: make an adas dbc file for dsu-less models | 
					 | 
					 | 
					 | 
					    # TODO: make an adas dbc file for dsu-less models | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ret.radarUnavailable = DBC[candidate]['radar'] is None or candidate in (NO_DSU_CAR - TSS2_CAR) | 
					 | 
					 | 
					 | 
					    ret.radarUnavailable = DBC[candidate]['radar'] is None or candidate in (NO_DSU_CAR - TSS2_CAR) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # if the smartDSU is detected, openpilot can send ACC_CONTROL and the smartDSU will block it from the DSU or radar. | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # since we don't yet parse radar on TSS2/TSS-P radar-based ACC cars, gate longitudinal behind experimental toggle | 
					 | 
					 | 
					 | 
					    # since we don't yet parse radar on TSS2/TSS-P radar-based ACC cars, gate longitudinal behind experimental toggle | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    use_sdsu = bool(ret.flags & ToyotaFlags.SMART_DSU) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if candidate in (RADAR_ACC_CAR | NO_DSU_CAR): | 
					 | 
					 | 
					 | 
					    if candidate in (RADAR_ACC_CAR | NO_DSU_CAR): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ret.experimentalLongitudinalAvailable = use_sdsu or candidate in RADAR_ACC_CAR | 
					 | 
					 | 
					 | 
					      ret.experimentalLongitudinalAvailable = candidate in RADAR_ACC_CAR | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if not use_sdsu: | 
					 | 
					 | 
					 | 
					      # Disabling radar is only supported on TSS2 radar-ACC cars | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        # Disabling radar is only supported on TSS2 radar-ACC cars | 
					 | 
					 | 
					 | 
					      if experimental_long and candidate in RADAR_ACC_CAR: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        if experimental_long and candidate in RADAR_ACC_CAR: | 
					 | 
					 | 
					 | 
					        ret.flags |= ToyotaFlags.DISABLE_RADAR.value | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          ret.flags |= ToyotaFlags.DISABLE_RADAR.value | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      else: | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        use_sdsu = use_sdsu and experimental_long | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # openpilot longitudinal enabled by default: | 
					 | 
					 | 
					 | 
					    # openpilot longitudinal enabled by default: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    #  - non-(TSS2 radar ACC cars) w/ smartDSU installed | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    #  - cars w/ DSU disconnected | 
					 | 
					 | 
					 | 
					    #  - cars w/ DSU disconnected | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    #  - TSS2 cars with camera sending ACC_CONTROL where we can block it | 
					 | 
					 | 
					 | 
					    #  - TSS2 cars with camera sending ACC_CONTROL where we can block it | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # openpilot longitudinal behind experimental long toggle: | 
					 | 
					 | 
					 | 
					    # openpilot longitudinal behind experimental long toggle: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    #  - TSS2 radar ACC cars w/ smartDSU installed | 
					 | 
					 | 
					 | 
					    #  - TSS2 radar ACC cars (disables radar) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    #  - TSS2 radar ACC cars w/o smartDSU installed (disables radar) | 
					 | 
					 | 
					 | 
					    ret.openpilotLongitudinalControl = ret.enableDsu or candidate in (TSS2_CAR - RADAR_ACC_CAR) or bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    #  - TSS-P DSU-less cars w/ CAN filter installed (no radar parser yet) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ret.openpilotLongitudinalControl = use_sdsu or ret.enableDsu or candidate in (TSS2_CAR - RADAR_ACC_CAR) or bool(ret.flags & ToyotaFlags.DISABLE_RADAR.value) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ret.autoResumeSng = ret.openpilotLongitudinalControl and candidate in NO_STOP_TIMER_CAR | 
					 | 
					 | 
					 | 
					    ret.autoResumeSng = ret.openpilotLongitudinalControl and candidate in NO_STOP_TIMER_CAR | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if not ret.openpilotLongitudinalControl: | 
					 | 
					 | 
					 | 
					    if not ret.openpilotLongitudinalControl: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -156,7 +139,7 @@ class CarInterface(CarInterfaceBase): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  @staticmethod | 
					 | 
					 | 
					 | 
					  @staticmethod | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def init(CP, logcan, sendcan): | 
					 | 
					 | 
					 | 
					  def init(CP, logcan, sendcan): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # disable radar if alpha longitudinal toggled on radar-ACC car without CAN filter/smartDSU | 
					 | 
					 | 
					 | 
					    # disable radar if alpha longitudinal toggled on radar-ACC car | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if CP.flags & ToyotaFlags.DISABLE_RADAR.value: | 
					 | 
					 | 
					 | 
					    if CP.flags & ToyotaFlags.DISABLE_RADAR.value: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) | 
					 | 
					 | 
					 | 
					      communication_control = bytes([uds.SERVICE_TYPE.COMMUNICATION_CONTROL, uds.CONTROL_TYPE.ENABLE_RX_DISABLE_TX, uds.MESSAGE_TYPE.NORMAL]) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      disable_ecu(logcan, sendcan, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=communication_control) | 
					 | 
					 | 
					 | 
					      disable_ecu(logcan, sendcan, bus=0, addr=0x750, sub_addr=0xf, com_cont_req=communication_control) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -165,7 +148,7 @@ class CarInterface(CarInterfaceBase): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  def _update(self, c): | 
					 | 
					 | 
					 | 
					  def _update(self, c): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    ret = self.CS.update(self.cp, self.cp_cam) | 
					 | 
					 | 
					 | 
					    ret = self.CS.update(self.cp, self.cp_cam) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR) or (self.CP.flags & ToyotaFlags.SMART_DSU and not self.CP.flags & ToyotaFlags.RADAR_CAN_FILTER): | 
					 | 
					 | 
					 | 
					    if self.CP.carFingerprint in (TSS2_CAR - RADAR_ACC_CAR): | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) | 
					 | 
					 | 
					 | 
					      ret.buttonEvents = create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # events | 
					 | 
					 | 
					 | 
					    # events | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |