def startCAN(recvport, sendport, motorFlag, use_power, use_gamePad, can_send_interval): cmd = [ ... ] process = subprocess.Popen( cmd, stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, bufsize=1, universal_newlines=True ) def read_output(): while True: line = process.stdout.readline() if line: print(line, end='') if process.poll() is not None: break def read_err(): while True: line = process.stderr.readline() if line: print(line, end='') if process.poll() is not None: break output_thread = threading.Thread(target=read_output) output_thread.start() err_thread = threading.Thread(target=read_err) err_thread.start()
|