annotate autocal/txchkmain.c @ 54:21f6dba5c4df

fc-rfcal-txcheck ready to test
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 16:03:40 +0000
parents bc2397f62bdb
children b313884c79fd
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 prepare_rf_test_system()
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 char cmd[80];
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 printf("Preparing RF test system for %s MHz Tx calibration\n",
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 selected_band->name);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 sprintf(cmd, "txpwr-cal-setup %s %u\n", selected_band->name, arfcn);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 tsid_command(cmd);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 return(0);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 main(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 char **argv;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
72 unsigned plnum;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
73 double meas;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
74
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 socket_pathname_options(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 finish_cmdline(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 connect_rvinterf_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 connect_tsid_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 setlinebuf(stdout); /* to allow logging with tee */
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 prepare_rf_test_system();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 printf("Putting the DUT into Test Mode\n");
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 do_tms(1);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 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
85 do_rfpw(TCH_ARFCN, arfcn);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
86 do_rfpw(AFC_ENA_FLAG, 0);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
87 printf("Starting RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
88 do_rfe(RX_TX_TCH);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
54
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
90 for (plnum = selected_band->start_plnum;
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
91 plnum <= selected_band->end_plnum; plnum++) {
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
92 do_txpw(TX_PWR_LEVEL, plnum);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
93 usleep(20000);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
94 meas = tx_power_meas();
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
95 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
96 }
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
97
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
98 printf("Stopping RF Tx on the DUT\n");
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
99 do_rfe(STOP_ALL);
21f6dba5c4df fc-rfcal-txcheck ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 53
diff changeset
100 exit(0);
53
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 }