summaryrefslogtreecommitdiff
path: root/gsm-tvoid
diff options
context:
space:
mode:
Diffstat (limited to 'gsm-tvoid')
-rwxr-xr-xgsm-tvoid/src/lib/gsm.i16
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst.cc9
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst.h20
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst_cf.cc7
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst_cf.h6
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst_ff.cc7
-rwxr-xr-xgsm-tvoid/src/lib/gsm_burst_ff.h6
-rwxr-xr-xgsm-tvoid/src/python/gsm_scan.py59
8 files changed, 97 insertions, 33 deletions
diff --git a/gsm-tvoid/src/lib/gsm.i b/gsm-tvoid/src/lib/gsm.i
index d990e8b..9d653ac 100755
--- a/gsm-tvoid/src/lib/gsm.i
+++ b/gsm-tvoid/src/lib/gsm.i
@@ -43,6 +43,9 @@
#define CLK_CORR_TRACK 0x00000010 //adjust timing based on correlation offsets
+#define BURST_CB_ADJ_OFFSET 1
+#define BURST_CB_TUNE 2
+
//EQ options
enum EQ_TYPE {
EQ_NONE,
@@ -73,6 +76,8 @@ public:
long d_unknown_count;
long d_total_count;
+ long next_arfcn;
+
int sync_state();
float last_freq_offset(void);
double mean_freq_offset(void);
@@ -80,25 +85,26 @@ public:
//Methods
void full_reset(void);
+
protected:
- gsm_burst();
+ gsm_burst(gr_feval_ll *);
};
GR_SWIG_BLOCK_MAGIC(gsm,burst_ff);
-gsm_burst_ff_sptr gsm_make_burst_ff ();
+gsm_burst_ff_sptr gsm_make_burst_ff (gr_feval_ll *);
class gsm_burst_ff : public gr_block, public gsm_burst {
private:
- gsm_burst_ff ();
+ gsm_burst_ff (gr_feval_ll *);
};
GR_SWIG_BLOCK_MAGIC(gsm,burst_cf);
-gsm_burst_cf_sptr gsm_make_burst_cf (float);
+gsm_burst_cf_sptr gsm_make_burst_cf (gr_feval_ll *,float);
class gsm_burst_cf : public gr_block, public gsm_burst {
private:
- gsm_burst_cf (float);
+ gsm_burst_cf (gr_feval_ll *,float);
};
diff --git a/gsm-tvoid/src/lib/gsm_burst.cc b/gsm-tvoid/src/lib/gsm_burst.cc
index 67d0886..4203f26 100755
--- a/gsm-tvoid/src/lib/gsm_burst.cc
+++ b/gsm-tvoid/src/lib/gsm_burst.cc
@@ -13,12 +13,15 @@
#include "gsmstack.h"
-gsm_burst::gsm_burst () :
+gsm_burst::gsm_burst (gr_feval_ll *t) :
+ p_tuner(t),
d_clock_options(DEFAULT_CLK_OPTS),
d_print_options(0),
d_equalizer_type(EQ_FIXED_DFE)
{
+// fprintf(stderr,"gsm_burst: enter constructor (t=%8.8x)\n",(unsigned int)t);
+
// M_PI = M_PI; //4.0 * atan(1.0);
full_reset();
@@ -643,6 +646,10 @@ int gsm_burst::get_burst(void)
d_fcch_count++;
calc_freq_offset();
+ if (p_tuner) {
+ p_tuner->calleval(BURST_CB_ADJ_OFFSET);
+ }
+
d_ts = 0;
break;
case PARTIAL_SCH:
diff --git a/gsm-tvoid/src/lib/gsm_burst.h b/gsm-tvoid/src/lib/gsm_burst.h
index def20e0..f1fb26e 100755
--- a/gsm-tvoid/src/lib/gsm_burst.h
+++ b/gsm-tvoid/src/lib/gsm_burst.h
@@ -8,7 +8,6 @@
#include "gsm_constants.h"
#include <gr_math.h>
-//#include <Python.h> //for callback testing
#include <gr_feval.h>
#include "gsmstack.h"
@@ -73,13 +72,17 @@ enum EQ_TYPE {
EQ_VITERBI
};
+#define BURST_CB_ADJ_OFFSET 1
+#define BURST_CB_TUNE 2
+
+
class gsm_burst;
class gsm_burst
{
protected:
- gsm_burst();
+ gsm_burst(gr_feval_ll *t);
//Burst Buffer: Storage for burst data
float d_burst_buffer[BBUF_SIZE];
@@ -116,6 +119,8 @@ protected:
double d_freq_off_sum;
double d_freq_off_weight;
+ gr_feval_ll *p_tuner;
+
//////// Methods
int get_burst(void);
BURST_TYPE get_fcch_burst(void);
@@ -157,12 +162,17 @@ public:
unsigned long d_print_options;
EQ_TYPE d_equalizer_type;
- int sync_state() { return d_sync_state;}
- float last_freq_offset() {return d_freq_offset;}
- double mean_freq_offset(void);
//Methods
void full_reset(void);
+
+ int sync_state() { return d_sync_state;}
+
+ //Frequency
+ float last_freq_offset() {return d_freq_offset;}
+ double mean_freq_offset(void);
+
+ long next_arfcn;
};
diff --git a/gsm-tvoid/src/lib/gsm_burst_cf.cc b/gsm-tvoid/src/lib/gsm_burst_cf.cc
index a91c569..08ff7ba 100755
--- a/gsm-tvoid/src/lib/gsm_burst_cf.cc
+++ b/gsm-tvoid/src/lib/gsm_burst_cf.cc
@@ -9,9 +9,9 @@
#include <stdio.h>
#include <gri_mmse_fir_interpolator_cc.h>
-gsm_burst_cf_sptr gsm_make_burst_cf (float sample_rate)
+gsm_burst_cf_sptr gsm_make_burst_cf (gr_feval_ll *t,float sample_rate)
{
- return gsm_burst_cf_sptr (new gsm_burst_cf (sample_rate));
+ return gsm_burst_cf_sptr (new gsm_burst_cf (t,sample_rate));
}
static const int MIN_IN = 1; // minimum number of input streams
@@ -19,7 +19,8 @@ static const int MAX_IN = 1; // maximum number of input streams
static const int MIN_OUT = 1; // minimum number of output streams
static const int MAX_OUT = 1; // maximum number of output streams
-gsm_burst_cf::gsm_burst_cf (float sample_rate) :
+gsm_burst_cf::gsm_burst_cf (gr_feval_ll *t, float sample_rate) :
+ gsm_burst(t),
gr_block ( "burst_cf",
gr_make_io_signature (MIN_IN, MAX_IN, sizeof (gr_complex)),
gr_make_io_signature (MIN_OUT, MAX_OUT, USEFUL_BITS * sizeof (float))),
diff --git a/gsm-tvoid/src/lib/gsm_burst_cf.h b/gsm-tvoid/src/lib/gsm_burst_cf.h
index 33f61f6..2b806e0 100755
--- a/gsm-tvoid/src/lib/gsm_burst_cf.h
+++ b/gsm-tvoid/src/lib/gsm_burst_cf.h
@@ -8,7 +8,7 @@ class gsm_burst_cf;
typedef boost::shared_ptr<gsm_burst_cf> gsm_burst_cf_sptr;
-gsm_burst_cf_sptr gsm_make_burst_cf(float);
+gsm_burst_cf_sptr gsm_make_burst_cf(gr_feval_ll *,float);
class gri_mmse_fir_interpolator_cc;
@@ -16,8 +16,8 @@ class gsm_burst_cf : public gr_block, public gsm_burst
{
private:
- friend gsm_burst_cf_sptr gsm_make_burst_cf(float);
- gsm_burst_cf(float);
+ friend gsm_burst_cf_sptr gsm_make_burst_cf(gr_feval_ll *,float);
+ gsm_burst_cf(gr_feval_ll *,float);
//clocking parameters
float d_relative_sample_rate;
diff --git a/gsm-tvoid/src/lib/gsm_burst_ff.cc b/gsm-tvoid/src/lib/gsm_burst_ff.cc
index 2980829..d73e73d 100755
--- a/gsm-tvoid/src/lib/gsm_burst_ff.cc
+++ b/gsm-tvoid/src/lib/gsm_burst_ff.cc
@@ -9,9 +9,9 @@
#include <stdio.h>
#include <gri_mmse_fir_interpolator_cc.h>
-gsm_burst_ff_sptr gsm_make_burst_ff ()
+gsm_burst_ff_sptr gsm_make_burst_ff (gr_feval_ll *t)
{
- return gsm_burst_ff_sptr (new gsm_burst_ff());
+ return gsm_burst_ff_sptr (new gsm_burst_ff(t));
}
static const int MIN_IN = 1; // minimum number of input streams
@@ -19,7 +19,8 @@ static const int MAX_IN = 1; // maximum number of input streams
static const int MIN_OUT = 1; // minimum number of output streams
static const int MAX_OUT = 1; // maximum number of output streams
-gsm_burst_ff::gsm_burst_ff () :
+gsm_burst_ff::gsm_burst_ff (gr_feval_ll *t) :
+ gsm_burst(t),
gr_block( "burst_ff",
gr_make_io_signature (MIN_IN, MAX_IN, sizeof (float)),
gr_make_io_signature (MIN_OUT, MAX_OUT, USEFUL_BITS * sizeof (float)))
diff --git a/gsm-tvoid/src/lib/gsm_burst_ff.h b/gsm-tvoid/src/lib/gsm_burst_ff.h
index 30c10dc..8ca61ef 100755
--- a/gsm-tvoid/src/lib/gsm_burst_ff.h
+++ b/gsm-tvoid/src/lib/gsm_burst_ff.h
@@ -8,14 +8,14 @@ class gsm_burst_ff;
typedef boost::shared_ptr<gsm_burst_ff> gsm_burst_ff_sptr;
-gsm_burst_ff_sptr gsm_make_burst_ff();
+gsm_burst_ff_sptr gsm_make_burst_ff(gr_feval_ll *);
class gsm_burst_ff : public gr_block, public gsm_burst
{
private:
- friend gsm_burst_ff_sptr gsm_make_burst_ff();
- gsm_burst_ff();
+ friend gsm_burst_ff_sptr gsm_make_burst_ff(gr_feval_ll *);
+ gsm_burst_ff(gr_feval_ll *t);
public:
~gsm_burst_ff ();
diff --git a/gsm-tvoid/src/python/gsm_scan.py b/gsm-tvoid/src/python/gsm_scan.py
index 43331e1..cc3c2d6 100755
--- a/gsm-tvoid/src/python/gsm_scan.py
+++ b/gsm-tvoid/src/python/gsm_scan.py
@@ -26,6 +26,34 @@ from math import pi
import wx
import gsm
+
+class burst_callback(gr.feval_ll):
+ def __init__(self, fg):
+ gr.feval_ll.__init__(self)
+ self.fg = fg
+
+ def eval(self, x):
+ try:
+ #print "burst_callback: ", x, "\n";
+ if gsm.BURST_CB_ADJ_OFFSET == x:
+ #TODO: rework so this will work on file input
+ last_offset = self.fg.burst.last_freq_offset()
+ if last_offset < 200.0:
+ return 0
+
+ self.fg.offset -= last_offset
+ print "burst_callback: ADJ_OFFSET:", last_offset, " ARFCN: ", self.fg.arfcn, "\n";
+ self.fg.set_channel(self.fg.arfcn)
+
+ elif gsm.BURST_CB_TUNE == x:
+ self.fg.set_channel(self.fg.burst.next_arfcn)
+
+ return 0
+
+ except Exception, e:
+ print "burst_callback: Exception: ", e
+
+
def pick_subdevice(u):
if u.db[0][0].dbid() >= 0:
return (0, 0)
@@ -73,6 +101,9 @@ class app_flow_graph(stdgui.gui_flow_graph):
def __init__(self, frame, panel, vbox, argv):
stdgui.gui_flow_graph.__init__(self)
+ #testing
+ self.status_msg = "Started."
+
self.frame = frame
self.panel = panel
@@ -217,9 +248,12 @@ class app_flow_graph(stdgui.gui_flow_graph):
if self.scopes.count("I"):
self.connect(self.u, self.input_fft_scope)
+ #create a tuner callback
+ self.burst_cb = burst_callback(self)
+
# Setup flow based on decoder selection
if options.decoder.count("c"):
- self.burst = gsm.burst_cf(input_rate)
+ self.burst = gsm.burst_cf(self.burst_cb,input_rate)
self.connect(self.filter, self.burst)
elif options.decoder.count("f"):
@@ -236,7 +270,7 @@ class app_flow_graph(stdgui.gui_flow_graph):
gain_mu,
0.3) #omega_relative_limit,
- self.burst = gsm.burst_ff()
+ self.burst = gsm.burst_ff(self.burst_cb)
self.connect(self.filter, self.demod, self.clocker, self.burst)
if self.scopes.count("d"):
@@ -349,8 +383,8 @@ class app_flow_graph(stdgui.gui_flow_graph):
##########################
#set burst tuning callback
- #self.tuner = gsm_tuner()
- #self.burst.set_tuner_callback(self.tuner)
+ #self.burst_cb = gsm_tuner()
+ #self.burst.set_tuner_callback(self.burst_cb)
# connect the primary path after source
self.v2s = gr.vector_to_stream(gr.sizeof_float,142) #burst output is 142 (USEFUL_BITS)
@@ -443,10 +477,10 @@ class app_flow_graph(stdgui.gui_flow_graph):
r = self.u.tune(0, self.subdev, freq)
if r:
- self._set_status_msg('%f' % (freq/1e6))
+ self.status_msg = '%f' % (freq/1e6)
return True
else:
- self._set_status_msg("Failed to set frequency (%f)" % (freq/1e6))
+ self.status_msg = "Failed to set frequency (%f)" % (freq/1e6)
return False
def set_gain(self, gain):
@@ -458,6 +492,8 @@ class app_flow_graph(stdgui.gui_flow_graph):
def set_channel(self, chan):
+ self.arfcn = chan
+
if not self.using_usrp:
return False
@@ -466,15 +502,17 @@ class app_flow_graph(stdgui.gui_flow_graph):
if freq:
self.set_freq(freq)
else:
- self._set_status_msg("Invalid Channel")
+ self.status_msg = "Invalid Channel"
def print_stats(self):
+
n_total = self.burst.d_total_count
n_unknown = self.burst.d_unknown_count
n_known = n_total - n_unknown
print "======== STATS ========="
- print 'freq_offset: ',self.burst.mean_freq_offset()
+ print 'freq_offset: ',self.offset
+ print 'mean_offset: ',self.burst.mean_freq_offset()
print 'sync_loss_count:',self.burst.d_sync_loss_count
print 'total_bursts: ',n_total
print 'fcch_count: ',self.burst.d_fcch_count
@@ -496,8 +534,9 @@ class app_flow_graph(stdgui.gui_flow_graph):
self.print_stats()
def on_idle(self, event):
- print "Idle.\n";
-
+ self._set_status_msg(self.status_msg)
+ #print "Idle.\n";
+
def main ():
app = stdgui.stdapp(app_flow_graph, "GSM Scanner", nstatus=1)
app.MainLoop()
personal git repositories of Harald Welte. Your mileage may vary