diff --git a/scripts/quality_control_leds.py b/scripts/quality_control_leds.py index 120eed6..e6e6c8d 100644 --- a/scripts/quality_control_leds.py +++ b/scripts/quality_control_leds.py @@ -37,7 +37,7 @@ def perform_hpos_test(repeat_no, solution, df): # print(data.split('\r')) # if 'SNE' in data: # ser.write(b'B') - if 'BC' in data: + if '#BC' in data: ser.write(b'P') if 'REND' in data: # print(data) @@ -102,7 +102,7 @@ def perform_auto_dac(df): while True: data += ser.readline().decode("utf-8") # print(data.split('\r')) - if 'CC' in data: + if '#CC' in data: # print(data) pattern = re.compile(r'LED(\d+)_DAC: (\d+)') @@ -217,14 +217,50 @@ def buffer_process(): df_autodac.to_excel(writer, sheet_name = autodac_sheet_name, index=False) writer.close() -def analysis_process(): - df = df.tail(5) +def diagnostics_process(): + try: + port = sys.argv[1] + baud_rate = 9600 + deviceId = 'QC' + data = "" + data_list = [] + + if not os.path.exists(port): + raise FileNotFoundError(f"Port {port} not found.") + + with serial.Serial(port, baud_rate, timeout=1, parity=serial.PARITY_NONE) as ser: + x = ser.read() + 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") + return + return + + except serial.serialutil.SerialException: + print("Device is not connected or resource busy!") + raise + except FileNotFoundError as e: + print(e) + raise + except Exception as err: + print("Error:", err) + raise + finally: + if ser is not None: + ser.close() if __name__ == "__main__": # device = Device(0.01, 0.001, '/dev/cu.usbserial-23APB124', 9600) + diagnostics_process() + autodac_process() - buffer_process() - - analysis_process() \ No newline at end of file + buffer_process() \ No newline at end of file