Esempio n. 1
0
def T_19_staticCurrent_A(product):
    u'''静态电流测试-判断静态电流值是否在正常范围内'''
    try:
        sc = board_digital.__askForPlateDeviceCom()
        iob = __getIoBoard()
        #        v = sc.testStaticCurrent()
        try:
            device = sc.bslDevice
            device.make_obu_enter_sleep()
            iob.output(GS11IOBoardDevice.UART_TX_OUTPUT, True)  #切换OBU的UART串口
            iob.output(GS11IOBoardDevice.UART_RX_OUTPUT, True)
            time.sleep(0.5)
            device.set_small_current_switch(0)
            current_val = device.read_adc_current()
            if current_val > 10:
                print "current_val=", current_val
                superUiLog("small_current_switch = 0,current_val=" +
                           str(current_val))
                raise
            device.set_small_current_switch(1)
            current_val = device.read_adc_current()
            v = sc.convertAdcToCurrent(current_val)
        finally:
            iob.output(GS11IOBoardDevice.UART_TX_OUTPUT, False)
            iob.output(GS11IOBoardDevice.UART_RX_OUTPUT, False)
            device.set_small_current_switch(0)
        resultMap = {u"静态电流": v}
        if v < SP('gs11.staticCurrent.low', 2) or v > SP(
                'gs11.staticCurrent.high', 18):
            raise TestItemFailException(failWeight=10,
                                        message=u'静态电流测试不通过,正常阈值4-18',
                                        output=resultMap)
        return resultMap
    except TestItemFailException, e:
        raise e
 def sendAndRecv(self, cmd):
     superUiLog(u"send to ip:%s,%s" % (self.ip, cmd))
     cmd += "\n"
     try:
         if self.con is None: self.initSocket()
         if self.con is None:
             raise AbortTestException(message=u'FE2RS232板通信失败')
         self.con.sendall(cmd)
         rcvFrame = []
         for i in range(5):
             f = self.con.recv(64)
             rcvFrame.append(f)
             if f.endswith("\n"):
                 if "PowerOnSuccess" in f:
                     continue
                 else:
                     break
         rcvFrame = "".join(rcvFrame)
         #print self.ip,binascii.hexlify(rcvFrame)
         superUiLog(self.ip + ":<-" + binascii.hexlify(rcvFrame))
         #superUiLog(u"receive from ip:%s,%s"%(self.ip,rcvFrame))
         #rcvFrame = rcvFrame.replace("PowerOnSuccess","").replace("\r","").replace("\n","").replace("\x00","")
         #rcvFrame = rcvFrame.decode("iso-8859-1")
         if rcvFrame != "": return rcvFrame.strip()
         raise Exception(u"OBU串口无响应")
     except Exception, e:
         if self.con is not None:
             self.con.close()
         self.con = None
         raise TestItemFailException(failWeight=10, message=unicode(e))
 def bslWriteData(self,addressDataList):
     '''bsl方式写入参数,入参passwd:密码,addressDataList:[[地址,数据],[地址,数据]……],按顺序排列'''
     upload_data = memory.Memory()
     wholeStart = addressDataList[0][0]
     
     segmentStart = [0x1800,0x1880,0x1900,0x1980][int((wholeStart-0x1800)/0x80)]
     
     upload_data.append(memory.Segment(segmentStart, self.memory_read(segmentStart, 0x80)))
     
     for ad in addressDataList:
         address = ad[0]
         data = ad[1]
         upload_data.set(address, data)
     
     self.BSL_ERASE_SEGMENT(segmentStart) 
     for segment in upload_data:
         print "Write segment at 0x%04x %d bytes\n" % (segment.startaddress, len(segment.data))
         superUiLog("Write segment at 0x%04x %d bytes\n" % (segment.startaddress, len(segment.data)))
         data = segment.data
         if len(data) & 1:
             data += '\xff'
         self.memory_write(segment.startaddress, data)
         
     print 'bsl write successfully, starting read and verification.'
     uiLog(u"BSL 写入完成,正在校验...")
     for segment in upload_data:
         sg = self.memory_read(segment.startaddress, len(segment.data))
         if sg != segment.data:
             raise
         print "verify %2.X OK"%segment.startaddress
     uiLog(u"BSL校验成功")
