FreeCalypso > hg > freecalypso-tools
changeset 859:e5ef798e2d35
fc-add-ramps new program written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 Dec 2021 21:15:21 +0000 |
parents | a684dd7799f8 |
children | 7d4f080f66db |
files | .hgignore ffstools/caltools/Makefile ffstools/caltools/fc-add-ramps.c |
diffstat | 3 files changed, 72 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sat Dec 18 21:10:49 2021 +0000 +++ b/.hgignore Sat Dec 18 21:15:21 2021 +0000 @@ -6,6 +6,7 @@ \.srec$ ^ffstools/cal2text/fc-cal2text$ +^ffstools/caltools/fc-add-ramps$ ^ffstools/caltools/c1xx-calextr$ ^ffstools/caltools/fc-bin2rftab$ ^ffstools/caltools/fc-cal2bin$
--- a/ffstools/caltools/Makefile Sat Dec 18 21:10:49 2021 +0000 +++ b/ffstools/caltools/Makefile Sat Dec 18 21:15:21 2021 +0000 @@ -1,6 +1,6 @@ CC= gcc CFLAGS= -O2 -PROGS= c1xx-calextr fc-bin2rftab fc-cal2bin fc-rftab2c +PROGS= c1xx-calextr fc-add-ramps fc-bin2rftab fc-cal2bin fc-rftab2c INSTALL_PREFIX= /opt/freecalypso @@ -10,6 +10,8 @@ LIBRFTAB= ../../librftab/librftab.a +ADDRAMPS_OBJS= fc-add-ramps.o ${LIBRFTAB} + BIN2RFTAB_OBJS= fc-bin2rftab.o ${LIBRFTAB} CAL2BIN_OBJS= fc-cal2bin.o ${LIBRFTAB} @@ -18,6 +20,9 @@ RFTAB2C_OBJS= fc-rftab2c.o ${LIBRFTAB} +fc-add-ramps: ${ADDRAMPS_OBJS} + ${CC} ${CFLAGS} -o $@ ${ADDRAMPS_OBJS} + fc-bin2rftab: ${BIN2RFTAB_OBJS} ${CC} ${CFLAGS} -o $@ ${BIN2RFTAB_OBJS}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ffstools/caltools/fc-add-ramps.c Sat Dec 18 21:15:21 2021 +0000 @@ -0,0 +1,65 @@ +/* + * This utility reads a tx-ramps table in FreeCalypso ASCII format, + * sums up each ramp and reports these sums. The intended purpose is + * to check if all ramps add up to 128 like they are supposed to. + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> + +u_char data[512]; +unsigned sums[32]; + +read_input(filename) + char *filename; +{ + char *format; + + if (read_rf_table_ext(filename, data, 1, &format, (unsigned *) 0)) + exit(1); + if (strcmp(format, "tx-ramps")) { + fprintf(stderr, "error: %s is not a tx-ramps table\n", + filename); + exit(1); + } +} + +compute_sums() +{ + int i, j; + unsigned accum; + u_char *dp = data; + + for (i = 0; i < 32; i++) { + accum = 0; + for (j = 0; j < 16; j++) + accum += *dp++; + sums[i] = accum; + } +} + +output() +{ + unsigned n; + + for (n = 0; n < 16; n++) { + printf("Template #%u ramp-up sum: %u\n", sums[n*2]); + printf("Template #%u ramp-down sum: %u\n", sums[n*2+1]); + } +} + +main(argc, argv) + char **argv; +{ + if (argc != 2) { + fprintf(stderr, "usage: %s tx-ramps-file\n", argv[0]); + exit(1); + } + read_input(argv[1]); + compute_sums(); + output(); + exit(0); +}