From: drowe67 Date: Sun, 25 Mar 2018 10:11:04 +0000 (+0000) Subject: first pass working ofdm demod cmd line program X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=256177284b9b3300880ff5460b74f7933b858b45;p=freetel-svn-tracking.git first pass working ofdm demod cmd line program git-svn-id: https://svn.code.sf.net/p/freetel/code@3435 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/ofdm_demod.c b/codec2-dev/src/ofdm_demod.c new file mode 100644 index 00000000..3bb5ceeb --- /dev/null +++ b/codec2-dev/src/ofdm_demod.c @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: ofdm_demod.c + AUTHOR......: David Rowe + DATE CREATED: Mar 2018 + + Given an input file of raw file (8kHz, 16 bit shorts) of OFDM modem + samples. Optionally outputs one char per bit (hard decision), or + soft decision rx_np and rx_amp QPSK symbols information for LDPC decoder. + +\*---------------------------------------------------------------------------*/ + +/* + Copyright (C) 2015 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 "octave.h" +#include "test_bits_ofdm.h" + +#define ASCALE (2E5*1.1491/2.0) /* scale from shorts back to floats */ +#define NFRAMES 100 /* just log the first 100 frames */ + +int opt_exists(char *argv[], int argc, char opt[]) { + int i; + for (i=0; irx_np[i]); + rx_np_log[OFDM_ROWSPERFRAME*OFDM_NC*f + i].imag = cimagf(ofdm->rx_np[i]); + } + + /* note phase/amp ests the same for each col, but check them all anyway */ + + for (i = 0; i < OFDM_ROWSPERFRAME; i++) { + for (j = 0; j < OFDM_NC; j++) { + phase_est_pilot_log[OFDM_ROWSPERFRAME*f+i][j] = ofdm->aphase_est_pilot_log[OFDM_NC*i+j]; + rx_amp_log[OFDM_ROWSPERFRAME*OFDM_NC*f+OFDM_NC*i+j] = ofdm->rx_amp[OFDM_NC*i+j]; + } + } + + foff_hz_log[f] = ofdm->foff_est_hz; + timing_est_log[f] = ofdm->timing_est + 1; /* offset by 1 to match Octave */ + if (f == (logframes-1)) + oct = 0; + } + + /* if this is in a pipeline, we probably don't want the usual + buffering to occur */ + + if (fout == stdout) fflush(stdout); + if (fin == stdin) fflush(stdin); + + f++; + } + + fclose(fin); + fclose(fout); + + /* optionally dump Octave files */ + + if (foct != NULL) { + octave_save_float(foct, "phase_est_pilot_log_c", (float*)phase_est_pilot_log, OFDM_ROWSPERFRAME*NFRAMES, OFDM_NC, OFDM_NC); + octave_save_complex(foct, "rx_np_log_c", (COMP*)rx_np_log, 1, OFDM_ROWSPERFRAME*OFDM_NC*NFRAMES, OFDM_ROWSPERFRAME*OFDM_NC*NFRAMES); + octave_save_float(foct, "rx_amp_log_c", (float*)rx_amp_log, 1, OFDM_ROWSPERFRAME*OFDM_NC*NFRAMES, OFDM_ROWSPERFRAME*OFDM_NC*NFRAMES); + octave_save_float(foct, "foff_hz_log_c", foff_hz_log, NFRAMES, 1, 1); + octave_save_int(foct, "timing_est_log_c", timing_est_log, NFRAMES, 1); + fclose(foct); + } + + ofdm_destroy(ofdm); + + return 0; +} diff --git a/codec2-dev/src/ofdm_put_test_bits.c b/codec2-dev/src/ofdm_put_test_bits.c new file mode 100644 index 00000000..fa3b8ef8 --- /dev/null +++ b/codec2-dev/src/ofdm_put_test_bits.c @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + + FILE........: ofdm_put_test_bits.c + AUTHOR......: David Rowe + DATE CREATED: Mar 2018 + + Slurps up a stream of test bits generated by ofdm_get_test_bits, useful for + testing ofdm_mod and ofdm_demod. + +\*---------------------------------------------------------------------------*/ + +/* + 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 "test_bits_ofdm.h" + +#define LOG_FRAMES 100 + +int opt_exists(char *argv[], int argc, char opt[]) { + int i; + for (i=0; i