def T_07_RecvRSSITest_A(product): u"单板ADC电路测试-计算RSRB4单板接收射频信号的RSSI值测试" proxy.open(PARAM["defaultNetOneIp"]) try: fpga_pll.config() proxy._write_fpga_reg(0x5a, 0x01) rx_pll.config(5722) proxy._write_fpga_reg(0x59, 0x00) proxy._write_fpga_reg(0x50, 0x01) proxy._write_fpga_reg(0x51, 0x02) proxy._write_fpga_reg(0x58, 0x01) proxy._write_fpga_reg(0x56, 0x00) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x52, 0x14) proxy._write_fpga_reg(0x95, 0x03) proxy._write_fpga_reg(0x96, 0x01) proxy._write_fpga_reg(0x9b, 0x01) proxy._write_fpga_reg(0x90, 0x01) time.sleep(0.5) # 工装发射单音 FrockSendRSSI() fpga_addr = "3f" fpga_addr = int(str(fpga_addr), 16) fpga_value = proxy._read_fpga_reg(fpga_addr) print hex(fpga_value)[2:] proxy._write_fpga_reg(0x5a, 0x1) proxy._write_fpga_reg(0x46, 0x1) proxy._write_fpga_reg(0x58, 0x0) proxy._write_fpga_reg(0x5a, 0x0) print "关闭接收" except Exception as e: PARAM["failNum"] = "1" raise TestItemFailException(failWeight=1, message=u"待测板接收异常,%s" % e) finally: proxy.close() proxyFrock.open(PARAM["defaultNetTwoIp"]) try: proxyFrock._write_fpga_reg(0x5a, 0x1) proxyFrock._write_fpga_reg(0x58, 0x0) proxyFrock._write_fpga_reg(0x59, 0x0) proxyFrock._write_fpga_reg(0x46, 0x1) proxyFrock._write_fpga_reg(0x3e, 0x0) proxyFrock._write_fpga_reg(0x5a, 0x0) print "关闭工控单音" except Exception as e: raise AbortTestException(message=u"工装异常,请检查工装,%s" % e) finally: proxyFrock.close() if fpga_value > int(PARAM["recvRSSILow"]) and fpga_value < int(PARAM["recvRSSIHigh"]): return {u"接收RSSI值为:":fpga_value} else: PARAM["failNum"] = "1" raise TestItemFailException(failWeight=1, message=u"接收RSSI测试不通过,,值:%d:"%fpga_value)
def _T_05_RecvRSSITest_A(product): u"接收RSSI值测试-RSRB4单板射频信号接收RSSI值测试" try: proxy.open(PARAM["defaultNetOneIp"]) fpga_pll.config() proxy._write_fpga_reg(0x5a, 0x01) rx_pll.config(5722) proxy._write_fpga_reg(0x59, 0x00) proxy._write_fpga_reg(0x50, 0x01) proxy._write_fpga_reg(0x51, 0x02) proxy._write_fpga_reg(0x58, 0x01) proxy._write_fpga_reg(0x56, 0x00) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x52, 0x00) proxy._write_fpga_reg(0x95, 0x03) proxy._write_fpga_reg(0x96, 0x01) proxy._write_fpga_reg(0x9b, 0x01) proxy._write_fpga_reg(0x90, 0x01) time.sleep(0.5) # 工装发射单音 FrockSendRSSI() fpga_addr = "3f" fpga_addr = int(str(fpga_addr), 16) fpga_value = proxy._read_fpga_reg(fpga_addr) print hex(fpga_value)[2:] proxyFrock._write_fpga_reg(0x5a, 0x1) proxyFrock._write_fpga_reg(0x58, 0x0) proxyFrock._write_fpga_reg(0x59, 0x0) proxyFrock._write_fpga_reg(0x46, 0x1) proxyFrock._write_fpga_reg(0x3e, 0x0) proxyFrock._write_fpga_reg(0x5a, 0x0) print "关闭工控单音" proxy._write_fpga_reg(0x5a, 0x1) proxy._write_fpga_reg(0x58, 0x0) proxy._write_fpga_reg(0x59, 0x0) proxy._write_fpga_reg(0x46, 0x1) proxy._write_fpga_reg(0x3e, 0x0) proxy._write_fpga_reg(0x5a, 0x0) print "关闭单音" except Exception as e: raise AbortTestException(message=e) finally: proxy.close() proxyFrock.close() print fpga_value if fpga_value > int(PARAM["recvRSSILow"]) and fpga_value < int( PARAM["recvRSSIHigh"]): return {u"RSSI值为:": fpga_value, u"16进制:": hex(fpga_value)[2:]} raise TestItemFailException(failWeight=10, message=u"RSSI测试不通过")
def T_04_RecvRSSITest222_A(product): u"无连接测试-计算RSRB4单板接收射频信号的RSSI值测试" manulCheck(u'提示', u'请断开信号源', check="ok") try: proxy.open(PARAM["defaultNetOneIp"]) fpga_pll.config() proxy._write_fpga_reg(0x5a, 0x01) rx_pll.config(5722) proxy._write_fpga_reg(0x59, 0x00) proxy._write_fpga_reg(0x50, 0x01) proxy._write_fpga_reg(0x51, 0x02) proxy._write_fpga_reg(0x58, 0x01) proxy._write_fpga_reg(0x56, 0x00) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x52, 0x00) proxy._write_fpga_reg(0x95, 0x03) proxy._write_fpga_reg(0x96, 0x01) proxy._write_fpga_reg(0x9b, 0x01) proxy._write_fpga_reg(0x90, 0x01) time.sleep(0.5) # 工装发射单音 proxy._write_fpga_reg(0x52, 0x7f) fpga_addr = "3f" fpga_addr = int(str(fpga_addr), 16) fpga_value = proxy._read_fpga_reg(fpga_addr) print hex(fpga_value)[2:] proxy._write_fpga_reg(0x5a, 0x1) proxy._write_fpga_reg(0x46, 0x1) proxy._write_fpga_reg(0x58, 0x0) proxy._write_fpga_reg(0x5a, 0x0) print "关闭接收" except Exception as e: raise AbortTestException(message=e) finally: proxy.close() if fpga_value > int(PARAM["recvNothingLow"]) and fpga_value < int(PARAM["recvNothingHigh"]): return {u"无输入接收RSSI值为:": fpga_value} else: PARAM["failNum"] = "1" raise TestItemFailException(failWeight=1, message=u"无输入接收RSSI测试失败,值:%d:" % fpga_value)
def myReadMac(): macoffset = 0x40 proxy = MACProxy(PARAM["defaultNetOneIp"]) try: readMac = proxy.readEeprom(macoffset, 6) macstrRead = "" macstrRead += binascii.hexlify(readMac[0:1]) macstrRead += binascii.hexlify(readMac[1:2]) macstrRead += binascii.hexlify(readMac[2:3]) macstrRead += binascii.hexlify(readMac[3:4]) macstrRead += binascii.hexlify(readMac[4:5]) macstrRead += binascii.hexlify(readMac[5:6]) return macstrRead except: raise TestItemFailException(failWeight=10, message=u"读取mac失败,EEPROM测试失败") finally: proxy.close()
def myWriteMac(macstr): macoffset = 0x40 proxy = MACProxy(PARAM["defaultNetOneIp"]) for i in range(12): try: proxy.initResource() proxy.readEeprom(0x27, 12) break except: time.sleep(5) else: proxy.close() raise TestItemFailException(failWeight=10, message=u"建立连接失败,EEPROM测试失败") try: macLast = binascii.unhexlify(macstr) proxy.writeEeprom(macoffset, macLast) except: raise TestItemFailException(failWeight=10, message=u"写入mac失败,EEPROM测试失败") finally: proxy.close()
def T_02_simulationPowerTest_A(product): u"单板DAC电路测试-接入RSRB4单板发射模拟控制功率测试(MAX , MIN 2个值)" try: right = [] error = [] # 待测单板发射单音 # 模拟高,数字高 proxy.open(PARAM["defaultNetOneIp"]) proxy._init_fpga() fpga_pll.config() proxy._write_fpga_reg(0x5a, 0x01) proxy._write_fpga_reg(0x3e, 0x00) tx_pll.config(5830) proxy._write_fpga_reg(0x50, 0x02) proxy._write_fpga_reg(0x51, 0x01) proxy._write_fpga_reg(0x58, 0x01) proxy._write_fpga_reg(0x59, 0x01) proxy._write_fpga_reg(0x24, 0x47e) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) time.sleep(0.5) MaxMax = manulCheck(u'提示', u'最大功率MaxMax') if MaxMax: right.append("最大功率") else: error.append("最大功率") # 模拟高,数字低 proxy._write_fpga_reg(0x56, 0x24) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) MaxMin = manulCheck(u'提示', u'衰减数字信号MaxMin') if MaxMin: right.append("衰减数字") else: error.append("衰减数字") # 模拟低,数字高 proxy._write_fpga_reg(0x24, 0xa28) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) MinMax = manulCheck(u'提示', u'衰减模拟信号MinMax') if MinMax: right.append("衰减模拟") else: error.append("衰减模拟") # 关闭待测单板单音 proxy._write_fpga_reg(0x5a, 0x1) proxy._write_fpga_reg(0x58, 0x0) proxy._write_fpga_reg(0x59, 0x0) proxy._write_fpga_reg(0x46, 0x1) proxy._write_fpga_reg(0x3e, 0x0) proxy._write_fpga_reg(0x5a, 0x0) except Exception as e: raise AbortTestException(message=e) finally: proxy.close()
def T_02_simulationPowerTest_A(product): u"单板DAC电路测试-接入RSRB4单板发射模拟控制功率测试(MAX , MIN 2个值)" try: error = [] # 待测单板发射单音 # 模拟高,数字高 manulCheck(u'提示', u'请接入频谱仪开始测试') proxy.open(PARAM["defaultNetOneIp"]) proxy._init_fpga() fpga_pll.config() proxy._write_fpga_reg(0x5a, 0x01) proxy._write_fpga_reg(0x3e, 0x00) tx_pll.config(5830) proxy._write_fpga_reg(0x50, 0x02) proxy._write_fpga_reg(0x51, 0x01) proxy._write_fpga_reg(0x58, 0x01) proxy._write_fpga_reg(0x59, 0x01) proxy._write_fpga_reg(0x24, 0x47e) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) MaxMax = manulCheck(u'提示', u'最大功率是否达标') if not MaxMax: error.append("1.最大功率") # 模拟高,数字低 proxy._write_fpga_reg(0x56, 0x24) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) MaxMin = manulCheck(u'提示', u'衰减数字信号后的功率是否达标') if not MaxMin: error.append("2.衰减数字信号后的功率") # 模拟低,数字高 proxy._write_fpga_reg(0x24, 0xa28) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) MinMax = manulCheck(u'提示', u'衰减模拟信号后的功率是否达标') if not MinMax: error.append("3.衰减模拟信号后的功率") # 关闭待测单板单音 proxy._write_fpga_reg(0x5a, 0x1) proxy._write_fpga_reg(0x58, 0x0) proxy._write_fpga_reg(0x59, 0x0) proxy._write_fpga_reg(0x46, 0x1) proxy._write_fpga_reg(0x3e, 0x0) proxy._write_fpga_reg(0x5a, 0x0) except Exception as e: raise AbortTestException(message=e) finally: proxy.close() errorStr = ",".join(error) if error != []: PARAM["failNum"] = "1" raise TestItemFailException(failWeight=1, message=u"%s不达标" % errorStr) return
def _T_04_simulationPowerTest_A(product): u"发射模拟控制功率测试-RSRB4单板发射模拟控制功率测试(MAX , MIN 2个值)" for i in range(10): pingResult = pingIPOpen(PARAM["defaultNetOneIp"]) if pingResult == "ok": break time.sleep(5) else: raise TestItemFailException(failWeight=10, message=u"连接失败有可能是网口通信问题") k = float(str(PARAM["frockSlope"])) b = float(str(PARAM["frockB"])) damping = float(str(PARAM["frockDamping"])) error = float(str(PARAM["frockError"])) RSSIDict = {} try: # 打开工装接收 proxyFrock.open(PARAM["defaultNetTwoIp"]) fpga_pll.config1() proxyFrock._write_fpga_reg(0x5a, 0x01) rx_pll.config1(5762) proxyFrock._write_fpga_reg(0x59, 0x00) proxyFrock._write_fpga_reg(0x50, 0x01) proxyFrock._write_fpga_reg(0x51, 0x02) proxyFrock._write_fpga_reg(0x58, 0x01) proxyFrock._write_fpga_reg(0x56, 0x00) proxyFrock._write_fpga_reg(0x57, 0x00) proxyFrock._write_fpga_reg(0x57, 0x01) proxyFrock._write_fpga_reg(0x57, 0x00) proxyFrock._write_fpga_reg(0x52, 0x00) proxyFrock._write_fpga_reg(0x95, 0x03) proxyFrock._write_fpga_reg(0x96, 0x01) proxyFrock._write_fpga_reg(0x9b, 0x01) proxyFrock._write_fpga_reg(0x90, 0x01) time.sleep(2) # 待测单板发射单音 # 模拟高,数字高 proxy.open(PARAM["defaultNetOneIp"]) proxy._init_fpga() fpga_pll.config() proxy._write_fpga_reg(0x5a, 0x01) proxy._write_fpga_reg(0x3e, 0x00) tx_pll.config(5830) proxy._write_fpga_reg(0x50, 0x02) proxy._write_fpga_reg(0x51, 0x01) proxy._write_fpga_reg(0x58, 0x01) proxy._write_fpga_reg(0x59, 0x01) proxy._write_fpga_reg(0x24, 0x47e) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) time.sleep(0.5) MaxMaxValue = FrockRecvRSSI() sendPower1 = (MaxMaxValue - b) / k + error + damping MaxMaxKey = "MaxMax的发射功率为" + str(sendPower1) if sendPower1 > float(PARAM["xxLow"]) and sendPower1 < float( PARAM["xxHigh"]): RSSIDict[MaxMaxKey] = "通过" else: RSSIDict[MaxMaxKey] = "失败" # 模拟高,数字低 proxy._write_fpga_reg(0x56, 0x24) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) MaxMinValue = FrockRecvRSSI() sendPower2 = (MaxMinValue - b) / k + error + damping if sendPower2 > float(PARAM["xiLow"]) and sendPower2 < float( PARAM["xiHigh"]): RSSIDict["MaxMin的发射功率为" + str(sendPower2)] = "通过" else: RSSIDict["MaxMin的发射功率为" + str(sendPower2)] = "失败" # 模拟低,数字高 proxy._write_fpga_reg(0x24, 0xa28) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) MinMaxValue = FrockRecvRSSI() sendPower3 = (MinMaxValue - b) / k + error + damping MinMaxKey = "MinMax的发射功率为" + str(sendPower3) if sendPower3 > float(PARAM["ixLow"]) and sendPower3 < float( PARAM["ixHigh"]): RSSIDict[MinMaxKey] = "通过" else: RSSIDict[MinMaxKey] = "失败" # 关闭待测单板单音 proxy._write_fpga_reg(0x5a, 0x1) proxy._write_fpga_reg(0x58, 0x0) proxy._write_fpga_reg(0x59, 0x0) proxy._write_fpga_reg(0x46, 0x1) proxy._write_fpga_reg(0x3e, 0x0) proxy._write_fpga_reg(0x5a, 0x0) # 关闭工装单音 proxyFrock._write_fpga_reg(0x5a, 0x1) proxyFrock._write_fpga_reg(0x58, 0x0) proxyFrock._write_fpga_reg(0x59, 0x0) proxyFrock._write_fpga_reg(0x46, 0x1) proxyFrock._write_fpga_reg(0x3e, 0x0) proxyFrock._write_fpga_reg(0x5a, 0x0) except Exception as e: raise AbortTestException(message=e) finally: proxy.close() proxyFrock.close() for i in RSSIDict: if RSSIDict[i] == "失败": PARAM["failNum"] = "1" message = "\n".join([a + ": " + RSSIDict[a] for a in RSSIDict]) raise TestItemFailException(failWeight=1, message=unicode(message, "utf-8")) RSSIstr = ",".join([a for a in RSSIDict]) return {RSSIstr: u"全部测试通过"}
def T_06_simulationPowerTest_A(product): u"单板DAC电路测试-接入RSRB4单板发射模拟控制功率测试(MAX , MIN 2个值)" k = float(str(PARAM["frockSlope"])) b = float(str(PARAM["frockB"])) damping = float(str(PARAM["frockDamping"])) error = float(str(PARAM["frockError"])) power1 = {} power2 = {} power3 = {} RSSIDict = [power1,power2,power3] proxyFrock.open(PARAM["defaultNetTwoIp"]) try: # 打开工装接收 fpga_pll.config1() proxyFrock._write_fpga_reg(0x5a, 0x01) rx_pll.config1(5762) proxyFrock._write_fpga_reg(0x59, 0x00) proxyFrock._write_fpga_reg(0x50, 0x01) proxyFrock._write_fpga_reg(0x51, 0x02) proxyFrock._write_fpga_reg(0x58, 0x01) proxyFrock._write_fpga_reg(0x56, 0x00) proxyFrock._write_fpga_reg(0x57, 0x00) proxyFrock._write_fpga_reg(0x57, 0x01) proxyFrock._write_fpga_reg(0x57, 0x00) proxyFrock._write_fpga_reg(0x52, 0x14) proxyFrock._write_fpga_reg(0x95, 0x03) proxyFrock._write_fpga_reg(0x96, 0x01) proxyFrock._write_fpga_reg(0x9b, 0x01) proxyFrock._write_fpga_reg(0x90, 0x01) time.sleep(2) except Exception as e: raise AbortTestException(message=u"工装异常,请检查工装,%s" % e) finally: proxyFrock.close() proxy.open(PARAM["defaultNetOneIp"]) try: # 待测单板发射单音 # 模拟高,数字高 proxy._init_fpga() fpga_pll.config() proxy._write_fpga_reg(0x5a, 0x01) proxy._write_fpga_reg(0x3e, 0x00) tx_pll.config(5830) proxy._write_fpga_reg(0x50, 0x02) proxy._write_fpga_reg(0x51, 0x01) proxy._write_fpga_reg(0x58, 0x01) proxy._write_fpga_reg(0x59, 0x01) proxy._write_fpga_reg(0x24, 0x47e) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) time.sleep(0.5) MaxMaxValue = FrockRecvRSSI() sendPower1 = (MaxMaxValue - b) / k +error +damping MaxMaxKey = "最大发射功率为:" + str(round(sendPower1,2)) if sendPower1 > float(PARAM["xxLow"]) and sendPower1 < float(PARAM["xxHigh"]): power1[MaxMaxKey] = "通过" else: power1[MaxMaxKey] = "失败" # 模拟高,数字低 proxy._write_fpga_reg(0x56, 0x24) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) time.sleep(0.5) MaxMinValue = FrockRecvRSSI() sendPower2 = (MaxMinValue - b) / k +error +damping differ2 = sendPower1 - sendPower2 MaxMinKey = "数字衰减发射功率为:" + str(round(sendPower2,2)) + ", 与最大功率差值为:" + str(round(differ2,2)) if differ2 > float(PARAM["xiLow"]) and differ2 < float(PARAM["xiHigh"]): power2[MaxMinKey] = "通过" else: power2[MaxMinKey] = "失败" # 模拟低,数字高 proxy._write_fpga_reg(0x24, 0xa28) proxy._write_fpga_reg(0x56, 0x3c) proxy._write_fpga_reg(0x57, 0x00) proxy._write_fpga_reg(0x57, 0x01) proxy._write_fpga_reg(0x57, 0x00) time.sleep(0.5) MinMaxValue = FrockRecvRSSI() sendPower3 = (MinMaxValue - b) / k +error +damping differ3 = sendPower1 - sendPower3 MinMaxKey = "模拟衰减发射功率为:" + str(round(sendPower3,2)) + ", 与最大功率差值为:" + str(round(differ3,2)) if differ3 > float(PARAM["ixLow"]) and differ3 < float(PARAM["ixHigh"]): power3[MinMaxKey] = "通过" else: power3[MinMaxKey] = "失败" # 关闭待测单板单音 proxy._write_fpga_reg(0x5a, 0x1) proxy._write_fpga_reg(0x58, 0x0) proxy._write_fpga_reg(0x59, 0x0) proxy._write_fpga_reg(0x46, 0x1) proxy._write_fpga_reg(0x3e, 0x0) proxy._write_fpga_reg(0x5a, 0x0) except Exception as e: PARAM["failNum"] = "1" raise TestItemFailException(failWeight=1, message=u"发射单音异常,%s" % e) finally: proxy.close() # 关闭工装单音 # proxyFrock._write_fpga_reg(0x5a, 0x1) # proxyFrock._write_fpga_reg(0x58, 0x0) # proxyFrock._write_fpga_reg(0x59, 0x0) # proxyFrock._write_fpga_reg(0x46, 0x1) # proxyFrock._write_fpga_reg(0x3e, 0x0) # proxyFrock._write_fpga_reg(0x5a, 0x0) proxyFrock.open(PARAM["defaultNetTwoIp"]) try: # 关闭接收 proxyFrock._write_fpga_reg(0x5a, 0x1) proxyFrock._write_fpga_reg(0x46, 0x1) proxyFrock._write_fpga_reg(0x58, 0x0) proxyFrock._write_fpga_reg(0x5a, 0x0) except Exception as e: raise AbortTestException(message=u"工装异常,请检查工装,%s" % e) finally: proxyFrock.close() resultStr = "" for a in RSSIDict: for b in a: resultStr += b + " " + a[b] + "\n" print resultStr for i in range(3): for j in RSSIDict[i]: if RSSIDict[i][j] == "失败": PARAM["failNum"] = "1" raise TestItemFailException(failWeight=1, message=u"%s"%resultStr) return {u"%s"%resultStr:u"全部通过"}