FreeCalypso > hg > fc-rfcal-tools
annotate autocal/rxband.c @ 57:2588f9eed11a
fc-rfcal-rxband started
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 23:05:28 +0000 |
parents | |
children | 46c72323182a |
rev | line source |
---|---|
57
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module contains the main() function for fc-rfcal-rxband. |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <string.h> |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <strings.h> |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <rvinterf/l1tm.h> |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <rvinterf/exitcodes.h> |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "rxband.h" |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "rxcaldefs.h" |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "stdband.h" |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 struct rx_calchan_range rx_calchan_850[] = { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 {128, 138, 128}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 {139, 157, 148}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 {158, 178, 168}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 {179, 199, 189}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 {200, 217, 208}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 {218, 239, 228}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 {240, 251, 251} |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 }; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct rx_calchan_range rx_calchan_900[] = { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 { 0, 10, 1}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 { 11, 30, 20}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 { 31, 51, 37}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 { 52, 71, 62}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 { 72, 90, 80}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 { 91, 112, 100}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 { 113, 124, 124}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 { 975, 991, 975}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 { 992, 1009, 1000}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 {1010, 1023, 1017} |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 }; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 struct rx_calchan_range rx_calchan_1800[] = { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 {512, 548, 512}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 {549, 622, 585}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 {623, 680, 660}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 {681, 745, 698}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 {746, 812, 790}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 {813, 860, 835}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 {861, 885, 885} |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 }; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 struct rx_calchan_range rx_calchan_1900[] = { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 {512, 548, 512}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 {549, 622, 585}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 {623, 680, 661}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 {681, 745, 700}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 {746, 795, 790}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 {796, 810, 805} |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 }; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 struct rxcal_band rxcal_band_list[] = { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 {"850", RFPW_STD_BAND_850, 189, rx_calchan_850, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 sizeof(rx_calchan_850) / sizeof(struct rx_calchan_range)}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 {"900", RFPW_STD_BAND_900, 37, rx_calchan_900, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 sizeof(rx_calchan_900) / sizeof(struct rx_calchan_range)}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 {"1800", RFPW_STD_BAND_1800, 698, rx_calchan_1800, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 sizeof(rx_calchan_1800) / sizeof(struct rx_calchan_range)}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 {"1900", RFPW_STD_BAND_1900, 661, rx_calchan_1900, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 sizeof(rx_calchan_1900) / sizeof(struct rx_calchan_range)}, |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 {0, 0, 0, 0, 0} |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 }; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 struct rxcal_band *rxcal_band; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 finish_cmdline(argc, argv) |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 char **argv; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 extern int optind; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 struct rxcal_band *band; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 if (argc - optind != 1) { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 fprintf(stderr, "usage: %s band\n", argv[0]); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 exit(ERROR_USAGE); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 } |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 for (band = rxcal_band_list; band->name; band++) |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (!strcmp(band->name, argv[optind])) |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 break; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 if (!band->name) { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 fprintf(stderr, "error: \"%s\" is not a known band\n", |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 argv[optind]); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 exit(ERROR_USAGE); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 } |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 rxcal_band = band; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 return(0); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 prepare_rf_test_system() |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 char cmd[80]; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 printf("Preparing RF test system for %s MHz Rx calibration\n", |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 rxcal_band->name); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 sprintf(cmd, "signal-gen-setup %s\n", rxcal_band->name); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 tsid_command(cmd); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 return(0); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 } |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 main(argc, argv) |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 char **argv; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 { |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 int pm, Gmagic; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 char Gmagic_db[64]; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 socket_pathname_options(argc, argv); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 finish_cmdline(argc, argv); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 connect_rvinterf_socket(); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 connect_tsid_socket(); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 setlinebuf(stdout); /* to allow logging with tee */ |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 prepare_rf_test_system(); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 printf("Putting the DUT into Test Mode\n"); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 do_tms(1); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 do_rfpw(STD_BAND_FLAG, rxcal_band->rfpw_std_band); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 l1tm_setup_for_rxcal(); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 pm = rx_measure(rxcal_band->main_arfcn); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 Gmagic = pm - RXCAL_SIGGEN_LEVEL - RXCAL_AGC_DB * 2; |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 halfdb_to_string(Gmagic, Gmagic_db); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 printf("GMagic=%d (%s dB)\n", Gmagic, Gmagic_db); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 exit(0); |
2588f9eed11a
fc-rfcal-rxband started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 } |