def power_cycle_modem(self):

        if self.testConfig.psugwip != 'ww.xx.yy.zz':

            #switch_off_psu(psu_gwip=self.testConfig.psugwip, psu_gpib=self.testConfig.psugpib, psu_name='E3631A_0')
            PsuBenchOff(psu_gwip=self.testConfig.psugwip,
                        psu_gpib=self.testConfig.psugpib)
            time.sleep(3)
            #switch_on_psu(psu_gwip=self.testConfig.psugwip, psu_gpib=self.testConfig.psugpib, psu_name='E3631A_0', Vmax_V=self.testConfig.psuvolt, Imax_A=2)
            PsuBenchOn(psu_gwip=self.testConfig.psugwip,
                       psu_gpib=self.testConfig.psugpib,
                       setVolts=self.testConfig.psuvolt,
                       Imax_A=2)

            if poll_for_port(portName="Modem_port",
                             timeout_sec=60,
                             poll_time_sec=5):

                print "modem com port successfully found"

                time_secs = 10

                print "pausing for %s secs ..." % time_secs

                time.sleep(time_secs)

            else:

                errMsg = "modem com port not found after PSU switch on"
                raise ExFail(errMsg)

        else:
            print "\n\n\n\********************* Note ****************************************"
            print "A power cycle is needed after this test to ensure a known RFIC state\n\n\n\n"
예제 #2
0
def switch_mode_1_3():

    print "Will try to change modem mode to 1,3"

    try:

        modemObj = serialComms(timeout=2)

        #status, response = modemObj.send_cmd_rd_response(cmd_str="at%mode=1,3")

        modemObj.send_cmd(cmd_str="at%mode=1,3")

        modemObj.close()

        if poll_for_port(portName="Modem_port",
                         timeout_sec=30,
                         poll_time_sec=5,
                         reason="pausing after changing to boot loader mode"):

            print "modem com port successfully found"

            time_secs = 10

            print "pausing for %s secs ..." % time_secs

            time.sleep(time_secs)

        else:

            print "modem com port not found after boot loader mode change"

            sys.exit(ec.ERRCODE_COM_PORT_DETECT)

        mode = query_modem_mode()

        print "Mode : %s" % mode

        BOOT_LOADER_MODE = 1

        if mode == BOOT_LOADER_MODE:

            print "Successful detection of boot loader mode"

        else:

            print "Unsuccessful detection of boot loader mode"

            sys.exit(ec.ERRCODE_BOOT_LOADER_MODE_FAIL)

    except:

        print "Not able to change to boot laoder mode generic error"

        print traceback.format_exc()

        sys.exit(ec.ERRCODE_BOOT_LOADER_MODE_FAIL)
예제 #3
0
def set_modem_mode(mode=1):

    modemObj = serialComms(timeout=2)

    at_cmd = r'AT%%MODE=%d' % mode

    print "function %s" % sys._getframe(0).f_code.co_name

    try:

        modemObj.send_cmd_rd_response(cmd_str=at_cmd)

    except:

        #print "Not able to set the modem mode to %s" %mode

        pass

    modemObj.close()

    if poll_for_port(portName="Modem_port",
                     timeout_sec=30,
                     poll_time_sec=5,
                     reason="pausing after mode change"):

        print "modem com port successfully found"

        time_secs = 10

        print "pausing for %s secs ..." % time_secs

        time.sleep(time_secs)

    else:

        print "modem com port not found after modem change"

        sys.exit(ec.ERRCODE_COM_PORT_DETECT)

    modemMode = query_modem_mode()

    if mode == modemMode:

        print "Successful switch to mode %s" % mode

    else:

        print "Unsuccessful switch to mode %s" % mode

        sys.exit(ec.ERRCODE_MODE_SWITCH_FAIL)
예제 #4
0
def check_for_modem_port():

    func_name = sys._getframe(0).f_code.co_name

    logger = logging.getLogger(__name__ + func_name)

    if poll_for_port(portName="Modem_port", timeout_sec=60, poll_time_sec=5):

        logger.info("modem com port successfully found")

        insertPause(tsec=10, desc="delay after finding modem port")

        return tg.SUCCESS

    else:

        logger.info("modem com port not found")

        return tg.FAIL
