diff options
author | tvoid <tvoid@lesaige.com> | 2008-04-10 13:30:47 -0600 |
---|---|---|
committer | tvoid <tvoid@lesaige.com> | 2008-04-10 13:30:47 -0600 |
commit | cca7b770a8f3226c889820564006b3465f59710a (patch) | |
tree | 5f4572da40d3b0b2040c49c92d35eaeb1f2ea358 /gsm-tvoid/src | |
parent | 05290ecda16d34d3e4b074cf8feb602e5f5e4e5e (diff) |
-added gsm_burst_sink_c (sync_block)
-testing with altering signature (single sample) and forecast to minimize buffers
-gsm_scan.py: burst sink used when no burst scope
-gsm_scan.py: change timing deafults, ursp buffer settings
Diffstat (limited to 'gsm-tvoid/src')
-rw-r--r-- | gsm-tvoid/src/lib/Makefile.am | 20 | ||||
-rwxr-xr-x | gsm-tvoid/src/lib/gsm.i | 9 | ||||
-rwxr-xr-x | gsm-tvoid/src/lib/gsm_burst_sink_c.cc | 126 | ||||
-rwxr-xr-x | gsm-tvoid/src/lib/gsm_burst_sink_c.h | 50 | ||||
-rwxr-xr-x | gsm-tvoid/src/python/gsm_scan.py | 22 |
5 files changed, 211 insertions, 16 deletions
diff --git a/gsm-tvoid/src/lib/Makefile.am b/gsm-tvoid/src/lib/Makefile.am index 2d4d7f7..88b8faa 100644 --- a/gsm-tvoid/src/lib/Makefile.am +++ b/gsm-tvoid/src/lib/Makefile.am @@ -37,16 +37,17 @@ ourpython_PYTHON = \ ourlib_LTLIBRARIES = _gsm.la # These are the source files that go into the shared library -_gsm_la_SOURCES = \ +_gsm_la_SOURCES = \ gsmstack.c \ - interleave.c \ + interleave.c \ conv.c \ sch.c \ cch.c \ gsm.cc \ - gsm_burst.cc \ - gsm_burst_ff.cc \ - gsm_burst_cf.cc + gsm_burst.cc \ + gsm_burst_ff.cc \ + gsm_burst_cf.cc \ + gsm_burst_sink_c.cc # magic flags @@ -62,16 +63,17 @@ gsm.cc gsm.py: $(LOCAL_IFILES) $(ALL_IFILES) $(SWIG) $(SWIGPYTHONARGS) -module gsm -o gsm.cc $(LOCAL_IFILES) # These headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ +grinclude_HEADERS = \ gsm_burst.h \ gsmstack.h \ - interleave.h \ + interleave.h \ conv.h \ sch.h \ cch.h \ system.h \ - gsm_burst_ff.h \ - gsm_burst_cf.h \ + gsm_burst_ff.h \ + gsm_burst_cf.h \ + gsm_burst_sink_c.h \ gsm_constants.h diff --git a/gsm-tvoid/src/lib/gsm.i b/gsm-tvoid/src/lib/gsm.i index 81e9062..30981f2 100755 --- a/gsm-tvoid/src/lib/gsm.i +++ b/gsm-tvoid/src/lib/gsm.i @@ -9,6 +9,7 @@ //#include "gsm_burst.h" #include "gsm_burst_ff.h" #include "gsm_burst_cf.h" +#include "gsm_burst_sink_c.h" //#include <stdexcept> %} @@ -108,6 +109,14 @@ private: gsm_burst_cf (gr_feval_ll *,float); }; +GR_SWIG_BLOCK_MAGIC(gsm,burst_sink_c); +gsm_burst_sink_c_sptr gsm_make_burst_sink_c(gr_feval_ll *,float); + +class gsm_burst_sink_c : public gr_sync_block, public gsm_burst { +private: + gsm_burst_sink_c (gr_feval_ll *,float); +}; + diff --git a/gsm-tvoid/src/lib/gsm_burst_sink_c.cc b/gsm-tvoid/src/lib/gsm_burst_sink_c.cc new file mode 100755 index 0000000..103c09f --- /dev/null +++ b/gsm-tvoid/src/lib/gsm_burst_sink_c.cc @@ -0,0 +1,126 @@ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "gsm_burst_sink_c.h" +#include <gr_io_signature.h> +#include <gr_math.h> +#include <stdio.h> +#include <gri_mmse_fir_interpolator_cc.h> + +gsm_burst_sink_c_sptr gsm_make_burst_sink_c (gr_feval_ll *t,float sample_rate) +{ + return gsm_burst_sink_c_sptr (new gsm_burst_sink_c(t,sample_rate)); +} + +static const int MIN_IN = 1; // minimum number of input streams +static const int MAX_IN = 1; // maximum number of input streams + +gsm_burst_sink_c::gsm_burst_sink_c (gr_feval_ll *t, float sample_rate) : + gsm_burst(t), + gr_sync_block ( "burst_sink_c", + gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)), + gr_make_io_signature (0,0,0) + ), + d_clock_counter(0.0), + d_mu(0.5), + d_last_sample(0.0,0.0), + d_ii(0), + d_interp(new gri_mmse_fir_interpolator_cc()) + +{ + + //clocking parameters + d_sample_interval = 1.0 / sample_rate; + d_relative_sample_rate = sample_rate / GSM_SYMBOL_RATE; + + fprintf(stderr,"Sample interval : %e\n",d_sample_interval); + fprintf(stderr,"Relative sample rate : %g\n",d_relative_sample_rate); + + //we need history for interpolator taps and some saftey relative to relative rate + int hist = d_interp->ntaps(); // + 16; // interpolator need -4/+3 samples NTAPS = 8 , 16 for safety margin + set_history(hist); //need history for interpolator + +} + +gsm_burst_sink_c::~gsm_burst_sink_c () +{ + delete d_interp; +} + + +int gsm_burst_sink_c::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) + +{ + const gr_complex *in = (const gr_complex *) input_items[0]; + +// fprintf(stderr,"#o=%d",noutput_items); + + assert( d_ii >= 0 ); + +// while (( rval < noutput_items) && ( ii < ni ) ) { + while ( d_ii < noutput_items ) { +// while ( oo++ < noutput_items ) { + //clock symbols + //TODO: this is very basic and can be improved. Need tracking... + //TODO: use burst_start offsets as timing feedback + //TODO: save complex samples for Viterbi EQ + + //from m&m + gr_complex sample = d_interp->interpolate (&in[d_ii], d_mu); + + gr_complex conjprod = sample * conj(d_last_sample); + float diff_angle = gr_fast_atan2f(imag(conjprod), real(conjprod)); + + d_last_sample = sample; + +#if 1 + assert(d_bbuf_pos <= BBUF_SIZE ); + + if (d_bbuf_pos >= 0) //could be negative offset from burst alignment. TODO: perhaps better just to add some padding to the buffer + d_burst_buffer[d_bbuf_pos] = diff_angle; + + d_bbuf_pos++; + + if ( d_bbuf_pos >= BBUF_SIZE ) { + if (get_burst()) { + //adjust timing + //TODO: generate timing error from burst buffer (phase & freq) + + switch ( d_clock_options & QB_MASK ) { + case QB_QUARTER: //extra 1/4 bit each burst + d_mu -= d_relative_sample_rate / 4.0; + break; + case QB_FULL04: //extra bit on timeslot 0 & 4 + if (!(d_ts%4)) + d_mu -= d_relative_sample_rate; + break; + case QB_NONE: //don't adjust for quarter bits at all + default: + break; + } + + d_last_burst_s_count = d_sample_count; + + //fprintf(stderr,"clock: %f, pos: %d\n",d_clock_counter,d_bbuf_pos); + } + } +#endif + + d_mu += d_relative_sample_rate; + d_ii += (int)floor(d_mu); + //d_sample_count += (int)floor(d_mu); //TODO: outside loop? + d_mu -= floor(d_mu); + } + + //reset d_ii, accounting for advance + d_ii -= noutput_items; + +// fprintf(stderr,"/mu=%f",d_mu); +// fprintf(stderr,"/ii=%d\n",d_ii); + + return noutput_items; +} diff --git a/gsm-tvoid/src/lib/gsm_burst_sink_c.h b/gsm-tvoid/src/lib/gsm_burst_sink_c.h new file mode 100755 index 0000000..5918dc6 --- /dev/null +++ b/gsm-tvoid/src/lib/gsm_burst_sink_c.h @@ -0,0 +1,50 @@ +#ifndef INCLUDED_gsm_burst_sink_c_H +#define INCLUDED_gsm_burst_sink_c_H + +#include <gr_sync_block.h> +#include <gsm_burst.h> + +class gsm_burst_sink_c; + +typedef boost::shared_ptr<gsm_burst_sink_c> gsm_burst_sink_c_sptr; + +gsm_burst_sink_c_sptr gsm_make_burst_sink_c(gr_feval_ll *,float); + +class gri_mmse_fir_interpolator_cc; + +//class gsm_burst_sink_c : public gr_block, public gsm_burst +class gsm_burst_sink_c : public gr_sync_block, public gsm_burst +{ +private: + + friend gsm_burst_sink_c_sptr gsm_make_burst_sink_c(gr_feval_ll *,float); + gsm_burst_sink_c(gr_feval_ll *,float); + + //clocking parameters + double d_sample_interval; + double d_clock_counter; + gr_complex d_last_sample; + + float d_relative_sample_rate; //omega + float d_mu; + int d_ii; //save index between work calls for interp advance + + gri_mmse_fir_interpolator_cc *d_interp; //sub-sample interpolator from GR + +public: + ~gsm_burst_sink_c (); + +// void forecast (int noutput_items, gr_vector_int &ninput_items_required); + + int work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); + +/* int general_work ( int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +*/ +}; + +#endif /* INCLUDED_gsm_burst_sink_c_H */ diff --git a/gsm-tvoid/src/python/gsm_scan.py b/gsm-tvoid/src/python/gsm_scan.py index 461abf1..2dcf538 100755 --- a/gsm-tvoid/src/python/gsm_scan.py +++ b/gsm-tvoid/src/python/gsm_scan.py @@ -59,7 +59,7 @@ class burst_callback(gr.feval_ll): #retune if greater than 100 Hz if mean_offset > 100.0: - print "burst_callback: mean offset:", mean_offset, "\n"; + print "burst_callback: mean offset adjust:", mean_offset, "\n"; self.fg.set_channel(self.fg.arfcn) elif gsm.BURST_CB_TUNE == x: @@ -149,7 +149,7 @@ class app_flow_graph(stdgui.gui_flow_graph): help="Sample clock offset frequency") parser.add_option("-E", "--equalizer", type="string", default="none", help="Type of equalizer to use. none, fixed-dfe [default=%default]") - parser.add_option("-t", "--timing", type="string", default="cq", + parser.add_option("-t", "--timing", type="string", default="cn", help="Type of timing techniques to use. [default=%default] \n" + "(n)one, (c)orrelation track, (q)uarter bit, (f)ull04 ") @@ -225,11 +225,13 @@ class app_flow_graph(stdgui.gui_flow_graph): # if options.fusb_block_size == 0 and options.fusb_nblocks == 0: if realtime: # be more aggressive - options.fusb_block_size = gr.prefs().get_long('fusb', 'rt_block_size', 1024) +# options.fusb_block_size = gr.prefs().get_long('fusb', 'rt_block_size', 1024) + options.fusb_block_size = gr.prefs().get_long('fusb', 'rt_block_size', 512) options.fusb_nblocks = gr.prefs().get_long('fusb', 'rt_nblocks', 16) else: - options.fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096) - options.fusb_nblocks = gr.prefs().get_long('fusb', 'nblocks', 16) +# options.fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 4096) + options.fusb_block_size = gr.prefs().get_long('fusb', 'block_size', 1024) + options.fusb_nblocks = gr.prefs().get_long('fusb', 'nblocks', 32) print "fusb_block_size =", options.fusb_block_size print "fusb_nblocks =", options.fusb_nblocks @@ -242,7 +244,8 @@ class app_flow_graph(stdgui.gui_flow_graph): self.source = gr.file_source(gr.sizeof_gr_complex, options.inputfile, options.fileloop) else: self.using_usrp = True - self.u = usrp.source_c(decim_rate=options.decim) + self.u = usrp.source_c(decim_rate=options.decim,fusb_block_size=options.fusb_block_size,fusb_nblocks=options.fusb_nblocks) + if options.rx_subdev_spec is None: options.rx_subdev_spec = pick_subdevice(self.u) self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) @@ -292,7 +295,12 @@ class app_flow_graph(stdgui.gui_flow_graph): # Setup flow based on decoder selection if options.decoder.count("c"): - self.burst = gsm.burst_cf(self.burst_cb,input_rate) + #use the sink version if burst scope not selected + if self.scopes.count("b"): + self.burst = gsm.burst_cf(self.burst_cb,input_rate) + else: + self.burst = gsm.burst_sink_c(self.burst_cb,input_rate) + self.connect(self.filter, self.burst) elif options.decoder.count("f"): |