Esempio n. 4
0
def T_01_readObuId_A(product):
    u"读取OBU内部标识-通过ICP方式读取OBU的内部标识"
    nul = board.__getNuLink()
    try:
        __switchToNulink()
        infos = nul.readInfo()
        superUiLog(u"信息区" + infos)
        currentSoftVersion = infos[18:26]
        vf = SP("gs11.vatVersion.filename", "GS11-VAT-09.00.00.version", str)
        targetVatSoftwareVersion = "".join(
            vf.split("-")[2].split(".")[:3]) + "00"
        if currentSoftVersion != targetVatSoftwareVersion:
            uiLog(u"整机内非测试版本,下载测试版本:" + vf)
            #下载测试版本
            vf = getVersionFile(
                SP("gs11.vatVersion.filename", "GS11-VAT-09.00.00.version",
                   str))
            nul.downloadVersion(vf)
            #写入测试版本号
            CONFIG_BUILD_INFO = infos[:32]
            CONFIG_RF_PARA = infos[128:154]
            CONFIG_BUILD_INFO = CONFIG_BUILD_INFO[:
                                                  18] + targetVatSoftwareVersion + CONFIG_BUILD_INFO[
                                                      26:]
            nul.writeToInfo(CONFIG_BUILD_INFO, CONFIG_RF_PARA)
    except Exception, e:
        print e
        raise AbortTestException(u"无法读取内部标识及版本号")
Esempio n. 5
0
def T_04_PSAMTest_A(product):
    u'PSAM卡接口测试-RSDB0单板连接RSIB0单板进行4个PSAM卡接口测试'
    errorList = []
    proxy = PsamProxy(PARAM["writeIP"])
    command = "00a4000002df01"
    try:
        for slot in range(4):
            ack = proxy.active(slot)
            if ack[0:4] != "e800":
                superUiLog(u"PSAM卡槽[%d]激活失败" % (slot + 1) + ack)
                errorList.append(str(slot + 1))
                continue
            else:
                superUiLog(u"PSAM卡槽[%d]激活成功" % (slot + 1) + ack[4:])
                ackRead = proxy.exchangeApdu(slot, command)
                if ackRead[0:4] != "e900":
                    uiLog(u"命令执行失败 " + ack)
                else:
                    uiLog(u"命令执行成功 " + ack[4:])
    finally:
        proxy.close()
    if errorList != []:
        raise TestItemFailException(failWeight=10,
                                    message=u'PSAM卡槽%s激活失败' %
                                    ",".join(errorList))
    return
 def register_and_serial(self, command, expect):
     m = 0
     y = 0
     self.serial.flushInput()
     while True:
         if m == 4:
             return "loginfail"
         response = self.serial.readline(100)
         if response == "":
             m += 1
             print "m:",m
         print "登录response:", response
         superUiLog("command:" + command.strip() + ",response:" + response.strip())
         if "UEC0, UEC1" in response:
             time.sleep(1)
             self.serial.flushInput()
             self.serial.write(command)
         elif "turn off boot console udbg0" in response:
             return "loginfail"
         elif "Reset Status:" in response:
             y += 1
             if y == 5:
                 return "EPLDError"
         elif expect in response:
             time.sleep(1)
             return
Esempio n. 7
0
 def assertSynComm(self, request, response=None, noResponseFailWeight=10, assertFailWeight=10):
     '''直接给出请求响应,自动判定串口通信值是否正确;如果response==None,则不判定响应'''
     superUiLog(u"串口发送:" + request)
     realResponse = self.linearSerialComm.synComm(request)
     superUiLog(u"收到串口响应:" + realResponse)
     if response != None and realResponse != response:
         raise TestItemFailException(failWeight=assertFailWeight, message=u'%s命令串口响应错误' % (request))
     return True
Esempio n. 8
0
 def forward_and_check(self, command, expect):
     self.serial.flushInput()
     self.serial.write(command)
     response = self.serial.readline(100)
     print command
     print response
     superUiLog("command:"+command.strip()+",response:"+response.strip())
     return expect in response
Esempio n. 9
0
 def __nulinkCmd(self, cmd):
     '''执行NuLink指令'''
     if self.nulinkId is None: self.nulinkId = ""
     fullCmd = "NuLink.exe " + self.nulinkId + " " + cmd
     superUiLog(u"执行NuLink指令:" + fullCmd)
     r = os.popen(fullCmd)
     dr = r.read()
     print dr
     return dr.strip()
Esempio n. 10
0
 def assertAndGetParam(self, request, response, noResponseFailWeight=10, assertFailWeight=10):
     '''判定响应命令正确与否,并返回输出参数'''
     superUiLog(u"串口发送:" + request)
     r = self.linearSerialComm.synComm(request)
     superUiLog(u"收到串口响应:" + r)
     if not r.startswith(response):
         raise TestItemFailException(failWeight=assertFailWeight, message=u'%s命令串口响应错误' % (request))
     else:
         return r[len(response):]
