summaryrefslogtreecommitdiff
path: root/gr-pager/src
diff options
context:
space:
mode:
Diffstat (limited to 'gr-pager/src')
-rw-r--r--gr-pager/src/Makefile.am3
-rw-r--r--gr-pager/src/__init__.py1
-rw-r--r--gr-pager/src/pager_utils.py47
-rwxr-xr-xgr-pager/src/usrp_flex.py15
-rwxr-xr-xgr-pager/src/usrp_flex_all.py17
-rwxr-xr-xgr-pager/src/usrp_flex_band.py19
6 files changed, 72 insertions, 30 deletions
diff --git a/gr-pager/src/Makefile.am b/gr-pager/src/Makefile.am
index 5c70db2f5..d0245444a 100644
--- a/gr-pager/src/Makefile.am
+++ b/gr-pager/src/Makefile.am
@@ -71,8 +71,9 @@ BUILT_SOURCES = \
ourpython_PYTHON = \
__init__.py \
pager_swig.py \
+ pager_utils.py \
flex_demod.py
-
+
ourlib_LTLIBRARIES = _pager_swig.la
# These are the source files that go into the shared library
diff --git a/gr-pager/src/__init__.py b/gr-pager/src/__init__.py
index 6ef60d939..664b79942 100644
--- a/gr-pager/src/__init__.py
+++ b/gr-pager/src/__init__.py
@@ -23,3 +23,4 @@
from pager_swig import *
from flex_demod import flex_demod
+from pager_utils import *
diff --git a/gr-pager/src/pager_utils.py b/gr-pager/src/pager_utils.py
new file mode 100644
index 000000000..bbcb633fd
--- /dev/null
+++ b/gr-pager/src/pager_utils.py
@@ -0,0 +1,47 @@
+#
+# Copyright 2008 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.
+#
+
+import gnuradio.gr.gr_threading as _threading
+
+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 top_block_runner(_threading.Thread):
+ def __init__(self, tb):
+ _threading.Thread.__init__(self)
+ self.setDaemon(1)
+ self.tb = tb
+ self.done = False
+ self.start()
+
+ def run(self):
+ self.tb.run()
+ self.done = True
diff --git a/gr-pager/src/usrp_flex.py b/gr-pager/src/usrp_flex.py
index f636030e9..6e09b3df6 100755
--- a/gr-pager/src/usrp_flex.py
+++ b/gr-pager/src/usrp_flex.py
@@ -160,27 +160,24 @@ def main():
# Flow graph emits pages into message queue
queue = gr.msg_queue()
tb = app_top_block(options, queue)
+ runner = pager.top_block_runner(tb)
try:
- tb.start()
while 1:
if not queue.empty_p():
msg = queue.delete_head() # Blocking read
page = join(split(msg.to_string(), chr(128)), '|')
- disp = []
- for n in range(len(page)):
- if ord(page[n]) < 32:
- disp.append('.')
- else:
- disp.append(page[n])
- print join(disp, '')
+ s = pager.make_printable(page)
+ print s
tb.adjust_freq()
-
+ elif runner.done:
+ break
else:
time.sleep(1)
except KeyboardInterrupt:
tb.stop()
+ runner = None
if __name__ == "__main__":
main()
diff --git a/gr-pager/src/usrp_flex_all.py b/gr-pager/src/usrp_flex_all.py
index daee3532c..b37c6a5da 100755
--- a/gr-pager/src/usrp_flex_all.py
+++ b/gr-pager/src/usrp_flex_all.py
@@ -77,25 +77,22 @@ def main():
queue = gr.msg_queue()
tb = app_top_block(options, queue)
+ runner = pager.top_block_runner(tb)
try:
- tb.start()
while 1:
if not queue.empty_p():
msg = queue.delete_head() # Blocking read
page = join(split(msg.to_string(), chr(128)), '|')
- disp = []
- for n in range(len(page)):
- if ord(page[n]) < 32:
- disp.append('.')
- else:
- disp.append(page[n])
- print join(disp, '')
-
+ s = pager.make_printable(page)
+ print s
+ elif runner.done:
+ break
else:
- time.sleep(1)
+ time.sleep(0.05)
except KeyboardInterrupt:
tb.stop()
+ runner = None
if __name__ == "__main__":
main()
diff --git a/gr-pager/src/usrp_flex_band.py b/gr-pager/src/usrp_flex_band.py
index 2f272575a..62307385b 100755
--- a/gr-pager/src/usrp_flex_band.py
+++ b/gr-pager/src/usrp_flex_band.py
@@ -9,6 +9,7 @@ import time
class app_top_block(gr.top_block):
def __init__(self, options, queue):
gr.top_block.__init__(self, "usrp_flex_all")
+ self.subdev = None
if options.from_file is not None:
self.src = gr.file_source(gr.sizeof_gr_complex, options.from_file)
@@ -57,6 +58,7 @@ class app_top_block(gr.top_block):
# Avoid weak-ref error
del self.subdev
+
def main():
parser = OptionParser(option_class=eng_option)
parser.add_option("-f", "--frequency", type="eng_float", default=929.5e6,
@@ -81,25 +83,22 @@ def main():
queue = gr.msg_queue()
tb = app_top_block(options, queue)
+ runner = pager.top_block_runner(tb)
try:
- tb.start()
while 1:
if not queue.empty_p():
msg = queue.delete_head() # Blocking read
page = join(split(msg.to_string(), chr(128)), '|')
- disp = []
- for n in range(len(page)):
- if ord(page[n]) < 32:
- disp.append('.')
- else:
- disp.append(page[n])
- print join(disp, '')
-
+ s = pager.make_printable(page)
+ print s
+ elif runner.done:
+ break
else:
- time.sleep(1)
+ time.sleep(0.05)
except KeyboardInterrupt:
tb.stop()
+ runner = None
if __name__ == "__main__":
main()