# HG changeset patch # User Mychaela Falconia # Date 1639862121 0 # Node ID e5ef798e2d352fa984d6a4504c66d5881d86e0a7 # Parent a684dd7799f88f907ca6e9f3864d21432432e675 fc-add-ramps new program written, compiles diff -r a684dd7799f8 -r e5ef798e2d35 .hgignore --- 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$ diff -r a684dd7799f8 -r e5ef798e2d35 ffstools/caltools/Makefile --- 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} diff -r a684dd7799f8 -r e5ef798e2d35 ffstools/caltools/fc-add-ramps.c --- /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 +#include +#include +#include +#include + +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); +}