diff options
author | Johnathan Corgan | 2009-12-12 09:34:35 -0800 |
---|---|---|
committer | Johnathan Corgan | 2009-12-12 09:34:35 -0800 |
commit | bdf985aa55ed90394f9015ac7577892dba7e5cae (patch) | |
tree | 2786e704053f248cace6b61608fece4db21f6541 /gr-pager/python | |
parent | 861d2d1b16e708b65087b86e864980415abd123f (diff) | |
parent | 34c64290e3146b50053494839847e9f894d98493 (diff) | |
download | gnuradio-bdf985aa55ed90394f9015ac7577892dba7e5cae.tar.gz gnuradio-bdf985aa55ed90394f9015ac7577892dba7e5cae.tar.bz2 gnuradio-bdf985aa55ed90394f9015ac7577892dba7e5cae.zip |
Merge branch 'wip/pager' of git@gnuradio.org:jcorgan
Merge-fix: Fix erroneous EXTRA_DIST in lib/
Merge-fix: Don't install usrp_rx_flex.py (unfinished)
Diffstat (limited to 'gr-pager/python')
-rw-r--r-- | gr-pager/python/.gitignore | 2 | ||||
-rw-r--r-- | gr-pager/python/Makefile.am | 39 | ||||
-rw-r--r-- | gr-pager/python/__init__.py | 26 | ||||
-rw-r--r-- | gr-pager/python/flex_demod.py | 64 | ||||
-rw-r--r-- | gr-pager/python/pager_utils.py | 60 | ||||
-rwxr-xr-x | gr-pager/python/qa_pager.py | 35 | ||||
-rw-r--r-- | gr-pager/python/run_tests.in | 10 |
7 files changed, 236 insertions, 0 deletions
diff --git a/gr-pager/python/.gitignore b/gr-pager/python/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gr-pager/python/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gr-pager/python/Makefile.am b/gr-pager/python/Makefile.am new file mode 100644 index 000000000..f80375c7c --- /dev/null +++ b/gr-pager/python/Makefile.am @@ -0,0 +1,39 @@ +# +# Copyright 2004,2005,2006,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 GNU Radio; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, +# Boston, MA 02110-1301, USA. +# + +include $(top_srcdir)/Makefile.common + +if PYTHON +pagerdir = $(grpythondir)/pager + +noinst_PYTHON = \ + qa_pager.py + +pager_PYTHON = \ + __init__.py \ + pager_utils.py \ + flex_demod.py + +TESTS = run_tests + +EXTRA_DIST = run_tests.in + +endif diff --git a/gr-pager/python/__init__.py b/gr-pager/python/__init__.py new file mode 100644 index 000000000..664b79942 --- /dev/null +++ b/gr-pager/python/__init__.py @@ -0,0 +1,26 @@ +# +# 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 + +from pager_swig import * +from flex_demod import flex_demod +from pager_utils import * diff --git a/gr-pager/python/flex_demod.py b/gr-pager/python/flex_demod.py new file mode 100644 index 000000000..b79c1adaa --- /dev/null +++ b/gr-pager/python/flex_demod.py @@ -0,0 +1,64 @@ +# +# 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, gru, optfir, blks2 +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 = gr.quadrature_demod_cf(k) + self.connect(self, quad) + + rsamp = blks2.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 = gr.file_sink(gr.sizeof_float, 'quad'+suffix) + rsamp_sink = gr.file_sink(gr.sizeof_float, 'rsamp'+suffix) + slicer_sink = gr.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() +
\ No newline at end of file diff --git a/gr-pager/python/pager_utils.py b/gr-pager/python/pager_utils.py new file mode 100644 index 000000000..72aac6826 --- /dev/null +++ b/gr-pager/python/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/qa_pager.py b/gr-pager/python/qa_pager.py new file mode 100755 index 000000000..5bf72b561 --- /dev/null +++ b/gr-pager/python/qa_pager.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +# +# Copyright 2004,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. +# + +from gnuradio import gr, gr_unittest +import pager_swig + +class qa_pgr(gr_unittest.TestCase): + + def setUp (self): + self.tb = gr.top_block () + + def tearDown (self): + self.tb = None + +if __name__ == '__main__': + gr_unittest.main () diff --git a/gr-pager/python/run_tests.in b/gr-pager/python/run_tests.in new file mode 100644 index 000000000..6bb0c3980 --- /dev/null +++ b/gr-pager/python/run_tests.in @@ -0,0 +1,10 @@ +#!/bin/sh + +# 1st parameter is absolute path to component source directory +# 2nd parameter is absolute path to component build directory +# 3rd parameter is path to Python QA directory + +@top_builddir@/run_tests.sh \ + @abs_top_srcdir@/gr-pager \ + @abs_top_builddir@/gr-pager \ + @srcdir@ |