changeset 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
files ffstools/caltools/c1xx-calextr.c
diffstat 1 files changed, 81 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ffstools/caltools/c1xx-calextr.c	Sat Nov 18 17:45:10 2017 +0000
+++ b/ffstools/caltools/c1xx-calextr.c	Sat Nov 18 17:58:35 2017 +0000
@@ -8,6 +8,7 @@
  */
 
 #include <sys/types.h>
+#include <sys/param.h>
 #include <sys/file.h>
 #include <string.h>
 #include <strings.h>
@@ -65,6 +66,78 @@
 	close(fd);
 }
 
+write_rx_agcparams_ascii(band, table)
+	struct band *band;
+	u_char *table;
+{
+	char pathname[MAXPATHLEN];
+	FILE *of;
+
+	sprintf(pathname, "%s/rx-agcparams.%s", ascii_output_dir, band->name);
+	of = fopen(pathname, "w");
+	if (!of) {
+		perror(pathname);
+		exit(1);
+	}
+	write_rx_agcparams_table(table, of);
+	fclose(of);
+}
+
+write_rx_agcparams_bin(band, table)
+	struct band *band;
+	u_char *table;
+{
+	char pathname[MAXPATHLEN];
+	int fd;
+
+	sprintf(pathname, "%s/rx", bin_output_dir);
+	mkdir_existok(pathname);
+	sprintf(pathname, "%s/rx/agcparams.%s", bin_output_dir, band->name);
+	fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+	if (fd < 0) {
+		perror(pathname);
+		exit(1);
+	}
+	write(fd, table, 8);
+	close(fd);
+}
+
+write_tx_levels_ascii(band, table)
+	struct band *band;
+	u_char *table;
+{
+	char pathname[MAXPATHLEN];
+	FILE *of;
+
+	sprintf(pathname, "%s/tx-levels.%s", ascii_output_dir, band->name);
+	of = fopen(pathname, "w");
+	if (!of) {
+		perror(pathname);
+		exit(1);
+	}
+	write_tx_levels_table(table, of);
+	fclose(of);
+}
+
+write_tx_levels_bin(band, table)
+	struct band *band;
+	u_char *table;
+{
+	char pathname[MAXPATHLEN];
+	int fd;
+
+	sprintf(pathname, "%s/tx", bin_output_dir);
+	mkdir_existok(pathname);
+	sprintf(pathname, "%s/tx/levels.%s", bin_output_dir, band->name);
+	fd = open(pathname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
+	if (fd < 0) {
+		perror(pathname);
+		exit(1);
+	}
+	write(fd, table, 128);
+	close(fd);
+}
+
 do_rx_agcparams(band, compal_data)
 	struct band *band;
 	u_char *compal_data;
@@ -79,7 +152,10 @@
 	rx_agcparams_table[5] = 0;
 	rx_agcparams_table[6] = 44;
 	rx_agcparams_table[7] = 0;
-	/* ASCII and binary write-out to be implemented */
+	if (ascii_output_dir)
+		write_rx_agcparams_ascii(band, rx_agcparams_table);
+	if (bin_output_dir)
+		write_rx_agcparams_bin(band, rx_agcparams_table);
 }
 
 do_tx_levels(band, compal_data)
@@ -99,7 +175,10 @@
 		*dp++ = n;
 		*dp++ = 0;
 	}
-	/* ASCII and binary write-out to be implemented */
+	if (ascii_output_dir)
+		write_tx_levels_ascii(band, tx_levels_table);
+	if (bin_output_dir)
+		write_tx_levels_bin(band, tx_levels_table);
 }
 
 process_band_record(band, offset)