FreeCalypso > hg > fc-rfcal-tools
annotate autocal/txstandbas.c @ 113:01bae2629ffd
doc/Test-system-interface: txpwr-cal-channel addition documented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Feb 2018 04:39:33 +0000 |
parents | c9bd1f75029f |
children | 6a7f8d201859 |
rev | line source |
---|---|
56
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
73
c9bd1f75029f
autocal: C main modules for standalone programs renamed more sensibly
Mychaela Falconia <falcon@freecalypso.org>
parents:
56
diff
changeset
|
2 * fc-rfcal-txbasis is a debug utility implementing just one part |
c9bd1f75029f
autocal: C main modules for standalone programs renamed more sensibly
Mychaela Falconia <falcon@freecalypso.org>
parents:
56
diff
changeset
|
3 * of the fc-rfcal-txband process in a standalone manner; |
c9bd1f75029f
autocal: C main modules for standalone programs renamed more sensibly
Mychaela Falconia <falcon@freecalypso.org>
parents:
56
diff
changeset
|
4 * this module contains the main() function for this standalone utlity. |
56
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <string.h> |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <strings.h> |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <unistd.h> |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <rvinterf/l1tm.h> |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <rvinterf/exitcodes.h> |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "stdband.h" |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern char *rvif_socket_pathname, *tsid_socket_pathname; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern double tx_power_meas(); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 static struct band { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 char *name; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 unsigned rfpw_std_band; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 unsigned default_arfcn; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 } bands[] = { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 {"850", RFPW_STD_BAND_850, 190}, |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 {"900", RFPW_STD_BAND_900, 40}, |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 {"1800", RFPW_STD_BAND_1800, 700}, |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 {"1900", RFPW_STD_BAND_1900, 660}, |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 {0, 0, 0} |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 }; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 static struct band *selected_band; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 static unsigned arfcn, arfcn_set; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 cmdline_options(argc, argv) |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 char **argv; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 extern char *optarg; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 int c; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 while ((c = getopt(argc, argv, "a:s:t:")) != EOF) { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 switch (c) { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 case 'a': |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 arfcn = atoi(optarg); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 arfcn_set = 1; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 continue; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 case 's': |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 rvif_socket_pathname = optarg; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 continue; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 case 't': |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 tsid_socket_pathname = optarg; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 continue; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 case '?': |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 default: |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 /* error msg already printed */ |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 exit(ERROR_USAGE); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 } |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 return(0); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 } |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 select_band(bandname) |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 char *bandname; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 struct band *band; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 for (band = bands; band->name; band++) |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if (!strcmp(band->name, bandname)) |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 break; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 if (!band->name) { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 fprintf(stderr, "error: \"%s\" is not a known band\n", |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 bandname); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 exit(ERROR_USAGE); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 } |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 selected_band = band; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 if (!arfcn_set) |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 arfcn = band->default_arfcn; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 return(0); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 main(argc, argv) |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 char **argv; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 extern int optind; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 int apc; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 double meas; |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 cmdline_options(argc, argv); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 if (argc - optind < 2) { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 fprintf(stderr, "usage: %s band apc...\n", argv[0]); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 exit(ERROR_USAGE); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 select_band(argv[optind++]); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 connect_rvinterf_socket(); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 connect_tsid_socket(); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 setlinebuf(stdout); /* to allow logging with tee */ |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 printf("Preparing RF test system for %s MHz Tx calibration\n", |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 selected_band->name); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 do_txpwr_cal_setup(selected_band->name, arfcn); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 printf("Putting the DUT into Test Mode\n"); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 do_tms(1); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 do_rfpw(TCH_ARFCN, arfcn); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 do_rfpw(AFC_ENA_FLAG, 0); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 printf("Starting RF Tx on the DUT\n"); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 do_rfe(RX_TX_TCH); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 for (; optind < argc; optind++) { |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 apc = atoi(argv[optind]); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 do_txpw(TX_APC_DAC, apc); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 usleep(20000); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 meas = tx_power_meas(); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 printf("APC DAC=%d: %.2f dBm\n", apc, meas); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 } |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 printf("Stopping RF Tx on the DUT\n"); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 do_rfe(STOP_ALL); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 exit(0); |
df827df6db82
fc-rfcal-txbasis written, ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 } |