FreeCalypso > hg > fc-rfcal-tools
changeset 101:b0618796d28d
fc-rfcal-txband: added safety checks for NaN power measurements and
out-of-tolerance final Tx power levels
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 11 Aug 2017 03:20:43 +0000 |
parents | 7ad5836d3b87 |
children | 80281b67511f |
files | autocal/txbasis.c autocal/txlevels.c |
diffstat | 2 files changed, 26 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/autocal/txbasis.c Fri Aug 11 02:45:10 2017 +0000 +++ b/autocal/txbasis.c Fri Aug 11 03:20:43 2017 +0000 @@ -2,6 +2,7 @@ * The basis steps of Tx power level calibration are implemented here. */ +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <rvinterf/l1tm.h> @@ -19,6 +20,7 @@ { unsigned n; double meas; + int nanflag = 0; printf("Performing the calibration basis run\n"); do_txpw(TX_PWR_LEVEL, txcal_band->start_plnum); @@ -30,11 +32,17 @@ usleep(20000); meas = tx_power_meas(); printf("APC DAC=%u: %.2f dBm\n", tx_basis[n].apc, meas); + if (isnan(meas)) + nanflag = 1; tx_basis[n].vout = dbm_to_vout(meas); } printf("Stopping RF Tx on the DUT\n"); do_rfe(STOP_ALL); + if (nanflag) { + printf("Error: got NaN power measurement, aborting\n"); + exit(ERROR_TARGET); + } return(0); } @@ -47,7 +55,7 @@ fprintf(stderr, "error: Vout at APC=%u is not greater than at APC=%u\n", tx_basis[n+1].apc, tx_basis[n].apc); - exit(ERROR_RFTEST); + exit(ERROR_TARGET); } tx_basis[n].slope = (tx_basis[n+1].vout - tx_basis[n].vout) / (tx_basis[n+1].apc - tx_basis[n].apc);
--- a/autocal/txlevels.c Fri Aug 11 02:45:10 2017 +0000 +++ b/autocal/txlevels.c Fri Aug 11 03:20:43 2017 +0000 @@ -2,6 +2,7 @@ * The calibration of Tx power levels is implemented here. */ +#include <math.h> #include <stdio.h> #include <stdlib.h> #include <rvinterf/l1tm.h> @@ -38,7 +39,8 @@ calibrate_tx_levels() { unsigned plnum, plidx, apc; - double target, meas; + double target, meas, error; + int nanflag = 0, errflag = 0; printf("Calibrating Tx power levels\n"); printf("Starting RF Tx on the DUT\n"); @@ -54,12 +56,25 @@ do_txpw(TX_APC_DAC, apc); usleep(20000); meas = tx_power_meas(); + if (isnan(meas)) + nanflag = 1; + error = meas - target; + if (error < -2.0 || error > 2.0) + errflag = 1; printf( "Tx power level #%u: target %.1f dBm, APC=%u, meas %.2f dBm (%+.2f)\n", - plnum, target, apc, meas, meas - target); + plnum, target, apc, meas, error); } printf("Stopping RF Tx on the DUT\n"); do_rfe(STOP_ALL); + if (nanflag) { + printf("Error: got NaN power measurement, aborting\n"); + exit(ERROR_TARGET); + } + if (errflag) { + printf("Error: Tx power off by more than 2 dBm, aborting\n"); + exit(ERROR_TARGET); + } return(0); }