FreeCalypso > hg > freecalypso-tools
annotate ffstools/caltools/c1xx-calextr.c @ 818:cf30ebf626bb
CHANGES: BSIM support
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 May 2021 02:31:44 +0000 |
parents | 7de38a7e1fa5 |
children |
rev | line source |
---|---|
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program parses Compal's proprietary data structure that contains |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * the factory RF calibration values among other data, locates those RF |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * calibration records, extracts their essential content (Rx GMagic and |
296
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
5 * Tx APC values), converts this distilled content into TCS211 RF calibration |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
6 * tables (Rx agcparams and Tx levels) and writes these tables out in either |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
7 * FreeCalypso ASCII or FFS binary format. |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 */ |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <sys/types.h> |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
11 #include <sys/param.h> |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <sys/file.h> |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <string.h> |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <strings.h> |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <stdio.h> |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <stdlib.h> |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <unistd.h> |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #define COMPAL_SECTOR_LENGTH 0x2000 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 u_char sector[COMPAL_SECTOR_LENGTH]; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 u_char endmarker[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 u_char record_magic[4] = {0xAA, 0x00, 0x00, 0x00}; |
296
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
24 char *ascii_output_dir, *bin_output_dir; |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
301
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
26 struct rx_calchan_map { |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
27 unsigned upper_bound; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
28 unsigned compal_start; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
29 unsigned compal_num; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
30 }; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
31 |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
32 #define RF_RX_CAL_CHAN_SIZE 10 /* TI/FC canonical version */ |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
33 |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
34 struct rx_calchan_map rx_calchan_map_850[RF_RX_CAL_CHAN_SIZE] = { |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
35 {140, 0, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
36 {152, 2, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
37 {164, 4, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
38 {176, 6, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
39 {188, 8, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
40 {200, 10, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
41 {212, 12, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
42 {224, 14, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
43 {236, 16, 2}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
44 {251, 18, 3} |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
45 }; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
46 |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
47 struct rx_calchan_map rx_calchan_map_900[RF_RX_CAL_CHAN_SIZE] = { |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
48 { 18, 0, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
49 { 36, 3, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
50 { 54, 6, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
51 { 72, 9, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
52 { 90, 12, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
53 { 108, 15, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
54 { 124, 18, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
55 { 987, 21, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
56 {1005, 24, 3}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
57 {1023, 27, 3} |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
58 }; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
59 |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
60 struct rx_calchan_map rx_calchan_map_1800[RF_RX_CAL_CHAN_SIZE] = { |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
61 {548, 0, 6}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
62 {584, 6, 6}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
63 {620, 12, 6}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
64 {656, 18, 6}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
65 {692, 24, 6}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
66 {728, 30, 6}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
67 {764, 36, 6}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
68 {806, 42, 7}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
69 {848, 49, 7}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
70 {885, 56, 7} |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
71 }; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
72 |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
73 struct rx_calchan_map rx_calchan_map_1900[RF_RX_CAL_CHAN_SIZE] = { |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
74 {542, 0, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
75 {572, 5, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
76 {602, 10, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
77 {632, 15, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
78 {662, 20, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
79 {692, 25, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
80 {722, 30, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
81 {752, 35, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
82 {782, 40, 5}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
83 {810, 45, 5} |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
84 }; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
85 |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 struct band { |
301
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
87 char *name; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
88 unsigned compal_record_id; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
89 unsigned record_length; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
90 unsigned magic2_offset; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
91 struct rx_calchan_map *rx_calchan_map; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
92 unsigned start_plnum; |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
93 unsigned end_plnum; |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } bands[] = { |
301
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
95 {"900", 0x00, 0x94, 0x54, rx_calchan_map_900, 5, 19}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
96 {"1800", 0x01, 0xC8, 0x74, rx_calchan_map_1800, 0, 15}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
97 {"1900", 0x02, 0xB4, 0x68, rx_calchan_map_1900, 0, 15}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
98 {"850", 0x18, 0x88, 0x4C, rx_calchan_map_850, 5, 19}, |
31369f326ee3
c1xx-calextr: preparations for Rx calchan conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
299
diff
changeset
|
99 {0, 0, 0, 0, 0, 0, 0} |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 }; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 read_binfile(filename, offset_arg) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 char *filename, *offset_arg; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 int fd, cc; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 u_long offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 char *endp; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 fd = open(filename, O_RDONLY); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 if (fd < 0) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 perror(filename); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 offset = strtoul(offset_arg, &endp, 0); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 if (*endp) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 fprintf(stderr, "error: invalid offset argument \"%s\"\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 offset_arg); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 lseek(fd, offset, SEEK_SET); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 cc = read(fd, sector, COMPAL_SECTOR_LENGTH); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 if (cc != COMPAL_SECTOR_LENGTH) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 "error: unable to read Compal sector of %d bytes from %s at offset %s\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 COMPAL_SECTOR_LENGTH, filename, offset_arg); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 close(fd); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
131 write_rx_agcparams_ascii(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
132 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
133 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
134 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
135 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
136 FILE *of; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
137 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
138 sprintf(pathname, "%s/rx-agcparams.%s", ascii_output_dir, band->name); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
139 of = fopen(pathname, "w"); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
140 if (!of) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
141 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
142 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
143 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
144 write_rx_agcparams_table(table, of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
145 fclose(of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
146 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
147 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
148 write_rx_agcparams_bin(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
149 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
150 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
151 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
152 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
153 int fd; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
154 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
155 sprintf(pathname, "%s/rx", bin_output_dir); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
156 mkdir_existok(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
157 sprintf(pathname, "%s/rx/agcparams.%s", bin_output_dir, band->name); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
158 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
159 if (fd < 0) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
160 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
161 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
162 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
163 write(fd, table, 8); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
164 close(fd); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
165 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
166 |
303
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
167 write_rx_calchan_ascii(band, table) |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
168 struct band *band; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
169 u_char *table; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
170 { |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
171 char pathname[MAXPATHLEN]; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
172 FILE *of; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
173 |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
174 sprintf(pathname, "%s/rx-calchan.%s", ascii_output_dir, band->name); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
175 of = fopen(pathname, "w"); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
176 if (!of) { |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
177 perror(pathname); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
178 exit(1); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
179 } |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
180 write_rx_calchan_table(table, of); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
181 fclose(of); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
182 } |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
183 |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
184 write_rx_calchan_bin(band, table) |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
185 struct band *band; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
186 u_char *table; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
187 { |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
188 char pathname[MAXPATHLEN]; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
189 int fd; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
190 |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
191 sprintf(pathname, "%s/rx", bin_output_dir); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
192 mkdir_existok(pathname); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
193 sprintf(pathname, "%s/rx/calchan.%s", bin_output_dir, band->name); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
194 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
195 if (fd < 0) { |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
196 perror(pathname); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
197 exit(1); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
198 } |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
199 write(fd, table, 40); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
200 close(fd); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
201 } |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
202 |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
203 write_tx_levels_ascii(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
204 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
205 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
206 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
207 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
208 FILE *of; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
209 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
210 sprintf(pathname, "%s/tx-levels.%s", ascii_output_dir, band->name); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
211 of = fopen(pathname, "w"); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
212 if (!of) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
213 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
214 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
215 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
216 write_tx_levels_table(table, of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
217 fclose(of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
218 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
219 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
220 write_tx_levels_bin(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
221 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
222 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
223 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
224 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
225 int fd; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
226 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
227 sprintf(pathname, "%s/tx", bin_output_dir); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
228 mkdir_existok(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
229 sprintf(pathname, "%s/tx/levels.%s", bin_output_dir, band->name); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
230 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
231 if (fd < 0) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
232 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
233 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
234 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
235 write(fd, table, 128); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
236 close(fd); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
237 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
238 |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
239 do_rx_agcparams(band, compal_data) |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
240 struct band *band; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
241 u_char *compal_data; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
242 { |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
243 u_char rx_agcparams_table[8]; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
244 |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
245 bcopy(compal_data, rx_agcparams_table, 2); |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
246 /* the remaining fields are constants unchanged from TI */ |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
247 rx_agcparams_table[2] = 40; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
248 rx_agcparams_table[3] = 0; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
249 rx_agcparams_table[4] = 40; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
250 rx_agcparams_table[5] = 0; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
251 rx_agcparams_table[6] = 44; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
252 rx_agcparams_table[7] = 0; |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
253 if (ascii_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
254 write_rx_agcparams_ascii(band, rx_agcparams_table); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
255 if (bin_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
256 write_rx_agcparams_bin(band, rx_agcparams_table); |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
257 } |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
258 |
303
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
259 do_rx_calchan(band, compal_data) |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
260 struct band *band; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
261 signed char *compal_data; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
262 { |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
263 u_char rx_calchan_table[40], *dp; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
264 struct rx_calchan_map *map; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
265 unsigned i, j; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
266 int accum, average; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
267 |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
268 dp = rx_calchan_table; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
269 for (i = 0; i < RF_RX_CAL_CHAN_SIZE; i++) { |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
270 map = band->rx_calchan_map + i; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
271 *dp++ = map->upper_bound; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
272 *dp++ = map->upper_bound >> 8; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
273 accum = 0; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
274 for (j = 0; j < map->compal_num; j++) |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
275 accum += compal_data[map->compal_start + j]; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
276 average = accum / (int)map->compal_num; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
277 *dp++ = average; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
278 *dp++ = average >> 8; |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
279 } |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
280 if (ascii_output_dir) |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
281 write_rx_calchan_ascii(band, rx_calchan_table); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
282 if (bin_output_dir) |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
283 write_rx_calchan_bin(band, rx_calchan_table); |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
284 } |
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
285 |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
286 do_tx_levels(band, compal_data) |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
287 struct band *band; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
288 u_char *compal_data; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
289 { |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
290 u_char tx_levels_table[128], *sp, *dp; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
291 unsigned num_levels, n; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
292 |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
293 bzero(tx_levels_table, sizeof tx_levels_table); |
299
7fefa4f73c6a
c1xx-calextr: off-by-1 error in the Tx levels table conversion
Mychaela Falconia <falcon@freecalypso.org>
parents:
298
diff
changeset
|
294 num_levels = band->end_plnum - band->start_plnum + 1; |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
295 sp = compal_data; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
296 dp = tx_levels_table + band->start_plnum * 4; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
297 for (n = 0; n < num_levels; n++) { |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
298 *dp++ = *sp++; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
299 *dp++ = *sp++; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
300 *dp++ = n; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
301 *dp++ = 0; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
302 } |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
303 if (ascii_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
304 write_tx_levels_ascii(band, tx_levels_table); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
305 if (bin_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
306 write_tx_levels_bin(band, tx_levels_table); |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
307 } |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
308 |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 process_band_record(band, offset) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 struct band *band; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 unsigned offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 u_char *record; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 record = sector + offset + 8; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 if (bcmp(record, record_magic, 4)) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 printf("bad magic1, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 return(-1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 if (bcmp(record + band->magic2_offset, record_magic, 4)) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 printf("bad magic2, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 return(-1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 if (bcmp(record + band->magic2_offset + 8, record_magic, 4)) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 printf("bad magic3, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 return(-1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 } |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
328 do_rx_agcparams(band, record + 4); |
303
7de38a7e1fa5
c1xx-calextr: Rx calchan conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
301
diff
changeset
|
329 do_rx_calchan(band, record + 6); |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
330 do_tx_levels(band, record + band->magic2_offset + 12); |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 return(0); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 |
296
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
334 process_sector_data() |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 unsigned offset, next_offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 u_char *header; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 unsigned hdr_words[4]; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 struct band *band; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 int i; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 for (offset = 0; ; offset = next_offset) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 if (offset > COMPAL_SECTOR_LENGTH - 12) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 break; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 header = sector + offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 if (!bcmp(header, endmarker, 8)) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 break; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 for (i = 0; i < 4; i++) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 hdr_words[i] = header[i*2] | (header[i*2+1] << 8); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 if (!hdr_words[3]) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 "error at offset 0x%X: rounded record length word is 0\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 if (hdr_words[3] & 3) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 "error at offset 0x%X: rounded record length word is not aligned to 4\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 if (hdr_words[3] > COMPAL_SECTOR_LENGTH - offset - 8) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 "error at offset 0x%X: rounded record length spills past end of sector\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 if (hdr_words[2] > hdr_words[3]) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 "error at offset 0x%X: native record length is greater than rounded\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 next_offset = offset + 8 + hdr_words[3]; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 if (hdr_words[0] != 0x000C) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 continue; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 for (band = bands; band->name; band++) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 if (hdr_words[1] == band->compal_record_id) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 break; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 if (!band->name) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 continue; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 printf("Found %s MHz calibration record at offset 0x%X\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 band->name, offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 if (hdr_words[2] != band->record_length) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 printf("Oops, wrong length, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 continue; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 process_band_record(band, offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 } |
296
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
390 } |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
391 |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
392 main(argc, argv) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
393 char **argv; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
394 { |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
395 int c; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
396 extern char *optarg; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
397 extern int optind; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
398 |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
399 while ((c = getopt(argc, argv, "a:b:")) != EOF) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
400 switch (c) { |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
401 case 'a': |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
402 ascii_output_dir = optarg; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
403 continue; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
404 case 'b': |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
405 bin_output_dir = optarg; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
406 continue; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
407 case '?': |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
408 default: |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
409 usage: fprintf(stderr, |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
410 "usage: %s [-a ascii_outdir] [-b bin_outdir] c1xx-binfile offset\n", |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
411 argv[0]); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
412 exit(1); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
413 } |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
414 if (argc - optind != 2) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
415 goto usage; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
416 read_binfile(argv[optind], argv[optind+1]); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
417 if (ascii_output_dir) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
418 mkdir_existok(ascii_output_dir); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
419 if (bin_output_dir) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
420 mkdir_existok(bin_output_dir); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
421 process_sector_data(); |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 exit(0); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 } |