summaryrefslogtreecommitdiff
path: root/gsm-tvoid/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gsm-tvoid/src/lib')
-rw-r--r--gsm-tvoid/src/lib/Makefile.am20
-rwxr-xr-xgsm-tvoid/src/lib/gsm.i9
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst_sink_c.cc126
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst_sink_c.h50
4 files changed, 196 insertions, 9 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 */
personal git repositories of Harald Welte. Your mileage may vary