FreeCalypso > hg > fc-rfcal-tools
annotate autocal/gmagicstand.c @ 117:4c3f4231a021
autocal: vout_t definition factored out of txband.h into txvout.h
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Feb 2018 07:02:17 +0000 |
parents | c9bd1f75029f |
children |
rev | line source |
---|---|
42
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
73
c9bd1f75029f
autocal: C main modules for standalone programs renamed more sensibly
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
2 * fc-rfcal-gmagic is a debug utility implementing just one part |
c9bd1f75029f
autocal: C main modules for standalone programs renamed more sensibly
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
3 * of the fc-rfcal-rxband process in a standalone manner; |
c9bd1f75029f
autocal: C main modules for standalone programs renamed more sensibly
Mychaela Falconia <falcon@freecalypso.org>
parents:
51
diff
changeset
|
4 * this module contains the main() function for this standalone utlity. |
42
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <string.h> |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <strings.h> |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <rvinterf/l1tm.h> |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <rvinterf/exitcodes.h> |
44
5018fd8eecce
autocal: started Rx cal core code
Mychaela Falconia <falcon@freecalypso.org>
parents:
43
diff
changeset
|
13 #include "rxcaldefs.h" |
42
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "stdband.h" |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 static struct band { |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char *name; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 unsigned rfpw_std_band; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 unsigned default_arfcn; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 } bands[] = { |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 {"850", RFPW_STD_BAND_850, 189}, |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 {"900", RFPW_STD_BAND_900, 37}, |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 {"1800", RFPW_STD_BAND_1800, 698}, |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 {"1900", RFPW_STD_BAND_1900, 661}, |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 {0, 0, 0} |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 }; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 static struct band *selected_band; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static unsigned arfcn; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 finish_cmdline(argc, argv) |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 char **argv; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 { |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 extern int optind; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 struct band *band; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (argc - optind < 1 || argc - optind > 2) { |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 fprintf(stderr, "usage: %s band [arfcn]\n", argv[0]); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 exit(ERROR_USAGE); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 for (band = bands; band->name; band++) |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 if (!strcmp(band->name, argv[optind])) |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 break; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (!band->name) { |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 fprintf(stderr, "error: \"%s\" is not a known band\n", |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 argv[optind]); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 exit(ERROR_USAGE); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 selected_band = band; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (argv[optind+1]) |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 arfcn = atoi(argv[optind+1]); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 else |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 arfcn = band->default_arfcn; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 return(0); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
43
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
56 prepare_rf_test_system() |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
57 { |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
58 char cmd[80]; |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
59 |
51
fe39aac56cde
autocal/gmagicmain.c: printf fix
Mychaela Falconia <falcon@freecalypso.org>
parents:
50
diff
changeset
|
60 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
|
61 selected_band->name); |
43
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
62 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
|
63 tsid_command(cmd); |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
64 return(0); |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
65 } |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
66 |
42
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 main(argc, argv) |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 char **argv; |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 { |
50
d309241fcae3
fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
70 int pm, Gmagic; |
d309241fcae3
fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
71 char Gmagic_db[64]; |
d309241fcae3
fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
72 |
42
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 socket_pathname_options(argc, argv); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 finish_cmdline(argc, argv); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 connect_rvinterf_socket(); |
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 connect_tsid_socket(); |
43
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
77 setlinebuf(stdout); /* to allow logging with tee */ |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
78 prepare_rf_test_system(); |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
79 |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
80 printf("Putting the DUT into Test Mode\n"); |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
81 do_tms(1); |
8c7b0ba1e5c4
fc-rfcal-gmagic: main() coming along
Mychaela Falconia <falcon@freecalypso.org>
parents:
42
diff
changeset
|
82 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
|
83 l1tm_setup_for_rxcal(); |
50
d309241fcae3
fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
84 pm = rx_measure(arfcn); |
d309241fcae3
fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
85 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
|
86 halfdb_to_string(Gmagic, Gmagic_db); |
d309241fcae3
fc-rfcal-gmagic ready to test
Mychaela Falconia <falcon@freecalypso.org>
parents:
44
diff
changeset
|
87 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
|
88 exit(0); |
42
dcf7cd305e2b
fc-rfcal-gmagic started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |