@ -1,6 +1,7 @@ 
			
		
	
		
		
			
				
					
					#!/usr/bin/env python3 #!/usr/bin/env python3  
			
		
	
		
		
			
				
					
					import  datetime import  datetime  
			
		
	
		
		
			
				
					
					import  os import  os  
			
		
	
		
		
			
				
					
					import  json  
			
		
	
		
		
			
				
					
					import  queue import  queue  
			
		
	
		
		
			
				
					
					import  threading import  threading  
			
		
	
		
		
			
				
					
					import  time import  time  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -375,8 +376,6 @@ def thermald_thread(end_event, hw_queue): 
			
		
	
		
		
			
				
					
					    msg . deviceState . thermalStatus  =  thermal_status      msg . deviceState . thermalStatus  =  thermal_status   
			
		
	
		
		
			
				
					
					    pm . send ( " deviceState " ,  msg )      pm . send ( " deviceState " ,  msg )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    should_start_prev  =  should_start   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    # Log to statsd      # Log to statsd   
			
		
	
		
		
			
				
					
					    statlog . gauge ( " free_space_percent " ,  msg . deviceState . freeSpacePercent )      statlog . gauge ( " free_space_percent " ,  msg . deviceState . freeSpacePercent )   
			
		
	
		
		
			
				
					
					    statlog . gauge ( " gpu_usage_percent " ,  msg . deviceState . gpuUsagePercent )      statlog . gauge ( " gpu_usage_percent " ,  msg . deviceState . gpuUsagePercent )   
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -399,15 +398,26 @@ def thermald_thread(end_event, hw_queue): 
			
		
	
		
		
			
				
					
					    statlog . gauge ( " screen_brightness_percent " ,  msg . deviceState . screenBrightnessPercent )      statlog . gauge ( " screen_brightness_percent " ,  msg . deviceState . screenBrightnessPercent )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    # report to server once every 10 minutes      # report to server once every 10 minutes   
			
		
	
		
		
			
				
					
					    if  ( count  %  int ( 600.  /  DT_TRML ) )  ==  0 :      rising_edge_started  =  should_start  and  not  should_start_prev   
			
				
				
			
		
	
		
		
			
				
					
					      cloudlog . event ( " STATUS_PACKET " ,      if  rising_edge_started  or  ( count  %  int ( 600.  /  DT_TRML ) )  ==  0 :   
			
				
				
			
		
	
		
		
			
				
					
					                     count = count ,        dat  =  {   
			
				
				
			
		
	
		
		
			
				
					
					                     pandaStates = [ strip_deprecated_keys ( p . to_dict ( ) )  for  p  in  pandaStates ] ,          ' count ' :  count ,   
			
				
				
			
		
	
		
		
			
				
					
					                     peripheralState = strip_deprecated_keys ( peripheralState . to_dict ( ) ) ,          ' pandaStates ' :  [ strip_deprecated_keys ( p . to_dict ( ) )  for  p  in  pandaStates ] ,   
			
				
				
			
		
	
		
		
			
				
					
					                     location = ( strip_deprecated_keys ( sm [ " gpsLocationExternal " ] . to_dict ( ) )  if  sm . alive [ " gpsLocationExternal " ]  else  None ) ,          ' peripheralState ' :  strip_deprecated_keys ( peripheralState . to_dict ( ) ) ,   
			
				
				
			
		
	
		
		
			
				
					
					                     deviceState = strip_deprecated_keys ( msg . to_dict ( ) ) )          ' location ' :  ( strip_deprecated_keys ( sm [ " gpsLocationExternal " ] . to_dict ( ) )  if  sm . alive [ " gpsLocationExternal " ]  else  None ) ,   
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					        ' deviceState ' :  strip_deprecated_keys ( msg . to_dict ( ) )   
			
		
	
		
		
			
				
					
					      }   
			
		
	
		
		
			
				
					
					      cloudlog . event ( " STATUS_PACKET " ,  * * dat )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					      # save last one before going onroad   
			
		
	
		
		
			
				
					
					      if  rising_edge_started :   
			
		
	
		
		
			
				
					
					        try :   
			
		
	
		
		
			
				
					
					          params . put ( " LastOffroadStatusPacket " ,  json . dumps ( dat ) )   
			
		
	
		
		
			
				
					
					        except  Exception :   
			
		
	
		
		
			
				
					
					          cloudlog . exception ( " failed to save offroad status " )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					    count  + =  1      count  + =  1   
			
		
	
		
		
			
				
					
					    should_start_prev  =  should_start   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					def  main ( ) : def  main ( ) :