Esempio n. 11
0
def __readOldMac():
    '''读取旧MAC地址'''
    sc = __askForPlateDeviceCom()
    try:
        superUiLog(u"BSL方式尝试读取旧MAC地址")
        macBytes = sc.read_obu_id(versionFile)
        mac = "".join(["%.2X" % i for i in macBytes])
        superUiLog(u"尝试读取旧MAC地址结果:%s" % mac)
        return mac
    except Exception, e:
        raise AbortTestException(message=u'BSL方式读取产品标识失败:' + e.message)
 def read_frame_num(self):
     self.serial.write("ReadTestFrameNum\r\n")
     print "ReadTestFrameNum\r\n"
     superUiLog("command:ReadTestFrameNum")
     response = self.serial.readline(128).strip()
     print response
     superUiLog("response:"+response)
     if not response or (len(response) < 6) or (response[0:5] != "TRNum"):
         raise
     recv_num = int(response[5:])
     return recv_num
 def finishBslWritten(self):
     '''完成BSL写入'''
     self.quit_bsl()
     self.quit_bsl()
     print "quit bsl"
     superUiLog("quit bsl")
     self.serial.baudrate = 115200
     self.serial.parity = serial.PARITY_NONE
     self.serial.timeout = 5
     self.set_TEST(False)
     uiLog(u"BSL方式写入完成")
 def test_if_obu_wakeup(self):
     self.serial.write("IfObuWakeUp\r\n")
     print "IfObuWakeUp\r\n"
     superUiLog("command:IfObuWakeUp")
     response = self.serial.readline(128).strip()
     print response
     superUiLog("response:"+response)
     if response == "TWFALSE":
         return False
     elif response == "TWOK":
         return True
     else:
         raise
Esempio n. 15
0
 def download_ver(self, old_file_path=None, new_file_path=None, mass_erase=False):
     self.forward_and_check("BSL\r\n", "BSLOK")
     self.serial.baudrate = 9600
     self.serial.parity = serial.PARITY_EVEN
     self.serial.timeout = 1        
     try:
         download_data = memory.Memory() # prepare downloaded data        
         data = memory.load(new_file_path)
         download_data.merge(data)
         self.start_bsl()
         if mass_erase:
             self.bsl_mass_erase()
             print "Mass Erase Success!\r\n"
         passwd = _getPasswordFromFile(old_file_path)
         self.BSL_RX_PASSWORD(passwd)
         self.set_baudrate(115200)
         for segment in download_data:
             print "Write segment at 0x%04x %d bytes\n" % (segment.startaddress, len(segment.data))
             uiLog(u"版本信息正在写入位置: 0x%04x %d bytes"%(segment.startaddress, len(segment.data)))
             data = segment.data
             if len(data) & 1:
                 data += '\xff'
             self.memory_write(segment.startaddress, data)
         print "version downloaded successfully, starting read and verification." 
         uiLog(u"版本写入完成,正在校验...")   
         #读回版本并验证
         for segment in download_data:
             sg = self.memory_read(segment.startaddress, len(segment.data))
             #这是bytearray对象
             if sg != segment.data:
                 raise
             print "verify %2.X OK"%segment.startaddress
         uiLog(u'版本校验成功')    
             
     except Exception as e:
         print "Program fail! " + str(e)
         superUiLog("Program fail! " + str(e))
         raise e
     else:
         print "Program OK!"
     finally:
         self.quit_bsl()
         self.quit_bsl()
         print "quit bsl"
         superUiLog("quite bsl")
         self.serial.baudrate = 115200
         self.serial.parity = serial.PARITY_NONE
         self.serial.timeout = 5
         self.set_TEST(False)
Esempio n. 16
0
 def testDeepStaticCurrent(self):
     '''深度静态电流测试'''
     try:
         device = self.bslDevice
         device.set_small_current_switch(0)
         current_val = device.read_adc_current()
         print "current_val=", current_val
         superUiLog("small_current_switch = 0,current_val=" + str(current_val))
         if current_val > 20:  # 原值为10,20151106为测试而修改
             raise
         device.set_small_current_switch(1)
         current_val = device.read_adc_current()
         print "current_val=", current_val
         superUiLog("small_current_switch = 1,current_val=" + str(current_val))
         return self.convertAdcToCurrent(current_val)
     finally:
         device.set_small_current_switch(0)
 def forward_and_check(self, command, expect):
     self.serial.flushInput()
     self.serial.write(command)
     m = 0
     while True:
         if m == 4:
             return "unknowError"
         response = self.serial.readline(100)
         if response == "":
             m += 1
             print "m:",m
         print "下载response:",response
         superUiLog("command:"+command.strip()+",response:"+response.strip())
         if response.strip() == expect:
             return "OK"
         elif "Retry count exceeded" in response or "Not retrying" in response:
             return "TFTPfail"
