# HG changeset patch # User Mychaela Falconia # Date 1723431977 0 # Node ID 914eeb3ab866efc5ea7758c55dcf042e50fcb239 # Parent 0db059f4632db582439ea30b4227a67d34d9c833 efr-sid OS#6538: generate test frames in hex form diff -r 0db059f4632d -r 914eeb3ab866 .hgignore --- a/.hgignore Mon Aug 12 02:49:28 2024 +0000 +++ b/.hgignore Mon Aug 12 03:06:17 2024 +0000 @@ -2,6 +2,7 @@ \.[oa]$ \.bin$ +\.hex$ \.inc$ \.gsm$ \.gsmx$ @@ -60,3 +61,4 @@ ^ul-test/fr-uplink\. ^utils/gen-hex-c$ +^utils/gen-hex-lines$ diff -r 0db059f4632d -r 914eeb3ab866 Makefile --- a/Makefile Mon Aug 12 02:49:28 2024 +0000 +++ b/Makefile Mon Aug 12 03:06:17 2024 +0000 @@ -4,6 +4,7 @@ all: ${SUBDIR} ae-dec-dhf: ul-test +efr-sid: utils pcma2efr: utils pcmu2efr: utils ringing: utils diff -r 0db059f4632d -r 914eeb3ab866 efr-sid/Makefile --- a/efr-sid/Makefile Mon Aug 12 02:49:28 2024 +0000 +++ b/efr-sid/Makefile Mon Aug 12 03:06:17 2024 +0000 @@ -6,7 +6,8 @@ INPUT= dtx01-frame71.cod OUT1= efr-sid-test.gsmx OUT2= efr-sid-test2.gsmx -OUTPUTS=${OUT1} ${OUT2} +OUT2H= efr-sid-test2.hex +OUTPUTS=${OUT1} ${OUT2} ${OUT2H} all: ${PROGS} ${OUTPUTS} @@ -22,5 +23,8 @@ ${OUT2}: ${PROG2} ${INPUT} ./${PROG2} ${INPUT} $@ +${OUT2H}: ${OUT2} + ../utils/gen-hex-lines ${OUT2} $@ 31 + clean: - rm -f ${PROGS} *.o *.gsmx + rm -f ${PROGS} *.o *.gsmx *.hex diff -r 0db059f4632d -r 914eeb3ab866 utils/Makefile --- a/utils/Makefile Mon Aug 12 02:49:28 2024 +0000 +++ b/utils/Makefile Mon Aug 12 03:06:17 2024 +0000 @@ -1,11 +1,14 @@ CC= gcc CFLAGS= -O2 -PROG= gen-hex-c +PROGS= gen-hex-c gen-hex-lines + +all: ${PROGS} -all: ${PROG} +gen-hex-c: gen-hex-c.c + ${CC} ${CFLAGS} -o $@ $@.c -${PROG}: ${PROG}.c +gen-hex-lines: gen-hex-lines.c ${CC} ${CFLAGS} -o $@ $@.c clean: - rm -f *.o ${PROG} + rm -f *.o ${PROGS} diff -r 0db059f4632d -r 914eeb3ab866 utils/gen-hex-lines.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/utils/gen-hex-lines.c Mon Aug 12 03:06:17 2024 +0000 @@ -0,0 +1,48 @@ +/* + * This program reads an arbitrary binary file and converts it into ASCII hex + * output with a specified number of bytes per line. The intended purpose + * is to convert gsmx files (FR or EFR) into hex files with one frame per line. + */ + +#include +#include + +main(argc, argv) + char **argv; +{ + FILE *inf, *outf; + int c, lcnt, bpl; + + if (argc != 4) { + fprintf(stderr, + "usage: %s input.bin output.hex bytes-per-line\n", + argv[0]); + exit(1); + } + inf = fopen(argv[1], "r"); + if (!inf) { + perror(argv[1]); + exit(1); + } + outf = fopen(argv[2], "w"); + if (!outf) { + perror(argv[2]); + exit(1); + } + bpl = atoi(argv[3]); + lcnt = 0; + for (;;) { + c = getc(inf); + if (c < 0) + break; + fprintf(outf, "%02X", c); + lcnt++; + if (lcnt >= bpl) { + putc('\n', outf); + lcnt = 0; + } + } + if (lcnt) + putc('\n', outf); + exit(0); +}