diff --git a/scripts/gem/me0_lpgbt/powercycle_test_ucla/prog_power_supply.py b/scripts/gem/me0_lpgbt/powercycle_test_ucla/prog_power_supply.py index 384cc3a08bd7f0cc56207d21cc8dacf9ae5a41f3..b00ae2dc2a16fde46c7761a5c726f9f7b5ce2ef6 100644 --- a/scripts/gem/me0_lpgbt/powercycle_test_ucla/prog_power_supply.py +++ b/scripts/gem/me0_lpgbt/powercycle_test_ucla/prog_power_supply.py @@ -19,6 +19,7 @@ class PowerSupply: ) # Turn off echo commands and flush serial buffer self._ser.write('ECHO OFF\r\n'.encode()) + self.read_serial(1) # Read in values from serial device self._ramp_time = self.get_ramp_time(read=True) self._output = self.get_output(read=True) @@ -42,7 +43,7 @@ class PowerSupply: def get_ramp_time(self,read=False): # Flush serial - self.read_serial(0) + self.read_serial(0.5) if read: self._ser.write('RAMP\r\n'.encode()) ramp = self.read_serial() @@ -58,7 +59,7 @@ class PowerSupply: def get_voltage(self,read=False): # flush serial - self.read_serial(0) + self.read_serial(0.5) if read: # Read voltage value self._ser.write('VREAD\r\n'.encode()) @@ -75,7 +76,7 @@ class PowerSupply: def get_current(self,read=False): # Flush serial - self.read_serial(0) + self.read_serial(0.5) if read: # Read current value self._ser.write('IREAD\r\n'.encode()) @@ -88,14 +89,16 @@ class PowerSupply: def set_output(self,output:bool): if output: + print('Turning output ON\n') self._ser.write('PWR ON\r\n'.encode()) else: + print('Turning output OFF\n') self._ser.write('PWR OFF\r\n'.encode()) self._output = output def get_output(self,read=False): # Flush serial - self.read_serial(0) + self.read_serial(0.5) if read: self._ser.write('PWR\r\n'.encode()) # Cast to bool @@ -113,7 +116,7 @@ class PowerSupply: def power_sequence(self,power:bool): # Power on sequence if power: - print('Powering ON') + print('Powering ON\n') # Copy voltage sequence to not alter property voltages = self.v_sequence.copy() # Check if output is OFF and turn on @@ -123,9 +126,9 @@ class PowerSupply: time.sleep(1) for voltage in voltages: self.set_voltage(voltage) - time.sleep((self.get_ramp_time()+100)/1000) + time.sleep((self.get_ramp_time()+10)/1000) else: - print('Powering OFF') + print('Powering OFF\n') self.set_voltage(0.001) def close(self): @@ -142,6 +145,7 @@ def main(): parser.add_argument('-r','--read',action='store_true',dest='read',help='read = Read and print power supply output at the end of operations.') args = parser.parse_args() + print('\nConfiguring power supply\n') pwr = PowerSupply() # configure power sequence @@ -214,6 +218,8 @@ def main(): pwr.close() sys.exit() + print('Config Done\n') + # Run power sequence if power!=None: pwr.power_sequence(power) diff --git a/scripts/gem/me0_lpgbt/powercycle_test_ucla/pwr_supply_lpgbt_ready_status_test_i2c.py b/scripts/gem/me0_lpgbt/powercycle_test_ucla/pwr_supply_lpgbt_ready_status_test_i2c.py index 31bfc6ce7493a975f39562ac1f5368fcd5e30c70..75eff36d34b328b2d90faaa854471a00fe62027f 100644 --- a/scripts/gem/me0_lpgbt/powercycle_test_ucla/pwr_supply_lpgbt_ready_status_test_i2c.py +++ b/scripts/gem/me0_lpgbt/powercycle_test_ucla/pwr_supply_lpgbt_ready_status_test_i2c.py @@ -23,109 +23,110 @@ def main(system, oh_select, gbt_list, ramp_time, current, voltages, niter): pwr.v_sequence = voltages # Get first list of registers to compare - print ("Turning off power, then on and getting initial list of registers and turning off power") + # print ("Turning off power, then on and getting initial list of registers and turning off power") + print ("Turning off power, then commencing powercycle test") # Turn power supply off pwr.power_sequence(OFF) sleep(1) - # Turn power supply on - pwr.power_sequence(ON) - # Check value set - set_status = pwr.get_voltage() == voltages[-1] - if not set_status: - print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) - rw_terminate() - # Wait and check if value reached - v_read = pwr.get_voltage(read=True) - read_status = (v_read > (voltages[-1] - 0.1)) and (v_read < (voltages[-1] + 0.1)) - timeout = 10 - while not read_status: - timeout -= 1 - if timeout == 1: - break - v_read = pwr.get_voltage(read=True) - read_status = (v_read > (voltages[-1] - 0.1)) and (v_read < (voltages[-1] + 0.1)) - if not read_status: - print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) - rw_terminate() - else: - print(Colors.GREEN + 'Power ON done!\n' + Colors.ENDC) - sleep(0.5) - - # Configure lpGBTs - os.system("python3 init_frontend.py") - sleep(1) - - reg_list_boss = {} - reg_list_sub = {} - n_rw_reg = 0 - for gbt in gbt_list["boss"]: - reg_list_boss[gbt] = {} - oh_ver = get_oh_ver(str(oh_select), str(gbt)) - if oh_ver == 1: - n_rw_reg = (0x13C+1) - if oh_ver == 2: - n_rw_reg = (0x14F+1) - select_ic_link(oh_select, gbt) - for reg in range(n_rw_reg): - reg_list_boss[gbt][reg] = mpeek(reg) - for gbt in gbt_list["sub"]: - reg_list_sub[gbt] = {} - oh_ver = get_oh_ver(str(oh_select), str(gbt)) - select_ic_link(oh_select, gbt) - if oh_ver == 1: - for i in range(0,10): - test_read = mpeek(0x00) - n_rw_reg = (0x13C+1) - if oh_ver == 2: - n_rw_reg = (0x14F+1) - for reg in range(n_rw_reg): - reg_list_sub[gbt][reg] = mpeek(reg) + # # Turn power supply on + # pwr.power_sequence(ON) + # # Check value set + # set_status = pwr.get_voltage() == voltages[-1] + # if not set_status: + # print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) + # rw_terminate() + # # Wait and check if value reached + # v_read = pwr.get_voltage(read=True) + # read_status = (v_read > (voltages[-1] - 0.1)) and (v_read < (voltages[-1] + 0.1)) + # timeout = 10 + # while not read_status: + # timeout -= 1 + # if timeout == 1: + # break + # v_read = pwr.get_voltage(read=True) + # read_status = (v_read > (voltages[-1] - 0.1)) and (v_read < (voltages[-1] + 0.1)) + # if not read_status: + # print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) + # rw_terminate() + # else: + # print(Colors.GREEN + 'Power ON done!\n' + Colors.ENDC) + # sleep(0.5) + + # # Configure lpGBTs + # os.system("python3 init_frontend.py") + # sleep(1) + + # reg_list_boss = {} + # reg_list_sub = {} + # n_rw_reg = 0 + # for gbt in gbt_list["boss"]: + # reg_list_boss[gbt] = {} + # oh_ver = get_oh_ver(str(oh_select), str(gbt)) + # if oh_ver == 1: + # n_rw_reg = (0x13C+1) + # if oh_ver == 2: + # n_rw_reg = (0x14F+1) + # select_ic_link(oh_select, gbt) + # for reg in range(n_rw_reg): + # reg_list_boss[gbt][reg] = mpeek(reg) + # for gbt in gbt_list["sub"]: + # reg_list_sub[gbt] = {} + # oh_ver = get_oh_ver(str(oh_select), str(gbt)) + # select_ic_link(oh_select, gbt) + # if oh_ver == 1: + # for i in range(0,10): + # test_read = mpeek(0x00) + # n_rw_reg = (0x13C+1) + # if oh_ver == 2: + # n_rw_reg = (0x14F+1) + # for reg in range(n_rw_reg): + # reg_list_sub[gbt][reg] = mpeek(reg) - # Turn power supply off - pwr.power_sequence(OFF) - # Check value set - set_status = pwr.get_voltage() == 0.001 - if not set_status: - print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) - rw_terminate() - # Wait and check if value reached - timeout = 10 - read_status = pwr.get_voltage(read=True) < 0.1 - while not read_status: - timeout -= 1 - if timeout == 1: - break - read_status = pwr.get_voltage(read=True) < 0.1 - if not read_status: - print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) - rw_terminate() - else: - print(Colors.GREEN + 'Power OFF done!\n' + Colors.ENDC) - sleep(0.5) + # # Turn power supply off + # pwr.power_sequence(OFF) + # # Check value set + # set_status = pwr.get_voltage() == 0.001 + # if not set_status: + # print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) + # rw_terminate() + # # Wait and check if value reached + # timeout = 10 + # read_status = pwr.get_voltage(read=True) < 0.1 + # while not read_status: + # timeout -= 1 + # if timeout == 1: + # break + # read_status = pwr.get_voltage(read=True) < 0.1 + # if not read_status: + # print (Colors.RED + "ERROR: Exiting" + Colors.ENDC) + # rw_terminate() + # else: + # print(Colors.GREEN + 'Power OFF done!\n' + Colors.ENDC) + # sleep(0.5) - n_error_backend_ready_boss = {} - n_error_backend_ready_sub = {} - n_error_uplink_fec_boss = {} - n_error_uplink_fec_sub = {} - n_error_pusm_ready_boss = {} - n_error_pusm_ready_sub = {} - n_error_mode_boss = {} - n_error_mode_sub = {} - n_error_reg_list_boss = {} - n_error_reg_list_sub = {} - - for gbt in gbt_list["boss"]: - n_error_backend_ready_boss[gbt] = 0 - n_error_uplink_fec_boss[gbt] = 0 - n_error_pusm_ready_boss[gbt] = 0 - n_error_mode_boss[gbt] = 0 - n_error_reg_list_boss[gbt] = 0 - for gbt in gbt_list["sub"]: - n_error_backend_ready_sub[gbt] = 0 - n_error_uplink_fec_sub[gbt] = 0 - n_error_pusm_ready_sub[gbt] = 0 - n_error_mode_sub[gbt] = 0 - n_error_reg_list_sub[gbt] = 0 + # n_error_backend_ready_boss = {} + # n_error_backend_ready_sub = {} + # n_error_uplink_fec_boss = {} + # n_error_uplink_fec_sub = {} + # n_error_pusm_ready_boss = {} + # n_error_pusm_ready_sub = {} + # n_error_mode_boss = {} + # n_error_mode_sub = {} + # n_error_reg_list_boss = {} + # n_error_reg_list_sub = {} + + # for gbt in gbt_list["boss"]: + # n_error_backend_ready_boss[gbt] = 0 + # n_error_uplink_fec_boss[gbt] = 0 + # n_error_pusm_ready_boss[gbt] = 0 + # n_error_mode_boss[gbt] = 0 + # n_error_reg_list_boss[gbt] = 0 + # for gbt in gbt_list["sub"]: + # n_error_backend_ready_sub[gbt] = 0 + # n_error_uplink_fec_sub[gbt] = 0 + # n_error_pusm_ready_sub[gbt] = 0 + # n_error_mode_sub[gbt] = 0 + # n_error_reg_list_sub[gbt] = 0 # cheesecake parameters router_ip = "169.254.181.119" @@ -145,6 +146,8 @@ def main(system, oh_select, gbt_list, ramp_time, current, voltages, niter): password=router_password, look_for_keys=False) + n_error_backend_ready_boss = 0 + n_error_backend_ready_sub = 0 print ("Begin powercycle iteration\n") # Power cycle interations for n in range(0,niter): @@ -179,24 +182,40 @@ def main(system, oh_select, gbt_list, ramp_time, current, voltages, niter): ssh_command += "python3 me0_lpgbt_rw_register.py -s chc -q ME0 -o 1 -g 0 -r 0x00 -d 0x01" ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(ssh_command) output = ssh_stdout.readlines() - print (output) + # print (output) + i2c_success = True for line in output: if "ERROR" in line: - print("I2C connection ERROR Boss GBT! Exit the Test") - rw_terminate() + i2c_success = False + n_error_backend_ready_boss += 1 + print(Colors.RED + "I2C connection ERROR reading BOSS GBT!" + Colors.ENDC) + print(Colors.YELLOW + f'BOSS Link Ready Errors: {n_error_backend_ready_boss}' + Colors.ENDC) + break # so that it does not count multiple + # print("Exit the Test") + # rw_terminate() + if i2c_success: + print(Colors.GREEN + 'BOSS I2C read successful!' + Colors.ENDC) sleep(2) ssh_command = "cd /home/pi/Documents/0xbefe/scripts/; source env.sh me0 cvp13 0; cd gem/;" ssh_command += "python3 me0_lpgbt_rw_register.py -s chc -q ME0 -o 1 -g 1 -r 0x00 -d 0x01" ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(ssh_command) output = ssh_stdout.readlines() - print (output) + # print (output) + i2c_success = True for line in output: if "ERROR" in line: - print("I2C connection ERROR Sub GBT! Exit the Test") - rw_terminate() + i2c_success = False + n_error_backend_ready_sub += 1 + print(Colors.RED + "I2C connection ERROR reading SUB GBT!" + Colors.ENDC) + print(Colors.YELLOW + f'SUB Link Ready Errors: {n_error_backend_ready_sub}' + Colors.ENDC) + break + # print("Exit the Test") + # rw_terminate() + if i2c_success: + print(Colors.GREEN + 'SUB I2C read successful!' + Colors.ENDC) - print("I2C connection successful, continue...") + # print("I2C connection successful, continue...") sleep(2) # -----------------no longer need cheesecake connection from here---------------------- @@ -346,6 +365,8 @@ def main(system, oh_select, gbt_list, ramp_time, current, voltages, niter): sleep(0.5) print ("\nEnd of powercycle iteration") + print(Colors.YELLOW + f'BOSS Link Ready Errors: {n_error_backend_ready_boss}' + Colors.ENDC) + print(Colors.YELLOW + f'SUB Link Ready Errors: {n_error_backend_ready_sub}' + Colors.ENDC) print ("Number of iterations: %d\n"%niter) ssh.close()