comparison rvinterf/tmsh/saverftab.c @ 139:b5e3899b1265

fc-tmsh: save-rf-table command implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 26 Feb 2017 23:13:52 +0000
parents
children e6c265bf5a6d
comparison
equal deleted inserted replaced
138:3803f838e1f3 139:b5e3899b1265
1 /*
2 * Here we implement fc-tmsh operator commands which save the RF table data
3 * received via rftr and ttr commands into files.
4 */
5
6 #include <sys/types.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <strings.h>
10 #include <stdlib.h>
11 #include "l1tm.h"
12 #include "exitcodes.h"
13
14 extern unsigned rftr_table_index, rftr_table_size;
15 extern u_char rftr_table_data[];
16 extern u_char ttr_ramp_data[];
17
18 extern void write_afcparams_table();
19 extern void write_agcwords_table();
20 extern void write_agcglobals_table();
21 extern void write_il2agc_table();
22 extern void write_tx_levels_table();
23 extern void write_tx_calchan_table();
24 extern void write_tx_caltemp_table();
25 extern void write_rx_calchan_table();
26 extern void write_rx_caltemp_table();
27 extern void write_rx_agcparams_table();
28
29 static struct table_map {
30 int index;
31 int size;
32 void (*func)();
33 } table_map[] = {
34 {RX_AGC_TABLE, 40, write_agcwords_table},
35 {AFC_PARAMS, 24, write_afcparams_table},
36 {RX_AGC_GLOBAL_PARAMS, 8, write_agcglobals_table},
37 {RX_IL_2_AGC_MAX, 121, write_il2agc_table},
38 {RX_IL_2_AGC_PWR, 121, write_il2agc_table},
39 {RX_IL_2_AGC_AV, 121, write_il2agc_table},
40 {TX_LEVELS, 128, write_tx_levels_table},
41 {TX_CAL_CHAN, 128, write_tx_calchan_table},
42 {TX_CAL_TEMP, 40, write_tx_caltemp_table},
43 {RX_CAL_CHAN, 40, write_rx_calchan_table},
44 {RX_CAL_TEMP, 44, write_rx_caltemp_table},
45 {RX_AGC_PARAMS, 8, write_rx_agcparams_table},
46 {0, 0, 0}
47 };
48
49 cmd_save_rf_table(argc, argv)
50 char **argv;
51 {
52 struct table_map *tp;
53 FILE *outf;
54
55 if (!rftr_table_size) {
56 printf("error: no RF table has been received\n");
57 return(ERROR_TARGET);
58 }
59 for (tp = table_map; tp->index; tp++) {
60 if (tp->index == rftr_table_index)
61 break;
62 }
63 if (!tp->index) {
64 printf("error: received table index %u not known\n",
65 rftr_table_index);
66 return(ERROR_TARGET);
67 }
68 if (rftr_table_size != tp->size &&
69 (rftr_table_index != RX_AGC_PARAMS || rftr_table_size != 10)) {
70 printf("error: received table index and size don't match\n");
71 return(ERROR_TARGET);
72 }
73 outf = fopen(argv[1], "w");
74 if (!outf) {
75 perror(argv[1]);
76 return(ERROR_UNIX);
77 }
78 tp->func(rftr_table_data, outf);
79 fclose(outf);
80 return(0);
81 }