1. Generate 10 seconds of test frame bits, modulate, and play audio
out of sound device:
- build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | play -t raw -r 8000 -s -2 -
+ build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | play -t raw -r 8000 -s -2 -
2. Generate 10 seconds of uncoded test frame bits, modulate, demodulate, count errors:
- build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | ./ofdm_demod - /dev/null -t
+ build_linux/src$ ./ofdm_get_test_bits - 10 | ./ofdm_mod - - | ./ofdm_demod - /dev/null -t
- (TODO write ofdm_demod_c.m)
- Use Octave to look at plots of C modem operation:
+ Use Octave to look at plots of C modem operation:
- $ cd ../octave
- $ octave
- octave:1> ofdm_demod_c("../src/demod_dump.txt")
+ $ cd ../octave
+ $ octave
+ octave:1> ofdm_demod_c("../src/demod_dump.txt")
4. Run Octave versions of mod and demod (called tx and rx to avoid
namespace clashes in Octave):
C demodulator/LDPC decoder:
build_linux/src$ ./ofdm_demod ../../octave/ofdm_test.raw /dev/null -v -t --ldpc --interleave 4
-
+
+6. Run C mod/demod with LDPC and 2 frames interleaving:
+
+ build_linux/src$ ./ofdm_mod /dev/zero - --ldpc -t 2 --interleave 2 | ./ofdm_demod - /dev/null -t --ldpc -v --interleave 2
+
+7. Pass Codec 2 700C through modem:
+
+ build_linux/src$ ./c2enc 700C ../../raw/ve9qrp_10s.raw - --bitperchar | ./ofdm_mod - - --ldpc --interleave 2 | ./ofdm_demod - - --ldpc --interleave 2 | ./c2dec 700C - - --bitperchar | play -t raw -r 8000 -s -2 -
+
+
Acceptance Tests
----------------
exit(1);
}
- mode = -1;
-
// Attempt to detect a .c2 file with a header
struct c2_header in_hdr;
char *ext = strrchr(argv[2], '.');
- if (ext != NULL) {
- if (strcmp(ext, ".c2") == 0) {
- fread(&in_hdr,sizeof(in_hdr),1,fin);
+ if ((ext != NULL) && (strcmp(ext, ".c2") == 0)) {
+ fread(&in_hdr,sizeof(in_hdr),1,fin);
- if (memcmp(in_hdr.magic, c2_file_magic, sizeof(c2_file_magic)) == 0) {
- fprintf(stderr, "Detected Codec2 file version %d.%d in mode %d\n",
- in_hdr.version_major,
- in_hdr.version_minor,
- in_hdr.mode);
+ if (memcmp(in_hdr.magic, c2_file_magic, sizeof(c2_file_magic)) == 0) {
+ fprintf(stderr, "Detected Codec2 file version %d.%d in mode %d\n",
+ in_hdr.version_major,
+ in_hdr.version_minor,
+ in_hdr.mode);
- mode = in_hdr.mode;
- } else {
- fprintf(stderr, "Codec2 file specified but no header detected\n");
- // Rewind the input file so we can try to decode
- // based on command line mode selection
- fseek(fin,0,SEEK_SET);
- } /* end if - magic detection */
- };
+ mode = in_hdr.mode;
+ } else {
+ fprintf(stderr, "Codec2 file specified but no header detected\n");
+ // Rewind the input file so we can try to decode
+ // based on command line mode selection
+ fseek(fin,0,SEEK_SET);
+ } /* end if - magic detection */
} else {
// If we got here, we need to honor the command line mode
if (strcmp(argv[1],"3200") == 0)
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;
- //fprintf(stderr, "iter: %d pcc: %d Nerrs: %d\n", iter, parityCheckCount, Nerrs);
- if (Nerrs < 10) {
+ 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)) {
/* sucessful decode! */
strcpy(next_sync_state_interleaver, "synced");
ofdm->frame_count_interleaver = interleave_frames;
&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);
if (testframes) {
Nerrs = 0;
for(i=0; i<data_bits_per_frame; i++) {
Terrs_coded += Nerrs;
Tbits_coded += data_bits_per_frame;
}
- fwrite(out_char, sizeof(char), coded_bits_per_frame, fout);
+ fwrite(out_char, sizeof(char), data_bits_per_frame, fout);
}
} /* if interleaver synced ..... */
struct OFDM *ofdm;
int frames;
int i, j, arg;
- int testframes, ldpc_en, interleaver_frames;
+ int testframes, ldpc_en, interleave_frames;
/* Set up default LPDC code. We could add other codes here if we like */
if (argc < 3) {
fprintf(stderr, "\n");
fprintf(stderr, "usage: %s InputOneCharPerBitFile OutputModemRawFile [--lpdc] [--interleaver depth]\n\n", argv[0]);
- fprintf(stderr, " -t Transmit test frames (adjusts test frames for raw and LDPC modes)\n");
+ fprintf(stderr, " -t Nsecs Transmit test frames (adjusts test frames for raw and LDPC modes)\n");
fprintf(stderr, " --ldpc Run (%d,%d) LDPC decoder. This forces 112, one char/bit output values\n"
" per frame. In testframe mode (-t) raw and coded errors will be counted\n",
coded_bits_per_frame, data_bits_per_frame);
- fprintf(stderr, " --interleave Interleaver for LDPC frames, e.g. 1,2,4,8,16, default is 1\n");
+ fprintf(stderr, " --interleave Interleave depth for LDPC frames, e.g. 1,2,4,8,16, default is 1\n");
fprintf(stderr, "\n");
exit(1);
}
ofdm = ofdm_create(OFDM_CONFIG_700D);
assert(ofdm != NULL);
- testframes = 0;
- if (opt_exists(argv, argc, "-t")) {
- testframes = 1;
- }
-
/* set for LDPC coded or uncoded frames */
- ldpc_en = 0; interleaver_frames = 1;
+ ldpc_en = 0; interleave_frames = 1;
int Nbitsperframe;
if (opt_exists(argv, argc, "--ldpc")) {
assert((OFDM_NUWBITS+OFDM_NTXTBITS+coded_bits_per_frame) == OFDM_BITSPERFRAME); /* sanity check */
ldpc_en = 1;
- if ((arg = opt_exists(argv, argc, "--interleaver"))) {
- interleaver_frames = atoi(argv[arg]);
+ if ((arg = opt_exists(argv, argc, "--interleave"))) {
+ interleave_frames = atoi(argv[arg+1]);
}
- Nbitsperframe = interleaver_frames*data_bits_per_frame;
+ Nbitsperframe = interleave_frames*data_bits_per_frame;
} else {
/* vanilla uncoded input bits mode */
}
int Nsamperframe = ofdm_get_samples_per_frame();
+ fprintf(stderr, "Nbitsperframe: %d interleave_frames: %d\n", Nbitsperframe, interleave_frames);
unsigned char tx_bits_char[Nbitsperframe];
int tx_bits[Nbitsperframe];
tx_symbols[i] = uw_txt_syms[i].real + I * uw_txt_syms[i].imag;
}
+ testframes = 0;
+ int Nframes = 0;
+ if ((arg = (opt_exists(argv, argc, "-t")))) {
+ testframes = 1;
+ int Nsec, Nrows;
+ Nsec = atoi(argv[arg+1]);
+ Nrows = Nsec*OFDM_RS;
+ Nframes = floor((Nrows-1)/OFDM_NS);
+ fprintf(stderr, "Nframes: %d\n", Nframes);
+ }
+
/* main loop ----------------------------------------------------------------*/
frames = 0;
while(fread(tx_bits_char, sizeof(char), Nbitsperframe, fin) == Nbitsperframe) {
- frames++;
-
if (ldpc_en) {
/* fancy interleaved LDPC encoded frames ----------------------------------------*/
/* optionally overwrite input data with test frame nown to demodulator */
if (testframes) {
- for (j=0; j<interleaver_frames; j++) {
+ for (j=0; j<interleave_frames; j++) {
for(i=0; i<data_bits_per_frame; i++) {
tx_bits_char[j*data_bits_per_frame + i] = payload_data_bits[i];
}
}
int codeword[coded_bits_per_frame];
- COMP coded_symbols[interleaver_frames*coded_syms_per_frame];
- COMP coded_symbols_inter[interleaver_frames*coded_syms_per_frame];
+ COMP coded_symbols[interleave_frames*coded_syms_per_frame];
+ COMP coded_symbols_inter[interleave_frames*coded_syms_per_frame];
complex float tx_sams[Nsamperframe];
- for (j=0; j<interleaver_frames; j++) {
+ for (j=0; j<interleave_frames; j++) {
ldpc_encode_frame(&ldpc, codeword, &tx_bits_char[j*data_bits_per_frame]);
qpsk_modulate_frame(&coded_symbols[j*coded_syms_per_frame], codeword, coded_syms_per_frame);
- gp_interleave_comp(coded_symbols_inter, coded_symbols, interleaver_frames*coded_syms_per_frame);
+ }
+ gp_interleave_comp(coded_symbols_inter, coded_symbols, interleave_frames*coded_syms_per_frame);
+ for (j=0; j<interleave_frames; j++) {
for(i=0; i<coded_syms_per_frame; i++) {
tx_symbols[(OFDM_NUWBITS+OFDM_NTXTBITS)/OFDM_BPS+i] = coded_symbols_inter[j*coded_syms_per_frame+i].real
+ I * coded_symbols_inter[j*coded_syms_per_frame+i].imag;
tx_scaled[i] = ASCALE * crealf(tx_sams[i]);
}
fwrite(tx_scaled, sizeof(short), Nsamperframe, fout);
+ frames++;
}
-
- } else {
+ } else {
/* just modulate uncoded raw bits ----------------------------------------------*/
if (testframes) {
tx_scaled[i] = ASCALE * tx_sams[i].real;
fwrite(tx_scaled, sizeof(short), Nsamperframe, fout);
+ frames++;
}
/* if this is in a pipeline, we probably don't want the usual
if (fout == stdout) fflush(stdout);
if (fin == stdin) fflush(stdin);
+
+ if (testframes && (frames >= Nframes)) {
+ goto finished;
+ }
}
+ finished:
fclose(fin);
fclose(fout);
ofdm_destroy(ofdm);