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 <wolffja@ubuntu20.04LTS>
Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 26c5e7b826
commatwo_master
jimw 4 years ago committed by GitHub
parent d4cbef299b
commit aaae6ac738
  1. 16
      tools/sim/bridge.py

@ -97,6 +97,21 @@ def panda_state_function(exit_event: threading.Event):
pm.send('pandaStates', dat) pm.send('pandaStates', dat)
time.sleep(0.5) 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): def gps_callback(gps, vehicle_state):
dat = messaging.new_message('gpsLocationExternal') dat = messaging.new_message('gpsLocationExternal')
@ -215,6 +230,7 @@ def bridge(q):
threads = [] threads = []
exit_event = threading.Event() exit_event = threading.Event()
threads.append(threading.Thread(target=panda_state_function, args=(exit_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=fake_driver_monitoring, args=(exit_event,)))
threads.append(threading.Thread(target=can_function_runner, args=(vehicle_state, exit_event,))) threads.append(threading.Thread(target=can_function_runner, args=(vehicle_state, exit_event,)))
for t in threads: for t in threads:

Loading…
Cancel
Save