FreeCalypso > hg > freecalypso-tools
comparison ffstools/caltools/c1xx-calextr.c @ 296:77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 Nov 2017 17:30:26 +0000 |
parents | 1416fe200069 |
children | b1ac1bd1dbbf |
comparison
equal
deleted
inserted
replaced
295:79434b9de159 | 296:77d561735b07 |
---|---|
1 /* | 1 /* |
2 * This program parses Compal's proprietary data structure that contains | 2 * This program parses Compal's proprietary data structure that contains |
3 * the factory RF calibration values among other data, locates those RF | 3 * the factory RF calibration values among other data, locates those RF |
4 * calibration records, extracts their essential content (Rx GMagic and | 4 * calibration records, extracts their essential content (Rx GMagic and |
5 * Tx APC values) and writes this calibration out in the form of FreeCalypso | 5 * Tx APC values), converts this distilled content into TCS211 RF calibration |
6 * ASCII RF tables. | 6 * tables (Rx agcparams and Tx levels) and writes these tables out in either |
7 * FreeCalypso ASCII or FFS binary format. | |
7 */ | 8 */ |
8 | 9 |
9 #include <sys/types.h> | 10 #include <sys/types.h> |
10 #include <sys/file.h> | 11 #include <sys/file.h> |
11 #include <string.h> | 12 #include <string.h> |
17 #define COMPAL_SECTOR_LENGTH 0x2000 | 18 #define COMPAL_SECTOR_LENGTH 0x2000 |
18 | 19 |
19 u_char sector[COMPAL_SECTOR_LENGTH]; | 20 u_char sector[COMPAL_SECTOR_LENGTH]; |
20 u_char endmarker[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; | 21 u_char endmarker[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; |
21 u_char record_magic[4] = {0xAA, 0x00, 0x00, 0x00}; | 22 u_char record_magic[4] = {0xAA, 0x00, 0x00, 0x00}; |
23 char *ascii_output_dir, *bin_output_dir; | |
22 | 24 |
23 struct band { | 25 struct band { |
24 char *name; | 26 char *name; |
25 unsigned compal_record_id; | 27 unsigned compal_record_id; |
26 unsigned record_length; | 28 unsigned record_length; |
84 } | 86 } |
85 /* Rx GMagic and Tx levels extraction to be filled */ | 87 /* Rx GMagic and Tx levels extraction to be filled */ |
86 return(0); | 88 return(0); |
87 } | 89 } |
88 | 90 |
89 main(argc, argv) | 91 process_sector_data() |
90 char **argv; | |
91 { | 92 { |
92 unsigned offset, next_offset; | 93 unsigned offset, next_offset; |
93 u_char *header; | 94 u_char *header; |
94 unsigned hdr_words[4]; | 95 unsigned hdr_words[4]; |
95 struct band *band; | 96 struct band *band; |
96 int i; | 97 int i; |
97 | 98 |
98 if (argc != 3) { | |
99 fprintf(stderr, "usage: %s binfile offset\n", argv[0]); | |
100 exit(1); | |
101 } | |
102 read_binfile(argv[1], argv[2]); | |
103 for (offset = 0; ; offset = next_offset) { | 99 for (offset = 0; ; offset = next_offset) { |
104 if (offset > COMPAL_SECTOR_LENGTH - 12) | 100 if (offset > COMPAL_SECTOR_LENGTH - 12) |
105 break; | 101 break; |
106 header = sector + offset; | 102 header = sector + offset; |
107 if (!bcmp(header, endmarker, 8)) | 103 if (!bcmp(header, endmarker, 8)) |
146 printf("Oops, wrong length, skipping\n"); | 142 printf("Oops, wrong length, skipping\n"); |
147 continue; | 143 continue; |
148 } | 144 } |
149 process_band_record(band, offset); | 145 process_band_record(band, offset); |
150 } | 146 } |
147 } | |
148 | |
149 main(argc, argv) | |
150 char **argv; | |
151 { | |
152 int c; | |
153 extern char *optarg; | |
154 extern int optind; | |
155 | |
156 while ((c = getopt(argc, argv, "a:b:")) != EOF) | |
157 switch (c) { | |
158 case 'a': | |
159 ascii_output_dir = optarg; | |
160 continue; | |
161 case 'b': | |
162 bin_output_dir = optarg; | |
163 continue; | |
164 case '?': | |
165 default: | |
166 usage: fprintf(stderr, | |
167 "usage: %s [-a ascii_outdir] [-b bin_outdir] c1xx-binfile offset\n", | |
168 argv[0]); | |
169 exit(1); | |
170 } | |
171 if (argc - optind != 2) | |
172 goto usage; | |
173 read_binfile(argv[optind], argv[optind+1]); | |
174 if (ascii_output_dir) | |
175 mkdir_existok(ascii_output_dir); | |
176 if (bin_output_dir) | |
177 mkdir_existok(bin_output_dir); | |
178 process_sector_data(); | |
151 exit(0); | 179 exit(0); |
152 } | 180 } |