@ -13,6 +13,7 @@ import psutil 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					import  cereal . messaging  as  messaging import  cereal . messaging  as  messaging  
			
		
	
		
		
			
				
					
					from  cereal  import  log from  cereal  import  log  
			
		
	
		
		
			
				
					
					from  cereal . services  import  SERVICE_LIST  
			
		
	
		
		
			
				
					
					from  openpilot . common . dict_helpers  import  strip_deprecated_keys from  openpilot . common . dict_helpers  import  strip_deprecated_keys  
			
		
	
		
		
			
				
					
					from  openpilot . common . time  import  MIN_DATE from  openpilot . common . time  import  MIN_DATE  
			
		
	
		
		
			
				
					
					from  openpilot . common . filter_simple  import  FirstOrderFilter from  openpilot . common . filter_simple  import  FirstOrderFilter  
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -33,7 +34,7 @@ NetworkStrength = log.DeviceState.NetworkStrength 
			
		
	
		
		
			
				
					
					CURRENT_TAU  =  15.    # 15s time constant CURRENT_TAU  =  15.    # 15s time constant  
			
		
	
		
		
			
				
					
					TEMP_TAU  =  5.    # 5s time constant TEMP_TAU  =  5.    # 5s time constant  
			
		
	
		
		
			
				
					
					DISCONNECT_TIMEOUT  =  5.   # wait 5 seconds before going offroad after disconnect so you get an alert DISCONNECT_TIMEOUT  =  5.   # wait 5 seconds before going offroad after disconnect so you get an alert  
			
		
	
		
		
			
				
					
					PANDA_STATES_TIMEOUT  =  int ( 1000  *  1.5  *  DT_TRML )   # 1.5x the expected pandaState frequency PANDA_STATES_TIMEOUT  =  round ( 1000  /  SERVICE_LIST [ ' pandaStates ' ] . frequency  *  1.5 )   # 1.5x the expected pandaState frequency  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					ThermalBand  =  namedtuple ( " ThermalBand " ,  [ ' min_temp ' ,  ' max_temp ' ] ) ThermalBand  =  namedtuple ( " ThermalBand " ,  [ ' min_temp ' ,  ' max_temp ' ] )  
			
		
	
		
		
			
				
					
					HardwareState  =  namedtuple ( " HardwareState " ,  [ ' network_type ' ,  ' network_info ' ,  ' network_strength ' ,  ' network_stats ' , HardwareState  =  namedtuple ( " HardwareState " ,  [ ' network_type ' ,  ' network_info ' ,  ' network_strength ' ,  ' network_stats ' ,  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -210,6 +211,10 @@ def thermald_thread(end_event, hw_queue) -> None: 
			
		
	
		
		
			
				
					
					  while  not  end_event . is_set ( ) :    while  not  end_event . is_set ( ) :   
			
		
	
		
		
			
				
					
					    sm . update ( PANDA_STATES_TIMEOUT )      sm . update ( PANDA_STATES_TIMEOUT )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    # Run at 2Hz   
			
		
	
		
		
			
				
					
					    if  sm . frame  %  round ( SERVICE_LIST [ ' pandaStates ' ] . frequency  *  DT_TRML )  !=  0 :   
			
		
	
		
		
			
				
					
					      continue   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    pandaStates  =  sm [ ' pandaStates ' ]      pandaStates  =  sm [ ' pandaStates ' ]   
			
		
	
		
		
			
				
					
					    peripheralState  =  sm [ ' peripheralState ' ]      peripheralState  =  sm [ ' peripheralState ' ]   
			
		
	
		
		
			
				
					
					    peripheral_panda_present  =  peripheralState . pandaType  !=  log . PandaState . PandaType . unknown      peripheral_panda_present  =  peripheralState . pandaType  !=  log . PandaState . PandaType . unknown