summaryrefslogtreecommitdiff
path: root/gssm/src/python
diff options
context:
space:
mode:
authorHarald Welte <laforge@openmoko.org>2008-10-13 09:02:02 +0200
committerHarald Welte <laforge@openmoko.org>2008-10-13 09:02:02 +0200
commit08f95b2ac7f377f98f83761b52027b88824d7a64 (patch)
tree08a81eabd6f4dba1f66a6190a7668087634f1916 /gssm/src/python
parent3f97e0be9f90c505f34afa8371c25a0ffa3e97c1 (diff)
initial import of gssm-v0.1.1a
Diffstat (limited to 'gssm/src/python')
-rwxr-xr-xgssm/src/python/file_gssm.py45
-rwxr-xr-xgssm/src/python/file_stats.py46
-rwxr-xr-xgssm/src/python/gssm_stats.py85
-rwxr-xr-xgssm/src/python/gssm_usrp.py63
4 files changed, 239 insertions, 0 deletions
diff --git a/gssm/src/python/file_gssm.py b/gssm/src/python/file_gssm.py
new file mode 100755
index 0000000..47013f3
--- /dev/null
+++ b/gssm/src/python/file_gssm.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+# $Id: file_gssm.py,v 1.3 2007-07-07 16:31:44 jl Exp $
+
+from gnuradio import gr, usrp, db_dbs_rx, blks
+from gnuradio.blksimpl import gmsk
+import gssm
+import sys
+
+#sps = 1000e3
+
+usrp_rate = 64e6
+decim_rate = 112
+sps = usrp_rate / decim_rate
+
+gsm_rate = 1625000.0 / 6.0
+
+#xcf = 150e3
+#xtw = 50e3
+#xm = -31127.933289
+
+file_name = "signal.data"
+
+
+class gssm_graph(gr.flow_graph):
+ def __init__(self, fname):
+ gr.flow_graph.__init__(self)
+
+ src = gr.file_source(gr.sizeof_gr_complex, fname)
+ gs = gssm.sink()
+ self.connect(src, gs)
+
+def main():
+ fname = file_name
+ if len(sys.argv) == 2:
+ fname = sys.argv[1]
+ try:
+ gg = gssm_graph(fname)
+ gg.run()
+
+ except KeyboardInterrupt:
+ pass
+
+if __name__ == '__main__':
+ main()
diff --git a/gssm/src/python/file_stats.py b/gssm/src/python/file_stats.py
new file mode 100755
index 0000000..cf8a109
--- /dev/null
+++ b/gssm/src/python/file_stats.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+
+# $Id: file_stats.py,v 1.1 2007-07-07 16:26:33 jl Exp $
+
+from gnuradio import gr, usrp, db_dbs_rx, blks
+from gnuradio.blksimpl import gmsk
+import gssm
+import sys
+
+#sps = 1000e3
+
+usrp_rate = 64e6
+decim_rate = 112
+sps = usrp_rate / decim_rate
+
+gsm_rate = 1625000.0 / 6.0
+
+#xcf = 150e3
+#xtw = 50e3
+#xm = -31127.933289
+
+file_name = "signal.data"
+
+
+class gssm_graph(gr.flow_graph):
+ def __init__(self, fname):
+ gr.flow_graph.__init__(self)
+
+ src = gr.file_source(gr.sizeof_gr_complex, fname)
+ self.gs = gs = gssm.sink(sps)
+ self.connect(src, gs)
+
+def main():
+ fname = file_name
+ if len(sys.argv) == 2:
+ fname = sys.argv[1]
+ try:
+ gg = gssm_graph(fname)
+ gg.run()
+ gg.gs.stats()
+
+ except KeyboardInterrupt:
+ pass
+
+if __name__ == '__main__':
+ main()
diff --git a/gssm/src/python/gssm_stats.py b/gssm/src/python/gssm_stats.py
new file mode 100755
index 0000000..43677d9
--- /dev/null
+++ b/gssm/src/python/gssm_stats.py
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+
+# $Id: gssm_stats.py,v 1.2 2007-07-07 16:31:44 jl Exp $
+
+from gnuradio import gr, usrp, db_dbs_rx, blks
+from gnuradio.blksimpl import gmsk
+import usrp_dbid
+import gssm
+import sys
+import time
+import thread
+
+# constant
+gsm_rate = 1625000.0 / 6.0
+
+# script constant
+decim = 112
+gain = 32
+
+# bts channel
+c0 = 874e6
+
+# experimental constant
+default_usrp_offset = 4e3
+
+# filter constants
+xcf = 150e3
+xtw = 50e3
+
+def display_stats(gs):
+ while 1:
+ print "%d:\t%d:%d" % \
+ (gs.d_found_fc_count, gs.d_valid_s, gs.d_invalid_s)
+ time.sleep(1)
+
+
+class gssm_flow_graph(gr.flow_graph):
+ def __init__(self, usrp_offset):
+ gr.flow_graph.__init__(self)
+
+ print "decim = %d, gain = %d, offset = %.2f" % \
+ (decim, gain, usrp_offset)
+ print "filter center %.2f, filter width %.2f" % \
+ (xcf, xtw)
+
+ u = usrp.source_c(decim_rate = decim)
+ s = usrp.pick_subdev(u, (usrp_dbid.DBS_RX,))
+ u.set_mux(usrp.determine_rx_mux_value(u, s))
+ subdev = usrp.selected_subdev(u, s)
+
+ if subdev.dbid() != usrp_dbid.DBS_RX:
+ raise Exception('dbs daughterboard not detected!')
+
+ subdev.set_gain(gain)
+
+ sps = u.adc_freq() / u.decim_rate()
+ if sps < 2 * gsm_rate:
+ raise Exception('sample rate too low')
+
+ u.tune(0, subdev, c0 + usrp_offset)
+
+ xt = gr.firdes.low_pass(1.0, sps, xcf, xtw,
+ gr.firdes.WIN_HAMMING)
+ xf = gr.fir_filter_ccf(1, xt)
+
+ self.gs = gs = gssm.sink()
+
+ self.connect(u, xf, gs)
+
+def main():
+ if len(sys.argv) == 2:
+ uo = float(sys.argv[1])
+ else:
+ uo = default_usrp_offset
+ g = gssm_flow_graph(uo)
+ # thread.start_new_thread(display_stats, (g.gs,))
+ # g.run()
+ g.start()
+ time.sleep(10.0)
+ g.stop()
+ g.gs.stats()
+
+if __name__ == '__main__':
+ main()
+
diff --git a/gssm/src/python/gssm_usrp.py b/gssm/src/python/gssm_usrp.py
new file mode 100755
index 0000000..6fe84c5
--- /dev/null
+++ b/gssm/src/python/gssm_usrp.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+
+# $Id: gssm_usrp.py,v 1.2 2007-07-07 16:31:44 jl Exp $
+
+from gnuradio import gr, usrp, db_dbs_rx, blks
+from gnuradio.blksimpl import gmsk
+from usrpm import usrp_dbid
+import gssm
+import sys
+
+# constant
+gsm_rate = 1625000.0 / 6.0
+
+# script constant
+decim = 112
+gain = 70
+
+# bts channel
+c0 = 875.4e6
+
+# experimental constant
+default_usrp_offset = 12e3
+
+class gssm_flow_graph(gr.flow_graph):
+ def __init__(self, usrp_offset):
+ gr.flow_graph.__init__(self)
+
+ u = usrp.source_c(decim_rate = decim)
+ s = usrp.pick_subdev(u, (usrp_dbid.DBS_RX,))
+ u.set_mux(usrp.determine_rx_mux_value(u, s))
+ subdev = usrp.selected_subdev(u, s)
+
+ if subdev.dbid() != usrp_dbid.DBS_RX:
+ raise Exception('dbs daughterboard not detected!')
+
+ subdev.set_gain(gain)
+
+ sps = u.adc_freq() / u.decim_rate()
+ if sps < 2 * gsm_rate:
+ raise Exception('sample rate too low')
+
+ u.tune(0, subdev, c0 + usrp_offset)
+
+ xcf = 150e3
+ xtw = 50e3
+ xt = gr.firdes.low_pass(1.0, sps, xcf, xtw,
+ gr.firdes.WIN_HAMMING)
+ xf = gr.fir_filter_ccf(1, xt)
+
+ g = gssm.sink()
+
+ self.connect(u, xf, g)
+
+def main():
+ if len(sys.argv) == 2:
+ uo = float(sys.argv[1])
+ else:
+ uo = default_usrp_offset
+ g = gssm_flow_graph(uo)
+ g.run()
+
+if __name__ == '__main__':
+ main()
personal git repositories of Harald Welte. Your mileage may vary