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