From: drowe67 Date: Thu, 19 Apr 2018 23:55:49 +0000 (+0000) Subject: reporting iters/pcc during sync, and cohpsk cmd line interface and results re-written... X-Git-Url: http://git.whiteaudio.com/gitweb/?a=commitdiff_plain;h=8ce5bda9485f3be78a6f6039ce67f13291b65002;p=freetel-svn-tracking.git reporting iters/pcc during sync, and cohpsk cmd line interface and results re-written to help test ofdm git-svn-id: https://svn.code.sf.net/p/freetel/code@3511 01035d8c-6547-0410-b346-abe4f91aad63 --- diff --git a/codec2-dev/src/cohpsk_ch.c b/codec2-dev/src/cohpsk_ch.c index 76a5a31d..9ce6ab83 100644 --- a/codec2-dev/src/cohpsk_ch.c +++ b/codec2-dev/src/cohpsk_ch.c @@ -56,15 +56,28 @@ #define PAPR_TARGET 7.0 /* This file gets generated using the function write_noise_file in tcohpsk.m. You have to run - tcohpsk first (any variant) to load the function into Octave, e.g.: + tcohpsk first (any variant) to load the function into Octave, e.g. for Fs=7500Hz: - octave:17> tcohpsk - octave:18> write_noise_file("../raw/fading_samples.float", 7500, 7500*60) + octave:26> cohpsk_ch_fading("../raw/fast_fading_samples.float", 8000, 1.0, 8000*60) + octave:27> cohpsk_ch_fading("../raw/slow_fading_samples.float", 8000, 0.1, 8000*60) + + Note: for Fs=8000Hz operation 7500 Hz is OK - these are just the two path fading complex numbers, + a few % different in fading bandwidth won't matter. */ #define FAST_FADING_FILE_NAME "../../raw/fast_fading_samples.float" #define SLOW_FADING_FILE_NAME "../../raw/slow_fading_samples.float" +int opt_exists(char *argv[], int argc, char opt[]) { + int i; + for (i=0; i 3) { if (strcmp(argv[1], "-") == 0) fin = stdin; else if ( (fin = fopen(argv[1],"rb")) == NULL ) { fprintf(stderr, "Error opening input modem raw file: %s: %s.\n", @@ -104,15 +117,41 @@ int main(int argc, char *argv[]) } NodB = atof(argv[3]); - foff_hz = atof(argv[4]); - fading_en = atoi(argv[5]); - inclip = atof(argv[6]); + + Fs = COHPSK_FS; + if ((arg = opt_exists(argv, argc, "--Fs"))) { + Fs = atoi(argv[arg+1]); + } + + foff_hz = 0.0; + if ((arg = opt_exists(argv, argc, "-f"))) { + foff_hz = atoi(argv[arg+1]); + } + fading_en = 0; + if (opt_exists(argv, argc, "--fast")) { + fading_en = 1; + } + if (opt_exists(argv, argc, "--slow")) { + fading_en = 2; + } + inclip = 1.0; + if ((arg = opt_exists(argv, argc, "--clip"))) { + inclip = atof(argv[arg+1]); + } + ssbfilt_en = 1; + if ((arg = opt_exists(argv, argc, "--ssbfilt"))) { + ssbfilt_en = atof(argv[arg+1]); + } } else { - fprintf(stderr, "usage: %s InputRealModemRawFileFs7500Hz OutputRealModemRawFileFs7500Hz No(dB/Hz) FoffHz Fading[0-none 1-fast 2-slow] InputClip0to1\n", argv[0]); + fprintf(stderr, "usage: %s InputRealModemRawFile OutputRealModemRawFile No(dB/Hz) [--Fs SampleRateHz]" + " [-f FoffHz] [--slow] [--fast] [--clip 0to1] [--ssbfilt 0|1]\n", argv[0]); exit(1); } - fprintf(stderr, "NodB: %4.2f foff: %4.2f Hz fading: %d inclip: %4.2f\n", NodB, foff_hz, fading_en, inclip); + fprintf(stderr, "cohpsk_ch ----------------------------------------------------------------------------------\n"); + fprintf(stderr, "Fs: %d NodB: %4.2f foff: %4.2f Hz fading: %d inclip: %4.2f ssbfilt: %d\n", + Fs, NodB, foff_hz, fading_en, inclip, ssbfilt_en); + fprintf(stderr, "cohpsk_ch ----------------------------------------------------------------------------------\n"); phase_ch.real = 1.0; phase_ch.imag = 0.0; noise_r = 0; @@ -121,7 +160,7 @@ int main(int argc, char *argv[]) /* N = var = NoFs */ No = pow(10.0, NodB/10.0); - variance = COHPSK_FS*No; + variance = Fs*No; tx_pwr = tx_pwr_fade = noise_pwr = 0.0; clipped = 0; @@ -135,19 +174,21 @@ int main(int argc, char *argv[]) if (fading_en == 1) { ffading = fopen(FAST_FADING_FILE_NAME, "rb"); if (ffading == NULL) { - printf("Can't find fast fading file: %s\n", FAST_FADING_FILE_NAME); + fprintf(stderr, "-----------------------------------------------------\n"); + fprintf(stderr, "cohpsk_ch ERROR: Can't find fast fading file: %s\n", FAST_FADING_FILE_NAME); + fprintf(stderr, "-----------------------------------------------------\n"); exit(1); } - nhfdelay = floor(FAST_FADING_DELAY_MS*COHPSK_FS/1000); + nhfdelay = floor(FAST_FADING_DELAY_MS*Fs/1000); } if (fading_en == 2) { ffading = fopen(SLOW_FADING_FILE_NAME, "rb"); if (ffading == NULL) { - printf("Can't find slow fading file: %s\n", SLOW_FADING_FILE_NAME); + fprintf(stderr, "Can't find slow fading file: %s\n", SLOW_FADING_FILE_NAME); exit(1); } - nhfdelay = floor(SLOW_FADING_DELAY_MS*COHPSK_FS/1000); + nhfdelay = floor(SLOW_FADING_DELAY_MS*Fs/1000); } ch_fdm_delay = (COMP*)malloc((nhfdelay+COHPSK_NOM_SAMPLES_PER_FRAME)*sizeof(COMP)); @@ -161,7 +202,7 @@ int main(int argc, char *argv[]) for (i=0; i<4; i++) ret = fread(&hf_gain, sizeof(float), 1, ffading); - fprintf(stderr, "hf_gain: %f\n", hf_gain); + //fprintf(stderr, "hf_gain: %f\n", hf_gain); } for(i=0; isync_state_interleaver); - if (strcmp(ofdm->sync_state_interleaver,"search") == 0) { + if ((strcmp(ofdm->sync_state_interleaver,"search") == 0) && (ofdm->frame_count >= (interleave_frames-1))) { symbols_to_llrs(llr, codeword_symbols_de, codeword_amps_de, EsNo, coded_syms_per_frame); - iter = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount); - Nerrs = data_bits_per_frame - parityCheckCount; - for(i=0; i<20; i++) - fprintf(stderr,"%d ", out_char[i]); - fprintf(stderr,"\n"); - fprintf(stderr, "iter: %d pcc: %d Nerrs: %d\n", iter, parityCheckCount, Nerrs); - if ((Nerrs < 10)) { + iter[0] = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount[0]); + Nerrs_coded[0] = data_bits_per_frame - parityCheckCount[0]; + //for(i=0; i<20; i++) + // fprintf(stderr,"%d ", out_char[i]); + //fprintf(stderr,"\n"); + //fprintf(stderr, " iter: %d pcc: %d Nerrs: %d\n", iter, parityCheckCount, Nerrs); + if ((Nerrs_coded[0] == 0) && (iter[0] <= 5)) { /* sucessful decode! */ strcpy(next_sync_state_interleaver, "synced"); ofdm->frame_count_interleaver = interleave_frames; @@ -298,8 +300,8 @@ int main(int argc, char *argv[]) symbols_to_llrs(llr, &codeword_symbols_de[j*coded_syms_per_frame], &codeword_amps_de[j*coded_syms_per_frame], EsNo, coded_syms_per_frame); - iter = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount); - fprintf(stderr,"j: %d iter: %d parityCheckCount: %d\n", j, iter, parityCheckCount); + iter[j] = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount[j]); + //fprintf(stderr,"j: %d iter: %d pcc: %d\n", j, iter[j], parityCheckCount[j]); if (testframes) { Nerrs = 0; for(i=0; iverbose) { - int r = ofdm->frame_count_interleaver % interleave_frames; - fprintf(stderr, "f: %3d st: %-6s uw_errs: %2d %1d inter_st: %-6s inter_fr: %2d Nerrs_raw: %3d Nerrs_coded: %3d foff: %4.1f", - f, ofdm->last_sync_state, ofdm->uw_errors, ofdm->sync_counter, + int r=0; + if (testframes) { + r = (ofdm->frame_count_interleaver - 1 ) % interleave_frames; + } + fprintf(stderr, "%3d st: %-6s euw: %2d %1d f: %5.1f ist: %-6s %2d eraw: %3d ecdd: %3d iter: %3d pcc: %3d", + f, ofdm->last_sync_state, ofdm->uw_errors, ofdm->sync_counter, ofdm->foff_est_hz, ofdm->last_sync_state_interleaver, ofdm->frame_count_interleaver, - Nerrs_raw[r], Nerrs_coded[r], ofdm->foff_est_hz); + Nerrs_raw[r], Nerrs_coded[r], iter[r], parityCheckCount[r]); fprintf(stderr, "\n"); }