annotate rvinterf/tmsh/saverftab.c @ 220:5c78f132547c

rvinterf/include/exitcodes.h: added ERROR_RFTEST for use by autocal tools
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 20 May 2017 19:57:49 +0000
parents 6b01d4ef85c3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
139
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * Here we implement fc-tmsh operator commands which save the RF table data
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * received via rftr and ttr commands into files.
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <strings.h>
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "l1tm.h"
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "exitcodes.h"
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 extern unsigned rftr_table_index, rftr_table_size;
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern u_char rftr_table_data[];
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern u_char ttr_ramp_data[];
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 extern void write_afcparams_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 extern void write_agcwords_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 extern void write_agcglobals_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 extern void write_il2agc_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 extern void write_tx_levels_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 extern void write_tx_calchan_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 extern void write_tx_caltemp_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 extern void write_rx_calchan_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 extern void write_rx_caltemp_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 extern void write_rx_agcparams_table();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 static struct table_map {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 int index;
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 int size;
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 void (*func)();
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 } table_map[] = {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 {RX_AGC_TABLE, 40, write_agcwords_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 {AFC_PARAMS, 24, write_afcparams_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 {RX_AGC_GLOBAL_PARAMS, 8, write_agcglobals_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 {RX_IL_2_AGC_MAX, 121, write_il2agc_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 {RX_IL_2_AGC_PWR, 121, write_il2agc_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 {RX_IL_2_AGC_AV, 121, write_il2agc_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 {TX_LEVELS, 128, write_tx_levels_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 {TX_CAL_CHAN, 128, write_tx_calchan_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 {TX_CAL_TEMP, 40, write_tx_caltemp_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 {RX_CAL_CHAN, 40, write_rx_calchan_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 {RX_CAL_TEMP, 44, write_rx_caltemp_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 {RX_AGC_PARAMS, 8, write_rx_agcparams_table},
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 {0, 0, 0}
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 };
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 cmd_save_rf_table(argc, argv)
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 char **argv;
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 struct table_map *tp;
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 FILE *outf;
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 if (!rftr_table_size) {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 printf("error: no RF table has been received\n");
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 return(ERROR_TARGET);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 }
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 for (tp = table_map; tp->index; tp++) {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if (tp->index == rftr_table_index)
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 break;
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 if (!tp->index) {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 printf("error: received table index %u not known\n",
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 rftr_table_index);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 return(ERROR_TARGET);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 if (rftr_table_size != tp->size &&
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 (rftr_table_index != RX_AGC_PARAMS || rftr_table_size != 10)) {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 printf("error: received table index and size don't match\n");
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 return(ERROR_TARGET);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 }
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 outf = fopen(argv[1], "w");
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 if (!outf) {
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 perror(argv[1]);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 return(ERROR_UNIX);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 tp->func(rftr_table_data, outf);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 fclose(outf);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 return(0);
b5e3899b1265 fc-tmsh: save-rf-table command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 }
140
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
82
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
83 cmd_save_rf_table_raw(argc, argv)
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
84 char **argv;
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
85 {
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
86 FILE *outf;
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
87 int off, l, j;
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
88
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
89 if (!rftr_table_size) {
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
90 printf("error: no RF table has been received\n");
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
91 return(ERROR_TARGET);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
92 }
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
93 outf = fopen(argv[1], "w");
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
94 if (!outf) {
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
95 perror(argv[1]);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
96 return(ERROR_UNIX);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
97 }
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
98 fputs("rf_table raw\n\n", outf);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
99 for (off = 0; off < rftr_table_size; ) {
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
100 l = rftr_table_size - off;
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
101 if (l > 16)
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
102 l = 16;
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
103 for (j = 0; j < l; j++) {
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
104 if (j)
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
105 putc(' ', outf);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
106 if (j == 8)
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
107 putc(' ', outf);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
108 fprintf(outf, "%02X", rftr_table_data[off++]);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
109 }
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
110 putc('\n', outf);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
111 }
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
112 fclose(outf);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
113 return(0);
e6c265bf5a6d fc-tmsh: save-rf-table-raw command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 139
diff changeset
114 }
141
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
115
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
116 cmd_save_tx_ramp(argc, argv)
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
117 char **argv;
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
118 {
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
119 FILE *outf;
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
120
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
121 outf = fopen(argv[1], "w");
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
122 if (!outf) {
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
123 perror(argv[1]);
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
124 return(ERROR_UNIX);
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
125 }
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
126 write_tx_ramp(ttr_ramp_data, outf);
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
127 fclose(outf);
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
128 return(0);
6b01d4ef85c3 fc-tmsh: save-tx-ramp command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 140
diff changeset
129 }