FreeCalypso > hg > freecalypso-tools
annotate ffstools/caltools/c1xx-calextr.c @ 298:734b38f634db
c1xx-calextr: output implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 Nov 2017 17:58:35 +0000 |
parents | b1ac1bd1dbbf |
children | 7fefa4f73c6a |
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 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 struct band { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 char *name; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 unsigned compal_record_id; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 unsigned record_length; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 unsigned magic2_offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 unsigned start_plnum; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 unsigned end_plnum; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } bands[] = { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 {"900", 0x00, 0x94, 0x54, 5, 19}, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 {"1800", 0x01, 0xC8, 0x74, 0, 15}, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 {"1900", 0x02, 0xB4, 0x68, 0, 15}, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 {"850", 0x18, 0x88, 0x4C, 5, 19}, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 }; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 read_binfile(filename, offset_arg) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 char *filename, *offset_arg; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 int fd, cc; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 u_long offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 char *endp; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 fd = open(filename, O_RDONLY); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (fd < 0) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 perror(filename); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 offset = strtoul(offset_arg, &endp, 0); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 if (*endp) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 fprintf(stderr, "error: invalid offset argument \"%s\"\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 offset_arg); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 lseek(fd, offset, SEEK_SET); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 cc = read(fd, sector, COMPAL_SECTOR_LENGTH); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 if (cc != COMPAL_SECTOR_LENGTH) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 "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
|
63 COMPAL_SECTOR_LENGTH, filename, offset_arg); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 close(fd); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
69 write_rx_agcparams_ascii(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
70 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
71 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
72 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
73 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
74 FILE *of; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
75 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
76 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
|
77 of = fopen(pathname, "w"); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
78 if (!of) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
79 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
80 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
81 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
82 write_rx_agcparams_table(table, of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
83 fclose(of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
84 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
85 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
86 write_rx_agcparams_bin(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
87 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
88 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
89 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
90 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
91 int fd; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
92 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
93 sprintf(pathname, "%s/rx", bin_output_dir); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
94 mkdir_existok(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
95 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
|
96 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
97 if (fd < 0) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
98 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
99 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
100 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
101 write(fd, table, 8); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
102 close(fd); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
103 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
104 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
105 write_tx_levels_ascii(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
106 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
107 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
108 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
109 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
110 FILE *of; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
111 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
112 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
|
113 of = fopen(pathname, "w"); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
114 if (!of) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
115 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
116 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
117 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
118 write_tx_levels_table(table, of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
119 fclose(of); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
120 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
121 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
122 write_tx_levels_bin(band, table) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
123 struct band *band; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
124 u_char *table; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
125 { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
126 char pathname[MAXPATHLEN]; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
127 int fd; |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
128 |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
129 sprintf(pathname, "%s/tx", bin_output_dir); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
130 mkdir_existok(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
131 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
|
132 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
133 if (fd < 0) { |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
134 perror(pathname); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
135 exit(1); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
136 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
137 write(fd, table, 128); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
138 close(fd); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
139 } |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
140 |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
141 do_rx_agcparams(band, compal_data) |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
142 struct band *band; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
143 u_char *compal_data; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
144 { |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
145 u_char rx_agcparams_table[8]; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
146 |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
147 bcopy(compal_data, rx_agcparams_table, 2); |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
148 /* the remaining fields are constants unchanged from TI */ |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
149 rx_agcparams_table[2] = 40; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
150 rx_agcparams_table[3] = 0; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
151 rx_agcparams_table[4] = 40; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
152 rx_agcparams_table[5] = 0; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
153 rx_agcparams_table[6] = 44; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
154 rx_agcparams_table[7] = 0; |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
155 if (ascii_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
156 write_rx_agcparams_ascii(band, rx_agcparams_table); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
157 if (bin_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
158 write_rx_agcparams_bin(band, rx_agcparams_table); |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
159 } |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
160 |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
161 do_tx_levels(band, compal_data) |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
162 struct band *band; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
163 u_char *compal_data; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
164 { |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
165 u_char tx_levels_table[128], *sp, *dp; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
166 unsigned num_levels, n; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
167 |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
168 bzero(tx_levels_table, sizeof tx_levels_table); |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
169 num_levels = band->end_plnum - band->start_plnum; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
170 sp = compal_data; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
171 dp = tx_levels_table + band->start_plnum * 4; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
172 for (n = 0; n < num_levels; n++) { |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
173 *dp++ = *sp++; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
174 *dp++ = *sp++; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
175 *dp++ = n; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
176 *dp++ = 0; |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
177 } |
298
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
178 if (ascii_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
179 write_tx_levels_ascii(band, tx_levels_table); |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
180 if (bin_output_dir) |
734b38f634db
c1xx-calextr: output implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
297
diff
changeset
|
181 write_tx_levels_bin(band, tx_levels_table); |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
182 } |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
183 |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 process_band_record(band, offset) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 struct band *band; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 unsigned offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 u_char *record; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 record = sector + offset + 8; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 if (bcmp(record, record_magic, 4)) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 printf("bad magic1, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 return(-1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 if (bcmp(record + band->magic2_offset, record_magic, 4)) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 printf("bad magic2, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 return(-1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 if (bcmp(record + band->magic2_offset + 8, record_magic, 4)) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 printf("bad magic3, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 return(-1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 } |
297
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
203 do_rx_agcparams(band, record + 4); |
b1ac1bd1dbbf
c1xx-calextr: table conversion implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
296
diff
changeset
|
204 do_tx_levels(band, record + band->magic2_offset + 12); |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 return(0); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 |
296
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
208 process_sector_data() |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 unsigned offset, next_offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 u_char *header; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 unsigned hdr_words[4]; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 struct band *band; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 int i; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 for (offset = 0; ; offset = next_offset) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 if (offset > COMPAL_SECTOR_LENGTH - 12) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 break; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 header = sector + offset; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 if (!bcmp(header, endmarker, 8)) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 break; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 for (i = 0; i < 4; i++) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 hdr_words[i] = header[i*2] | (header[i*2+1] << 8); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 if (!hdr_words[3]) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 "error at offset 0x%X: rounded record length word is 0\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 if (hdr_words[3] & 3) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 "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
|
233 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 if (hdr_words[3] > COMPAL_SECTOR_LENGTH - offset - 8) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 "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
|
239 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 if (hdr_words[2] > hdr_words[3]) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 fprintf(stderr, |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 "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
|
245 offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 exit(1); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 next_offset = offset + 8 + hdr_words[3]; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 if (hdr_words[0] != 0x000C) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 continue; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 for (band = bands; band->name; band++) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 if (hdr_words[1] == band->compal_record_id) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 break; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 if (!band->name) |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 continue; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 printf("Found %s MHz calibration record at offset 0x%X\n", |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 band->name, offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 if (hdr_words[2] != band->record_length) { |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 printf("Oops, wrong length, skipping\n"); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 continue; |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 } |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 process_band_record(band, offset); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 } |
296
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
264 } |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
265 |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
266 main(argc, argv) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
267 char **argv; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
268 { |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
269 int c; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
270 extern char *optarg; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
271 extern int optind; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
272 |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
273 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
|
274 switch (c) { |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
275 case 'a': |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
276 ascii_output_dir = optarg; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
277 continue; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
278 case 'b': |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
279 bin_output_dir = optarg; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
280 continue; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
281 case '?': |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
282 default: |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
283 usage: fprintf(stderr, |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
284 "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
|
285 argv[0]); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
286 exit(1); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
287 } |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
288 if (argc - optind != 2) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
289 goto usage; |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
290 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
|
291 if (ascii_output_dir) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
292 mkdir_existok(ascii_output_dir); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
293 if (bin_output_dir) |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
294 mkdir_existok(bin_output_dir); |
77d561735b07
c1xx-calextr: preparations for both ASCII and binary output
Mychaela Falconia <falcon@freecalypso.org>
parents:
294
diff
changeset
|
295 process_sector_data(); |
294
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 exit(0); |
1416fe200069
c1xx-calextr started
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 } |