comparison 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
comparison
equal deleted inserted replaced
297:b1ac1bd1dbbf 298:734b38f634db
6 * tables (Rx agcparams and Tx levels) and writes these tables out in either 6 * tables (Rx agcparams and Tx levels) and writes these tables out in either
7 * FreeCalypso ASCII or FFS binary format. 7 * FreeCalypso ASCII or FFS binary format.
8 */ 8 */
9 9
10 #include <sys/types.h> 10 #include <sys/types.h>
11 #include <sys/param.h>
11 #include <sys/file.h> 12 #include <sys/file.h>
12 #include <string.h> 13 #include <string.h>
13 #include <strings.h> 14 #include <strings.h>
14 #include <stdio.h> 15 #include <stdio.h>
15 #include <stdlib.h> 16 #include <stdlib.h>
63 exit(1); 64 exit(1);
64 } 65 }
65 close(fd); 66 close(fd);
66 } 67 }
67 68
69 write_rx_agcparams_ascii(band, table)
70 struct band *band;
71 u_char *table;
72 {
73 char pathname[MAXPATHLEN];
74 FILE *of;
75
76 sprintf(pathname, "%s/rx-agcparams.%s", ascii_output_dir, band->name);
77 of = fopen(pathname, "w");
78 if (!of) {
79 perror(pathname);
80 exit(1);
81 }
82 write_rx_agcparams_table(table, of);
83 fclose(of);
84 }
85
86 write_rx_agcparams_bin(band, table)
87 struct band *band;
88 u_char *table;
89 {
90 char pathname[MAXPATHLEN];
91 int fd;
92
93 sprintf(pathname, "%s/rx", bin_output_dir);
94 mkdir_existok(pathname);
95 sprintf(pathname, "%s/rx/agcparams.%s", bin_output_dir, band->name);
96 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
97 if (fd < 0) {
98 perror(pathname);
99 exit(1);
100 }
101 write(fd, table, 8);
102 close(fd);
103 }
104
105 write_tx_levels_ascii(band, table)
106 struct band *band;
107 u_char *table;
108 {
109 char pathname[MAXPATHLEN];
110 FILE *of;
111
112 sprintf(pathname, "%s/tx-levels.%s", ascii_output_dir, band->name);
113 of = fopen(pathname, "w");
114 if (!of) {
115 perror(pathname);
116 exit(1);
117 }
118 write_tx_levels_table(table, of);
119 fclose(of);
120 }
121
122 write_tx_levels_bin(band, table)
123 struct band *band;
124 u_char *table;
125 {
126 char pathname[MAXPATHLEN];
127 int fd;
128
129 sprintf(pathname, "%s/tx", bin_output_dir);
130 mkdir_existok(pathname);
131 sprintf(pathname, "%s/tx/levels.%s", bin_output_dir, band->name);
132 fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
133 if (fd < 0) {
134 perror(pathname);
135 exit(1);
136 }
137 write(fd, table, 128);
138 close(fd);
139 }
140
68 do_rx_agcparams(band, compal_data) 141 do_rx_agcparams(band, compal_data)
69 struct band *band; 142 struct band *band;
70 u_char *compal_data; 143 u_char *compal_data;
71 { 144 {
72 u_char rx_agcparams_table[8]; 145 u_char rx_agcparams_table[8];
77 rx_agcparams_table[3] = 0; 150 rx_agcparams_table[3] = 0;
78 rx_agcparams_table[4] = 40; 151 rx_agcparams_table[4] = 40;
79 rx_agcparams_table[5] = 0; 152 rx_agcparams_table[5] = 0;
80 rx_agcparams_table[6] = 44; 153 rx_agcparams_table[6] = 44;
81 rx_agcparams_table[7] = 0; 154 rx_agcparams_table[7] = 0;
82 /* ASCII and binary write-out to be implemented */ 155 if (ascii_output_dir)
156 write_rx_agcparams_ascii(band, rx_agcparams_table);
157 if (bin_output_dir)
158 write_rx_agcparams_bin(band, rx_agcparams_table);
83 } 159 }
84 160
85 do_tx_levels(band, compal_data) 161 do_tx_levels(band, compal_data)
86 struct band *band; 162 struct band *band;
87 u_char *compal_data; 163 u_char *compal_data;
97 *dp++ = *sp++; 173 *dp++ = *sp++;
98 *dp++ = *sp++; 174 *dp++ = *sp++;
99 *dp++ = n; 175 *dp++ = n;
100 *dp++ = 0; 176 *dp++ = 0;
101 } 177 }
102 /* ASCII and binary write-out to be implemented */ 178 if (ascii_output_dir)
179 write_tx_levels_ascii(band, tx_levels_table);
180 if (bin_output_dir)
181 write_tx_levels_bin(band, tx_levels_table);
103 } 182 }
104 183
105 process_band_record(band, offset) 184 process_band_record(band, offset)
106 struct band *band; 185 struct band *band;
107 unsigned offset; 186 unsigned offset;