From 2a093a39f2303afd87209951ff7054d267519cb4 Mon Sep 17 00:00:00 2001 From: Robbe Date: Mon, 25 Nov 2019 13:09:58 -0800 Subject: [PATCH] Added heartbeat to echo test --- tests/echo.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/echo.py b/tests/echo.py index 4e52921281d696..9ef0cf1074b73f 100755 --- a/tests/echo.py +++ b/tests/echo.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 - import os import sys +import time +import _thread sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")) from panda import Panda @@ -9,10 +10,21 @@ # This script is intended to be used in conjunction with the echo_loopback_test.py test script from panda jungle. # It sends a reversed response back for every message received containing b"test". +def heartbeat_thread(p): + while True: + try: + p.send_heartbeat() + time.sleep(1) + except: + break + # Resend every CAN message that has been received on the same bus, but with the data reversed if __name__ == "__main__": p = Panda() + _thread.start_new_thread(heartbeat_thread, (p,)) p.set_safety_mode(Panda.SAFETY_ALLOUTPUT) + p.set_power_save(False) + while True: incoming = p.can_recv() for message in incoming: