From bc3d2ae4906b22cb7ca9b13cf656d63171b42a8f Mon Sep 17 00:00:00 2001 From: drowe67 Date: Tue, 20 Mar 2018 22:57:49 +0000 Subject: [PATCH] Octave compatable ofdm_get_test_bits.c, and a few minor omment tweaks git-svn-id: https://svn.code.sf.net/p/freetel/code@3423 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/ofdm_rx.m | 4 +- codec2-dev/octave/ofdm_tx.m | 2 +- codec2-dev/src/ofdm_get_test_bits.c | 85 +++++++++++++++++++++++++++++ codec2-dev/src/ofdm_internal.h | 9 +-- 4 files changed, 93 insertions(+), 7 deletions(-) create mode 100644 codec2-dev/src/ofdm_get_test_bits.c diff --git a/codec2-dev/octave/ofdm_rx.m b/codec2-dev/octave/ofdm_rx.m index a04602c5..ba9f3a33 100644 --- a/codec2-dev/octave/ofdm_rx.m +++ b/codec2-dev/octave/ofdm_rx.m @@ -36,7 +36,7 @@ function ofdm_rx(filename, error_pattern_filename) % OK re-generate tx frame for BER calcs - rand('seed', 100); + rand('seed', 1); tx_bits = round(rand(1,Nbitsperframe)); % init logs and BER stats @@ -173,7 +173,7 @@ function ofdm_rx(filename, error_pattern_filename) figure(4); clf; plot(foff_est_hz_log) - mx = max(abs(foff_est_hz_log)); + mx = max(abs(foff_est_hz_log))+1; axis([1 max(Nframes,2) -mx mx]); title('Fine Freq'); ylabel('Hz') diff --git a/codec2-dev/octave/ofdm_tx.m b/codec2-dev/octave/ofdm_tx.m index 3b09d3ab..174743e5 100644 --- a/codec2-dev/octave/ofdm_tx.m +++ b/codec2-dev/octave/ofdm_tx.m @@ -30,7 +30,7 @@ function ofdm_tx(filename, Nsec, EbNodB=100, channel='awgn', freq_offset_Hz=0) Nrows = Nsec*Rs; Nframes = floor((Nrows-1)/Ns); - rand('seed', 100); + rand('seed', 1); tx_bits = round(rand(1,Nbitsperframe)); tx = []; diff --git a/codec2-dev/src/ofdm_get_test_bits.c b/codec2-dev/src/ofdm_get_test_bits.c new file mode 100644 index 00000000..2ee037d1 --- /dev/null +++ b/codec2-dev/src/ofdm_get_test_bits.c @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: ofdm_get_test_bits.c + AUTHOR......: David Rowe + DATE CREATED: Mar 2018 + + Generates frames of test bits, useful for input to ofdm_mod. + +\*---------------------------------------------------------------------------*/ + + +/* + Copyright (C) 2018 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, 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 +#include +#include + +#include "codec2_ofdm.h" +#include "ofdm_internal.h" +#include "test_bits_ofdm.h" + +int main(int argc, char *argv[]) +{ + struct OFDM *ofdm; + FILE *fout; + int Nsec, Nrows, Nframes, i,n; + + if (argc < 2) { + printf("usage: %s OutputOneCharPerBitFile numSecs\n", argv[0]); + exit(1); + } + + if (strcmp(argv[1], "-") == 0) fout = stdout; + else if ( (fout = fopen(argv[1],"wb")) == NULL ) { + fprintf(stderr, "Error opening output file: %s: %s.\n", + argv[1], strerror(errno)); + exit(1); + } + + ofdm = ofdm_create(OFDM_CONFIG_700D); + assert(ofdm != NULL); + int Nbitsperframe = ofdm_get_bits_per_frame(ofdm); + char tx_bits_char[Nbitsperframe]; + ofdm_destroy(ofdm); + + for(i=0; i