annotate autocal/gmagicmain.c @ 63:131abadbd74d

doc/Rx-cal-theory written
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 28 May 2017 03:21:34 +0000
parents fe39aac56cde
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
42
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the main() function for fc-rfcal-gmagic.
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdlib.h>
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <string.h>
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <strings.h>
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <rvinterf/l1tm.h>
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <rvinterf/exitcodes.h>
44
5018fd8eecce autocal: started Rx cal core code
Mychaela Falconia <falcon@freecalypso.org>
parents: 43
diff changeset
11 #include "rxcaldefs.h"
42
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "stdband.h"
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 static struct band {
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char *name;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 unsigned rfpw_std_band;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned default_arfcn;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 } bands[] = {
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {"850", RFPW_STD_BAND_850, 189},
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 {"900", RFPW_STD_BAND_900, 37},
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 {"1800", RFPW_STD_BAND_1800, 698},
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 {"1900", RFPW_STD_BAND_1900, 661},
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {0, 0, 0}
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 };
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 static struct band *selected_band;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 static unsigned arfcn;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 finish_cmdline(argc, argv)
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 char **argv;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 {
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 extern int optind;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 struct band *band;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (argc - optind < 1 || argc - optind > 2) {
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 exit(ERROR_USAGE);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 for (band = bands; band->name; band++)
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (!strcmp(band->name, argv[optind]))
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 break;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (!band->name) {
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 fprintf(stderr, "error: \"%s\" is not a known band\n",
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 argv[optind]);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 exit(ERROR_USAGE);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 selected_band = band;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (argv[optind+1])
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 arfcn = atoi(argv[optind+1]);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 else
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 arfcn = band->default_arfcn;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 return(0);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
43
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
54 prepare_rf_test_system()
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
55 {
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
56 char cmd[80];
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
57
51
fe39aac56cde autocal/gmagicmain.c: printf fix
Mychaela Falconia <falcon@freecalypso.org>
parents: 50
diff changeset
58 printf("Preparing RF test system for %s MHz Rx calibration\n",
fe39aac56cde autocal/gmagicmain.c: printf fix
Mychaela Falconia <falcon@freecalypso.org>
parents: 50
diff changeset
59 selected_band->name);
43
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
60 sprintf(cmd, "signal-gen-setup %s\n", selected_band->name);
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
61 tsid_command(cmd);
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
62 return(0);
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
63 }
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
64
42
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 main(argc, argv)
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 char **argv;
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 {
50
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
68 int pm, Gmagic;
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
69 char Gmagic_db[64];
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
70
42
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 socket_pathname_options(argc, argv);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 finish_cmdline(argc, argv);
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 connect_rvinterf_socket();
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 connect_tsid_socket();
43
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
75 setlinebuf(stdout); /* to allow logging with tee */
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
76 prepare_rf_test_system();
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
77
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
78 printf("Putting the DUT into Test Mode\n");
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
79 do_tms(1);
8c7b0ba1e5c4 fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents: 42
diff changeset
80 do_rfpw(STD_BAND_FLAG, selected_band->rfpw_std_band);
44
5018fd8eecce autocal: started Rx cal core code
Mychaela Falconia <falcon@freecalypso.org>
parents: 43
diff changeset
81 l1tm_setup_for_rxcal();
50
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
82 pm = rx_measure(arfcn);
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
83 Gmagic = pm - RXCAL_SIGGEN_LEVEL - RXCAL_AGC_DB * 2;
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
84 halfdb_to_string(Gmagic, Gmagic_db);
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
85 printf("GMagic=%d (%s dB)\n", Gmagic, Gmagic_db);
d309241fcae3 fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents: 44
diff changeset
86 exit(0);
42
dcf7cd305e2b fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 }