| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -167,11 +167,11 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.state = State.disabled | 
					 | 
					 | 
					 | 
					    self.state = State.disabled | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.enabled = False | 
					 | 
					 | 
					 | 
					    self.enabled = False | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.active = False | 
					 | 
					 | 
					 | 
					    self.active = False | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.can_rcv_timeout = False | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.soft_disable_timer = 0 | 
					 | 
					 | 
					 | 
					    self.soft_disable_timer = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.mismatch_counter = 0 | 
					 | 
					 | 
					 | 
					    self.mismatch_counter = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.cruise_mismatch_counter = 0 | 
					 | 
					 | 
					 | 
					    self.cruise_mismatch_counter = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.can_rcv_timeout_counter = 0 | 
					 | 
					 | 
					 | 
					    self.can_rcv_timeout_counter = 0      # conseuctive timeout count | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    self.can_rcv_cum_timeout_counter = 0  # cumulative timeout count | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.last_blinker_frame = 0 | 
					 | 
					 | 
					 | 
					    self.last_blinker_frame = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.last_steering_pressed_frame = 0 | 
					 | 
					 | 
					 | 
					    self.last_steering_pressed_frame = 0 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    self.distance_traveled = 0 | 
					 | 
					 | 
					 | 
					    self.distance_traveled = 0 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -349,9 +349,10 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      self.events.add(EventName.canError) | 
					 | 
					 | 
					 | 
					      self.events.add(EventName.canError) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # generic catch-all. ideally, a more specific event should be added above instead | 
					 | 
					 | 
					 | 
					    # generic catch-all. ideally, a more specific event should be added above instead | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    can_rcv_timeout = self.can_rcv_timeout_counter >= 5 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    has_disable_events = self.events.any(ET.NO_ENTRY) and (self.events.any(ET.SOFT_DISABLE) or self.events.any(ET.IMMEDIATE_DISABLE)) | 
					 | 
					 | 
					 | 
					    has_disable_events = self.events.any(ET.NO_ENTRY) and (self.events.any(ET.SOFT_DISABLE) or self.events.any(ET.IMMEDIATE_DISABLE)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    no_system_errors = (not has_disable_events) or (len(self.events) == num_events) | 
					 | 
					 | 
					 | 
					    no_system_errors = (not has_disable_events) or (len(self.events) == num_events) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if (not self.sm.all_checks() or self.can_rcv_timeout) and no_system_errors: | 
					 | 
					 | 
					 | 
					    if (not self.sm.all_checks() or can_rcv_timeout) and no_system_errors: | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if not self.sm.all_alive(): | 
					 | 
					 | 
					 | 
					      if not self.sm.all_alive(): | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        self.events.add(EventName.commIssue) | 
					 | 
					 | 
					 | 
					        self.events.add(EventName.commIssue) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      elif not self.sm.all_freq_ok(): | 
					 | 
					 | 
					 | 
					      elif not self.sm.all_freq_ok(): | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -363,7 +364,7 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'invalid': [s for s, valid in self.sm.valid.items() if not valid], | 
					 | 
					 | 
					 | 
					        'invalid': [s for s, valid in self.sm.valid.items() if not valid], | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'not_alive': [s for s, alive in self.sm.alive.items() if not alive], | 
					 | 
					 | 
					 | 
					        'not_alive': [s for s, alive in self.sm.alive.items() if not alive], | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'not_freq_ok': [s for s, freq_ok in self.sm.freq_ok.items() if not freq_ok], | 
					 | 
					 | 
					 | 
					        'not_freq_ok': [s for s, freq_ok in self.sm.freq_ok.items() if not freq_ok], | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'can_rcv_timeout': self.can_rcv_timeout, | 
					 | 
					 | 
					 | 
					        'can_rcv_timeout': can_rcv_timeout, | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } | 
					 | 
					 | 
					 | 
					      } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      if logs != self.logged_comm_issue: | 
					 | 
					 | 
					 | 
					      if logs != self.logged_comm_issue: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        cloudlog.event("commIssue", error=True, **logs) | 
					 | 
					 | 
					 | 
					        cloudlog.event("commIssue", error=True, **logs) | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -445,9 +446,9 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # Check for CAN timeout | 
					 | 
					 | 
					 | 
					    # Check for CAN timeout | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    if not can_strs: | 
					 | 
					 | 
					 | 
					    if not can_strs: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      self.can_rcv_timeout_counter += 1 | 
					 | 
					 | 
					 | 
					      self.can_rcv_timeout_counter += 1 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      self.can_rcv_timeout = True | 
					 | 
					 | 
					 | 
					      self.can_rcv_cum_timeout_counter += 1 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    else: | 
					 | 
					 | 
					 | 
					    else: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      self.can_rcv_timeout = False | 
					 | 
					 | 
					 | 
					      self.can_rcv_timeout_counter = 0 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # When the panda and controlsd do not agree on controls_allowed | 
					 | 
					 | 
					 | 
					    # When the panda and controlsd do not agree on controls_allowed | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    # we want to disengage openpilot. However the status from the panda goes through | 
					 | 
					 | 
					 | 
					    # we want to disengage openpilot. However the status from the panda goes through | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -785,7 +786,7 @@ class Controls: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    controlsState.cumLagMs = -self.rk.remaining * 1000. | 
					 | 
					 | 
					 | 
					    controlsState.cumLagMs = -self.rk.remaining * 1000. | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    controlsState.startMonoTime = int(start_time * 1e9) | 
					 | 
					 | 
					 | 
					    controlsState.startMonoTime = int(start_time * 1e9) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    controlsState.forceDecel = bool(force_decel) | 
					 | 
					 | 
					 | 
					    controlsState.forceDecel = bool(force_decel) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    controlsState.canErrorCounter = self.can_rcv_timeout_counter | 
					 | 
					 | 
					 | 
					    controlsState.canErrorCounter = self.can_rcv_cum_timeout_counter | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    controlsState.experimentalMode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl | 
					 | 
					 | 
					 | 
					    controlsState.experimentalMode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    lat_tuning = self.CP.lateralTuning.which() | 
					 | 
					 | 
					 | 
					    lat_tuning = self.CP.lateralTuning.which() | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |