From aaae6ac7389e97444bd1eae71c6d1e127ebd19ad Mon Sep 17 00:00:00 2001 From: jimw Date: Wed, 13 Oct 2021 20:16:56 -0400 Subject: [PATCH] sim: send peripheralState message (#22541) * controlsd: ignore peripheralState for Simulation * controlsd: use fake peripheralState for Simulation * controlsd: use fake peripheralState for Simulation * controlsd: use fake peripheralState for Simulation * Apply suggestions from code review * sim: send peripheralState message * sim: send peripheralState message * sim: send peripheralState message * sim: send peripheralState message Co-authored-by: wolffja Co-authored-by: Adeeb Shihadeh old-commit-hash: 26c5e7b826cc04e301e3c8c50884582f05e27ceb --- tools/sim/bridge.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/sim/bridge.py b/tools/sim/bridge.py index 52af243ce2..2873aa7223 100755 --- a/tools/sim/bridge.py +++ b/tools/sim/bridge.py @@ -97,6 +97,21 @@ def panda_state_function(exit_event: threading.Event): pm.send('pandaStates', dat) time.sleep(0.5) +def peripheral_state_function(exit_event: threading.Event): + pm = messaging.PubMaster(['peripheralState']) + while not exit_event.is_set(): + dat = messaging.new_message('peripheralState') + dat.valid = True + # fake peripheral state data + dat.peripheralState = { + 'pandaType': log.PandaState.PandaType.blackPanda, + 'voltage': 12000, + 'current': 5678, + 'fanSpeedRpm': 1000 + } + pm.send('peripheralState', dat) + time.sleep(0.5) + def gps_callback(gps, vehicle_state): dat = messaging.new_message('gpsLocationExternal') @@ -215,6 +230,7 @@ def bridge(q): threads = [] exit_event = threading.Event() threads.append(threading.Thread(target=panda_state_function, args=(exit_event,))) + threads.append(threading.Thread(target=peripheral_state_function, args=(exit_event,))) threads.append(threading.Thread(target=fake_driver_monitoring, args=(exit_event,))) threads.append(threading.Thread(target=can_function_runner, args=(vehicle_state, exit_event,))) for t in threads: