annotate rvinterf/etmsync/l1tmcmd.c @ 555:0093bf43c813

loadtools/scripts: added leonardo and tango configs
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 05 Jan 2020 22:43:18 +0000
parents dd97e75620a7
children 4694c7686ccd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
273
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module contains the user command wrappers around the functions
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * in the l1tmops.c module.
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <ctype.h>
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "pktmux.h"
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include "limits.h"
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "localtypes.h"
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "tm3.h"
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include "l1tm.h"
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "exitcodes.h"
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 extern void write_afcparams_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 extern void write_agcwords_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 extern void write_agcglobals_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 extern void write_il2agc_table();
290
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
23 extern void write_tx_ramps_table();
273
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 extern void write_tx_levels_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 extern void write_tx_calchan_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 extern void write_tx_caltemp_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 extern void write_rx_calchan_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 extern void write_rx_caltemp_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 extern void write_rx_agcparams_table();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 cmd_tms(argc, argv)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 char **argv;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 u16 arg;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 arg = strtoul(argv[1], 0, 0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return do_tms(arg);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 static
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 is_num_string(argstr)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 char *argstr;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 char *cp = argstr;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (!isdigit(*cp++))
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return(0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 while (*cp) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 if (!isdigit(*cp++))
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return(0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 return(1);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 struct kwtab {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 char *kw;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 int val;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 };
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 static
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 keyword_or_num(argstr, kwtab, valp)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 char *argstr;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 struct kwtab *kwtab;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 u16 *valp;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 struct kwtab *tp;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 if (is_num_string(argstr)) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 *valp = atoi(argstr);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 return(0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 for (tp = kwtab; tp->kw; tp++) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 if (!strcmp(tp->kw, argstr)) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 *valp = tp->val;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 return(0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 printf("error: non-numeric argument not understood\n");
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 return(ERROR_USAGE);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 static struct kwtab rf_param_arg[] = {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 {"bcch-arfcn", BCCH_ARFCN},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 {"tch-arfcn", TCH_ARFCN},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 {"mon-arfcn", MON_ARFCN},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 {"pdtch-arfcn", PDTCH_ARFCN},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 {"std-band", STD_BAND_FLAG},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 {"afc-enable", AFC_ENA_FLAG},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 {"afc-dac-val", AFC_DAC_VALUE},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 {"init-afc-dac", INITIAL_AFC_DAC},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 {"multislot-class", MULTISLOT_CLASS},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 {0, 0}
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 };
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 cmd_rfpw2(argc, argv)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 char **argv;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 u16 index, value;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 if (keyword_or_num(argv[1], rf_param_arg, &index))
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 return(ERROR_USAGE);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 value = strtol(argv[2], 0, 0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 return do_rfpw(index, value);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 cmd_rfpw3(argc, argv)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 char **argv;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 u16 index;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 u8 val1, val2;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 if (keyword_or_num(argv[1], rf_param_arg, &index))
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 return(ERROR_USAGE);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 val1 = strtoul(argv[2], 0, 0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 val2 = strtoul(argv[3], 0, 0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 return do_rfpw(index, (val2 << 8) | val1);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 cmd_rfpw(argc, argv)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 char **argv;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 switch (argc) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 case 3:
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 return cmd_rfpw2(argc, argv);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 case 4:
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 return cmd_rfpw3(argc, argv);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 default:
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 fprintf(stderr, "BUG: wrong argc in cmd_rfpw()\n");
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 return(ERROR_BUG);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 cmd_rfpr(argc, argv)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 char **argv;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 u16 index, val;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 int rc;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 if (keyword_or_num(argv[1], rf_param_arg, &index))
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 return(ERROR_USAGE);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 rc = do_rfpr(index, &val);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 if (rc)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 return(rc);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 if (val >= 0x8000)
275
81da9717babe fc-tmsync: missed newline at the end of rfpr output
Mychaela Falconia <falcon@freecalypso.org>
parents: 273
diff changeset
145 printf("read value: 0x%04X (%u or %d)\n", val, val,
273
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 (int)val - 65536);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 else
275
81da9717babe fc-tmsync: missed newline at the end of rfpr output
Mychaela Falconia <falcon@freecalypso.org>
parents: 273
diff changeset
148 printf("read value: 0x%04X (%u)\n", val, val);
273
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 return(0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 static struct kwtab rf_table_arg[] = {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 {"rx-agc-table", RX_AGC_TABLE},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 {"afcparams", AFC_PARAMS},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 {"rx-agc-global-params", RX_AGC_GLOBAL_PARAMS},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 {"rx-il2agc-max", RX_IL_2_AGC_MAX},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 {"rx-il2agc-pwr", RX_IL_2_AGC_PWR},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 {"rx-il2agc-av", RX_IL_2_AGC_AV},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 {"tx-levels", TX_LEVELS},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 {"tx-calchan", TX_CAL_CHAN},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 {"tx-caltemp", TX_CAL_TEMP},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 {"rx-calchan", RX_CAL_CHAN},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 {"rx-caltemp", RX_CAL_TEMP},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 {"rx-agcparams", RX_AGC_PARAMS},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 {0, 0}
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 };
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 static struct table_map {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 int index;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 int size;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 void (*func)();
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 } table_map[] = {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 {RX_AGC_TABLE, 40, write_agcwords_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 {AFC_PARAMS, 24, write_afcparams_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 {RX_AGC_GLOBAL_PARAMS, 8, write_agcglobals_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 {RX_IL_2_AGC_MAX, 121, write_il2agc_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 {RX_IL_2_AGC_PWR, 121, write_il2agc_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 {RX_IL_2_AGC_AV, 121, write_il2agc_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 {TX_LEVELS, 128, write_tx_levels_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 {TX_CAL_CHAN, 128, write_tx_calchan_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 {TX_CAL_TEMP, 40, write_tx_caltemp_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 {RX_CAL_CHAN, 40, write_rx_calchan_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 {RX_CAL_TEMP, 44, write_rx_caltemp_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 {RX_AGC_PARAMS, 8, write_rx_agcparams_table},
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 {0, 0, 0}
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 };
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 cmd_rftr(argc, argv)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 char **argv;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 u16 index;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 struct table_map *tp;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 u_char table_data[MAX_RF_TABLE_SIZE];
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 int rc;
290
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
195 FILE *of;
273
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 if (keyword_or_num(argv[1], rf_table_arg, &index))
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 return(ERROR_USAGE);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 for (tp = table_map; tp->index; tp++) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 if (tp->index == index)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 break;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 if (!tp->index) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 printf("error: table index %u not supported, use fc-tmsh\n",
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 index);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 return(ERROR_USAGE);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 rc = do_rftr(index, table_data, tp->size);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 if (rc)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 return(rc);
290
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
211 if (argv[2]) {
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
212 of = fopen(argv[2], "w");
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
213 if (!of) {
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
214 perror(argv[2]);
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
215 return(ERROR_UNIX);
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
216 }
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
217 tp->func(table_data, of);
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
218 fclose(of);
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
219 } else
94234e9c843b fc-tmsync: rftr save to file implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 275
diff changeset
220 tp->func(table_data, stdout);
273
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 return(0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 cmd_ttr(argc, argv)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 char **argv;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 unsigned index;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 u_char ramp_data[32];
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 int rc;
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 index = strtoul(argv[1], 0, 0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 if (index >= 16) {
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 printf("error: index out of range\n");
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 return(ERROR_USAGE);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 }
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 rc = do_ttr(index, ramp_data);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 if (rc)
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 return(rc);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 write_tx_ramp(ramp_data, stdout);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 return(0);
18a8fb3d845b fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 }
291
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
242
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
243 cmd_ttr_all(argc, argv)
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
244 char **argv;
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
245 {
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
246 u_char table[512];
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
247 int rc, i;
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
248 FILE *of;
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
249
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
250 for (i = 0; i < 16; i++) {
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
251 rc = do_ttr(i, table + i * 32);
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
252 if (rc)
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
253 return(rc);
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
254 }
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
255 of = fopen(argv[1], "w");
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
256 if (!of) {
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
257 perror(argv[1]);
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
258 return(ERROR_UNIX);
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
259 }
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
260 write_tx_ramps_table(table, of);
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
261 fclose(of);
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
262 return(0);
dd97e75620a7 fc-tmsync: ttr-all implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 290
diff changeset
263 }