annotate autocal/txchkmain.c @ 71:784ce9f3a80a

fc-rfcal-txcheck: spec and error values added to the output
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 14 Jul 2017 06:58:36 +0000
parents b313884c79fd
children
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;
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
22 int spec_max_dbm;
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 } bands[] = {
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
24 {"850", RFPW_STD_BAND_850, 190, 5, 19, 33},
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
25 {"900", RFPW_STD_BAND_900, 40, 5, 19, 33},
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
26 {"1800", RFPW_STD_BAND_1800, 700, 0, 15, 30},
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
27 {"1900", RFPW_STD_BAND_1900, 660, 0, 15, 30},
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {0, 0, 0}
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 };
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 static struct band *selected_band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 static unsigned arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 finish_cmdline(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 char **argv;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 extern int optind;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 struct band *band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (argc - optind < 1 || argc - optind > 2) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 exit(ERROR_USAGE);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 for (band = bands; band->name; band++)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (!strcmp(band->name, argv[optind]))
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 break;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (!band->name) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 fprintf(stderr, "error: \"%s\" is not a known band\n",
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 argv[optind]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 exit(ERROR_USAGE);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 selected_band = band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 if (argv[optind+1])
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 arfcn = atoi(argv[optind+1]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 else
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 arfcn = band->default_arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 return(0);
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
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 main(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 char **argv;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 {
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
62 unsigned plnum;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
63 double meas;
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
64 int spec_dbm;
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
65
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 socket_pathname_options(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 finish_cmdline(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 connect_rvinterf_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 connect_tsid_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 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
71 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
72 selected_band->name);
b313884c79fd autocal Tx: txpwr-cal-setup factored out of fc-rfcal-txcheck
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
73 do_txpwr_cal_setup(selected_band->name, arfcn);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 printf("Putting the DUT into Test Mode\n");
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 do_tms(1);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 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
78 do_rfpw(TCH_ARFCN, arfcn);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
79 do_rfpw(AFC_ENA_FLAG, 0);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
80 printf("Starting RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
81 do_rfe(RX_TX_TCH);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
83 spec_dbm = selected_band->spec_max_dbm;
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
84 for (plnum = selected_band->start_plnum;
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
85 plnum <= selected_band->end_plnum; plnum++, spec_dbm -= 2) {
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
86 do_txpw(TX_PWR_LEVEL, plnum);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
87 usleep(20000);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
88 meas = tx_power_meas();
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
89 printf(
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
90 "Tx power level #%u: spec %d dBm, meas %.2f dBm (%+.2f)\n",
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
91 plnum, spec_dbm, meas, meas - spec_dbm);
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
92 }
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
93
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
94 printf("Stopping RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
95 do_rfe(STOP_ALL);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
96 exit(0);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 }