Files
sunnypilot/selfdrive/debug/check_timings.py
Adeeb Shihadeh 2d838f95da boardd: add debug flag for injecting SPI errors (#32346)
* pull out ll first

* errors

---------

Co-authored-by: Comma Device <device@comma.ai>
2024-05-07 21:36:04 -07:00

26 lines
707 B
Python
Executable File

#!/usr/bin/env python3
import sys
import time
import numpy as np
from collections.abc import MutableSequence
from collections import defaultdict, deque
import cereal.messaging as messaging
socks = {s: messaging.sub_sock(s, conflate=False) for s in sys.argv[1:]}
ts: defaultdict[str, MutableSequence[float]] = defaultdict(lambda: deque(maxlen=100))
if __name__ == "__main__":
while True:
print()
for s, sock in socks.items():
msgs = messaging.drain_sock(sock)
for m in msgs:
ts[s].append(m.logMonoTime / 1e6)
if len(ts[s]) > 2:
d = np.diff(ts[s])
print(f"{s:25} {np.mean(d):7.2f} {np.std(d):7.2f} {np.max(d):7.2f} {np.min(d):7.2f}")
time.sleep(1)