timing_recovery_cc outputs data, but segfaults with --octave
This commit is contained in:
parent
26c12746eb
commit
969992f734
3 changed files with 14 additions and 5 deletions
5
csdr.c
5
csdr.c
|
@ -2353,7 +2353,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
if(!strcmp(argv[1],"timing_recovery_cc")) //<algorithm> <decimation> [--add_q]
|
||||
if(!strcmp(argv[1],"timing_recovery_cc")) //<algorithm> <decimation> [--add_q [--octave <debug_n>]]
|
||||
{
|
||||
if(argc<=2) return badsyntax("need required parameter (algorithm)");
|
||||
timing_recovery_algorithm_t algorithm = timing_recovery_get_algorithm_from_string(argv[2]);
|
||||
|
@ -2368,6 +2368,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
int debug_n = 0;
|
||||
if(argc>=7 && !strcmp(argv[5], "--octave")) debug_n = atoi(argv[6]);
|
||||
if(debug_n<0) badsyntax("debug_n should be >= 0");
|
||||
|
||||
if(!initialize_buffers()) return -2;
|
||||
sendbufsize(the_bufsize/decimation);
|
||||
|
@ -2379,8 +2380,8 @@ int main(int argc, char *argv[])
|
|||
for(;;)
|
||||
{
|
||||
FEOF_CHECK;
|
||||
if(debug_n && ++debug_i%debug_n==0) timing_recovery_trigger_debug(&state, 3);
|
||||
timing_recovery_cc((complexf*)input_buffer, (complexf*)output_buffer, the_bufsize, &state);
|
||||
if(++debug_i%debug_n==0) timing_recovery_trigger_debug(&state, 3);
|
||||
//fprintf(stderr, "os %d\n",state.output_size);
|
||||
fwrite(output_buffer, sizeof(complexf), state.output_size, stdout);
|
||||
fflush(stdout);
|
||||
|
|
13
libcsdr.c
13
libcsdr.c
|
@ -1673,6 +1673,7 @@ timing_recovery_state_t timing_recovery_init(timing_recovery_algorithm_t algorit
|
|||
to_return.decimation_rate = decimation_rate;
|
||||
to_return.use_q = use_q;
|
||||
to_return.debug_phase = -1;
|
||||
to_return.debug_count = 3;
|
||||
return to_return;
|
||||
}
|
||||
|
||||
|
@ -1681,6 +1682,7 @@ void timing_recovery_trigger_debug(timing_recovery_state_t* state, int debug_pha
|
|||
state->debug_phase=debug_phase;
|
||||
}
|
||||
|
||||
#define MTIMINGR_HDEBUG 1
|
||||
|
||||
void timing_recovery_cc(complexf* input, complexf* output, int input_size, timing_recovery_state_t* state)
|
||||
{
|
||||
|
@ -1690,8 +1692,10 @@ void timing_recovery_cc(complexf* input, complexf* output, int input_size, timin
|
|||
int num_samples_bit = state->decimation_rate;
|
||||
int num_samples_halfbit = state->decimation_rate / 2;
|
||||
int num_samples_quarterbit = state->decimation_rate / 4;
|
||||
int debug_i = state->debug_count;
|
||||
float error;
|
||||
int si;
|
||||
if(MTIMINGR_HDEBUG) fprintf(stderr, "timing_recovery_cci started, nsb = %d, nshb = %d, nsqb = %d\n", num_samples_bit, num_samples_halfbit, num_samples_quarterbit);
|
||||
if(state->algorithm == TIMING_RECOVERY_ALGORITHM_GARDNER)
|
||||
{
|
||||
for(si=0;;si++)
|
||||
|
@ -1708,16 +1712,19 @@ void timing_recovery_cc(complexf* input, complexf* output, int input_size, timin
|
|||
) * qof(input, current_bitstart_index + num_samples_halfbit * 2);
|
||||
error /= 2;
|
||||
}
|
||||
if(state->debug_phase == si)
|
||||
if(state->debug_phase >= si && debug_i)
|
||||
{
|
||||
state->debug_phase = -1;
|
||||
debug_i--;
|
||||
if(!debug_i) state->debug_phase = -1;
|
||||
octave_plot_point_on_cplxsig(input+current_bitstart_index, state->decimation_rate*2,
|
||||
num_samples_halfbit * 1, 'r',
|
||||
num_samples_halfbit * 2, 'r',
|
||||
num_samples_halfbit * 3, 'r',
|
||||
0); //last argument is dummy, for the comma
|
||||
}
|
||||
current_bitstart_index += num_samples_halfbit * 2 + (error)?((error>0)?1:-1):0;
|
||||
if(MTIMINGR_HDEBUG) fprintf(stderr, "current_bitstart_index = %d, error = %g\n", current_bitstart_index, error);
|
||||
current_bitstart_index += num_samples_halfbit * 2 + ((error)?((error>0)?1:-1):0);
|
||||
if(MTIMINGR_HDEBUG) fprintf(stderr, "new current_bitstart_index = %d\n", current_bitstart_index);
|
||||
}
|
||||
state->input_processed = current_bitstart_index;
|
||||
state->output_size = si;
|
||||
|
|
|
@ -304,6 +304,7 @@ typedef struct timing_recovery_state_s
|
|||
int input_processed;
|
||||
int use_q; //use both I and Q for calculating the error
|
||||
int debug_phase;
|
||||
int debug_count;
|
||||
} timing_recovery_state_t;
|
||||
|
||||
timing_recovery_state_t timing_recovery_init(timing_recovery_algorithm_t algorithm, int decimation_rate, int use_q);
|
||||
|
|
Loading…
Reference in a new issue