% state machine(s) for modem and interleaver sync ------------------------------------
- if strcmp(states.sync_state,'searching')
+ if strcmp(states.sync_state,'search')
[timing_valid states] = ofdm_sync_search(states, rxbuf_in);
end
- if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial_sync')
+ if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial')
[rx_bits states aphase_est_pilot_log arx_np arx_amp] = ofdm_demod(states, rxbuf_in);
rx_uw = rx_bits(1:states.Nuwbits);
next_sync_state_interleaver = states.sync_state_interleaver;
- if strcmp(states.sync_state_interleaver,'searching')
+ if strcmp(states.sync_state_interleaver,'search')
st = 1; en = Ncodedbitsperframe/bps;
[rx_codeword parity_checks] = ldpc_dec(code_param, max_iterations, demod_type, decoder_type, rx_np_de(st:en), min(EsNo,30), rx_amp_de(st:en));
Nerrs = code_param.data_bits_per_frame - max(parity_checks);
if states.verbose
r = mod(states.frame_count_interleaver, interleave_frames)+1;
- printf("f: %2d st: %-10s uw_errs: %2d %1d inter_st: %-10s inter_fr: %2d Nerrs_raw: %3d Nerrs_coded: %3d foff: %4.1f\n",
+ printf("f: %3d st: %-6s uw_errs: %2d %1d inter_st: %-6s inter_fr: %2d Nerrs_raw: %3d Nerrs_coded: %3d foff: %4.1f\n",
f, states.last_sync_state, states.uw_errors, states.sync_counter, states.last_sync_state_interleaver, states.frame_count_interleaver,
Nerrs_raw(r), Nerrs_coded(r), states.foff_est_hz);
end
% sync state machine
- states.sync_state = states.last_sync_state = 'searching';
+ states.sync_state = states.last_sync_state = 'search';
states.uw_errors = 0;
states.sync_counter = 0;
states.frame_count = 0;
states.sync_start = 0;
states.sync_end = 0;
- states.sync_state_interleaver = 'searching';
+ states.sync_state_interleaver = 'search';
states.frame_count_interleaver = 0;
% LDPC code is optionally enabled
next_state = states.sync_state;
states.sync_start = states.sync_end = 0;
- if strcmp(states.sync_state,'searching')
+ if strcmp(states.sync_state,'search')
if states.timing_valid
states.frame_count = 0;
states.sync_counter = 0;
states.sync_start = 1;
- next_state = 'trial_sync';
+ next_state = 'trial';
end
end
- if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial_sync')
+ if strcmp(states.sync_state,'synced') || strcmp(states.sync_state,'trial')
states.frame_count++;
states.frame_count_interleaver++;
if (states.uw_errors > uw_thresh)
states.sync_counter++;
if states.sync_counter == sync_counter_thresh
- next_state = 'searching';
- states.sync_state_interleaver = 'searching';
+ next_state = 'search';
+ states.sync_state_interleaver = 'search';
end
else
states.sync_counter = 0;
/* sync state machine */
- strcpy(ofdm->sync_state,"searching");
- strcpy(ofdm->last_sync_state,"searching");
+ strcpy(ofdm->sync_state,"search");
+ strcpy(ofdm->last_sync_state,"search");
ofdm->uw_errors = 0;
ofdm->sync_counter = 0;
ofdm->frame_count = 0;
ofdm->sync_start = 0;
ofdm->sync_end = 0;
- strcpy(ofdm->sync_state_interleaver,"searching");
- strcpy(ofdm->last_sync_state_interleaver,"searching");
+ strcpy(ofdm->sync_state_interleaver,"search");
+ strcpy(ofdm->last_sync_state_interleaver,"search");
ofdm->frame_count_interleaver = 0;
/* create the OFDM waveform */
strcpy(next_state, ofdm->sync_state);
ofdm->sync_start = ofdm->sync_end = 0;
- if (strcmp(ofdm->sync_state,"searching") == 0) {
+ if (strcmp(ofdm->sync_state,"search") == 0) {
if (ofdm->timing_valid) {
ofdm->frame_count = 0;
ofdm->sync_counter = 0;
ofdm->sync_start = 1;
- strcpy(next_state, "trial_sync");
+ strcpy(next_state, "trial");
}
}
- if (!strcmp(ofdm->sync_state,"synced") || !strcmp(ofdm->sync_state, "trial_sync")) {
+ if (!strcmp(ofdm->sync_state,"synced") || !strcmp(ofdm->sync_state, "trial")) {
ofdm->frame_count++;
ofdm->frame_count_interleaver++;
for 3 consecutive frames with low error rate to confirm
sync */
- if (!strcmp(ofdm->sync_state, "trial_sync")) {
+ if (!strcmp(ofdm->sync_state, "trial")) {
if (ofdm->uw_errors > 1) {
/* if we exceed thresh stay in trial sync */
ofdm->sync_counter++;
}
if (ofdm->sync_counter == 2) {
/* if we get two bad frames drop sync and start again */
- strcpy(next_state, "searching");
- strcpy(ofdm->sync_state_interleaver, "searching");
+ strcpy(next_state, "search");
+ strcpy(ofdm->sync_state_interleaver, "search");
}
if (ofdm->frame_count == 4) {
if (ofdm->sync_counter == 6) {
/* run of consective bad frames ... drop sync */
- strcpy(next_state, "searching");
- strcpy(ofdm->sync_state_interleaver, "searching");
+ strcpy(next_state, "search");
+ strcpy(ofdm->sync_state_interleaver, "search");
}
}
}
rxbuf_in[i].imag = 0.0;
}
- if (strcmp(ofdm->sync_state,"searching") == 0) {
+ if (strcmp(ofdm->sync_state,"search") == 0) {
ofdm_sync_search(ofdm, rxbuf_in);
}
- if ((strcmp(ofdm->sync_state,"synced") == 0) || (strcmp(ofdm->sync_state,"trial_sync") == 0) ) {
+ if ((strcmp(ofdm->sync_state,"synced") == 0) || (strcmp(ofdm->sync_state,"trial") == 0) ) {
ofdm_demod(ofdm, rx_bits, rxbuf_in);
if (llr_en) {
char next_sync_state_interleaver[OFDM_STATE_STR];
strcpy(next_sync_state_interleaver, ofdm->sync_state_interleaver);
- if (strcmp(ofdm->sync_state_interleaver,"searching") == 0) {
+ if (strcmp(ofdm->sync_state_interleaver,"search") == 0) {
symbols_to_llrs(llr, codeword_symbols_de, codeword_amps_de, EsNo, CODED_SYMSPERFRAME);
iter = run_ldpc_decoder(&ldpc, out_char, llr, &parityCheckCount);
Nerrs = DATA_BITSPERFRAME - parityCheckCount;
if (ofdm->verbose) {
int r = ofdm->frame_count_interleaver % interleave_frames;
- fprintf(stderr, "f: %2d st: %-10s uw_errs: %2d %1d inter_st: %-10s inter_fr: %2d Nerrs_raw: %3d Nerrs_coded: %3d foff: %4.1f",
+ 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,
ofdm->last_sync_state_interleaver, ofdm->frame_count_interleaver,
Nerrs_raw[r], Nerrs_coded[r], ofdm->foff_est_hz);