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