28 lines
704 B
Python
Executable File
28 lines
704 B
Python
Executable File
#!/usr/bin/env python
|
|
import os
|
|
import sys
|
|
import usb1
|
|
import time
|
|
import select
|
|
from panda.lib.panda import Panda
|
|
|
|
setcolor = ["\033[1;32;40m", "\033[1;31;40m"]
|
|
unsetcolor = "\033[00m"
|
|
|
|
if __name__ == "__main__":
|
|
port_number = int(os.getenv("PORT", 0))
|
|
|
|
serials = Panda.list()
|
|
pandas = map(lambda x: Panda(x, False), serials)
|
|
while 1:
|
|
for i, panda in enumerate(pandas):
|
|
ret = panda.serial_read(port_number)
|
|
if len(ret) > 0:
|
|
sys.stdout.write(setcolor[i] + ret + unsetcolor)
|
|
sys.stdout.flush()
|
|
if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []):
|
|
ln = sys.stdin.readline()
|
|
panda.serial_write(port_number)
|
|
time.sleep(0.05)
|
|
|