summaryrefslogtreecommitdiff
path: root/gsm-tvoid/src/python
diff options
context:
space:
mode:
Diffstat (limited to 'gsm-tvoid/src/python')
-rwxr-xr-xgsm-tvoid/src/python/gsm_scan.py59
1 files changed, 49 insertions, 10 deletions
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