FreeCalypso > hg > fc-rfcal-tools
view autocal/txstandchk.c @ 104:7ad0495991ed
autocal: use the new ERROR_RFFAIL exit code
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 09 Dec 2017 07:01:13 +0000 |
parents | c9bd1f75029f |
children | 94e8a410d6bd |
line wrap: on
line source
/* * fc-rfcal-txcheck 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 double tx_power_meas(); static struct band { char *name; unsigned rfpw_std_band; unsigned default_arfcn; unsigned start_plnum; unsigned end_plnum; int spec_max_dbm; } bands[] = { {"850", RFPW_STD_BAND_850, 190, 5, 19, 33}, {"900", RFPW_STD_BAND_900, 40, 5, 19, 33}, {"1800", RFPW_STD_BAND_1800, 700, 0, 15, 30}, {"1900", RFPW_STD_BAND_1900, 660, 0, 15, 30}, {0, 0, 0} }; static struct band *selected_band; static unsigned arfcn; finish_cmdline(argc, argv) char **argv; { extern int optind; struct band *band; if (argc - optind < 1 || argc - optind > 2) { fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]); exit(ERROR_USAGE); } for (band = bands; band->name; band++) if (!strcmp(band->name, argv[optind])) break; if (!band->name) { fprintf(stderr, "error: \"%s\" is not a known band\n", argv[optind]); exit(ERROR_USAGE); } selected_band = band; if (argv[optind+1]) arfcn = atoi(argv[optind+1]); else arfcn = band->default_arfcn; return(0); } main(argc, argv) char **argv; { unsigned plnum; double meas; int spec_dbm; socket_pathname_options(argc, argv); finish_cmdline(argc, argv); 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); spec_dbm = selected_band->spec_max_dbm; for (plnum = selected_band->start_plnum; plnum <= selected_band->end_plnum; plnum++, spec_dbm -= 2) { do_txpw(TX_PWR_LEVEL, plnum); usleep(20000); meas = tx_power_meas(); printf( "Tx power level #%u: spec %d dBm, meas %.2f dBm (%+.2f)\n", plnum, spec_dbm, meas, meas - spec_dbm); } printf("Stopping RF Tx on the DUT\n"); do_rfe(STOP_ALL); exit(0); }