@ -347,7 +347,7 @@ def replay_process(cfg, lr, fingerprint=None):
else :
else :
return cpp_replay_process ( cfg , lr , fingerprint )
return cpp_replay_process ( cfg , lr , fingerprint )
def setup_env ( simulation = False ) :
def setup_env ( simulation = False , CP = None ) :
params = Params ( )
params = Params ( )
params . clear_all ( )
params . clear_all ( )
params . put_bool ( " OpenpilotEnabledToggle " , True )
params . put_bool ( " OpenpilotEnabledToggle " , True )
@ -358,12 +358,22 @@ def setup_env(simulation=False):
os . environ [ " NO_RADAR_SLEEP " ] = " 1 "
os . environ [ " NO_RADAR_SLEEP " ] = " 1 "
os . environ [ " REPLAY " ] = " 1 "
os . environ [ " REPLAY " ] = " 1 "
os . environ [ ' SKIP_FW_QUERY ' ] = " "
os . environ [ ' FINGERPRINT ' ] = " "
if simulation :
if simulation :
os . environ [ " SIMULATION " ] = " 1 "
os . environ [ " SIMULATION " ] = " 1 "
elif " SIMULATION " in os . environ :
elif " SIMULATION " in os . environ :
del os . environ [ " SIMULATION " ]
del os . environ [ " SIMULATION " ]
# Regen or python process
if CP is not None :
if CP . fingerprintSource == " fw " and CP . carFingerprint in FW_VERSIONS :
params . put ( " CarParamsCache " , CP . as_builder ( ) . to_bytes ( ) )
else :
os . environ [ ' SKIP_FW_QUERY ' ] = " 1 "
os . environ [ ' FINGERPRINT ' ] = CP . carFingerprint
def python_replay_process ( cfg , lr , fingerprint = None ) :
def python_replay_process ( cfg , lr , fingerprint = None ) :
sub_sockets = [ s for _ , sub in cfg . pub_sub . items ( ) for s in sub ]
sub_sockets = [ s for _ , sub in cfg . pub_sub . items ( ) for s in sub ]
pub_sockets = [ s for s in cfg . pub_sub . keys ( ) if s != ' can ' ]
pub_sockets = [ s for s in cfg . pub_sub . keys ( ) if s != ' can ' ]
@ -378,30 +388,13 @@ def python_replay_process(cfg, lr, fingerprint=None):
all_msgs = sorted ( lr , key = lambda msg : msg . logMonoTime )
all_msgs = sorted ( lr , key = lambda msg : msg . logMonoTime )
pub_msgs = [ msg for msg in all_msgs if msg . which ( ) in list ( cfg . pub_sub . keys ( ) ) ]
pub_msgs = [ msg for msg in all_msgs if msg . which ( ) in list ( cfg . pub_sub . keys ( ) ) ]
setup_env ( )
# TODO: remove after getting new route for civic & accord
migration = {
" HONDA CIVIC 2016 TOURING " : " HONDA CIVIC 2016 " ,
" HONDA ACCORD 2018 SPORT 2T " : " HONDA ACCORD 2018 " ,
" HONDA ACCORD 2T 2018 " : " HONDA ACCORD 2018 " ,
" Mazda CX-9 2021 " : " MAZDA CX-9 2021 " ,
}
if fingerprint is not None :
if fingerprint is not None :
os . environ [ ' SKIP_FW_QUERY ' ] = " 1 "
os . environ [ ' SKIP_FW_QUERY ' ] = " 1 "
os . environ [ ' FINGERPRINT ' ] = fingerprint
os . environ [ ' FINGERPRINT ' ] = fingerprint
setup_env ( )
else :
else :
os . environ [ ' SKIP_FW_QUERY ' ] = " "
CP = [ m for m in lr if m . which ( ) == ' carParams ' ] [ 0 ] . carParams
os . environ [ ' FINGERPRINT ' ] = " "
setup_env ( CP = CP )
for msg in lr :
if msg . which ( ) == ' carParams ' :
car_fingerprint = migration . get ( msg . carParams . carFingerprint , msg . carParams . carFingerprint )
if msg . carParams . fingerprintSource == " fw " and ( car_fingerprint in FW_VERSIONS ) :
Params ( ) . put ( " CarParamsCache " , msg . carParams . as_builder ( ) . to_bytes ( ) )
else :
os . environ [ ' SKIP_FW_QUERY ' ] = " 1 "
os . environ [ ' FINGERPRINT ' ] = car_fingerprint
assert ( type ( managed_processes [ cfg . proc_name ] ) is PythonProcess )
assert ( type ( managed_processes [ cfg . proc_name ] ) is PythonProcess )
managed_processes [ cfg . proc_name ] . prepare ( )
managed_processes [ cfg . proc_name ] . prepare ( )