annotate autocal/txchkmain.c @ 53:bc2397f62bdb

rf-cal-txcheck started
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 27 May 2017 15:41:54 +0000
parents
children 21f6dba5c4df
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>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <rvinterf/l1tm.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/exitcodes.h>
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "stdband.h"
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 static struct band {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 char *name;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 unsigned rfpw_std_band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 unsigned default_arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned start_plnum;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 unsigned end_plnum;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 } bands[] = {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {"850", RFPW_STD_BAND_850, 190, 5, 19},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {"900", RFPW_STD_BAND_900, 40, 5, 19},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {"1800", RFPW_STD_BAND_1800, 700, 0, 15},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {"1900", RFPW_STD_BAND_1900, 660, 0, 15},
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {0, 0, 0}
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 };
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 static struct band *selected_band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 static unsigned arfcn;
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 finish_cmdline(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 char **argv;
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 extern int optind;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 struct band *band;
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 if (argc - optind < 1 || argc - optind > 2) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 exit(ERROR_USAGE);
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 for (band = bands; band->name; band++)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (!strcmp(band->name, argv[optind]))
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 break;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!band->name) {
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 fprintf(stderr, "error: \"%s\" is not a known band\n",
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 argv[optind]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 exit(ERROR_USAGE);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 selected_band = band;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 if (argv[optind+1])
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 arfcn = atoi(argv[optind+1]);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 else
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 arfcn = band->default_arfcn;
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 return(0);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 prepare_rf_test_system()
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 char cmd[80];
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 printf("Preparing RF test system for %s MHz Tx calibration\n",
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 selected_band->name);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 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
62 tsid_command(cmd);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 return(0);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 main(argc, argv)
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 char **argv;
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 socket_pathname_options(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 finish_cmdline(argc, argv);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 connect_rvinterf_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 connect_tsid_socket();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 setlinebuf(stdout); /* to allow logging with tee */
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 prepare_rf_test_system();
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 printf("Putting the DUT into Test Mode\n");
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 do_tms(1);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band);
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80
bc2397f62bdb rf-cal-txcheck started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }