FreeCalypso > hg > fc-rfcal-tools
comparison autocal/txstandbas.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/txbasis.c@df827df6db82 |
children | 6a7f8d201859 |
comparison
equal
deleted
inserted
replaced
72:2db97ef5e169 | 73:c9bd1f75029f |
---|---|
1 /* | |
2 * fc-rfcal-txbasis 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 char *rvif_socket_pathname, *tsid_socket_pathname; | |
17 | |
18 extern double tx_power_meas(); | |
19 | |
20 static struct band { | |
21 char *name; | |
22 unsigned rfpw_std_band; | |
23 unsigned default_arfcn; | |
24 } bands[] = { | |
25 {"850", RFPW_STD_BAND_850, 190}, | |
26 {"900", RFPW_STD_BAND_900, 40}, | |
27 {"1800", RFPW_STD_BAND_1800, 700}, | |
28 {"1900", RFPW_STD_BAND_1900, 660}, | |
29 {0, 0, 0} | |
30 }; | |
31 static struct band *selected_band; | |
32 static unsigned arfcn, arfcn_set; | |
33 | |
34 cmdline_options(argc, argv) | |
35 char **argv; | |
36 { | |
37 extern char *optarg; | |
38 int c; | |
39 | |
40 while ((c = getopt(argc, argv, "a:s:t:")) != EOF) { | |
41 switch (c) { | |
42 case 'a': | |
43 arfcn = atoi(optarg); | |
44 arfcn_set = 1; | |
45 continue; | |
46 case 's': | |
47 rvif_socket_pathname = optarg; | |
48 continue; | |
49 case 't': | |
50 tsid_socket_pathname = optarg; | |
51 continue; | |
52 case '?': | |
53 default: | |
54 /* error msg already printed */ | |
55 exit(ERROR_USAGE); | |
56 } | |
57 } | |
58 return(0); | |
59 } | |
60 | |
61 select_band(bandname) | |
62 char *bandname; | |
63 { | |
64 struct band *band; | |
65 | |
66 for (band = bands; band->name; band++) | |
67 if (!strcmp(band->name, bandname)) | |
68 break; | |
69 if (!band->name) { | |
70 fprintf(stderr, "error: \"%s\" is not a known band\n", | |
71 bandname); | |
72 exit(ERROR_USAGE); | |
73 } | |
74 selected_band = band; | |
75 if (!arfcn_set) | |
76 arfcn = band->default_arfcn; | |
77 return(0); | |
78 } | |
79 | |
80 main(argc, argv) | |
81 char **argv; | |
82 { | |
83 extern int optind; | |
84 int apc; | |
85 double meas; | |
86 | |
87 cmdline_options(argc, argv); | |
88 if (argc - optind < 2) { | |
89 fprintf(stderr, "usage: %s band apc...\n", argv[0]); | |
90 exit(ERROR_USAGE); | |
91 } | |
92 select_band(argv[optind++]); | |
93 | |
94 connect_rvinterf_socket(); | |
95 connect_tsid_socket(); | |
96 setlinebuf(stdout); /* to allow logging with tee */ | |
97 printf("Preparing RF test system for %s MHz Tx calibration\n", | |
98 selected_band->name); | |
99 do_txpwr_cal_setup(selected_band->name, arfcn); | |
100 | |
101 printf("Putting the DUT into Test Mode\n"); | |
102 do_tms(1); | |
103 do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band); | |
104 do_rfpw(TCH_ARFCN, arfcn); | |
105 do_rfpw(AFC_ENA_FLAG, 0); | |
106 printf("Starting RF Tx on the DUT\n"); | |
107 do_rfe(RX_TX_TCH); | |
108 | |
109 for (; optind < argc; optind++) { | |
110 apc = atoi(argv[optind]); | |
111 do_txpw(TX_APC_DAC, apc); | |
112 usleep(20000); | |
113 meas = tx_power_meas(); | |
114 printf("APC DAC=%d: %.2f dBm\n", apc, meas); | |
115 } | |
116 | |
117 printf("Stopping RF Tx on the DUT\n"); | |
118 do_rfe(STOP_ALL); | |
119 exit(0); | |
120 } |