FreeCalypso > hg > freecalypso-tools
annotate rvinterf/etmsync/l1tmcmd.c @ 274:f22874b351b7
fc-tmsync: L1TM operation commands hooked in
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 16 Nov 2017 23:44:48 +0000 |
parents | 18a8fb3d845b |
children | 81da9717babe |
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(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 extern void write_tx_levels_table(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 extern void write_tx_calchan_table(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 extern void write_tx_caltemp_table(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 extern void write_rx_calchan_table(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 extern void write_rx_caltemp_table(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 extern void write_rx_agcparams_table(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 cmd_tms(argc, argv) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 char **argv; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 u16 arg; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 arg = strtoul(argv[1], 0, 0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 return do_tms(arg); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
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 static |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 is_num_string(argstr) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 char *argstr; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 char *cp = argstr; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (!isdigit(*cp++)) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 while (*cp) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (!isdigit(*cp++)) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 return(0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 return(1); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
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 struct kwtab { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 char *kw; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 int val; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 }; |
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 static |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 keyword_or_num(argstr, kwtab, valp) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 char *argstr; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 struct kwtab *kwtab; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 u16 *valp; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 struct kwtab *tp; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if (is_num_string(argstr)) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 *valp = atoi(argstr); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 return(0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 } |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 for (tp = kwtab; tp->kw; tp++) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 if (!strcmp(tp->kw, argstr)) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 *valp = tp->val; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 return(0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } |
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 printf("error: non-numeric argument not understood\n"); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 return(ERROR_USAGE); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 } |
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 static struct kwtab rf_param_arg[] = { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 {"bcch-arfcn", BCCH_ARFCN}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 {"tch-arfcn", TCH_ARFCN}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 {"mon-arfcn", MON_ARFCN}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 {"pdtch-arfcn", PDTCH_ARFCN}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 {"std-band", STD_BAND_FLAG}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 {"afc-enable", AFC_ENA_FLAG}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 {"afc-dac-val", AFC_DAC_VALUE}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 {"init-afc-dac", INITIAL_AFC_DAC}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 {"multislot-class", MULTISLOT_CLASS}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 {0, 0} |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 }; |
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 cmd_rfpw2(argc, argv) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 char **argv; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 u16 index, value; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 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
|
100 return(ERROR_USAGE); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 value = strtol(argv[2], 0, 0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 return do_rfpw(index, value); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
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 cmd_rfpw3(argc, argv) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 char **argv; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 u16 index; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 u8 val1, val2; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 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
|
112 return(ERROR_USAGE); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 val1 = strtoul(argv[2], 0, 0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 val2 = strtoul(argv[3], 0, 0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 return do_rfpw(index, (val2 << 8) | val1); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 } |
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 cmd_rfpw(argc, argv) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 char **argv; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 switch (argc) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 case 3: |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 return cmd_rfpw2(argc, argv); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 case 4: |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 return cmd_rfpw3(argc, argv); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 default: |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 fprintf(stderr, "BUG: wrong argc in cmd_rfpw()\n"); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 return(ERROR_BUG); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
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 cmd_rfpr(argc, argv) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 char **argv; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 u16 index, val; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 int rc; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 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
|
139 return(ERROR_USAGE); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 rc = do_rfpr(index, &val); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 if (rc) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 return(rc); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 if (val >= 0x8000) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 printf("read value: 0x%04X (%u or %d)", val, val, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 (int)val - 65536); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 else |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 printf("read value: 0x%04X (%u)", val, val); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 return(0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 } |
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 static struct kwtab rf_table_arg[] = { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 {"rx-agc-table", RX_AGC_TABLE}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 {"afcparams", AFC_PARAMS}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 {"rx-agc-global-params", RX_AGC_GLOBAL_PARAMS}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 {"rx-il2agc-max", RX_IL_2_AGC_MAX}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 {"rx-il2agc-pwr", RX_IL_2_AGC_PWR}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 {"rx-il2agc-av", RX_IL_2_AGC_AV}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 {"tx-levels", TX_LEVELS}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 {"tx-calchan", TX_CAL_CHAN}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 {"tx-caltemp", TX_CAL_TEMP}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 {"rx-calchan", RX_CAL_CHAN}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 {"rx-caltemp", RX_CAL_TEMP}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 {"rx-agcparams", RX_AGC_PARAMS}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 {0, 0} |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 }; |
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 static struct table_map { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 int index; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 int size; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 void (*func)(); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } table_map[] = { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 {RX_AGC_TABLE, 40, write_agcwords_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 {AFC_PARAMS, 24, write_afcparams_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 {RX_AGC_GLOBAL_PARAMS, 8, write_agcglobals_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 {RX_IL_2_AGC_MAX, 121, write_il2agc_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 {RX_IL_2_AGC_PWR, 121, write_il2agc_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 {RX_IL_2_AGC_AV, 121, write_il2agc_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 {TX_LEVELS, 128, write_tx_levels_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 {TX_CAL_CHAN, 128, write_tx_calchan_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 {TX_CAL_TEMP, 40, write_tx_caltemp_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 {RX_CAL_CHAN, 40, write_rx_calchan_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 {RX_CAL_TEMP, 44, write_rx_caltemp_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 {RX_AGC_PARAMS, 8, write_rx_agcparams_table}, |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 {0, 0, 0} |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 }; |
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 cmd_rftr(argc, argv) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 char **argv; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 u16 index; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 struct table_map *tp; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 u_char table_data[MAX_RF_TABLE_SIZE]; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 int rc; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 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
|
196 return(ERROR_USAGE); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 for (tp = table_map; tp->index; tp++) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 if (tp->index == index) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 break; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 } |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 if (!tp->index) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 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
|
203 index); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 return(ERROR_USAGE); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 } |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 rc = do_rftr(index, table_data, tp->size); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 if (rc) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 return(rc); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 tp->func(table_data, stdout); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 return(0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 } |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 cmd_ttr(argc, argv) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 char **argv; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 unsigned index; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 u_char ramp_data[32]; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 int rc; |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 index = strtoul(argv[1], 0, 0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 if (index >= 16) { |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 printf("error: index out of range\n"); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 return(ERROR_USAGE); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 } |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 rc = do_ttr(index, ramp_data); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 if (rc) |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 return(rc); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 write_tx_ramp(ramp_data, stdout); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 return(0); |
18a8fb3d845b
fc-tmsync: user command wrappers implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 } |