diff --git a/tools/flaskIfc/serial_script.py b/tools/flaskIfc/serial_script.py index 0e1064225921f..a91587341e557 100644 --- a/tools/flaskIfc/serial_script.py +++ b/tools/flaskIfc/serial_script.py @@ -3,11 +3,9 @@ def send_serial_command(port, baudrate, command): try: - # Open the serial port with 1 second timeout - ser = serial.Serial(port, baudrate, timeout=60) + ser = serial.Serial(port, baudrate) - ser.write(command.encode()) # Encode command to bytes - ser.write('\n'.encode()) # Encode command to bytes + ser.write((command + '\n').encode()) # Send command with newline # Wait to read the serial port data = '\0' @@ -15,7 +13,10 @@ def send_serial_command(port, baudrate, command): try: line = ser.readline() if line: # Check if line is not empty - data += line.decode('utf-8') # Keep the line as-is with newline + read_next_line = line.decode('utf-8') + if ("run-platform-done" in read_next_line) or ("@agilex7_dk_si_agf014ea" in read_next_line): + break + data += read_next_line # Keep the line as-is with newline else: break # Exit loop if no data is received except serial.SerialException as e: @@ -25,7 +26,7 @@ def send_serial_command(port, baudrate, command): ser.close() return ("Program interrupted by user") ser.close() - print (data) + print(data) return data except serial.SerialException as e: