annotate librftab/rftablerd.c @ 1011:6d9b10633f10 default tip

etmsync Pirelli IMEI retrieval: fix poor use of printf() Bug reported by Vadim Yanitskiy <fixeria@osmocom.org>: the construct where a static-allocated string was passed to printf() without any format arguments causes newer compilers to report a security problem. Given that formatted output is not needed here, just fixed string output, change printf() to fputs(), and direct the error message to stderr while at it.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 23 May 2024 17:29:57 +0000
parents 059649902c7f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
2 * Reading RF tables from formatted ASCII files: used for the rftw command
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
3 * in fc-tmsh, for the upload-rf-table command in fc-fsio, and in the
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
4 * standalone fc-cal2bin utility.
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <ctype.h>
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdlib.h>
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
13 #include "../rvinterf/include/exitcodes.h"
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
314
a0f79bba0ad8 librftab: reading of Tx ramp template files split from rftablerd module
Mychaela Falconia <falcon@freecalypso.org>
parents: 283
diff changeset
15 #include "rdcommon.c"
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static char *format;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 static u_char *writeptr;
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
19 static unsigned written_size, maxsize;
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 process_number(size)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 char *field;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 int rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 u_long number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (rc < 0)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (!rc) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 printf("error: %s is too short for table format %s\n",
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 filename, format);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 if (field[0] == '-')
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 number = strtol(field, 0, 0);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 else
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 number = strtoul(field, 0, 0);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 switch (size) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 case 1:
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 *writeptr++ = number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 break;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 case 2:
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 *writeptr++ = number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 *writeptr++ = number >> 8;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 break;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 case 4:
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 *writeptr++ = number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 *writeptr++ = number >> 8;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 *writeptr++ = number >> 16;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 *writeptr++ = number >> 24;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 break;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 default:
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 abort();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 written_size += size;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 return(0);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 static
283
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
62 expect_keyword(kw)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
63 char *kw;
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
64 {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
65 char *field;
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
66 int rc;
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
67
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
68 rc = get_field(&field);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
69 if (rc < 0)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
70 return(ERROR_USAGE);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
71 if (!rc) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
72 printf("error: %s is too short for table format %s\n",
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
73 filename, format);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
74 return(ERROR_USAGE);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
75 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
76 if (strcmp(field, kw)) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
77 printf("%s line %d: expected %s keyword\n", filename, lineno,
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
78 kw);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
79 return(ERROR_USAGE);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
80 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
81 return(0);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
82 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
83
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
84 static
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 ensure_eof()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 char *field;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 int rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 if (rc < 0)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 if (rc) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 printf("error: %s is too long for table format %s\n",
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 filename, format);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 return(0);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 static
721
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
102 read_adccal_table()
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
103 {
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
104 u_char tmpbuf[36], *finalbuf;
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
105 int i, rc;
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
106
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
107 finalbuf = writeptr;
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
108 writeptr = tmpbuf;
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
109 for (i = 0; i < 18; i++) {
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
110 rc = process_number(2);
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
111 if (rc)
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
112 return(rc);
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
113 }
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
114 writeptr = finalbuf;
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
115 for (i = 0; i < 9; i++) {
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
116 *writeptr++ = tmpbuf[i*4];
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
117 *writeptr++ = tmpbuf[i*4 + 1];
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
118 }
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
119 for (i = 0; i < 9; i++) {
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
120 *writeptr++ = tmpbuf[i*4 + 2];
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
121 *writeptr++ = tmpbuf[i*4 + 3];
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
122 }
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
123 return ensure_eof();
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
124 }
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
125
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
126 static
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 read_agc_table()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 for (i = 0; i < 20; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 read_afcparams()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 rc = process_number(4);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 read_agc_global_params()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 read_il2agc()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 for (i = 0; i < 121; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 rc = process_number(1);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 static
283
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
184 read_tx_ramps()
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
185 {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
186 int i, j, rc;
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
187
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
188 if (maxsize < 512) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
189 printf("error: tx-ramps table not allowed in this context\n");
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
190 return(ERROR_USAGE);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
191 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
192 for (i = 0; i < 16; i++) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
193 rc = expect_keyword("ramp-up");
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
194 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
195 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
196 for (j = 0; j < 16; j++) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
197 rc = process_number(1);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
198 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
199 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
200 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
201 rc = expect_keyword("ramp-down");
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
202 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
203 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
204 for (j = 0; j < 16; j++) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
205 rc = process_number(1);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
206 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
207 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
208 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
209 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
210 return ensure_eof();
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
211 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
212
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
213 static
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 read_tx_levels()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 for (i = 0; i < 32; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 rc = process_number(1);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 rc = process_number(1);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
232 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 read_tx_calchan()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237 for (i = 0; i < 64; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
244
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
245 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 read_tx_caltemp()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250 for (i = 0; i < 20; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
257
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
258 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 read_rx_calchan()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263 for (i = 0; i < 20; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
270
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
271 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 read_rx_caltemp()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 for (i = 0; i < 22; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 read_rx_agc_params()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
286 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
288
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
293 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
294 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
296
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 read_raw_table()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
299 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
300 int rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 char *field;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 u_long number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 for (;;) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 if (rc < 0)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 if (!rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
309 break;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 number = strtoul(field, 0, 16);
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
311 if (written_size >= maxsize) {
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 printf("error: raw table %s exceeds maximum size\n",
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 filename);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 *writeptr++ = number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 written_size++;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
318 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
319 if (!written_size) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
320 printf("error: raw table %s is empty\n", filename);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
321 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 return(0);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
325
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
326 static struct table_format {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 char *kw;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 int (*handler)();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329 } table_formats[] = {
721
059649902c7f librftab: added support for adc-cal tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 314
diff changeset
330 {"adc-cal", read_adccal_table},
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 {"agc-table", read_agc_table},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 {"afcparams", read_afcparams},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 {"agc-global-params", read_agc_global_params},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 {"il2agc", read_il2agc},
283
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
335 {"tx-ramps", read_tx_ramps},
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 {"tx-levels", read_tx_levels},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 {"tx-calchan", read_tx_calchan},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 {"tx-caltemp", read_tx_caltemp},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 {"rx-calchan", read_rx_calchan},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 {"rx-caltemp", read_rx_caltemp},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 {"rx-agc-params", read_rx_agc_params},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
342 {"raw", read_raw_table},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 {0, 0}
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
344 };
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
345
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
346 read_rf_table_ext(filename_arg, rdbuf, allow_large, format_ret, size_ret)
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 char *filename_arg;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 u_char *rdbuf;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 char **format_ret;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 unsigned *size_ret;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 char *field;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 int rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 struct table_format *tp;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
355
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 filename = filename_arg;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 rdfile = fopen(filename, "r");
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 if (!rdfile) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 perror(filename);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 return(ERROR_UNIX);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 lineno = 0;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 line_nfields = 0;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 if (rc <= 0) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 not_valid_rftable:
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 printf("error: %s is not a valid RF table file\n", filename);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
368 fclose(rdfile);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 if (strcmp(field, "rf_table"))
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 goto not_valid_rftable;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
373 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
374 if (rc <= 0)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
375 goto not_valid_rftable;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
376 for (tp = table_formats; tp->kw; tp++)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
377 if (!strcmp(tp->kw, field))
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
378 break;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
379 if (!tp->kw) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
380 printf("error: table format \"%s\" not recognized\n", field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
381 fclose(rdfile);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
382 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
383 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
384 format = tp->kw;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
385 if (format_ret)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
386 *format_ret = format;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
387 writeptr = rdbuf;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
388 written_size = 0;
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
389 if (allow_large)
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
390 maxsize = 512;
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
391 else
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
392 maxsize = 128;
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
393 rc = tp->handler();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
394 fclose(rdfile);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
395 if (size_ret)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
396 *size_ret = written_size;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
397 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
398 }