From abb13409915004db87ad840ba8a1968ac5c6fc07 Mon Sep 17 00:00:00 2001 From: Pritimay Sarkar Date: Tue, 5 Mar 2024 17:41:39 +0530 Subject: [PATCH] add eprom commands --- scripts/quality_control_leds.py | 52 +++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/scripts/quality_control_leds.py b/scripts/quality_control_leds.py index e6e6c8d..ba9f535 100644 --- a/scripts/quality_control_leds.py +++ b/scripts/quality_control_leds.py @@ -31,6 +31,17 @@ def perform_hpos_test(repeat_no, solution, df): s = ser.read(10) line = ser.readline() + ser.write(b'E') + while True: + data += ser.readline().decode("utf-8") + # print(data.split('\r')) + if '#RC' in data: + # print(data) + # print("DAC values fetched from EPORM") + break + + time.sleep(0.5) + ser.write(b'B') while True: data += ser.readline().decode("utf-8") @@ -98,6 +109,17 @@ def perform_auto_dac(df): s = ser.read(10) line = ser.readline() + ser.write(b'D') + while True: + data += ser.readline().decode("utf-8") + # print(data.split('\r')) + if '#DC' in data: + print(data) + print("D_CMD process completed") + break + + time.sleep(0.5) + ser.write(b'C') while True: data += ser.readline().decode("utf-8") @@ -128,6 +150,18 @@ def perform_auto_dac(df): "deviceId": deviceId, "time": datetime.today().strftime('%d-%m-%y %H:%M:%S')}) break + + time.sleep(0.5) + + ser.write(b'G') + while True: + data += ser.readline().decode("utf-8") + # print(data.split('\r')) + if '#WC' in data: + print(data) + print("DAC values saved to EPROM") + break + return data_list except serial.serialutil.SerialException: @@ -145,19 +179,19 @@ def perform_auto_dac(df): ser.close() -def autodac_process(): +def diagnostics_and_autodac_process(): data_file = 'quality_control_leds.xlsx' sheet_name = 'auto_dac' if os.path.exists(data_file): xls = pd.ExcelFile(data_file) if sheet_name in xls.sheet_names: - df = pd.read_excel(data_file, sheet_name=sheet_name) + df_autodac = pd.read_excel(data_file, sheet_name=sheet_name) else: print(f"Sheet '{sheet_name}' does not exist in the Excel file.") - df = pd.DataFrame(columns=["LED1_DAC", "LED2_DAC", "LED3_DAC", "LED4_DAC", "deviceId", "time"]) + df_autodac = pd.DataFrame(columns=["LED1_DAC", "LED2_DAC", "LED3_DAC", "LED4_DAC", "deviceId", "time"]) else: - df = pd.DataFrame(columns=["LED1_DAC", "LED2_DAC", "LED3_DAC", "LED4_DAC", "deviceId", "time"]) + df_autodac = pd.DataFrame(columns=["LED1_DAC", "LED2_DAC", "LED3_DAC", "LED4_DAC", "deviceId", "time"]) buffer_sheet_name = 'buffer' if os.path.exists(data_file): @@ -170,12 +204,12 @@ def autodac_process(): else: df_buffer = pd.DataFrame(columns=["sol", "led1Buffer", "led2Buffer", "led3Buffer", "led4Buffer", "deviceId", "time"]) - data_list = perform_auto_dac(df) + data_list = perform_auto_dac(df_autodac) - df = pd.concat([df, pd.DataFrame(data_list)], ignore_index=True) + df_autodac = pd.concat([df_autodac, pd.DataFrame(data_list)], ignore_index=True) writer = pd.ExcelWriter(data_file, engine = 'openpyxl') - df.to_excel(writer, sheet_name = sheet_name, index=False) + df_autodac.to_excel(writer, sheet_name = sheet_name, index=False) df_buffer.to_excel(writer, sheet_name = buffer_sheet_name, index=False) writer.close() time.sleep(1) @@ -259,8 +293,8 @@ def diagnostics_process(): if __name__ == "__main__": # device = Device(0.01, 0.001, '/dev/cu.usbserial-23APB124', 9600) - diagnostics_process() + # diagnostics_process() - autodac_process() + diagnostics_and_autodac_process() buffer_process() \ No newline at end of file