def set_mode(ts, crate, slot, n): # 0: normal mode, 1: link test mode A (test mode string), 2: link test mode B (IGLOO register) s = 0 if n == 0: cmds = [ "put HF{0}-{1}-iTop_LinkTestMode 0x0".format(crate, slot, n), "put HF{0}-{1}-iBot_LinkTestMode 0x0".format(crate, slot, n), "get HF{0}-{1}-iTop_LinkTestMode".format(crate, slot, n), "get HF{0}-{1}-iBot_LinkTestMode".format(crate, slot, n), ] output = ngccm.send_commands_parsed(ts, cmds)["output"] # print output if "ERROR" not in output[0]["result"] and "ERROR" not in output[1]["result"]: s = 1 elif n == 1: cmds = [ "put HF{0}-{1}-iTop_LinkTestMode 0x1".format(crate, slot, n), "put HF{0}-{1}-iBot_LinkTestMode 0x1".format(crate, slot, n), "get HF{0}-{1}-iTop_LinkTestMode".format(crate, slot, n), "get HF{0}-{1}-iBot_LinkTestMode".format(crate, slot, n), ] output = ngccm.send_commands_parsed(ts, cmds)["output"] if "ERROR" not in output[0]["result"] and "ERROR" not in output[1]["result"]: s = 1 elif n == 2: cmds = [ "put HF{0}-{1}-iTop_LinkTestMode 0x7".format(crate, slot, n), "put HF{0}-{1}-iBot_LinkTestMode 0x7".format(crate, slot, n), "get HF{0}-{1}-iTop_LinkTestMode".format(crate, slot, n), "get HF{0}-{1}-iBot_LinkTestMode".format(crate, slot, n), ] output = ngccm.send_commands_parsed(ts, cmds)["output"] # print output if "ERROR" not in output[0]["result"] and "ERROR" not in output[1]["result"]: s = 1 return s
def get_status(ts=None, crate=-1): # Perform basic checks of the FE crate backplanes: log = "" s = status(ts=ts, crate=crate) if ts: # Enable, reset, and check the BKP power: if crate in ts.fe_crates: ngfec_output = ngccm.send_commands_parsed( ts, "get HF{0}-bkp_pwr_bad".format(crate))["output"] if "ERROR" not in ngfec_output[0]["result"]: try: good = not int(ngfec_output[0]["result"]) s.pwr = int(good) s.status.append(int(good)) except Exception as ex: print ex s.status.append(0) else: s.status.append(0) else: print "ERROR (bkp.get_status): The crate you want ({0}) is not in the teststand object you supplied.".format( crate) s.update() return s
def get_unique_id(ts, crate, slot): # Reads the unique ID of a given crate and slot and returns it as a list. ngccm_output = ngccm.send_commands_parsed(ts, ["get HF{0}-{1}-UniqueID".format(crate,slot)]) # Results in something like "get HF1-1-UniqueID # '1 0x5f000000 0x9b46ce70'" result = ngccm_output["output"][0]["result"] if "ERROR" not in result: return result.split()[1:3] # Get the result of the command, and turn the result into a list (ignoring the first element). else: return []
def get_igloo_info(ts, crate, slot): # Returns a dictionary of information about the IGLOO2, such as the FW versions. data = [ ["version_fw_major_top", 'get HF{0}-{1}-iTop_FPGA_MAJOR_VERSION'.format(crate, slot), 0], ["version_fw_minor_top", 'get HF{0}-{1}-iTop_FPGA_MINOR_VERSION'.format(crate, slot), 0], ["version_fw_major_bot", 'get HF{0}-{1}-iBot_FPGA_MAJOR_VERSION'.format(crate, slot), 0], ["version_fw_minor_bot", 'get HF{0}-{1}-iBot_FPGA_MINOR_VERSION'.format(crate, slot), 0], ] log = "" parsed_output = ngccm.send_commands_parsed(ts, [info[1] for info in data])["output"] # print parsed_output for info in data: result = parsed_output[data.index(info)]["result"] cmd = parsed_output[data.index(info)]["cmd"] if "ERROR" not in result: info[2] = int(result, 16) else: log += '>> ERROR: Failed to find the result of "{0}". The data string follows:\n{1}'.format(cmd, result) version_fw_top = "{0:02d}.{1:02d}".format(data[0][2], data[1][2]) version_fw_bot = "{0:02d}.{1:02d}".format(data[2][2], data[3][2]) return { "slot": slot, "version_fw_major_top": data[0][2], "version_fw_minor_top": data[1][2], "version_fw_top": version_fw_top, "version_fw_major_bot": data[2][2], "version_fw_minor_bot": data[3][2], "version_fw_bot": version_fw_bot, "log": log.strip(), }
def get_bridge_info(ts, crate, slot): # Returns a dictionary of information about the Bridge FPGA, such as the FW versions. data = [ ["version_fw_major", 'get HF{0}-{1}-B_FIRMVERSION_MAJOR'.format(crate, slot), 0], ["version_fw_minor", 'get HF{0}-{1}-B_FIRMVERSION_MINOR'.format(crate, slot), 0], ["version_fw_svn", 'get HF{0}-{1}-B_FIRMVERSION_SVN'.format(crate, slot), 0], ] log = "" parsed_output = ngccm.send_commands_parsed(ts, [info[1] for info in data])["output"] # print parsed_output for info in data: result = parsed_output[data.index(info)]["result"] cmd = parsed_output[data.index(info)]["cmd"] if "ERROR" not in result: info[2] = int(result, 16) else: log += '>> ERROR: Failed to find the result of "{0}". The data string follows:\n{1}'.format(cmd, result) version_fw = "{0:02d}.{1:02d}.{2:04d}".format(data[0][2], data[1][2], data[2][2]) return { "slot": slot, "version_fw_major": data[0][2], "version_fw_minor": data[1][2], "version_fw_svn": data[2][2], "version_fw": version_fw, "log": log.strip(), }
def testCache( self ) : errors = 0 executeErrors = 0 totalTests = 0 output = ngccm.send_commands_parsed( self.ts , self.commandCache )["output"] if self.verbosity >= 1 : print output if len( output ) % 2 != 0 : print "ERROR, register::testCach() - the wrong number of commands were executed" return -999 for i in range( len( output ) / 2 ) : if output[i*2]["cmd"].find("put ") == -1 : print "ERROR, register::testCach() - commands executed in wrong order??" return -999 else : value = output[i*2]["cmd"].split()[2:] if self.verbosity >= 1 : print "value:",value valueNum = [] for v in value : valueNum.append( int(v,16) ) if output[i*2]["result"] != "OK" : executeErrors = executeErrors + 1 continue else : totalTests = totalTests + 1 if output[i*2+1]["cmd"].find("get ") == -1 : print "ERROR, register::testCach() - commands executed in wrong order??" return -999 else : #check = output[i*2+1]["result"].split("'")[1].split() check = output[i*2+1]["result"].split() if self.verbosity >= 1 : print "check:",check checkNum = [] for c in check[::-1] : checkNum.append( int(c,16) ) ### valueNum and checkNum are compared so that ### leading zeroes will be conveniently ignored if valueNum != checkNum : errors = errors + 1 print "--------------------------------" print "REGISTER:",self.name print "--------------------------------" print "errors:",errors print "execution errors:",executeErrors print "success rate:", 100. * ( 1. - float( errors ) / float( totalTests ) ),"%"
def read( self ) : output = ngccm.send_commands_parsed( self.ts, ["get {0}".format(self.name)] )["output"][0]["result"] if self.verbosity >= 1 : print "REGISTER::READ() --" print output return output
def read(self): output = ngccm.send_commands_parsed( self.ts, ["get {0}".format(self.name)])["output"][0]["result"] if self.verbosity >= 1: print "REGISTER::READ() --" print output return output
def write( self , value = '') : output = ngccm.send_commands_parsed(self.ts, ["put {0} {1}".format(self.name,value)] )["output"][0]["result"] if self.verbosity >= 1 : print "REGISTER::WRITE() --" print output if output.find("ERROR!") != -1 : return False else : return True
def set_mode( ts, crate, slot, n ): # 0: normal mode, 1: link test mode A (test mode string), 2: link test mode B (IGLOO register) s = 0 if n == 0: cmds = [ "put HF{0}-{1}-iTop_LinkTestMode 0x0".format(crate, slot, n), "put HF{0}-{1}-iBot_LinkTestMode 0x0".format(crate, slot, n), "get HF{0}-{1}-iTop_LinkTestMode".format(crate, slot, n), "get HF{0}-{1}-iBot_LinkTestMode".format(crate, slot, n), ] output = ngccm.send_commands_parsed(ts, cmds)["output"] # print output if "ERROR" not in output[0]["result"] and "ERROR" not in output[1][ "result"]: s = 1 elif n == 1: cmds = [ "put HF{0}-{1}-iTop_LinkTestMode 0x1".format(crate, slot, n), "put HF{0}-{1}-iBot_LinkTestMode 0x1".format(crate, slot, n), "get HF{0}-{1}-iTop_LinkTestMode".format(crate, slot, n), "get HF{0}-{1}-iBot_LinkTestMode".format(crate, slot, n), ] output = ngccm.send_commands_parsed(ts, cmds)["output"] if "ERROR" not in output[0]["result"] and "ERROR" not in output[1][ "result"]: s = 1 elif n == 2: cmds = [ "put HF{0}-{1}-iTop_LinkTestMode 0x7".format(crate, slot, n), "put HF{0}-{1}-iBot_LinkTestMode 0x7".format(crate, slot, n), "get HF{0}-{1}-iTop_LinkTestMode".format(crate, slot, n), "get HF{0}-{1}-iBot_LinkTestMode".format(crate, slot, n), ] output = ngccm.send_commands_parsed(ts, cmds)["output"] # print output if "ERROR" not in output[0]["result"] and "ERROR" not in output[1][ "result"]: s = 1 return s
def get_unique_id( ts, crate, slot ): # Reads the unique ID of a given crate and slot and returns it as a list. ngccm_output = ngccm.send_commands_parsed( ts, ["get HF{0}-{1}-UniqueID".format(crate, slot)] ) # Results in something like "get HF1-1-UniqueID # '1 0x5f000000 0x9b46ce70'" result = ngccm_output["output"][0]["result"] if "ERROR" not in result: return result.split( )[1: 3] # Get the result of the command, and turn the result into a list (ignoring the first element). else: return []
def read_counter_qie_bridge(ts, crate, slot): log = "" count = -1 cmd = "get HF{0}-{1}-B_RESQIECOUNTER".format(crate, slot) output = ngccm.send_commands_parsed(ts, cmd)["output"] try: count = int(output[0]["result"], 16) except Exception as ex: log += output[0]["cmd"] + " -> " + output[0]["result"] + "\n" return { "count": count, "log": log, }
def write(self, value=''): output = ngccm.send_commands_parsed( self.ts, ["put {0} {1}".format(self.name, value)])["output"][0]["result"] if self.verbosity >= 1: print "REGISTER::WRITE() --" print output if output.find("ERROR!") != -1: return False else: return True
def get_temps(ts=False): # It's more flexible to not have the input be a teststand object. I should make it accept both. output = {} if ts: for crate, slots in ts.fe.iteritems(): output[crate] = [] for slot in slots: cmds = [ "get HF{0}-{1}-bkp_temp_f".format(crate, slot), # The temperature sensor on the QIE card, near the bottom, labeled "U40". ] output[crate] += ngccm.send_commands_parsed(ts, cmds)["output"] return output else: return output
def get_igloo_info( ts, crate, slot ): # Returns a dictionary of information about the IGLOO2, such as the FW versions. data = [ [ "version_fw_major_top", 'get HF{0}-{1}-iTop_FPGA_MAJOR_VERSION'.format(crate, slot), 0 ], [ "version_fw_minor_top", 'get HF{0}-{1}-iTop_FPGA_MINOR_VERSION'.format(crate, slot), 0 ], [ "version_fw_major_bot", 'get HF{0}-{1}-iBot_FPGA_MAJOR_VERSION'.format(crate, slot), 0 ], [ "version_fw_minor_bot", 'get HF{0}-{1}-iBot_FPGA_MINOR_VERSION'.format(crate, slot), 0 ], ] log = "" parsed_output = ngccm.send_commands_parsed(ts, [info[1] for info in data])["output"] # print parsed_output for info in data: result = parsed_output[data.index(info)]["result"] cmd = parsed_output[data.index(info)]["cmd"] if "ERROR" not in result: info[2] = int(result, 16) else: log += '>> ERROR: Failed to find the result of "{0}". The data string follows:\n{1}'.format( cmd, result) version_fw_top = "{0:02d}.{1:02d}".format(data[0][2], data[1][2]) version_fw_bot = "{0:02d}.{1:02d}".format(data[2][2], data[3][2]) return { "slot": slot, "version_fw_major_top": data[0][2], "version_fw_minor_top": data[1][2], "version_fw_top": version_fw_top, "version_fw_major_bot": data[2][2], "version_fw_minor_bot": data[3][2], "version_fw_bot": version_fw_bot, "log": log.strip(), }
def get_temps( ts=False ): # It's more flexible to not have the input be a teststand object. I should make it accept both. output = {} if ts: for crate, slots in ts.fe.iteritems(): output[crate] = [] for slot in slots: cmds = [ "get HF{0}-{1}-bkp_temp_f".format( crate, slot ), # The temperature sensor on the QIE card, near the bottom, labeled "U40". ] output[crate] += ngccm.send_commands_parsed(ts, cmds)["output"] return output else: return output
def read_counter_qie_igloo(ts, crate, slot): log = "" counts = [-1, -1] times = [-1, -1] cmds = [ "get HF{0}-{1}-iTop_RST_QIE_count".format(crate, slot), "get HF{0}-{1}-iBot_RST_QIE_count".format(crate, slot), ] result = ngccm.send_commands_parsed(ts, cmds) output = result["output"] for i in range(2): try: counts[i] = int(output[i]["result"], 16) times[i] = output[i]["times"][0] except Exception as ex: log += output[i][0] + " -> " + output[i][1] + "\n" + ex + "\n" return { "counts": counts, "times": times, "log": log, }
def get_bridge_info( ts, crate, slot ): # Returns a dictionary of information about the Bridge FPGA, such as the FW versions. data = [ [ "version_fw_major", 'get HF{0}-{1}-B_FIRMVERSION_MAJOR'.format(crate, slot), 0 ], [ "version_fw_minor", 'get HF{0}-{1}-B_FIRMVERSION_MINOR'.format(crate, slot), 0 ], [ "version_fw_svn", 'get HF{0}-{1}-B_FIRMVERSION_SVN'.format(crate, slot), 0 ], ] log = "" parsed_output = ngccm.send_commands_parsed(ts, [info[1] for info in data])["output"] # print parsed_output for info in data: result = parsed_output[data.index(info)]["result"] cmd = parsed_output[data.index(info)]["cmd"] if "ERROR" not in result: info[2] = int(result, 16) else: log += '>> ERROR: Failed to find the result of "{0}". The data string follows:\n{1}'.format( cmd, result) version_fw = "{0:02d}.{1:02d}.{2:04d}".format(data[0][2], data[1][2], data[2][2]) return { "slot": slot, "version_fw_major": data[0][2], "version_fw_minor": data[1][2], "version_fw_svn": data[2][2], "version_fw": version_fw, "log": log.strip(), }
def get_status(ts=None, crate=-1): # Perform basic checks of the FE crate backplanes: log = "" s = status(ts=ts, crate=crate) if ts: # Enable, reset, and check the BKP power: if crate in ts.fe_crates: ngfec_output = ngccm.send_commands_parsed(ts, "get HF{0}-bkp_pwr_bad".format(crate))["output"] if "ERROR" not in ngfec_output[0]["result"]: try: good = not int(ngfec_output[0]["result"]) s.pwr = int(good) s.status.append(int(good)) except Exception as ex: print ex s.status.append(0) else: s.status.append(0) else: print "ERROR (bkp.get_status): The crate you want ({0}) is not in the teststand object you supplied.".format(crate) s.update() return s
def testCache(self): errors = 0 executeErrors = 0 totalTests = 0 output = ngccm.send_commands_parsed(self.ts, self.commandCache)["output"] if self.verbosity >= 1: print output if len(output) % 2 != 0: print "ERROR, register::testCach() - the wrong number of commands were executed" return -999 for i in range(len(output) / 2): if output[i * 2]["cmd"].find("put ") == -1: print "ERROR, register::testCach() - commands executed in wrong order??" return -999 else: value = output[i * 2]["cmd"].split()[2:] if self.verbosity >= 1: print "value:", value valueNum = [] for v in value: valueNum.append(int(v, 16)) if output[i * 2]["result"] != "OK": executeErrors = executeErrors + 1 continue else: totalTests = totalTests + 1 if output[i * 2 + 1]["cmd"].find("get ") == -1: print "ERROR, register::testCach() - commands executed in wrong order??" return -999 else: #check = output[i*2+1]["result"].split("'")[1].split() check = output[i * 2 + 1]["result"].split() if self.verbosity >= 1: print "check:", check checkNum = [] for c in check[::-1]: checkNum.append(int(c, 16)) ### valueNum and checkNum are compared so that ### leading zeroes will be conveniently ignored if valueNum != checkNum: errors = errors + 1 print "--------------------------------" print "REGISTER:", self.name print "--------------------------------" print "errors:", errors print "execution errors:", executeErrors print "success rate:", 100. * (1. - float(errors) / float(totalTests)), "%"
def set_clk_phase(ts, crate, slot, qie, phase=0): return ngccm.send_commands_parsed(ts, "put HF{0}-{1}-Qie{2}_ck_ph {3}".format(crate, slot, qie, phase))
def set_clk_phase_all(ts, crate, slot, phase=0): cmds = ["put HF{0}-{1}-Qie{2}_ck_ph {3}".format(crate, slot, qie, phase) for qie in range(1, 25)] return ngccm.send_commands_parsed(ts, cmds)
def set_clk_phase_all(ts, crate, slot, phase=0): cmds = [ "put HF{0}-{1}-Qie{2}_ck_ph {3}".format(crate, slot, qie, phase) for qie in range(1, 25) ] return ngccm.send_commands_parsed(ts, cmds)
def set_clk_phase(ts, crate, slot, qie, phase=0): return ngccm.send_commands_parsed( ts, "put HF{0}-{1}-Qie{2}_ck_ph {3}".format(crate, slot, qie, phase))