summaryrefslogtreecommitdiff
path: root/gr-pager/python/pager
diff options
context:
space:
mode:
Diffstat (limited to 'gr-pager/python/pager')
-rw-r--r--gr-pager/python/pager/CMakeLists.txt50
-rw-r--r--gr-pager/python/pager/__init__.py37
-rw-r--r--gr-pager/python/pager/flex_demod.py66
-rw-r--r--gr-pager/python/pager/pager_utils.py60
-rwxr-xr-xgr-pager/python/pager/qa_pager.py34
5 files changed, 247 insertions, 0 deletions
diff --git a/gr-pager/python/pager/CMakeLists.txt b/gr-pager/python/pager/CMakeLists.txt
new file mode 100644
index 0000000000..c93573c2ad
--- /dev/null
+++ b/gr-pager/python/pager/CMakeLists.txt
@@ -0,0 +1,50 @@
+# Copyright 2011-2012 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+########################################################################
+include(GrPython)
+
+GR_PYTHON_INSTALL(
+ FILES
+ __init__.py
+ pager_utils.py
+ flex_demod.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/pager
+ COMPONENT "pager_python"
+)
+
+########################################################################
+# Handle the unit tests
+########################################################################
+if(ENABLE_TESTING)
+
+ set(GR_TEST_TARGET_DEPS "")
+ set(GR_TEST_LIBRARY_DIRS "")
+ set(GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gruel/src/python
+ ${CMAKE_BINARY_DIR}/gnuradio-core/src/python
+ )
+
+ include(GrTest)
+ file(GLOB py_qa_test_files "qa_*.py")
+ foreach(py_qa_test_file ${py_qa_test_files})
+ get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
+ GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+ endforeach(py_qa_test_file)
+endif(ENABLE_TESTING)
diff --git a/gr-pager/python/pager/__init__.py b/gr-pager/python/pager/__init__.py
new file mode 100644
index 0000000000..ea4856fad6
--- /dev/null
+++ b/gr-pager/python/pager/__init__.py
@@ -0,0 +1,37 @@
+#
+# Copyright 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+# The presence of this file turns this directory into a Python package
+
+'''
+The GNU Radio pager application.
+'''
+import os
+
+try:
+ from pager_swig import *
+except ImportError:
+ dirname, filename = os.path.split(os.path.abspath(__file__))
+ __path__.append(os.path.join(dirname, "..", "..", "swig"))
+ from pager_swig import *
+
+from flex_demod import flex_demod
+from pager_utils import *
diff --git a/gr-pager/python/pager/flex_demod.py b/gr-pager/python/pager/flex_demod.py
new file mode 100644
index 0000000000..3ed469886c
--- /dev/null
+++ b/gr-pager/python/pager/flex_demod.py
@@ -0,0 +1,66 @@
+#
+# Copyright 2006,2007 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr
+from gnuradio import analog
+from gnuradio import blocks
+from gnuradio import filter
+from math import pi
+import pager_swig
+
+class flex_demod(gr.hier_block2):
+ """
+ FLEX pager protocol demodulation block.
+
+ This block demodulates a band-limited, complex down-converted baseband
+ channel into FLEX protocol frames.
+
+ """
+
+ def __init__(self, queue, freq=0.0, verbose=False, log=False):
+ gr.hier_block2.__init__(self, "flex_demod",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex),
+ gr.io_signature(0,0,0))
+
+ k = 25000/(2*pi*1600) # 4800 Hz max deviation
+ quad = analog.quadrature_demod_cf(k)
+ self.connect(self, quad)
+
+ rsamp = filter.rational_resampler_fff(16, 25)
+ self.slicer = pager_swig.slicer_fb(5e-6) # DC removal averaging filter constant
+ self.sync = pager_swig.flex_sync()
+
+ self.connect(quad, rsamp, self.slicer, self.sync)
+
+ for i in range(4):
+ self.connect((self.sync, i), pager_swig.flex_deinterleave(), pager_swig.flex_parse(queue, freq))
+
+ if log:
+ suffix = '_'+ "%3.3f" % (freq/1e6,) + '.dat'
+ quad_sink = blocks.file_sink(gr.sizeof_float, 'quad'+suffix)
+ rsamp_sink = blocks.file_sink(gr.sizeof_float, 'rsamp'+suffix)
+ slicer_sink = blocks.file_sink(gr.sizeof_char, 'slicer'+suffix)
+ self.connect(rsamp, rsamp_sink)
+ self.connect(quad, quad_sink)
+ self.connect(self.slicer, slicer_sink)
+
+ def dc_offset(self):
+ return self.slicer.dc_offset()
diff --git a/gr-pager/python/pager/pager_utils.py b/gr-pager/python/pager/pager_utils.py
new file mode 100644
index 0000000000..e935c86d4b
--- /dev/null
+++ b/gr-pager/python/pager/pager_utils.py
@@ -0,0 +1,60 @@
+#
+# Copyright 2008,2009 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+from gnuradio import gr
+import gnuradio.gr.gr_threading as _threading
+from string import split, join, printable
+import time
+
+def make_trans_table():
+ table = 256 * ['.']
+ for i in range(256):
+ if (i < 32):
+ table[i] = '.'
+ else:
+ table[i] = chr(i)
+ return ''.join(table)
+
+_trans_table = make_trans_table()
+
+def make_printable(s):
+ return s.translate(_trans_table)
+
+
+class queue_runner(_threading.Thread):
+ def __init__(self, msgq):
+ _threading.Thread.__init__(self)
+ self.msgq = msgq
+ self.done = False
+ self.start()
+
+ def run(self):
+ while 1:
+ msg = self.msgq.delete_head() # Blocking read
+ if msg.type() != 0:
+ break
+
+ page = join(split(msg.to_string(), chr(128)), '|')
+ s = make_printable(page)
+ print msg.type(), s
+
+ def end(self):
+ self.msgq.insert_tail(gr.message(1))
+ self.done = True
diff --git a/gr-pager/python/pager/qa_pager.py b/gr-pager/python/pager/qa_pager.py
new file mode 100755
index 0000000000..dc9705e292
--- /dev/null
+++ b/gr-pager/python/pager/qa_pager.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+#
+# Copyright 2004,2006,2010 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+from gnuradio import gr, gr_unittest, pager
+
+class test_pager(gr_unittest.TestCase):
+
+ def setUp (self):
+ self.tb = gr.top_block ()
+
+ def tearDown (self):
+ self.tb = None
+
+if __name__ == '__main__':
+ gr_unittest.run(test_pager, "test_pager.xml")