FreeCalypso > hg > fc-rfcal-tools
view autocal/txstandbas.c @ 84:a2d4cab0a592
fc-rfcal-txband: works after a couple of bugfixes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 Jul 2017 23:57:56 +0000 |
parents | c9bd1f75029f |
children | 6a7f8d201859 |
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" 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); }