From ffe045a424894637ee58ea2cc639e0be50c92b92 Mon Sep 17 00:00:00 2001 From: Lewis Lui Date: Thu, 12 Jun 2025 13:58:36 -0700 Subject: [PATCH 1/3] @FIR-731 - serial_script.py changes to identify end of output --- tools/flaskIfc/serial_script.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/flaskIfc/serial_script.py b/tools/flaskIfc/serial_script.py index 0e1064225921f..0354f15ff2ca3 100644 --- a/tools/flaskIfc/serial_script.py +++ b/tools/flaskIfc/serial_script.py @@ -3,19 +3,21 @@ def send_serial_command(port, baudrate, command): try: - # Open the serial port with 1 second timeout - ser = serial.Serial(port, baudrate, timeout=60) + # Open the serial port with 1 second timeout (timeout = 60 but removed it for testing!) + 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' while True: try: line = ser.readline() + check = line.decode('utf-8') + if ("run-platform-done" in check) or ("@agilex7_dk_si_agf014ea" in check): + break if line: # Check if line is not empty - data += line.decode('utf-8') # Keep the line as-is with newline + data += check # Keep the line as-is with newline else: break # Exit loop if no data is received except serial.SerialException as e: @@ -25,7 +27,6 @@ def send_serial_command(port, baudrate, command): ser.close() return ("Program interrupted by user") ser.close() - print (data) return data except serial.SerialException as e: @@ -42,3 +43,4 @@ def send_serial_command(port, baudrate, command): baudrate = int(sys.argv[2]) command = sys.argv[3] response = send_serial_command(port, baudrate, command) + print(response) From 3211f60eeab04f757d2fce0f730aad87b584937b Mon Sep 17 00:00:00 2001 From: Lewis Lui Date: Thu, 12 Jun 2025 14:35:23 -0700 Subject: [PATCH 2/3] Some more changes to address the comments --- tools/flaskIfc/serial_script.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/flaskIfc/serial_script.py b/tools/flaskIfc/serial_script.py index 0354f15ff2ca3..aca14a60f5c9a 100644 --- a/tools/flaskIfc/serial_script.py +++ b/tools/flaskIfc/serial_script.py @@ -13,11 +13,11 @@ def send_serial_command(port, baudrate, command): while True: try: line = ser.readline() - check = line.decode('utf-8') - if ("run-platform-done" in check) or ("@agilex7_dk_si_agf014ea" in check): - break if line: # Check if line is not empty - data += check # 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: @@ -27,6 +27,7 @@ def send_serial_command(port, baudrate, command): ser.close() return ("Program interrupted by user") ser.close() + print(data) return data except serial.SerialException as e: @@ -43,4 +44,3 @@ def send_serial_command(port, baudrate, command): baudrate = int(sys.argv[2]) command = sys.argv[3] response = send_serial_command(port, baudrate, command) - print(response) From a411fd97096431afd4a759487d1236890791ae62 Mon Sep 17 00:00:00 2001 From: Lewis Lui Date: Thu, 12 Jun 2025 14:43:29 -0700 Subject: [PATCH 3/3] Removed a comment --- tools/flaskIfc/serial_script.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/flaskIfc/serial_script.py b/tools/flaskIfc/serial_script.py index aca14a60f5c9a..a91587341e557 100644 --- a/tools/flaskIfc/serial_script.py +++ b/tools/flaskIfc/serial_script.py @@ -3,7 +3,6 @@ def send_serial_command(port, baudrate, command): try: - # Open the serial port with 1 second timeout (timeout = 60 but removed it for testing!) ser = serial.Serial(port, baudrate) ser.write((command + '\n').encode()) # Send command with newline