@ -2,7 +2,6 @@
import datetime
import os
import time
from collections import namedtuple
from typing import Dict , Optional , Tuple
import psutil
@ -15,15 +14,13 @@ from common.numpy_fast import clip, interp
from common . params import Params
from common . realtime import DT_TRML , sec_since_boot
from selfdrive . controls . lib . alertmanager import set_offroad_alert
from selfdrive . hardware import EON , HARDWARE , TICI
from selfdrive . hardware import EON , HARDWARE
from selfdrive . loggerd . config import get_available_percent
from selfdrive . pandad import get_expected_signature
from selfdrive . swaglog import cloudlog
from selfdrive . thermald . power_monitoring import PowerMonitoring
from selfdrive . version import get_git_branch , terms_version , training_version
ThermalConfig = namedtuple ( ' ThermalConfig ' , [ ' cpu ' , ' gpu ' , ' mem ' , ' bat ' , ' ambient ' ] )
FW_SIGNATURE = get_expected_signature ( )
ThermalStatus = log . DeviceState . ThermalStatus
@ -40,17 +37,6 @@ prev_offroad_states: Dict[str, Tuple[bool, Optional[str]]] = {}
LEON = False
last_eon_fan_val = None
def get_thermal_config ( ) :
# (tz, scale)
if EON :
return ThermalConfig ( cpu = ( ( 5 , 7 , 10 , 12 ) , 10 ) , gpu = ( ( 16 , ) , 10 ) , mem = ( 2 , 10 ) , bat = ( 29 , 1000 ) , ambient = ( 25 , 1 ) )
elif TICI :
return ThermalConfig ( cpu = ( ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ) , 1000 ) , gpu = ( ( 48 , 49 ) , 1000 ) , mem = ( 15 , 1000 ) , bat = ( None , 1 ) , ambient = ( 70 , 1000 ) )
else :
return ThermalConfig ( cpu = ( ( None , ) , 1 ) , gpu = ( ( None , ) , 1 ) , mem = ( None , 1 ) , bat = ( None , 1 ) , ambient = ( None , 1 ) )
def read_tz ( x ) :
if x is None :
return 0
@ -198,7 +184,7 @@ def thermald_thread():
power_monitor = PowerMonitoring ( )
no_panda_cnt = 0
thermal_config = get_thermal_config ( )
thermal_config = HARDWARE . get_thermal_config ( )
while 1 :
pandaState = messaging . recv_sock ( pandaState_sock , wait = True )
@ -395,7 +381,7 @@ def thermald_thread():
cloudlog . info ( f " shutting device down, offroad since { off_ts } " )
# TODO: add function for blocking cloudlog instead of sleep
time . sleep ( 10 )
os . system ( ' LD_LIBRARY_PATH= " " svc power shutdown ' )
HARDWARE . shutdown ( )
msg . deviceState . chargingError = current_filter . x > 0. and msg . deviceState . batteryPercent < 90 # if current is positive, then battery is being discharged
msg . deviceState . started = started_ts is not None