Skip to content

Commit

Permalink
Added heartbeat to echo test
Browse files Browse the repository at this point in the history
  • Loading branch information
robbederks committed Nov 25, 2019
1 parent 2246435 commit 2a093a3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/echo.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
#!/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

# 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:
Expand Down

0 comments on commit 2a093a3

Please sign in to comment.