FreeCalypso > hg > fc-rfcal-tools
diff autocal/txbasis.c @ 56:df827df6db82
fc-rfcal-txbasis written, ready to test
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 20:02:10 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/autocal/txbasis.c Sat May 27 20:02:10 2017 +0000 @@ -0,0 +1,118 @@ +/* + * This module contains the main() function for fc-rfcal-txbasis. + */ + +#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" + +extern char *rvif_socket_pathname, *tsid_socket_pathname; + +extern double tx_power_meas(); + +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; + +cmdline_options(argc, argv) + char **argv; +{ + extern char *optarg; + int c; + + while ((c = getopt(argc, argv, "a:s:t:")) != EOF) { + switch (c) { + case 'a': + arfcn = atoi(optarg); + arfcn_set = 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; + double meas; + + 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 (; 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); + } + + printf("Stopping RF Tx on the DUT\n"); + do_rfe(STOP_ALL); + exit(0); +}