def frequency_change(self, rat, arfcn, powerdBm, ud_config=None, iterations=4, with_tx=False): """Verify that changing frequency while RX is running works. Turn on RX and switch between the given earfcn and 10 MHz higher 5 times.""" tone_offset_khz = 200 if rat.upper() == "3G": band, base_freq_ul, base_freq_dl = get_umts_ul_dl_freq_band(arfcn) assert (ud_config is None) else: band, base_freq_ul, base_freq_dl = get_lte_ul_dl_freq_band(arfcn) #setup modem - serial comms self.setup_modem() #setup tester self.instr.setup_rf_tone(cable_loss_dB=self.testConfig.cable_loss) self.teststep_idx = 0 self.modemObj.set_rat_band(rat=self.test_rat, band=band) self.modemObj.enable_rx(ant='m') self.modemObj.set_rxagc_auto(ant='m') if ud_config is not None: self.modemObj.set_ud_config(ud_config) if with_tx: self.start_tx(base_freq_ul) self.set_curr_power(power_dBm=powerdBm) self.instr.gprf_gen.set_rf_level(power_dBm=powerdBm) rf_cf.pause(duration_s=1, poll_time_sec=1, desc="short pause to allow rf level to settle") for freq_offset in [0, 10] * iterations: freq_dl = base_freq_dl + freq_offset freq_ul = base_freq_ul + freq_offset self.modemObj.set_freqMHz(direction='rx', freqMHz=freq_dl) if with_tx: self.modemObj.set_freqMHz(direction='tx', freqMHz=freq_ul) self.set_freq(freq_dl) self.instr.gprf_gen.set_rf_freqkHz(freqkHz=(freq_dl * 1e3) + tone_offset_khz) rf_cf.pause(duration_s=2, poll_time_sec=1, desc="short pause") #self.check_for_iq_data_clipping(ant='m',n_samples=20) self.check_rx_antpower(ant='m', tol_dB=5) self.instr.gprf_gen.set_rf_generator_state(state='OFF')
def crash_simulation(self): loggerModem = logging.getLogger(__name__ + 'crash_simulation') loggerModem.info("Forced crash simulation") self.send_cmd(cmd_str='AT%IDBGTEST=1') rf_cf.pause(duration_s=60, poll_time_sec=5, desc="Wait for modem to crash") return
def executeTest(self,instr_control): func_name = sys._getframe(0).f_code.co_name logger_test = logging.getLogger(__name__ + func_name) modeminfo = "" modeminfo = query_build_info_from_modem() self.instr= instr_control self.set_instr_sw_version(version=self.instr.get_sw_version()) self.instr.set_verdictObj(self.verdictObj) self.set_csvSummaryReport(results_f=self.results_f, modeminfo=modeminfo, instrswinfo=self.get_instr_sw_version()) try: test_function = getattr(self,self.test_func) test_function(**self.test_params) if self.instr and self.FinalTest: self.instr.close() self.instr = None self.set_meas(meas="") verdictStr = self.verdictObj.GetSummaryVerdict(col_len=80) self.update_csvSummaryReport(verdictStr=verdictStr) self.shut_down_modem() return verdictStr,self.verdictObj except (IOError,SerialException) as err: # communication error with modem, likely assert print traceback.format_exc() if self.instr and self.FinalTest: self.instr.close() self.instr=None # capture core dump and close modem connection if self.modemObj: rf_cf.pause(duration_s=20, poll_time_sec=2, desc="short pause prior to modem crash detection!!") if self.modemObj.check_for_crash(): self.capture_core_dump() else: # no point in shutting down as there is likely # communication issue with modem self.modemObj.close() self.modemObj=None verdictStr = rf_global.verdict_dict[rf_global.FAIL] self.update_csvSummaryReport(verdictStr=verdictStr) return verdictStr,self.verdictObj except ExFail: if self.instr and self.FinalTest: self.instr.close() self.instr=None verdictStr = rf_global.verdict_dict[rf_global.FAIL] self.update_csvSummaryReport(verdictStr=verdictStr) self.shut_down_modem() return verdictStr,self.verdictObj except ExUserBreakPoint, e: print '%s' %e.message verdictStr = rf_global.verdict_dict[rf_global.INCONC] return verdictStr,self.verdictObj
def receiver_filter_characterization(self, rat, arfcn, offsetkhz, stepkHz, powerdBm, bwMhz): #This test is designed to set the modem to receive on a particular channel and sweep the cmw tone frequency across #-offset - arfcn_freq - +offset and record the IQ power. Fixed AGC is used. import matplotlib.pyplot as pyplot sweep_results = OrderedDict() modeminfo = query_build_info_from_modem() changelist = get_build_cl_from_modem(modeminfo) platform = get_platform_from_modem(modeminfo) if rat.upper() == "3G": band, freq_ul, freq_dl = get_umts_ul_dl_freq_band(arfcn) else: band, freq_ul, freq_dl = get_lte_ul_dl_freq_band(arfcn) sweep_low_kHz = int(1e3 * freq_dl - offsetkhz) sweep_high_kHz = int(1e3 * freq_dl + offsetkhz) init_tone_offset_kHz = 200000 print "sweep low", sweep_low_kHz print "sweep high", sweep_high_kHz #setup modem - serial comms self.setup_modem() #setup tester self.instr.setup_rf_tone(cable_loss_dB=self.testConfig.cable_loss) self.modemObj.set_rat_band(rat=self.test_rat, band=band) self.modemObj.set_rxagc_auto(ant='m') self.modemObj.set_freqMHz(direction='rx', freqMHz=freq_dl) self.set_freq(freq_dl) self.instr.gprf_gen.set_rf_freqkHz(freqkHz=(freq_dl * 1e3) + init_tone_offset_kHz) rf_cf.pause(duration_s=2, poll_time_sec=1, desc="short pause") self.set_curr_power(power_dBm=powerdBm) self.instr.gprf_gen.set_rf_level(power_dBm=powerdBm) if rat == "LTE": rf_config = LTE_rf_config(bwMHz=bwMhz) self.modemObj.set_rb(direction='ul', num_rb=rf_config.num_rbs) self.modemObj.set_rb(direction='dl', num_rb=rf_config.num_rbs) self.modemObj.set_rb_len(rb_len=rf_config.rb_len) self.modemObj.set_rb_start(rb_offset=rf_config.rb_offset) self.modemObj.set_rx_bw(rx_bw=bwMhz) self.modemObj.enable_rx(ant='m') rf_cf.pause(duration_s=1, poll_time_sec=1, desc="short pause to allow rf level to settle") verdict = self.check_for_iq_data_clipping(ant='m', n_samples=20) if verdict == "PASS": #Change AGC to manual at current auto selected backend gain curr_agc_be = self.modemObj.query_rxagc(ant='m', agc_val='backend') if curr_agc_be == 86: curr_agc_be = 85 #86 returns error self.modemObj.set_rxagc_manual(ant='m', be_val=curr_agc_be) sweep_range = range(sweep_low_kHz, sweep_high_kHz + 1, stepkHz) for freq in sweep_range: self.instr.gprf_gen.set_rf_freqkHz(freqkHz=freq) #rf_cf.pause(duration_s=1, poll_time_sec=1, desc="rf pause") iq_pwr = self.modemObj.query_rxdata_iq_pow_from_ssi_ssq() sweep_results[freq] = iq_pwr else: raise ExGeneral('IQ Clipping') #print sweep_results self.instr.gprf_gen.set_rf_generator_state(state='OFF') pyplot.plot(sweep_results.keys(), sweep_results.values()) pyplot.title('RX IQ Power vs Frequency - Fixed AGC %d - %dMhz Sweep' % (curr_agc_be, (offsetkhz * 2) / 1e3)) pyplot.ylabel('IQ Power') pyplot.xlabel('Frequency') pyplot.grid(True) pyplot.axis([sweep_low_kHz - 50, sweep_high_kHz + 50, 15, 50]) #pyplot.show() #savetitle = curr_f+'\%s_%s_%s-band%s_%dMHzBW_%dMHzSweep' % (platform,changelist,rat,str(band),bwMhz,(offsetkhz*2)/1e3) savetitle = self.curr_f + '\%s_%s_%s-band%s_%dMHzBW_%dMHzSweep' % ( platform, changelist, rat, str(band), bwMhz, (offsetkhz * 2) / 1e3) pyplot.savefig(savetitle + '.svg') pyplot.clf() writer = csv.writer(open(savetitle + '.csv', 'w')) freq_list = sweep_results.keys() iq_list = sweep_results.values() rows = zip(freq_list, iq_list) for row in rows: writer.writerow(row)
def auto_agc_and_manual(self, rat, arfcn, powerdBm, ud_config=None, iterations=4, with_tx=False): tone_offset_khz = 200 if rat.upper() == "3G": band, freq_ul, freq_dl = get_umts_ul_dl_freq_band(arfcn) toldB = 4 else: band, freq_ul, freq_dl = get_lte_ul_dl_freq_band(arfcn) toldB = 5 #setup modem - serial comms self.setup_modem() #setup tester self.instr.setup_rf_tone(cable_loss_dB=self.testConfig.cable_loss) self.teststep_idx = 0 self.modemObj.set_rat_band(rat=self.test_rat, band=band) if ud_config is not None: self.modemObj.set_ud_config(ud_config) self.modemObj.set_freqMHz(direction='rx', freqMHz=freq_dl) self.set_freq(freq_dl) self.instr.gprf_gen.set_rf_freqkHz(freqkHz=(freq_dl * 1e3) + tone_offset_khz) rf_cf.pause(duration_s=2, poll_time_sec=1, desc="short pause") self.set_curr_power(power_dBm=powerdBm) self.instr.gprf_gen.set_rf_level(power_dBm=powerdBm) self.modemObj.enable_rx(ant='m') if with_tx: assert (int(ud_config) >= 0) self.start_tx(freq_ul) rf_cf.pause(duration_s=1, poll_time_sec=1, desc="short pause to allow rf level to settle") self.modemObj.set_rxagc_auto(ant='m') manual_atten = self.modemObj.query_rxagc(ant='m') for i in range(iterations): # Set manual rx gain logging.info("Iteration %d, set manual RX gain." % (i)) self.modemObj.set_rxagc_manual(ant='m', be_val=manual_atten) rf_cf.pause(duration_s=1, poll_time_sec=1, desc="short pause to allow rf level to settle") # self.check_for_iq_data_clipping(ant='m',n_samples=20) self.check_rx_antpower(ant='m', tol_dB=toldB) # Back to auto logging.info("Iteration %d, set auto RX gain." % (i)) self.modemObj.set_rxagc_auto(ant='m') rf_cf.pause(duration_s=1, poll_time_sec=1, desc="short pause to allow rf level to settle") # self.check_for_iq_data_clipping(ant='m',n_samples=20) self.check_rx_antpower(ant='m', tol_dB=toldB) self.instr.gprf_gen.set_rf_generator_state(state='OFF')
def auto_agc_verification(self, rat, arfcn, powerdBm, ud_config=None, special_sf_config=0, with_tx=False): tone_offset_khz = 200 if rat.upper() == "3G": band, freq_ul, freq_dl = get_umts_ul_dl_freq_band(arfcn) toldB = 4 else: band, freq_ul, freq_dl = get_lte_ul_dl_freq_band(arfcn) toldB = 5 #setup modem - serial comms self.setup_modem() #setup tester self.instr.setup_rf_tone(cable_loss_dB=self.testConfig.cable_loss) self.teststep_idx = 0 self.modemObj.set_rat_band(rat=self.test_rat, band=band) self.modemObj.set_rxagc_auto(ant='m') if ud_config is not None: self.modemObj.set_ud_config(ud_config) self.modemObj.set_special_sf_config(special_sf_config) self.modemObj.set_freqMHz(direction='rx', freqMHz=freq_dl) self.set_freq(freq_dl) self.instr.gprf_gen.set_rf_freqkHz(freqkHz=(freq_dl * 1e3) + tone_offset_khz) rf_cf.pause(duration_s=2, poll_time_sec=1, desc="short pause") self.set_curr_power(power_dBm=powerdBm) self.instr.gprf_gen.set_rf_level(power_dBm=powerdBm) self.modemObj.enable_rx(ant='m') if with_tx: assert (int(ud_config) >= 0) self.start_tx(freq_ul) rf_cf.pause(duration_s=1, poll_time_sec=1, desc="short pause to allow rf level to settle") if ud_config is None: self.check_for_iq_data_clipping(ant='m', n_samples=20) self.check_rx_antpower(ant='m', tol_dB=toldB) if ud_config is not None: fine_gain_tol_dB = 0.4 # Higher tolerance for TDD else: fine_gain_tol_dB = 0.15 self.check_rx_fine_gain_steps(ant='m', full_range=False, tol_dB=fine_gain_tol_dB) self.instr.gprf_gen.set_rf_generator_state(state='OFF')
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)