|
|
@ -3,7 +3,9 @@ |
|
|
|
import os |
|
|
|
import os |
|
|
|
import usb1 |
|
|
|
import usb1 |
|
|
|
import time |
|
|
|
import time |
|
|
|
|
|
|
|
import signal |
|
|
|
import subprocess |
|
|
|
import subprocess |
|
|
|
|
|
|
|
import sys |
|
|
|
from typing import NoReturn |
|
|
|
from typing import NoReturn |
|
|
|
|
|
|
|
|
|
|
|
from panda import Panda, PandaDFU, PandaProtocolMismatch, FW_PATH |
|
|
|
from panda import Panda, PandaDFU, PandaProtocolMismatch, FW_PATH |
|
|
@ -62,12 +64,26 @@ def flash_panda(panda_serial: str) -> Panda: |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main() -> NoReturn: |
|
|
|
def main() -> NoReturn: |
|
|
|
|
|
|
|
# override manager's immediate SystemExit to allow pandad to exit gracefully |
|
|
|
|
|
|
|
do_exit = False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def signal_handler(signum, frame): |
|
|
|
|
|
|
|
nonlocal do_exit, process |
|
|
|
|
|
|
|
do_exit = True |
|
|
|
|
|
|
|
cloudlog.warning(f"caught signal {signum}, exiting") |
|
|
|
|
|
|
|
if process is not None: |
|
|
|
|
|
|
|
process.terminate() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sys.exit(0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signal.signal(signal.SIGTERM, signal_handler) |
|
|
|
|
|
|
|
|
|
|
|
count = 0 |
|
|
|
count = 0 |
|
|
|
first_run = True |
|
|
|
first_run = True |
|
|
|
params = Params() |
|
|
|
params = Params() |
|
|
|
no_internal_panda_count = 0 |
|
|
|
no_internal_panda_count = 0 |
|
|
|
|
|
|
|
|
|
|
|
while True: |
|
|
|
while not do_exit: |
|
|
|
try: |
|
|
|
try: |
|
|
|
count += 1 |
|
|
|
count += 1 |
|
|
|
cloudlog.event("pandad.flash_and_connect", count=count) |
|
|
|
cloudlog.event("pandad.flash_and_connect", count=count) |
|
|
@ -160,7 +176,8 @@ def main() -> NoReturn: |
|
|
|
# run pandad with all connected serials as arguments |
|
|
|
# run pandad with all connected serials as arguments |
|
|
|
os.environ['MANAGER_DAEMON'] = 'pandad' |
|
|
|
os.environ['MANAGER_DAEMON'] = 'pandad' |
|
|
|
os.chdir(os.path.join(BASEDIR, "selfdrive/pandad")) |
|
|
|
os.chdir(os.path.join(BASEDIR, "selfdrive/pandad")) |
|
|
|
subprocess.run(["./pandad", *panda_serials], check=True) |
|
|
|
process = subprocess.Popen(["./pandad", *panda_serials]) |
|
|
|
|
|
|
|
process.wait() |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
main() |
|
|
|
main() |
|
|
|