From ac7c48b4dee99d4c772f133d70d8d1b38262fcd2 Mon Sep 17 00:00:00 2001 From: Author Name Date: Fri, 7 Jul 2023 12:20:59 +0930 Subject: shallow zip-file copy from codec2 e9d726bf20 --- src/fsk_get_test_bits.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 src/fsk_get_test_bits.c (limited to 'src/fsk_get_test_bits.c') diff --git a/src/fsk_get_test_bits.c b/src/fsk_get_test_bits.c new file mode 100644 index 0000000..937ccf0 --- /dev/null +++ b/src/fsk_get_test_bits.c @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: fsk_get_test_bits.c + AUTHOR......: Brady O'Brien + DATE CREATED: January 2016 + + Generates a pseudorandom sequence of bits for testing of fsk_mod and fsk_demod + +\*---------------------------------------------------------------------------*/ + + +/* + Copyright (C) 2016 David Rowe + + All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License version 2.1, as + published by the Free Software Foundation. This program is + distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this program; if not, see . +*/ + + +#include +#include +#include +#include "fsk.h" + +#define TEST_FRAME_SIZE 100 /* arbitrary choice, repeats after this + many bits, sets frame size for rx + processing */ + +int main(int argc,char *argv[]){ + int bitcnt, framecnt; + int framesize = TEST_FRAME_SIZE; + int i; + FILE *fout; + uint8_t *bitbuf; + + if(argc < 3){ + fprintf(stderr,"usage: %s OutputBitsOnePerByte numBits [framesize]\n",argv[0]); + exit(1); + } + + if (argc == 4){ + framesize = atoi(argv[3]); + fprintf(stderr, "Using custom frame size of %d bits\n", framesize); + } + + /* Extract parameters */ + bitcnt = atoi(argv[2]); + framecnt = bitcnt/framesize; + if (framecnt == 0) { + fprintf(stderr,"Need a minimum of %d bits\n", framesize); + exit(1); + } + + if(strcmp(argv[1],"-")==0){ + fout = stdout; + }else{ + fout = fopen(argv[1],"w"); + } + + if(fout==NULL){ + fprintf(stderr,"Couldn't open output file: %s\n", argv[1]); + exit(1); + } + + /* allocate buffers for processing */ + bitbuf = (uint8_t*)malloc(sizeof(uint8_t)*framesize); + + /* Generate buffer of test frame bits from known seed */ + srand(158324); + for(i=0; i