Esempio n. 18
0
 def testStaticCurrent(self):
     ''' 测试静态电流  测试完静态电流后必须手动复位OBU,此项正在调试中'''
     # 但在实际测试中,此为单板测试的最后一项(后面正式版本下载不影响),可以不复位
     # 返回值为静态电流值
     try:
         device = self.bslDevice
         device.make_obu_enter_sleep()
         time.sleep(1)  # 延时时间待定
         device.set_small_current_switch(0)
         current_val = device.read_adc_current()
         if current_val > 10:
             print "current_val=", current_val
             superUiLog("small_current_switch = 0,current_val=" + str(current_val))
             raise
         device.set_small_current_switch(1)
         current_val = device.read_adc_current()
         return self.convertAdcToCurrent(current_val)
     finally:
         device.set_small_current_switch(0)
Esempio n. 19
0
 def adjustWakenSensi(self, target_power, assertFailWeight=10):
     self.clearSerialBuffer()
     print "target power is %.2f " % target_power
     superUiLog("target power is %.2f " % target_power)
     device = self.bslDevice
     device.calibra_target_power(target_power)
     grade = 0x03
     level = 0x0e
     grade_list = [0x03, 0x02, 0x01, 0x00]
     level_list = [0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01]
     yes_waken = False
     not_waken = False
     device.test_if_obu_wakeup()
     try:
         for grade in grade_list:
             for level in level_list:
                 device.set_obu_waken_sensi(grade, level)
                 time.sleep(0.2)
                 device.send_14k(10)
                 time.sleep(0.2)
                 result = device.test_if_obu_wakeup()
                 if result:
                     yes_waken = True
                     break
                 else:
                     not_waken = True
             if yes_waken and not_waken:
                 print "find it , grade is {0:02X} {1:02X}".format(grade, level)
                 uiLog(u'发现%.2f功率的灵敏度灵敏度:grade=0x%.2X,level=0x%.2X' % (target_power, grade, level))
                 break
             if not_waken:
                 print "Can not find grade and level!"
                 uiLog(u'无法发现%.2f功率灵敏度' % target_power)
                 break
     except Exception as e:
         print str(e)
         uiLog(str(e))
     #        finally:
     #            device.close()
     if yes_waken and not_waken:
         return (grade, level)
     else:
         raise TestItemFailException(failWeight=assertFailWeight)
 def read_obuid(self, old_file_path):
     obuid = ""
     self.forward_and_check("BSL\r\n", "BSLOK")
     self.serial.baudrate = 9600
     self.serial.parity = serial.PARITY_EVEN
     self.serial.timeout = 1        
     try:
         self.start_bsl()
         passwd = _getPasswordFromFile(old_file_path)
         self.BSL_RX_PASSWORD(passwd)
         obuid = self.memory_read(0x1884, 4)
     except Exception as e:
         print "Read obuid fail! " + str(e)
         superUiLog("Read obuid fail! " + str(e))
         raise e
     else:
         print "Read obuid success!"
         superUiLog("Read obuid success!")
     finally:
         self.quit_bsl()
         self.quit_bsl()
         print "quit bsl"
         superUiLog("quite bsl")
         self.serial.baudrate = 115200
         self.serial.parity = serial.PARITY_NONE
         self.serial.timeout = 5
         self.set_TEST(False)
     print repr(obuid)
     return obuid
