FreeCalypso > hg > fc-rfcal-tools
view autocal/txstandbas.c @ 118:6a7f8d201859
fc-rfcal-txbasis: added -l option to show slope (check linearity)
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Feb 2018 07:17:31 +0000 |
parents | c9bd1f75029f |
children |
line wrap: on
line source
/* * fc-rfcal-txbasis is a debug utility implementing just one part * of the fc-rfcal-txband process in a standalone manner; * this module contains the main() function for this standalone utlity. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> #include <rvinterf/l1tm.h> #include <rvinterf/exitcodes.h> #include "stdband.h" #include "txvout.h" extern char *rvif_socket_pathname, *tsid_socket_pathname; extern double tx_power_meas(); extern vout_t dbm_to_vout(); static struct band { char *name; unsigned rfpw_std_band; unsigned default_arfcn; } bands[] = { {"850", RFPW_STD_BAND_850, 190}, {"900", RFPW_STD_BAND_900, 40}, {"1800", RFPW_STD_BAND_1800, 700}, {"1900", RFPW_STD_BAND_1900, 660}, {0, 0, 0} }; static struct band *selected_band; static unsigned arfcn, arfcn_set; static int do_slope; cmdline_options(argc, argv) char **argv; { extern char *optarg; int c; while ((c = getopt(argc, argv, "a:ls:t:")) != EOF) { switch (c) { case 'a': arfcn = atoi(optarg); arfcn_set = 1; continue; case 'l': do_slope = 1; continue; case 's': rvif_socket_pathname = optarg; continue; case 't': tsid_socket_pathname = optarg; continue; case '?': default: /* error msg already printed */ exit(ERROR_USAGE); } } return(0); } select_band(bandname) char *bandname; { struct band *band; for (band = bands; band->name; band++) if (!strcmp(band->name, bandname)) break; if (!band->name) { fprintf(stderr, "error: \"%s\" is not a known band\n", bandname); exit(ERROR_USAGE); } selected_band = band; if (!arfcn_set) arfcn = band->default_arfcn; return(0); } main(argc, argv) char **argv; { extern int optind; int apc, apc_prev; double meas; vout_t vout, vout_prev; int nanflag = 0, first; cmdline_options(argc, argv); if (argc - optind < 2) { fprintf(stderr, "usage: %s band apc...\n", argv[0]); exit(ERROR_USAGE); } select_band(argv[optind++]); connect_rvinterf_socket(); connect_tsid_socket(); setlinebuf(stdout); /* to allow logging with tee */ printf("Preparing RF test system for %s MHz Tx calibration\n", selected_band->name); do_txpwr_cal_setup(selected_band->name, arfcn); printf("Putting the DUT into Test Mode\n"); do_tms(1); do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band); do_rfpw(TCH_ARFCN, arfcn); do_rfpw(AFC_ENA_FLAG, 0); printf("Starting RF Tx on the DUT\n"); do_rfe(RX_TX_TCH); for (first = 1; optind < argc; optind++) { apc = atoi(argv[optind]); do_txpw(TX_APC_DAC, apc); usleep(20000); meas = tx_power_meas(); printf("APC DAC=%d: %.2f dBm\n", apc, meas); if (isnan(meas)) nanflag = 1; if (do_slope && !nanflag) { vout = dbm_to_vout(meas); if (!first) printf("slope=%f\n", (vout - vout_prev) / (apc - apc_prev)); apc_prev = apc; vout_prev = vout; } first = 0; } printf("Stopping RF Tx on the DUT\n"); do_rfe(STOP_ALL); exit(0); }