summaryrefslogtreecommitdiff
path: root/gsm-tvoid/src/python
diff options
context:
space:
mode:
authortvoid <tvoid@lesaige.com>2008-04-04 00:25:27 -0600
committertvoid <tvoid@lesaige.com>2008-04-04 00:25:27 -0600
commitcac311da272dc0607979d7f8ad85c62a52fb80aa (patch)
tree771082b612a27c9b3472683eda3b0afd3f77ca16 /gsm-tvoid/src/python
parent9cdb53878ddd6c93c05bf701b1665c58fe7d16d1 (diff)
tvoid working copy as of 2008-04-03
Diffstat (limited to 'gsm-tvoid/src/python')
-rwxr-xr-xgsm-tvoid/src/python/gsm_scan.py96
1 files changed, 76 insertions, 20 deletions
diff --git a/gsm-tvoid/src/python/gsm_scan.py b/gsm-tvoid/src/python/gsm_scan.py
index 42f7944..f8fa033 100755
--- a/gsm-tvoid/src/python/gsm_scan.py
+++ b/gsm-tvoid/src/python/gsm_scan.py
@@ -1,9 +1,13 @@
#!/usr/bin/env python
# TODO:
-# * Auto-tune offset
+# * Adjust offset by PPM
+# * Auto-tune offset (add option to enable)
# * Add status info to window (frequency, offset, etc)
# * Put direct frequency tuning back
-# * Add rate-limited of file reads (Fix throttle?)
+# * Add rate-limited file reads (throttle?)
+# * Make console only version
+# * Reset burst_stats on retune
+# * Add better option checking
import sys
@@ -65,10 +69,29 @@ def get_freq_from_arfcn(chan,region):
return freq * 1e6
+#class gsm_tuner(gsm.gsm_tuner_callback):
+class gsm_tuner(gr.feval_dd):
+ def __init__(self, fg):
+ gr.feval_dd.__init__(self)
+ self.fg = fg
+
+ def eval(self, x):
+ try:
+ print "tune: ", x, "\n";
+ fg.cb_count += 1
+ return 0.0
+
+ except Exception, e:
+ print "tune: Exception: ", e
+
+
class app_flow_graph(stdgui.gui_flow_graph):
def __init__(self, frame, panel, vbox, argv):
stdgui.gui_flow_graph.__init__(self)
+ #testing
+ self.cb_count = 0
+
self.frame = frame
self.panel = panel
@@ -81,7 +104,7 @@ class app_flow_graph(stdgui.gui_flow_graph):
help="What to print on console. [default=%default]\n" +
"(n)othing, (e)verything, (s)tatus, (a)ll Types, (k)nown, (u)nknown, \n" +
"TS(0), (F)CCH, (S)CH, (N)ormal, (D)ummy\n" +
- "Usefull (b)its, All TS (B)its, (C)orrelation bits")
+ "Usefull (b)its, All TS (B)its, (C)orrelation bits, he(x) burst data")
#decoder options
@@ -110,6 +133,7 @@ class app_flow_graph(stdgui.gui_flow_graph):
#usrp options
parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
help="Select USRP Rx side A or B (default=first one with a daughterboard)")
+ #FIXME: gain not working?
parser.add_option("-g", "--gain", type="eng_float", default=None,
help="Set gain in dB (default is midpoint)")
parser.add_option("-c", "--channel", type="int", default=None,
@@ -144,7 +168,12 @@ class app_flow_graph(stdgui.gui_flow_graph):
if options.clock_offset:
clock_rate = 64e6 + options.clock_offset
elif options.channel:
- percent_offset = options.offset / get_freq_from_arfcn(options.channel,options.region)
+ f = get_freq_from_arfcn(options.channel,options.region)
+ if f:
+ percent_offset = options.offset / get_freq_from_arfcn(options.channel,options.region)
+ else:
+ percent_offset = 0.0
+
clock_rate += clock_rate * percent_offset
print "% offset = ", percent_offset, "clock = ", clock_rate
@@ -206,9 +235,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.tuner = gsm_tuner(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.tuner,input_rate)
self.connect(self.filter, self.burst)
elif options.decoder.count("f"):
@@ -225,7 +257,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.tuner)
self.connect(self.filter, self.demod, self.clocker, self.burst)
if self.scopes.count("d"):
@@ -284,6 +316,9 @@ class app_flow_graph(stdgui.gui_flow_graph):
#console print options
popts = 0
+ if options.print_console.count('s'):
+ popts |= gsm.PRINT_STATE
+
if options.print_console.count('e'):
popts |= gsm.PRINT_EVERYTHING
@@ -313,6 +348,9 @@ class app_flow_graph(stdgui.gui_flow_graph):
if options.print_console.count('C'):
popts |= gsm.PRINT_BITS | gsm.PRINT_CORR_BITS
+
+ if options.print_console.count('x'):
+ popts |= gsm.PRINT_BITS | gsm.PRINT_HEX
if options.print_console.count('B'):
popts |= gsm.PRINT_BITS | gsm.PRINT_ALL_BITS
@@ -320,7 +358,12 @@ class app_flow_graph(stdgui.gui_flow_graph):
elif options.print_console.count('b'):
popts |= gsm.PRINT_BITS
- self.burst.d_print_options = popts
+ self.burst.d_print_options = popts
+
+ ##########################
+ #set burst tuning callback
+ #self.tuner = gsm_tuner()
+ #self.burst.set_tuner_callback(self.tuner)
# connect the primary path after source
self.v2s = gr.vector_to_stream(gr.sizeof_float,142) #burst output is 142 (USEFUL_BITS)
@@ -434,21 +477,34 @@ class app_flow_graph(stdgui.gui_flow_graph):
self.set_freq(freq)
else:
self._set_status_msg("Invalid Channel")
-
+
+ def print_stats(self):
+ n_known = self.burst.d_fcch_count + self.burst.d_sch_count + self.burst.d_normal_count + self.burst.d_dummy_count
+ n_total = n_known + self.burst.d_dummy_count
+
+ print "======== STATS ========="
+ print 'freq_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
+ print 'part_sch_count: ',self.burst.d_part_sch_count
+ print 'sch_count: ',self.burst.d_sch_count
+ print 'normal_count: ',self.burst.d_normal_count
+ print 'dummy_count: ',self.burst.d_dummy_count
+ print 'unknown_count: ',self.burst.d_unknown_count
+ print 'known_count: ',n_known
+ if n_total:
+ print '%known: ', 100.0 * n_known / n_total
+ print 'CB count: ',self.cb_count
+ print ""
+
def on_tick(self, evt):
+ #if option.autotune
+ #tune offset
+
if self.print_status:
- #TODO: def print_stats:
- print "======== STATS ========="
- print 'freq_offset:',self.burst.freq_offset()
- print 'sync_loss_count:',self.burst.d_sync_loss_count
- print 'fcch_count:',self.burst.d_fcch_count
- print 'part_sch_count:',self.burst.d_part_sch_count
- print 'sch_count:',self.burst.d_sch_count
- print 'normal_count:',self.burst.d_normal_count
- print 'dummy_count:',self.burst.d_dummy_count
- print 'unknown_count:',self.burst.d_unknown_count
- print ""
-
+ self.print_stats()
+
def main ():
app = stdgui.stdapp(app_flow_graph, "GSM Scanner", nstatus=1)
app.MainLoop()
personal git repositories of Harald Welte. Your mileage may vary