annotate autocal/txchkmain.c @ 63:131abadbd74d

doc/Rx-cal-theory written
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 28 May 2017 03:21:34 +0000
parents b313884c79fd
children 784ce9f3a80a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the main() function for fc-rfcal-txcheck.
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
9 #include <unistd.h>
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/l1tm.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <rvinterf/exitcodes.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "stdband.h"
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
14 extern double tx_power_meas();
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
15
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 static struct band {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char *name;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 unsigned rfpw_std_band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 unsigned default_arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 unsigned start_plnum;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned end_plnum;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 } bands[] = {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {"850", RFPW_STD_BAND_850, 190, 5, 19},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {"900", RFPW_STD_BAND_900, 40, 5, 19},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 {"1800", RFPW_STD_BAND_1800, 700, 0, 15},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {"1900", RFPW_STD_BAND_1900, 660, 0, 15},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 {0, 0, 0}
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 };
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 static struct band *selected_band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 static unsigned arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 finish_cmdline(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 char **argv;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 extern int optind;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 struct band *band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (argc - optind < 1 || argc - optind > 2) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 exit(ERROR_USAGE);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 for (band = bands; band->name; band++)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (!strcmp(band->name, argv[optind]))
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 break;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 if (!band->name) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 fprintf(stderr, "error: \"%s\" is not a known band\n",
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 argv[optind]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 exit(ERROR_USAGE);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 selected_band = band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 if (argv[optind+1])
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 arfcn = atoi(argv[optind+1]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 else
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 arfcn = band->default_arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return(0);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 main(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 char **argv;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 {
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
61 unsigned plnum;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
62 double meas;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
63
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 socket_pathname_options(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 finish_cmdline(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 connect_rvinterf_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 connect_tsid_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 setlinebuf(stdout); /* to allow logging with tee */
55
b313884c79fd autocal Tx: txpwr-cal-setup factored out of fc-rfcal-txcheck
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
69 printf("Preparing RF test system for %s MHz Tx calibration\n",
b313884c79fd autocal Tx: txpwr-cal-setup factored out of fc-rfcal-txcheck
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
70 selected_band->name);
b313884c79fd autocal Tx: txpwr-cal-setup factored out of fc-rfcal-txcheck
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
71 do_txpwr_cal_setup(selected_band->name, arfcn);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 printf("Putting the DUT into Test Mode\n");
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 do_tms(1);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band);
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
76 do_rfpw(TCH_ARFCN, arfcn);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
77 do_rfpw(AFC_ENA_FLAG, 0);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
78 printf("Starting RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
79 do_rfe(RX_TX_TCH);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
81 for (plnum = selected_band->start_plnum;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
82 plnum <= selected_band->end_plnum; plnum++) {
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
83 do_txpw(TX_PWR_LEVEL, plnum);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
84 usleep(20000);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
85 meas = tx_power_meas();
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
86 printf("Tx power level #%u: %.2f dBm\n", plnum, meas);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
87 }
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
88
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
89 printf("Stopping RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
90 do_rfe(STOP_ALL);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
91 exit(0);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 }