mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 00:03:45 +08:00
replace custom clock helpers with time module (#29499)
* replace custom clock stuff wtih time module * fix double * fix release * bump cereal * update type * fix one more old-commit-hash: d61f86d3398900ef01423d24cfdf897392a8efbb
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import binascii
|
||||
import time
|
||||
from collections import defaultdict
|
||||
|
||||
import cereal.messaging as messaging
|
||||
from common.realtime import sec_since_boot
|
||||
|
||||
|
||||
def can_printer(bus, max_msg, addr, ascii_decode):
|
||||
logcan = messaging.sub_sock('can', addr=addr)
|
||||
|
||||
start = sec_since_boot()
|
||||
lp = sec_since_boot()
|
||||
start = time.monotonic()
|
||||
lp = time.monotonic()
|
||||
msgs = defaultdict(list)
|
||||
while 1:
|
||||
can_recv = messaging.drain_sock(logcan, wait_for_one=True)
|
||||
@@ -20,17 +20,17 @@ def can_printer(bus, max_msg, addr, ascii_decode):
|
||||
if y.src == bus:
|
||||
msgs[y.address].append(y.dat)
|
||||
|
||||
if sec_since_boot() - lp > 0.1:
|
||||
if time.monotonic() - lp > 0.1:
|
||||
dd = chr(27) + "[2J"
|
||||
dd += f"{sec_since_boot() - start:5.2f}\n"
|
||||
dd += f"{time.monotonic() - start:5.2f}\n"
|
||||
for addr in sorted(msgs.keys()):
|
||||
a = f"\"{msgs[addr][-1].decode('ascii', 'backslashreplace')}\"" if ascii_decode else ""
|
||||
x = binascii.hexlify(msgs[addr][-1]).decode('ascii')
|
||||
freq = len(msgs[addr]) / (sec_since_boot() - start)
|
||||
freq = len(msgs[addr]) / (time.monotonic() - start)
|
||||
if max_msg is None or addr < max_msg:
|
||||
dd += "%04X(%4d)(%6d)(%3dHz) %s %s\n" % (addr, addr, len(msgs[addr]), freq, x.ljust(20), a)
|
||||
print(dd)
|
||||
lp = sec_since_boot()
|
||||
lp = time.monotonic()
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="simple CAN data viewer",
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import numpy as np
|
||||
import time
|
||||
from collections import defaultdict, deque
|
||||
from typing import DefaultDict, Deque, MutableSequence
|
||||
|
||||
from common.realtime import sec_since_boot
|
||||
import cereal.messaging as messaging
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ if __name__ == "__main__":
|
||||
rcv_times: DefaultDict[str, MutableSequence[float]] = defaultdict(lambda: deque(maxlen=100))
|
||||
valids: DefaultDict[str, Deque[bool]] = defaultdict(lambda: deque(maxlen=100))
|
||||
|
||||
t = sec_since_boot()
|
||||
t = time.monotonic()
|
||||
for name in socket_names:
|
||||
sock = messaging.sub_sock(name, poller=poller)
|
||||
sockets[sock] = name
|
||||
@@ -36,7 +36,7 @@ if __name__ == "__main__":
|
||||
|
||||
name = msg.which()
|
||||
|
||||
t = sec_since_boot()
|
||||
t = time.monotonic()
|
||||
rcv_times[name].append(msg.logMonoTime / 1e9)
|
||||
valids[name].append(msg.valid)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user