예제 #5
0
    def runTest(self):

        curr_f = os.sep.join(
            os.environ['PL1_RF_SYSTEM_ROOT'].split(os.sep)[:] +
            ['results', 'current'])
        latest_f = os.sep.join(
            os.environ['PL1_RF_SYSTEM_ROOT'].split(os.sep)[:] +
            ['results', 'latest'])

        overall_result_str = rf_global.verdict_dict[rf_global.PASS]

        try:

            if self.config.instr_ip == "ww.xx.yy.zz":
                ErrMsg = "ERROR: runTest() : specify a valid Instrument IP address"
                raise ExRunTest(ErrMsg)

            test_selection = self.config.test_selection
            test_exec_dic = OrderedDict()
            total_test_count = 0
            current_test_count = 0

            #Build up list of tests to execute
            curr_test_p = tp.test_plan[test_selection]
            num_tests = len(curr_test_p)
            test_id_index_list = range(0, num_tests, 2)

            for test_id_idx in test_id_index_list:
                test_id = curr_test_p[test_id_idx]
                num_param_sets = len(curr_test_p[test_id_idx + 1])
                test_exec_dic[test_id] = {'param_idx': test_id_idx + 1}
                test_exec_dic[test_id]['total_iterations'] = num_param_sets
                test_exec_dic[test_id]['curr_iteration'] = 0
                test_exec_dic[test_id]['test_file'] = tp.testFilefromID(
                    test_id)
                test_exec_dic[test_id]['test_func'] = tp.testFuncfromID(
                    test_id)
                test_exec_dic[test_id]['test_rat'] = 'Undef'
                total_test_count += num_param_sets

            func_name = sys._getframe(0).f_code.co_name
            logfilename = os.sep.join(
                os.environ['PL1_RF_SYSTEM_ROOT'].split(os.sep)[:] +
                ['%s.LOG' % func_name])
            cfg_multilogging(log_level=self.config.log, log_file=logfilename)
            logger_test = logging.getLogger('runTest')

            resultStrDic = OrderedDict()
            verdictObjDic = OrderedDict()
            startTimeDic = {}
            endTimeDic = {}

            if self.config.psugwip != 'ww.xx.yy.zz':
                '''
                if check_output_state_on(psu_gwip=self.config.psugwip,
                                         psu_gpib=self.config.psugpib,
                                         psu_name='E3631A_0',
                                         check_volts = self.config.psuvolt,
                                         check_curr_amps=2):
                '''
                if PsuCheckOn(psu_gwip=self.config.psugwip,
                              psu_gpib=self.config.psugpib,
                              check_volts=self.config.psuvolt,
                              check_curr_amps=2):

                    print "PSU is already switched on"
                else:
                    PsuBenchOn(psu_gwip=self.config.psugwip,
                               psu_gpib=self.config.psugpib,
                               setVolts=self.config.psuvolt,
                               Imax_A=2)

                    if poll_for_port(portName="Modem_port",
                                     timeout_sec=60,
                                     poll_time_sec=5):

                        print "modem com port successfully found"

                        time_secs = 10

                        print "pausing for %s secs ..." % time_secs

                        time.sleep(time_secs)

                    else:
                        ErrMsg = "ERROR: runTest() : modem com port not found after switching on the PSU"
                        raise ExRunTest(ErrMsg)

            #Initiate CMW control

            if self.config.instr_ip == "no_instr":
                no_tester = True
            else:
                no_tester = False

            self.instr = cmw500.CmwControl(name=self.config.instr_name,
                                           ip_addr=self.config.instr_ip,
                                           NoTester=no_tester)

            for testID in test_exec_dic:

                while test_exec_dic[testID]['curr_iteration'] < test_exec_dic[
                        testID]['total_iterations']:

                    testfile = test_exec_dic[testID]['test_file']
                    testfunc = test_exec_dic[testID]['test_func']
                    testparams = tp.test_plan[test_selection][
                        test_exec_dic[testID]['param_idx']][
                            test_exec_dic[testID]['curr_iteration']]
                    finalTest = ((current_test_count + 1) == total_test_count)

                    self.print_pre_test_information(testID,
                                                    test_exec_dic[testID],
                                                    testparams)

                    if testfile == "wcdma_tx.py":

                        test_exec_dic[testID]['test_rat'] = 'WCDMA'
                        test_rf = Wcdma_tx(
                            testID=testID,
                            testConfig_s=self.config,
                            results_f=curr_f,
                            test_func=testfunc,
                            test_params=testparams,
                            test_rat='WCDMA',
                            final_test=finalTest,
                            unittest_enabled=self.unittest_enabled)

                    elif testfile == "lte_tx.py":

                        test_exec_dic[testID]['test_rat'] = 'LTE'

                        test_rf = Lte_tx(
                            testID=testID,
                            testConfig_s=self.config,
                            results_f=curr_f,
                            test_func=testfunc,
                            test_params=testparams,
                            test_rat='LTE',
                            final_test=finalTest,
                            unittest_enabled=self.unittest_enabled)

                    elif testfile == "general_purpose.py":

                        try:
                            testrat = tp.test_plan[test_selection][
                                test_exec_dic[testID]['param_idx']][
                                    test_exec_dic[testID]
                                    ['curr_iteration']]['rat']
                        except KeyError:
                            testrat = "None"

                        test_exec_dic[testID]['test_rat'] = testrat

                        test_rf = General_Purpose(
                            testID=testID,
                            testConfig_s=self.config,
                            results_f=curr_f,
                            test_func=testfunc,
                            test_params=testparams,
                            test_rat=testrat,
                            final_test=finalTest,
                            unittest_enabled=self.unittest_enabled)

                    else:

                        logger_test.warning(
                            "Test file %s does not exist. TestID %s SKIPPED" %
                            (testfile, testID))

                    test_param_idx = "%-08s  %s" % (
                        testID, str(test_exec_dic[testID]['curr_iteration']))
                    startTimeDic[test_param_idx] = time.localtime()
                    resultStrDic[test_param_idx], verdictObjDic[
                        test_param_idx] = test_rf.executeTest(self.instr)
                    endTimeDic[test_param_idx] = time.localtime()

                    test_exec_dic[testID]['curr_iteration'] = test_exec_dic[
                        testID]['curr_iteration'] + 1

                    if resultStrDic[test_param_idx] != rf_global.verdict_dict[
                            rf_global.PASS]:

                        overall_result_str = resultStrDic[test_param_idx]

                    current_test_count += 1

        except ExGeneral, e:
            print '%s' % e.message
            overall_result_str = rf_global.verdict_dict[rf_global.INCONC]
    def create_device_config_flash_file(self):

        chip_id = ""

        maxNumRetries = 2

        retryNum = 0

        while retryNum < maxNumRetries:

            chip_id = modem.get_chip_id_wrapper()

            if chip_id:

                self.create_device_bin_file(chip_id=chip_id)

                self.write_chip_id_file(data=chip_id)

                break

            else:

                print "Retry %s of %s" % ((retryNum + 1), maxNumRetries)

                print "cannot create local deviceConfig.bin file"

                try:

                    PsuBenchOff(psu_gwip=self.psu_gwip, psu_gpib=self.psu_gpib)

                except:

                    print "unable to switch off psu"

                    sys.exit(ec.ERRCODE_PSU_COMM_ERR)

                time.sleep(10)

                try:

                    PsuBenchOn(psu_gwip=self.psu_gwip, psu_gpib=self.psu_gpib)

                except:

                    sys.exit(ec.ERRCODE_PSU_COMM_ERR)

                if poll_for_port(portName="Modem_port",
                                 timeout_sec=60,
                                 poll_time_sec=5):

                    print "modem com port successfully found"

                    time.sleep(10)

                    chip_id = modem.get_chip_id_wrapper()

                    self.create_device_bin_file(chip_id=chip_id)

                    break

                else:

                    print "modem com port not found"

                    print "Not able to obtain the chip id!"

                    sys.exit(ec.ERRCODE_COM_PORT_DETECT)

            retryNum += 1
                  psu_channel='P6V',
                  psu_config=0,
                  psu_reset=0)

    output_state = psu_bench.read_output_state()

    Vmax_V=3.8
    Imax_A=5
    psuname='E3631A_0'

    if output_state == 1:
        logger.info("Power supply is switched on")
        logger.info("Check that the supply voltage is at the correct level of %s volts" %Vmax_V)
        if psu_bench.check_voltage_output(check_volts = Vmax_V):
            logger.info("Power supply is at the correct voltage")
            if poll_for_port(portName="Modem_port", timeout_sec=20, poll_time_sec=1):
                print "modem com port successfully found"
            else:
                print "modem com port not found"
                sys.exit(code.ERRCODE_SYS_MODEM_NO_COM)
        else:
            logger.info("PSU voltage is not at the required level")
            output_state = 0
    else:
        print "Power supply is currently switched off"
        output_state = 0

    if output_state == 0:
        psu_bench._reset()
        psu_bench.on()
        time.sleep(1)
