diff --git a/board/jungle/scripts/can_health.py b/board/jungle/scripts/can_health.py index ff068b5ba..47efbb2e6 100755 --- a/board/jungle/scripts/can_health.py +++ b/board/jungle/scripts/can_health.py @@ -1,13 +1,29 @@ #!/usr/bin/env python3 - import time +import re from panda import PandaJungle +RED = '\033[91m' +GREEN = '\033[92m' + +def colorize_errors(value): + if isinstance(value, str): + if re.search(r'(?i)No error', value): + return f'{GREEN}{value}\033[0m' + elif re.search(r'(?i)(? 0.1: dd = chr(27) + "[2J" dd += "%5.2f\n" % (sec_since_boot() - start) - for k,v in sorted(zip(list(msgs.keys()), [binascii.hexlify(x[-1]) for x in list(msgs.values())], strict=True)): - dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k,k),len(msgs[k]), v) + for k, v in sorted(msgs.items()): + last_msg, last_src = v[-1] + dd += "%d: %s(%6d): %s\n" % (last_src, "%04X(%4d)" % (k, k), len(v), binascii.hexlify(last_msg).decode()) print(dd) lp = sec_since_boot() diff --git a/board/jungle/scripts/spam_can.py b/board/jungle/scripts/spam_can.py new file mode 100755 index 000000000..c3d798b47 --- /dev/null +++ b/board/jungle/scripts/spam_can.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +import os +import random +from panda import PandaJungle + +def get_test_string(): + return b"test" + os.urandom(10) + +if __name__ == "__main__": + p = PandaJungle() + + p.set_safety_mode(PandaJungle.SAFETY_ALLOUTPUT) + + print("Spamming all buses...") + while True: + at = random.randint(1, 2000) + st = get_test_string()[0:8] + bus = random.randint(0, 2) + p.can_send(at, st, bus) + # print("Sent message on bus: ", bus) diff --git a/tests/can_health.py b/tests/can_health.py new file mode 100755 index 000000000..26de9cdab --- /dev/null +++ b/tests/can_health.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +import time +import re +from panda import Panda + +RED = '\033[91m' +GREEN = '\033[92m' + +def colorize_errors(value): + if isinstance(value, str): + if re.search(r'(?i)No error', value): + return f'{GREEN}{value}\033[0m' + elif re.search(r'(?i)(? 0.1: dd = chr(27) + "[2J" dd += "%5.2f\n" % (sec_since_boot() - start) - for k, v in sorted(zip(list(msgs.keys()), [binascii.hexlify(x[-1]) for x in list(msgs.values())], strict=True)): - dd += "%s(%6d) %s\n" % ("%04X(%4d)" % (k, k), len(msgs[k]), v) + for k, v in sorted(msgs.items()): + last_msg, last_src = v[-1] + dd += "%d: %s(%6d): %s\n" % (last_src, "%04X(%4d)" % (k, k), len(v), binascii.hexlify(last_msg).decode()) print(dd) lp = sec_since_boot()