From 790281e5333dba4ad3c17292ec158ac81e605e46 Mon Sep 17 00:00:00 2001 From: ha7ilm Date: Sun, 2 Apr 2017 12:51:53 +0200 Subject: [PATCH] Added docs for = and ? function, added = function, tinkered around costas loop --- README.md | 18 ++++++++++++++++++ csdr.c | 9 +++++++++ libcsdr.c | 6 ++++-- libcsdr.h | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c27117a..87e2d53 100644 --- a/README.md +++ b/README.md @@ -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` + ? + +You can search the functions available in `csdr` just as if you typed: `csdr 2>&1 | grep ` + + = + +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: diff --git a/csdr.c b/csdr.c index 9cdb81d..65d3332 100755 --- a/csdr.c +++ b/csdr.c @@ -135,6 +135,7 @@ char usage[]= " duplicate_samples_ntimes_u8_u8 \n" " bpsk_costas_loop_cc \n" " ?\n" +" =\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; } diff --git a/libcsdr.c b/libcsdr.c index cbfddd7..2121f52 100644 --- a/libcsdr.c +++ b/libcsdr.c @@ -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; diff --git a/libcsdr.h b/libcsdr.h index 81f05e7..1c15f90 100644 --- a/libcsdr.h +++ b/libcsdr.h @@ -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);