annotate autocal/txstandchk.c @ 90:713749548df6

fc-rfcal-tri900 script and fc-rfcal-tee helper implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 17 Jul 2017 05:51:31 +0000
parents c9bd1f75029f
children 94e8a410d6bd
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 /*
73
c9bd1f75029f autocal: C main modules for standalone programs renamed more sensibly
Mychaela Falconia <falcon@freecalypso.org>
parents: 71
diff changeset
2 * fc-rfcal-txcheck 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: 71
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: 71
diff changeset
4 * this module contains the main() function for this standalone utlity.
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
11 #include <unistd.h>
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <rvinterf/l1tm.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <rvinterf/exitcodes.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "stdband.h"
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
16 extern double tx_power_meas();
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
17
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static struct band {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 char *name;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 unsigned rfpw_std_band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned default_arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 unsigned start_plnum;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 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
24 int spec_max_dbm;
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 } bands[] = {
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
26 {"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
27 {"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
28 {"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
29 {"1900", RFPW_STD_BAND_1900, 660, 0, 15, 30},
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 {0, 0, 0}
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 static struct band *selected_band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 static unsigned arfcn;
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 finish_cmdline(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 char **argv;
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 extern int optind;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 struct band *band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (argc - optind < 1 || argc - optind > 2) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 exit(ERROR_USAGE);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 for (band = bands; band->name; band++)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (!strcmp(band->name, argv[optind]))
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 break;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 if (!band->name) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 fprintf(stderr, "error: \"%s\" is not a known band\n",
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 argv[optind]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 exit(ERROR_USAGE);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 selected_band = band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 if (argv[optind+1])
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 arfcn = atoi(argv[optind+1]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 else
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 arfcn = band->default_arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 return(0);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 main(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 char **argv;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
64 unsigned plnum;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
65 double meas;
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
66 int spec_dbm;
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
67
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 socket_pathname_options(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 finish_cmdline(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 connect_rvinterf_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 connect_tsid_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 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
73 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
74 selected_band->name);
b313884c79fd autocal Tx: txpwr-cal-setup factored out of fc-rfcal-txcheck
Mychaela Falconia <falcon@freecalypso.org>
parents: 54
diff changeset
75 do_txpwr_cal_setup(selected_band->name, arfcn);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 printf("Putting the DUT into Test Mode\n");
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 do_tms(1);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 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
80 do_rfpw(TCH_ARFCN, arfcn);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
81 do_rfpw(AFC_ENA_FLAG, 0);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
82 printf("Starting RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
83 do_rfe(RX_TX_TCH);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
71
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
85 spec_dbm = selected_band->spec_max_dbm;
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
86 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
87 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
88 do_txpw(TX_PWR_LEVEL, plnum);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
89 usleep(20000);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
90 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
91 printf(
784ce9f3a80a fc-rfcal-txcheck: spec and error values added to the output
Mychaela Falconia <falcon@freecalypso.org>
parents: 55
diff changeset
92 "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
93 plnum, spec_dbm, meas, meas - spec_dbm);
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
94 }
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
95
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
96 printf("Stopping RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
97 do_rfe(STOP_ALL);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
98 exit(0);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 }