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