예제 #8
0
def set_modem_mode(mode=1):

    func_name = sys._getframe(0).f_code.co_name

    loggerModem = logging.getLogger(__name__ + func_name)

    current_mode = query_modem_mode()

    if current_mode == mode:

        loggerModem.info(" Modem mode is already set to %s" % mode)

        return

    modemObj = None

    at_cmd = r'AT%%MODE=%d' % mode

    retryNum = 0

    maxRetry = 3

    SUCCESS = 0

    FAIL = 1

    response = ""

    status = FAIL

    while retryNum <= maxRetry:

        try:

            if not modemObj:

                modemObj = serialComms(timeout=4)

            (status, response) = modemObj.send_cmd_rd_response(cmd_str=at_cmd)

            break

        except Exception:

            loggerModem.error(" Not able to read response to %s" % at_cmd)

            if retryNum != maxRetry:

                loggerModem.info("Retry %s of %s" % (retryNum + 1, maxRetry))

                if modemObj:

                    modemObj.close()

                    modemObj = None

            else:

                errMsg = "Not able to read response to %s" % at_cmd

                if modemObj:

                    modemObj.close()

                    modemObj = None

                #self.RecordError(errMsg) #There is no self

            wait_sec = 20

            txt = "Waiting %s secs before sending AT cmd again" % wait_sec

            rf_cf.pause(duration_s=wait_sec, poll_time_sec=10, desc=txt)

            retryNum += 1

    if modemObj:

        modemObj.close()

    if status != SUCCESS:

        if poll_for_port(portName="Modem_port",
                         timeout_sec=30,
                         poll_time_sec=5,
                         reason="pausing after mode change"):

            print "modem com port successfully found"

            time_secs = 10

            print "pausing for %s secs ..." % time_secs

            time.sleep(time_secs)

        else:

            self.RecordError("modem com port not found after modem change")

    modemMode = query_modem_mode()

    if mode == modemMode:

        print "Successful switch to mode %s" % mode

    else:

        err_msg = ("Unsuccessful switch to mode %s" % mode)

        raise ExGeneral(err_msg)