Files
sunnypilot/selfdrive/debug/check_lag.py
Adeeb Shihadeh 2445fdc4d0 remove mypy ignore from a few scripts
old-commit-hash: 11b5d51da6
2022-06-30 15:36:40 -07:00

29 lines
558 B
Python
Executable File

#!/usr/bin/env python3
from typing import Dict
import cereal.messaging as messaging
from cereal.services import service_list
TO_CHECK = ['carState']
if __name__ == "__main__":
sm = messaging.SubMaster(TO_CHECK)
prev_t: Dict[str, float] = {}
while True:
sm.update()
for s in TO_CHECK:
if sm.updated[s]:
t = sm.logMonoTime[s] / 1e9
if s in prev_t:
expected = 1.0 / (service_list[s].frequency)
dt = t - prev_t[s]
if dt > 10 * expected:
print(t, s, dt)
prev_t[s] = t