Files
dragonpilot/panda/tests/debug_console.py

50 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
import os
import sys
import time
import select
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
from panda import Panda
setcolor = ["\033[1;32;40m", "\033[1;31;40m"]
unsetcolor = "\033[00m"
if __name__ == "__main__":
while True:
try:
port_number = int(os.getenv("PORT", 0))
claim = os.getenv("CLAIM") is not None
serials = Panda.list()
if os.getenv("SERIAL"):
serials = [x for x in serials if x==os.getenv("SERIAL")]
pandas = list([Panda(x, claim=claim) for x in serials])
if not len(pandas):
sys.exit("no pandas found")
if os.getenv("BAUD") is not None:
for panda in pandas:
Squashed 'panda/' changes from 869f12321..49ffbe99f 49ffbe99f disable non-universal checks in hyundai safety 3a85f4c25 use whole route when running safety replay from CLI 098f47a5b Fix leaf brake rx check (#547) b8267341a Add pre commit checks + CI (#545) 339976c3c document tx message addresses better (#543) a618e64d1 fix typing errors 9bece64e8 use mazda init 08db086d5 mazda cleanup 89658d0bd Mazda: safety tests add missing safety checks (#525) bdec1398e Fix length of 0x20b in NISSAN_TX_MSGS, wasn't cancelling ACC (#544) b48c74c2e Adding UNO to automated tests (#538) a5802cdd1 Hyundai: remove unused message from RX checks 9ebde2535 Reset state on safety mode init (#542) d4f3f15c3 Refactor addr check (#541) 5210e51b8 remove unused files 065706459 Hyundai checksum (#540) 07e668eca Fast CI (#539) 5307bf727 Fix multi message iso tp requests 0610ed1e2 Hyundai wheel speed counter is actually 4 bits spread over two signals 0d581aa5f dockerfile optimization eaefa2f6c fix docker file path 243a65f30 pull base image 0dd9470af only push to dockerhub from master 55b79b472 GitHub Actions (#535) b2c720bf4 Dos (#533) 01bf74024 remove 0x1BE checksum test 0bd06c9e0 remove 0x1BE check (breaks some vehicles) c31b899a5 honda bosch longitudinal safety 66250c41d Disable docker layer caching (#534) 6b19fa496 include nissan safety in release build db31886ad gate mazda safety behind debug flag e4558c073 Safety: message length check on RX and TX (#529) git-subtree-dir: panda git-subtree-split: 49ffbe99f65e64d23d27d9d3e37f68bc2368dccd
2020-05-31 13:22:43 -07:00
panda.set_uart_baud(port_number, int(os.getenv("BAUD"))) # type: ignore
while True:
for i, panda in enumerate(pandas):
while True:
ret = panda.serial_read(port_number)
if len(ret) > 0:
sys.stdout.write(setcolor[i] + ret.decode('ascii') + unsetcolor)
sys.stdout.flush()
else:
break
if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
ln = sys.stdin.readline()
if claim:
panda.serial_write(port_number, ln)
time.sleep(0.01)
except Exception:
print("panda disconnected!")
time.sleep(0.5);