FreeCalypso > hg > fc-rfcal-tools
comparison autocal/txstandchk.c @ 73:c9bd1f75029f
autocal: C main modules for standalone programs renamed more sensibly
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 Jul 2017 18:14:49 +0000 |
parents | autocal/txchkmain.c@784ce9f3a80a |
children | 94e8a410d6bd |
comparison
equal
deleted
inserted
replaced
72:2db97ef5e169 | 73:c9bd1f75029f |
---|---|
1 /* | |
2 * fc-rfcal-txcheck is a debug utility implementing just one part | |
3 * of the fc-rfcal-txband process in a standalone manner; | |
4 * this module contains the main() function for this standalone utlity. | |
5 */ | |
6 | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 #include <unistd.h> | |
12 #include <rvinterf/l1tm.h> | |
13 #include <rvinterf/exitcodes.h> | |
14 #include "stdband.h" | |
15 | |
16 extern double tx_power_meas(); | |
17 | |
18 static struct band { | |
19 char *name; | |
20 unsigned rfpw_std_band; | |
21 unsigned default_arfcn; | |
22 unsigned start_plnum; | |
23 unsigned end_plnum; | |
24 int spec_max_dbm; | |
25 } bands[] = { | |
26 {"850", RFPW_STD_BAND_850, 190, 5, 19, 33}, | |
27 {"900", RFPW_STD_BAND_900, 40, 5, 19, 33}, | |
28 {"1800", RFPW_STD_BAND_1800, 700, 0, 15, 30}, | |
29 {"1900", RFPW_STD_BAND_1900, 660, 0, 15, 30}, | |
30 {0, 0, 0} | |
31 }; | |
32 static struct band *selected_band; | |
33 static unsigned arfcn; | |
34 | |
35 finish_cmdline(argc, argv) | |
36 char **argv; | |
37 { | |
38 extern int optind; | |
39 struct band *band; | |
40 | |
41 if (argc - optind < 1 || argc - optind > 2) { | |
42 fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]); | |
43 exit(ERROR_USAGE); | |
44 } | |
45 for (band = bands; band->name; band++) | |
46 if (!strcmp(band->name, argv[optind])) | |
47 break; | |
48 if (!band->name) { | |
49 fprintf(stderr, "error: \"%s\" is not a known band\n", | |
50 argv[optind]); | |
51 exit(ERROR_USAGE); | |
52 } | |
53 selected_band = band; | |
54 if (argv[optind+1]) | |
55 arfcn = atoi(argv[optind+1]); | |
56 else | |
57 arfcn = band->default_arfcn; | |
58 return(0); | |
59 } | |
60 | |
61 main(argc, argv) | |
62 char **argv; | |
63 { | |
64 unsigned plnum; | |
65 double meas; | |
66 int spec_dbm; | |
67 | |
68 socket_pathname_options(argc, argv); | |
69 finish_cmdline(argc, argv); | |
70 connect_rvinterf_socket(); | |
71 connect_tsid_socket(); | |
72 setlinebuf(stdout); /* to allow logging with tee */ | |
73 printf("Preparing RF test system for %s MHz Tx calibration\n", | |
74 selected_band->name); | |
75 do_txpwr_cal_setup(selected_band->name, arfcn); | |
76 | |
77 printf("Putting the DUT into Test Mode\n"); | |
78 do_tms(1); | |
79 do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band); | |
80 do_rfpw(TCH_ARFCN, arfcn); | |
81 do_rfpw(AFC_ENA_FLAG, 0); | |
82 printf("Starting RF Tx on the DUT\n"); | |
83 do_rfe(RX_TX_TCH); | |
84 | |
85 spec_dbm = selected_band->spec_max_dbm; | |
86 for (plnum = selected_band->start_plnum; | |
87 plnum <= selected_band->end_plnum; plnum++, spec_dbm -= 2) { | |
88 do_txpw(TX_PWR_LEVEL, plnum); | |
89 usleep(20000); | |
90 meas = tx_power_meas(); | |
91 printf( | |
92 "Tx power level #%u: spec %d dBm, meas %.2f dBm (%+.2f)\n", | |
93 plnum, spec_dbm, meas, meas - spec_dbm); | |
94 } | |
95 | |
96 printf("Stopping RF Tx on the DUT\n"); | |
97 do_rfe(STOP_ALL); | |
98 exit(0); | |
99 } |