Added docs for = and ? function, added = function, tinkered around costas loop

This commit is contained in:
ha7ilm 2017-04-02 12:51:53 +02:00
parent df81d6847e
commit 790281e533
4 changed files with 32 additions and 2 deletions

View file

@ -474,6 +474,24 @@ By writing to the given FIFO file with the syntax below, you can control the shi
E.g. you can send `-0.05 0.02\n`
?<search_the_function_list>
You can search the functions available in `csdr` just as if you typed: `csdr 2>&1 | grep <search_what>`
=<evaluate_python_expression>
When running complicated `csdr` commands, we usually run into using `python` to calculate certain parameters.
This function can eliminate some typing and make our command clearer.
Instead of having to write: `csdr shift_addition_cc $(python -c "print 1200/2400000.")`
...we can type: `csdr shift_addition_cc $(csdr =1200/2400000.)`
If using parenthesis inside the expression, it needs to be escaped (as `bash` would want to parse it): `csdr shift_addition_cc $(csdr =\(1200+300\)/2400000)`
Another solution is using single quotes to wrap the expression: `csdr shift_addition_cc $(csdr '=(1200+300)/2400000.')`
#### Buffer sizes
*csdr* has three modes of determining the buffer sizes, which can be chosen by the appropriate environment variables:

9
csdr.c
View file

@ -135,6 +135,7 @@ char usage[]=
" duplicate_samples_ntimes_u8_u8 <sample_size_bytes> <ntimes>\n"
" bpsk_costas_loop_cc <samples_per_bits>\n"
" ?<search_the_function_list>\n"
" =<evaluate_python_expression>\n"
" \n"
;
@ -2674,5 +2675,13 @@ int main(int argc, char *argv[])
return 0;
}
if(argv[1][0]=='=')
{
char buffer[100];
snprintf(buffer, 100-1, "python -c \"print %s\"", argv[1]+1);
system(buffer);
return 0;
}
fprintf(stderr,"csdr: function name given in argument 1 (%s) does not exist. Possible causes:\n- You mistyped the commandline.\n- You need to update csdr to a newer version (if available).\n", argv[1]); return -1;
}

View file

@ -1939,11 +1939,11 @@ bpsk_costas_loop_state_t init_bpsk_costas_loop_cc(float samples_per_bits)
{
bpsk_costas_loop_state_t state;
state.vco_phase = 0;
state.last_vco_phase_addition = 0;
float virtual_sampling_rate = 10000;
float virtual_data_rate = virtual_sampling_rate / samples_per_bits;
fprintf(stderr, "virtual_sampling_rate = %g, virtual_data_rate = %g\n", virtual_sampling_rate, virtual_data_rate);
//float rc_filter_cutoff = virtual_data_rate * 2; //this is so far the best
float rc_filter_cutoff = virtual_data_rate * 2;
float rc_filter_cutoff = virtual_data_rate * 2; //this is so far the best
float rc_filter_rc = 1/(2*M_PI*rc_filter_cutoff); //as of Equation 24 in Feigin
float virtual_sampling_dt = 1.0/virtual_sampling_rate;
fprintf(stderr, "rc_filter_cutoff = %g, rc_filter_rc = %g, virtual_sampling_dt = %g\n",
@ -1981,6 +1981,8 @@ void bpsk_costas_loop_cc(complexf* input, complexf* output, int input_size, bpsk
state->last_lpfi_output = loop_output_i;
state->last_lpfq_output = loop_output_q;
float vco_phase_addition = loop_output_i * loop_output_q * state->vco_phase_addition_multiplier;
//vco_phase_addition = vco_phase_addition * state->rc_filter_alpha + state->last_vco_phase_addition * (1-state->rc_filter_alpha);
//state->last_vco_phase_addition = vco_phase_addition;
state->vco_phase += vco_phase_addition;
while(state->vco_phase>PI) state->vco_phase-=2*PI;
while(state->vco_phase<-PI) state->vco_phase+=2*PI;

View file

@ -332,6 +332,7 @@ typedef struct bpsk_costas_loop_state_s
float vco_phase;
float last_lpfi_output;
float last_lpfq_output;
float last_vco_phase_addition;
} bpsk_costas_loop_state_t;
bpsk_costas_loop_state_t init_bpsk_costas_loop_cc(float samples_per_bits);