comparison ffstools/caltools/c1xx-calextr.c @ 303:7de38a7e1fa5

c1xx-calextr: Rx calchan conversion implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 20 Nov 2017 06:10:54 +0000
parents 31369f326ee3
children
comparison
equal deleted inserted replaced
302:e05563f0dfcf 303:7de38a7e1fa5
162 } 162 }
163 write(fd, table, 8); 163 write(fd, table, 8);
164 close(fd); 164 close(fd);
165 } 165 }
166 166
167 write_rx_calchan_ascii(band, table)
168 struct band *band;
169 u_char *table;
170 {
171 char pathname[MAXPATHLEN];
172 FILE *of;
173
174 sprintf(pathname, "%s/rx-calchan.%s", ascii_output_dir, band->name);
175 of = fopen(pathname, "w");
176 if (!of) {
177 perror(pathname);
178 exit(1);
179 }
180 write_rx_calchan_table(table, of);
181 fclose(of);
182 }
183
184 write_rx_calchan_bin(band, table)
185 struct band *band;
186 u_char *table;
187 {
188 char pathname[MAXPATHLEN];
189 int fd;
190
191 sprintf(pathname, "%s/rx", bin_output_dir);
192 mkdir_existok(pathname);
193 sprintf(pathname, "%s/rx/calchan.%s", bin_output_dir, band->name);
194 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
195 if (fd < 0) {
196 perror(pathname);
197 exit(1);
198 }
199 write(fd, table, 40);
200 close(fd);
201 }
202
167 write_tx_levels_ascii(band, table) 203 write_tx_levels_ascii(band, table)
168 struct band *band; 204 struct band *band;
169 u_char *table; 205 u_char *table;
170 { 206 {
171 char pathname[MAXPATHLEN]; 207 char pathname[MAXPATHLEN];
218 write_rx_agcparams_ascii(band, rx_agcparams_table); 254 write_rx_agcparams_ascii(band, rx_agcparams_table);
219 if (bin_output_dir) 255 if (bin_output_dir)
220 write_rx_agcparams_bin(band, rx_agcparams_table); 256 write_rx_agcparams_bin(band, rx_agcparams_table);
221 } 257 }
222 258
259 do_rx_calchan(band, compal_data)
260 struct band *band;
261 signed char *compal_data;
262 {
263 u_char rx_calchan_table[40], *dp;
264 struct rx_calchan_map *map;
265 unsigned i, j;
266 int accum, average;
267
268 dp = rx_calchan_table;
269 for (i = 0; i < RF_RX_CAL_CHAN_SIZE; i++) {
270 map = band->rx_calchan_map + i;
271 *dp++ = map->upper_bound;
272 *dp++ = map->upper_bound >> 8;
273 accum = 0;
274 for (j = 0; j < map->compal_num; j++)
275 accum += compal_data[map->compal_start + j];
276 average = accum / (int)map->compal_num;
277 *dp++ = average;
278 *dp++ = average >> 8;
279 }
280 if (ascii_output_dir)
281 write_rx_calchan_ascii(band, rx_calchan_table);
282 if (bin_output_dir)
283 write_rx_calchan_bin(band, rx_calchan_table);
284 }
285
223 do_tx_levels(band, compal_data) 286 do_tx_levels(band, compal_data)
224 struct band *band; 287 struct band *band;
225 u_char *compal_data; 288 u_char *compal_data;
226 { 289 {
227 u_char tx_levels_table[128], *sp, *dp; 290 u_char tx_levels_table[128], *sp, *dp;
261 if (bcmp(record + band->magic2_offset + 8, record_magic, 4)) { 324 if (bcmp(record + band->magic2_offset + 8, record_magic, 4)) {
262 printf("bad magic3, skipping\n"); 325 printf("bad magic3, skipping\n");
263 return(-1); 326 return(-1);
264 } 327 }
265 do_rx_agcparams(band, record + 4); 328 do_rx_agcparams(band, record + 4);
329 do_rx_calchan(band, record + 6);
266 do_tx_levels(band, record + band->magic2_offset + 12); 330 do_tx_levels(band, record + band->magic2_offset + 12);
267 return(0); 331 return(0);
268 } 332 }
269 333
270 process_sector_data() 334 process_sector_data()