annotate librftab/rftablerd.c @ 627:d04502de49ed

CHANGES: mokosrec2bin default fill byte change documented
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 28 Feb 2020 06:07:19 +0000
parents a0f79bba0ad8
children 059649902c7f
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 read_agc_table()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 for (i = 0; i < 20; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 read_afcparams()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 rc = process_number(4);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 return(rc);
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 return ensure_eof();
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 read_agc_global_params()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 return(rc);
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 return ensure_eof();
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 read_il2agc()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 for (i = 0; i < 121; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 rc = process_number(1);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 return ensure_eof();
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 static
283
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
159 read_tx_ramps()
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
160 {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
161 int i, j, rc;
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
162
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
163 if (maxsize < 512) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
164 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
165 return(ERROR_USAGE);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
166 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
167 for (i = 0; i < 16; i++) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
168 rc = expect_keyword("ramp-up");
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
169 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
170 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
171 for (j = 0; j < 16; j++) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
172 rc = process_number(1);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
173 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
174 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
175 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
176 rc = expect_keyword("ramp-down");
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
177 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
178 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
179 for (j = 0; j < 16; j++) {
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
180 rc = process_number(1);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
181 if (rc)
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
182 return(rc);
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
183 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
184 }
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
185 return ensure_eof();
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
186 }
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 static
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 read_tx_levels()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 for (i = 0; i < 32; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 rc = process_number(1);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 rc = process_number(1);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 read_tx_calchan()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 for (i = 0; i < 64; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 return ensure_eof();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 read_tx_caltemp()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 for (i = 0; i < 20; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 return ensure_eof();
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
233 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
234 read_rx_calchan()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
235 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
236 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
237
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
238 for (i = 0; i < 20; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
239 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
240 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
241 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
242 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
243 return ensure_eof();
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
246 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
247 read_rx_caltemp()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
248 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
249 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
250
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
251 for (i = 0; i < 22; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
252 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
256 return ensure_eof();
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
259 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
260 read_rx_agc_params()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
261 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
262 int i, rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
263
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
264 for (i = 0; i < 4; i++) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
265 rc = process_number(2);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
266 if (rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
267 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
268 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
269 return ensure_eof();
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
272 static
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
273 read_raw_table()
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
274 {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
275 int rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
276 char *field;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
277 u_long number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
278
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
279 for (;;) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
280 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
281 if (rc < 0)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
282 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
283 if (!rc)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 break;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285 number = strtoul(field, 0, 16);
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
286 if (written_size >= maxsize) {
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
287 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
288 filename);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
289 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
290 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
291 *writeptr++ = number;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
292 written_size++;
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 if (!written_size) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
295 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
296 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
297 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
298 return(0);
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
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
301 static struct table_format {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
302 char *kw;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
303 int (*handler)();
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
304 } table_formats[] = {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
305 {"agc-table", read_agc_table},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
306 {"afcparams", read_afcparams},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
307 {"agc-global-params", read_agc_global_params},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
308 {"il2agc", read_il2agc},
283
64bb50fc470f librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
309 {"tx-ramps", read_tx_ramps},
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
310 {"tx-levels", read_tx_levels},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
311 {"tx-calchan", read_tx_calchan},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
312 {"tx-caltemp", read_tx_caltemp},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
313 {"rx-calchan", read_rx_calchan},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
314 {"rx-caltemp", read_rx_caltemp},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
315 {"rx-agc-params", read_rx_agc_params},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
316 {"raw", read_raw_table},
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
317 {0, 0}
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
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
320 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
321 char *filename_arg;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
322 u_char *rdbuf;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
323 char **format_ret;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
324 unsigned *size_ret;
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 char *field;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
327 int rc;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
328 struct table_format *tp;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
329
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
330 filename = filename_arg;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
331 rdfile = fopen(filename, "r");
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
332 if (!rdfile) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
333 perror(filename);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
334 return(ERROR_UNIX);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
335 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
336 lineno = 0;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
337 line_nfields = 0;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
338 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
339 if (rc <= 0) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
340 not_valid_rftable:
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
341 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
342 fclose(rdfile);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
343 return(ERROR_USAGE);
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 if (strcmp(field, "rf_table"))
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
346 goto not_valid_rftable;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
347 rc = get_field(&field);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
348 if (rc <= 0)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
349 goto not_valid_rftable;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
350 for (tp = table_formats; tp->kw; tp++)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
351 if (!strcmp(tp->kw, field))
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
352 break;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
353 if (!tp->kw) {
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
354 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
355 fclose(rdfile);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
356 return(ERROR_USAGE);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 }
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 format = tp->kw;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 if (format_ret)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 *format_ret = format;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 writeptr = rdbuf;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 written_size = 0;
281
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
363 if (allow_large)
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
364 maxsize = 512;
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
365 else
feb2ee302d25 librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents: 280
diff changeset
366 maxsize = 128;
121
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 rc = tp->handler();
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 if (size_ret)
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370 *size_ret = written_size;
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
371 return(rc);
4070847293a9 fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
372 }