Esempio n. 21
0
    def getObuSendPower(self, assertFailWeight=10):
        '''计算并获得OBU的发送功率'''
        device = self.bslDevice
        device.close_send_single()
        if "powerSendMode" in PARAM and PARAM["powerSendMode"] == "BIG":
            device.set_test_mode(3)
        else:
            device.set_test_mode(MODE_SEND_SMALL_POWER)

        read_string = device.read_eeprom(12, 12)
        print read_string
        superUiLog(u"read_eeprom:" + read_string)
        if read_string[0:8] != '55AA55AA':
            raise
        slope_k = float(int(read_string[8:16], 16)) / 1000000.0
        slope_b = float(int(read_string[16:24], 16)) / 1000.0
        print slope_k
        print slope_b
        superUiLog(u"slop_k:" + str(slope_k) + "slope_b:" + str(slope_b))
        time.sleep(0.5)
        device.obu_send_single()
        time.sleep(1.8)
        adc_value = device.read_adc_cable()
        print adc_value
        superUiLog(u"adc_value:" + str(adc_value))
        test_power = (adc_value - slope_b) / slope_k + device.cable_comsuption
        if "powerSendMode" in PARAM and PARAM["powerSendMode"] == "BIG":
            test_power -= 12
        device.obu_close_send_single()
        print test_power
        return test_power
Esempio n. 22
0
def T_03_initFactorySetting_A(product):
    u'''出厂信息写入-写入MAC地址,唤醒灵敏度参数等,通过ICP方式写入并自动判断信息一致'''
    #读取旧的信息内容
    magicWord = "55555555"
    try:
        uiLog(u"切换至NuLink模式")
        __getIoBoard().switchToNuLink()
        nul = __getNuLink()
        infos = None
        try:
            infos = nul.readInfo()
            obuid = infos[8:16]
            superUiLog(u"单板信息区内容:" + infos)
            if infos.startswith(
                    magicWord) and obuid != "FFFFFFFF":  #有魔术字,说明出场信息已经写过了
                uiLog(u"出厂信息已写入,原标识:%s" % obuid)
                product.setTestingProductIdCode(obuid)
                uiLog(u"复位芯片...")
                nul.resetChip()
                return {
                    "OBUID": obuid,
                    "原出厂信息区": infos[:36] + "," + infos[128:200]
                }
        except TestItemFailException, e:
            #如果读出失败,那么也判定为需要写
            uiLog(u"区域读取失败,开始写入出厂信息")
        obuid = serialCode("mac")  #分配新的MAC地址(obuid)
        displayDirect = SP("gs11.initParam.displayDirect", "00", str)  #显示方向

        softwareVerionFile = SP("gs11.vatVersion.filename",
                                "GS11-VAT-09.00.00.version", str)
        softwareVersion = "".join(
            softwareVerionFile.split("-")[2].split(".")[:3]) + "00"
        hardwareVersion = SP("gs11.initParam.hardwareVersion", "010000",
                             str)  #硬件版本号

        initWankenSensi_high_grade = SP('gs11.initWanken.high.grade', "03",
                                        str)  #高灵敏度-grade
        initWankenSensi_high_level = SP('gs11.initWanken.high.level', "0E",
                                        str)  #高灵敏度-level
        initWankenSensi_low_grade = SP('gs11.initWanken.low.grade', "03",
                                       str)  #低灵敏度-grade
        initWankenSensi_low_level = SP('gs11.initWanken.low.level', "0E",
                                       str)  #低灵敏度-level
        wakeupMode = SP("gs11.initParam.wakeupMode", "04", str)  #唤醒模式
        amIndex = SP("gs11.initParam.amIndex", "00", str)  #AmIndex
        transPower = SP("gs11.initParam.transPower", "02", str)  #发射功率
        txFilter = SP("gs11.initParam.txFilter", "06", str)  #TxFilter
        sensitivity = SP("gs11.initParam.sensitivity", "00", str)  #使用灵敏度

        CONFIG_BUILD_INFO = "".join((magicWord, obuid, displayDirect,
                                     softwareVersion, hardwareVersion))
        CONFIG_RF_PARA = "".join(
            (magicWord, initWankenSensi_high_grade, initWankenSensi_high_level,
             initWankenSensi_low_grade, initWankenSensi_low_level, wakeupMode,
             amIndex, transPower, txFilter, sensitivity))
        uiLog(u"初始化config区配置")
        nul.initCfg()
        nul.writeToInfo(CONFIG_BUILD_INFO, CONFIG_RF_PARA)
        uiLog(u"分配新的OBUID:%s" % obuid)
        product.setTestingProductIdCode(obuid)
        uiLog(u"复位芯片...")
        nul.resetChip()
        return {
            "OBUID": obuid,
            u"初始信息区": CONFIG_BUILD_INFO + "," + CONFIG_RF_PARA
        }
Esempio n. 23
0
 def initResource(self):
     dr = self.__nulinkCmd("-l")
     print dr
     self.nulinkId = dr.split("\n")[0][-10:]
     superUiLog(u"获取NuLinkID:" + self.nulinkId)