def get_info( ts ): # Returns a dictionary of information about the GLIB, such as the FW version. data = { "version_fw_d": ['get fec1-user_firmware_dd', 0], "version_fw_m": ['get fec1-user_firmware_mm', 0], "version_fw_y": ['get fec1-user_firmware_yy', 0], } log = "" raw_output = ngccm.send_commands(ts, [data[info][0] for info in data.keys()])["output"] for info in data.keys(): match = search("{0} # ((0x)?[0-9a-f]+)".format(data[info][0]), raw_output) if match: data[info][1] = int(match.group(1), 16) else: log += '>> ERROR: Failed to find FW versions.\n' version_fw = "{0:02d}{1:02d}{2:02d}".format(data["version_fw_y"][1], data["version_fw_m"][1], data["version_fw_d"][1]) return { "version_fw_d": data["version_fw_d"][1], "version_fw_m": data["version_fw_m"][1], "version_fw_y": data["version_fw_y"][1], "version_fw": version_fw, "log": log.strip(), }
def get_temp( ts, crate ): # It's more flexible to not have the input be a teststand object. I should make it accept both. log = "" command = "get HF{0}-adc56_f".format(crate) raw_output = ngccm.send_commands(ts, command)["output"] # print raw_output temp = -1 try: match = search("get HF{0}-adc56_f # ([\d\.]+)".format(crate), raw_output) # print match.group(0) # print match.group(1) temp = float(match.group(1)) except Exception as ex: # print raw_output log += 'Trying to find the temperature of Crate {0} with "{1}" resulted in: {2}\n'.format( crate, command, ex) match = search("\n(.*ERROR!!.*)\n", raw_output) if match: log += 'The data string was "{0}".'.format(match.group(0).strip()) return { "temp": temp, "log": log, }
def read_counter_qie(ts): count = -1 cmd = "get fec1-qie_reset_cnt" raw_output = ngccm.send_commands(ts, cmd)["output"] match = search(cmd + " # ((0x)?[0-9a-f]+)", raw_output) if match: count = int(match.group(1),16) # else: # print "ERROR:" return count
def set_unique_id(ts, crate, slot): # Saves the unique ID of a crate slot to the associated QIE card to IGLOO registers. unique_id = get_unique_id(ts, crate, slot) if unique_id: ngccm_output = ngccm.send_commands(ts, [ "put HF{0}-{1}-iTop_UniqueID {2} {3}".format(crate, slot, unique_id[0], unique_id[1]), "put HF{0}-{1}-iBot_UniqueID {2} {3}".format(crate, slot, unique_id[0], unique_id[1]) ]) return 1 else: return 0
def get_status(ts): # Perform basic checks of the GLIB with the ngccm tool. log = "" status = {} status["status"] = [] # Ping GLIB: ping_result = Popen(["ping -c 1 {0}".format(ts.glib_ip)], shell = True, stdout = PIPE, stderr = PIPE).stdout.read() if ping_result: status["status"].append(1) else: status["status"].append(0) # Check that the version was accessible: glib_info = get_info(ts) if (int(glib_info["version_fw"]) != 0): status["status"].append(1) else: status["status"].append(0) # Check the control (1) and clock (2): ngccm_output = ngccm.send_commands(ts, ["get fec1-ctrl", "get fec1-user_wb_regs"])["output"] log += ngccm_output ## (1) check control data: match = search("{0} # ((0x)?[0-9a-f]+)".format("get fec1-ctrl"), ngccm_output) if match: value = int(match.group(1), 16) if (value == int("0x10aa3071", 16)): status["status"].append(1) else: log += "ERROR: The result of {0} was {1}, not {2}".format("get fec1-ctrl", value, int("0x10aa3071", 16)) status["status"].append(0) else: log += "ERROR: Could not find the result of \"{0}\" in the output.".format("get fec1-ctrl") status["status"].append(0) ## (2) check the 40 MHz clock: match = search("{0} # '(.*)'".format("get fec1-user_wb_regs"), ngccm_output) if match: values = match.group(1).split() clock = float(int(values[-5], 16))/10000 status["clock"] = clock if ( (clock > 40.0640) and (clock < 40.0895) ): status["status"].append(1) else: log += "ERROR: The clock frequency of {0} MHz is not between {1} and {2}.".format(clock, 40.0640, 40.0895) status["status"].append(0) else: log += "ERROR: Could not find the result of \"{0}\" in the output.".format("get fec1-user_wb_regs") status["status"].append(0) # Check QIE resets: f_orbit = get_frequency_orbit(ts) if (f_orbit["f"] < 13000 and f_orbit["f"] > 10000 and f_orbit["f_e"] < 500): status["status"].append(1) else: status["status"].append(0) status["orbit"] = [f_orbit["f"], f_orbit["f_e"]] return status
def read_counter_qie(ts): count = -1 cmd = "get fec1-qie_reset_cnt" raw_output = ngccm.send_commands(ts, cmd)["output"] match = search(cmd + " # ((0x)?[0-9a-f]+)", raw_output) if match: count = int(match.group(1), 16) # else: # print "ERROR:" return count
def set_unique_id( ts, crate, slot ): # Saves the unique ID of a crate slot to the associated QIE card to IGLOO registers. unique_id = get_unique_id(ts, crate, slot) if unique_id: ngccm_output = ngccm.send_commands(ts, [ "put HF{0}-{1}-iTop_UniqueID {2} {3}".format( crate, slot, unique_id[0], unique_id[1]), "put HF{0}-{1}-iBot_UniqueID {2} {3}".format( crate, slot, unique_id[0], unique_id[1]) ]) return 1 else: return 0
def get_temp(ts, crate): # It's more flexible to not have the input be a teststand object. I should make it accept both. log ="" command = "get HF{0}-adc56_f".format(crate) raw_output = ngccm.send_commands(ts, command)["output"] # print raw_output temp = -1 try: match = search("get HF{0}-adc56_f # ([\d\.]+)".format(crate), raw_output) # print match.group(0) # print match.group(1) temp = float(match.group(1)) except Exception as ex: # print raw_output log += 'Trying to find the temperature of Crate {0} with "{1}" resulted in: {2}\n'.format(crate, command, ex) match = search("\n(.*ERROR!!.*)\n", raw_output) if match: log+='The data string was "{0}".'.format(match.group(0).strip()) return { "temp": temp, "log": log, }
def get_info(ts): # Returns a dictionary of information about the GLIB, such as the FW version. data = { "version_fw_d": ['get fec1-user_firmware_dd', 0], "version_fw_m": ['get fec1-user_firmware_mm', 0], "version_fw_y": ['get fec1-user_firmware_yy', 0], } log = "" raw_output = ngccm.send_commands(ts, [data[info][0] for info in data.keys()])["output"] for info in data.keys(): match = search("{0} # ((0x)?[0-9a-f]+)".format(data[info][0]), raw_output) if match: data[info][1] = int(match.group(1), 16) else: log += '>> ERROR: Failed to find FW versions.\n' version_fw = "{0:02d}{1:02d}{2:02d}".format(data["version_fw_y"][1], data["version_fw_m"][1], data["version_fw_d"][1]) return { "version_fw_d": data["version_fw_d"][1], "version_fw_m": data["version_fw_m"][1], "version_fw_y": data["version_fw_y"][1], "version_fw": version_fw, "log": log.strip(), }
def get_status(ts): # Perform basic checks of the GLIB with the ngccm tool. log = "" status = {} status["status"] = [] # Ping GLIB: ping_result = Popen(["ping -c 1 {0}".format(ts.glib_ip)], shell=True, stdout=PIPE, stderr=PIPE).stdout.read() if ping_result: status["status"].append(1) else: status["status"].append(0) # Check that the version was accessible: glib_info = get_info(ts) if (int(glib_info["version_fw"]) != 0): status["status"].append(1) else: status["status"].append(0) # Check the control (1) and clock (2): ngccm_output = ngccm.send_commands( ts, ["get fec1-ctrl", "get fec1-user_wb_regs"])["output"] log += ngccm_output ## (1) check control data: match = search("{0} # ((0x)?[0-9a-f]+)".format("get fec1-ctrl"), ngccm_output) if match: value = int(match.group(1), 16) if (value == int("0x10aa3071", 16)): status["status"].append(1) else: log += "ERROR: The result of {0} was {1}, not {2}".format( "get fec1-ctrl", value, int("0x10aa3071", 16)) status["status"].append(0) else: log += "ERROR: Could not find the result of \"{0}\" in the output.".format( "get fec1-ctrl") status["status"].append(0) ## (2) check the 40 MHz clock: match = search("{0} # '(.*)'".format("get fec1-user_wb_regs"), ngccm_output) if match: values = match.group(1).split() clock = float(int(values[-5], 16)) / 10000 status["clock"] = clock if ((clock > 40.0640) and (clock < 40.0895)): status["status"].append(1) else: log += "ERROR: The clock frequency of {0} MHz is not between {1} and {2}.".format( clock, 40.0640, 40.0895) status["status"].append(0) else: log += "ERROR: Could not find the result of \"{0}\" in the output.".format( "get fec1-user_wb_regs") status["status"].append(0) # Check QIE resets: f_orbit = get_frequency_orbit(ts) if (f_orbit["f"] < 13000 and f_orbit["f"] > 10000 and f_orbit["f_e"] < 500): status["status"].append(1) else: status["status"].append(0) status["orbit"] = [f_orbit["f"], f_orbit["f_e"]] return status