summaryrefslogtreecommitdiff
path: root/gr-pager
diff options
context:
space:
mode:
Diffstat (limited to 'gr-pager')
-rw-r--r--gr-pager/AUTHORS1
-rw-r--r--gr-pager/Makefile.am26
-rw-r--r--gr-pager/README38
-rw-r--r--gr-pager/src/Makefile.am109
-rw-r--r--gr-pager/src/__init__.py25
-rw-r--r--gr-pager/src/flex_demod.py57
-rw-r--r--gr-pager/src/pager.i61
-rw-r--r--gr-pager/src/pager_flex_deframer.cc324
-rw-r--r--gr-pager/src/pager_flex_deframer.h95
-rw-r--r--gr-pager/src/pager_slicer_fb.cc100
-rw-r--r--gr-pager/src/pager_slicer_fb.h58
-rw-r--r--gr-pager/src/pageri_bch3221.cc31
-rw-r--r--gr-pager/src/pageri_bch3221.h31
-rw-r--r--gr-pager/src/pageri_flex_modes.cc33
-rw-r--r--gr-pager/src/pageri_flex_modes.h45
-rwxr-xr-xgr-pager/src/qa_pager.py35
-rw-r--r--gr-pager/src/run_tests.in10
-rwxr-xr-xgr-pager/src/usrp_flex.py162
18 files changed, 1241 insertions, 0 deletions
diff --git a/gr-pager/AUTHORS b/gr-pager/AUTHORS
new file mode 100644
index 000000000..cdb61c9f1
--- /dev/null
+++ b/gr-pager/AUTHORS
@@ -0,0 +1 @@
+Johnathan Corgan <jcorgan@aeinet.com>
diff --git a/gr-pager/Makefile.am b/gr-pager/Makefile.am
new file mode 100644
index 000000000..a9fc0d490
--- /dev/null
+++ b/gr-pager/Makefile.am
@@ -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 2, 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
+
+SUBDIRS = src
+
+MOSTLYCLEANFILES = *~ *.tmp \ No newline at end of file
diff --git a/gr-pager/README b/gr-pager/README
new file mode 100644
index 000000000..f898d7ae0
--- /dev/null
+++ b/gr-pager/README
@@ -0,0 +1,38 @@
+This GNU Radio component implements (will implement) common radiopager
+signaling protocols such as POCSAG and FLEX.
+
+Current status (9/13/06):
+
+FLEX receiving is in mid-stream of implemention.
+
+pager.slicer_fb() Accepts a complex baseband downconverted channel
+ and outputs 4-level FSK symbols [0-3] as bytes.
+ This may migrate into gnuradio-core at some point.
+
+pager.flex_deframer() Accepts a symbol stream from slicer_fb() and
+ outputs received 32-bit FLEX codewords for each
+ defined phase. Auto adjusts for 1600 or 3200 bps,
+ and 2 or 4 level FSK encoding based on received
+ synchronization word. The sync portion of this
+ block may factor out into its own block for
+ purposes of clarity and code complexity.
+
+pager.bch3221_ecd() (not yet implemented) Accepts a stream of 32-bit
+ FLEX codewords and applies BCH (32,21) error
+ detection/correction (up to 2 bits), the emits
+ corrected stream. This may be absorbed into the
+ deframer at some point.
+
+pager.message_decode() (not yet implemented) Accepts a stream of 32-bit
+ FLEX codewords and separates individual paging
+ messages into output stream as bytes.
+
+pager.flex_decode() Combines the above blocks correctly to convert
+ from downconverted baseband to pager messages
+
+usrp_flex.py Instantiates USRP receive chain to receive FLEX
+ protocol pages. See command-line help for options.
+ This will probably make it into gnuradio-examples.
+
+Johnathan Corgan
+jcorgan@aeinet.com
diff --git a/gr-pager/src/Makefile.am b/gr-pager/src/Makefile.am
new file mode 100644
index 000000000..7438d2384
--- /dev/null
+++ b/gr-pager/src/Makefile.am
@@ -0,0 +1,109 @@
+#
+# Copyright 2004,2005,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 2, 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
+
+EXTRA_DIST = \
+ run_tests.in
+
+TESTS = \
+ run_tests
+
+noinst_PYTHON = \
+ qa_pager.py
+
+# Install this stuff so that it ends up as the gnuradio.pgr module
+# This usually ends up at:
+# ${prefix}/lib/python${python_version}/site-packages/gnuradio/pager
+
+ourpythondir = $(grpythondir)/pager
+ourlibdir = $(grpyexecdir)/pager
+
+INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS)
+
+SWIGPYTHONARGS = $(SWIGPYTHONFLAGS) $(STD_DEFINES_AND_INCLUDES)
+
+ALL_IFILES = \
+ $(LOCAL_IFILES) \
+ $(NON_LOCAL_IFILES)
+
+NON_LOCAL_IFILES = \
+ $(GNURADIO_I)
+
+LOCAL_IFILES = \
+ $(top_srcdir)/gr-pager/src/pager.i
+
+# These files are built by SWIG. The first is the C++ glue.
+# The second is the python wrapper that loads the _howto shared library
+# and knows how to call our extensions.
+
+BUILT_SOURCES = \
+ pager_swig.cc \
+ pager_swig.py
+
+# This gets pgr.py installed in the right place
+ourpython_PYTHON = \
+ __init__.py \
+ pager_swig.py \
+ flex_demod.py \
+ usrp_flex.py
+
+ourlib_LTLIBRARIES = _pager_swig.la
+
+# These are the source files that go into the shared library
+_pager_swig_la_SOURCES = \
+ pager_swig.cc \
+ pager_slicer_fb.cc \
+ pager_flex_deframer.cc \
+ pageri_flex_modes.cc \
+ pageri_bch3221.cc
+ # Additional source modules here
+
+# magic flags
+_pager_swig_la_LDFLAGS = $(NO_UNDEFINED) -module -avoid-version
+
+# link the library against the c++ standard library
+_pager_swig_la_LIBADD = \
+ $(PYTHON_LDFLAGS) \
+ $(GNURADIO_CORE_LIBS) \
+ -lstdc++
+
+pager_swig.cc pager_swig.py: $(ALL_IFILES)
+ $(SWIG) $(SWIGPYTHONARGS) -module pager_swig -o pager_swig.cc $(LOCAL_IFILES)
+
+# These headers get installed in ${prefix}/include/gnuradio
+grinclude_HEADERS = \
+ pager_slicer_fb.h \
+ pager_flex_deframer.h \
+ pageri_flex_modes.h \
+ pageri_bch3221.h
+ # Additional header files here
+
+# These swig headers get installed in ${prefix}/include/gnuradio/swig
+swiginclude_HEADERS = \
+ $(LOCAL_IFILES)
+
+MOSTLYCLEANFILES = $(BUILT_SOURCES) *.pyc *~ *.tmp
+
+# Don't distribute output of swig
+dist-hook:
+ @for file in $(BUILT_SOURCES); do echo $(RM) $(distdir)/$$file; done
+ @for file in $(BUILT_SOURCES); do $(RM) $(distdir)/$$file; done
diff --git a/gr-pager/src/__init__.py b/gr-pager/src/__init__.py
new file mode 100644
index 000000000..cf0edaa96
--- /dev/null
+++ b/gr-pager/src/__init__.py
@@ -0,0 +1,25 @@
+#
+# 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 2, 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
diff --git a/gr-pager/src/flex_demod.py b/gr-pager/src/flex_demod.py
new file mode 100644
index 000000000..8326c9fa5
--- /dev/null
+++ b/gr-pager/src/flex_demod.py
@@ -0,0 +1,57 @@
+#
+# 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 2, 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, optfir
+from math import pi
+import pager_swig
+
+class flex_demod(gr.hier_block):
+ """
+ FLEX protocol demodulation block.
+
+ This block demodulates a band-limited, complex down-converted baseband
+ channel into FLEX protocol frames.
+
+ Flow graph (so far):
+
+ QUAD - Quadrature demodulator converts FSK to baseband amplitudes
+ LPF - Low pass filter to remove noise prior to slicer
+ SLICER - Converts input to one of four symbols (0, 1, 2, 3)
+ DEFRAMER - Syncronizes symbol stream and outputs FLEX codewords
+ ---
+
+ @param fg: flowgraph
+ @param channel_rate: incoming sample rate of the baseband channel
+ @type sample_rate: integer
+ """
+
+ def __init__(self, fg, channel_rate):
+ k = channel_rate/(2*pi*4800) # 4800 Hz max deviation
+ QUAD = gr.quadrature_demod_cf(k)
+
+ taps = optfir.low_pass(1.0, channel_rate, 3200, 6400, 0.1, 60)
+ LPF = gr.fir_filter_fff(1, taps)
+ SLICER = pager_swig.slicer_fb(.001, .00001) # Attack, decay
+ DEFRAMER = pager_swig.flex_deframer(channel_rate)
+
+ fg.connect(QUAD, LPF, SLICER, DEFRAMER)
+
+ gr.hier_block.__init__(self, fg, QUAD, DEFRAMER)
diff --git a/gr-pager/src/pager.i b/gr-pager/src/pager.i
new file mode 100644
index 000000000..1e14af085
--- /dev/null
+++ b/gr-pager/src/pager.i
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2005,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 2, 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.
+ */
+
+%feature("autodoc","1");
+%include "exception.i"
+%import "gnuradio.i"
+
+%{
+#include "gnuradio_swig_bug_workaround.h" // mandatory bug fix
+#include "pager_slicer_fb.h"
+#include "pager_flex_deframer.h"
+#include <stdexcept>
+%}
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(pager,slicer_fb);
+
+pager_slicer_fb_sptr pager_make_slicer_fb(float alpha, float beta);
+
+class pager_slicer_fb : public gr_sync_block
+{
+private:
+ pager_slicer_fb(float alpha, float beta);
+
+public:
+};
+
+// ----------------------------------------------------------------
+
+GR_SWIG_BLOCK_MAGIC(pager,flex_deframer);
+
+pager_flex_deframer_sptr pager_make_flex_deframer(int rate);
+
+class pager_flex_deframer : public gr_block
+{
+private:
+ pager_flex_deframer(int rate);
+
+public:
+};
+
+// ----------------------------------------------------------------
diff --git a/gr-pager/src/pager_flex_deframer.cc b/gr-pager/src/pager_flex_deframer.cc
new file mode 100644
index 000000000..1f8c90209
--- /dev/null
+++ b/gr-pager/src/pager_flex_deframer.cc
@@ -0,0 +1,324 @@
+/*
+ * 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 2, 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pager_flex_deframer.h>
+#include <pageri_flex_modes.h>
+#include <gr_io_signature.h>
+#include <gr_count_bits.h>
+
+pager_flex_deframer_sptr pager_make_flex_deframer(int rate)
+{
+ return pager_flex_deframer_sptr(new pager_flex_deframer(rate));
+}
+
+// FLEX deframer block takes input from symbol stream with alphabet [0, 1, 2, 3]
+// at specified channel rate and and outputs deinterleaved 32-bit FLEX code words
+// at 50, 100, or 200 code words per second (based on detected mode in sync
+// word).
+
+pager_flex_deframer::pager_flex_deframer(int rate) :
+ gr_block ("flex_deframer",
+ gr_make_io_signature (1, 1, sizeof(unsigned char)),
+ gr_make_io_signature (1, 1, sizeof(gr_int32))),
+ d_sync(rate/1600) // Maximum samples per baud
+{
+ d_rate = rate;
+ set_output_multiple(1);
+ enter_idle();
+}
+
+void pager_flex_deframer::forecast(int noutput_items, gr_vector_int &inputs_required)
+{
+ // samples per bit X 32 bits * number of outputs needed
+ int items = noutput_items*sizeof(gr_int32)*8*d_spb;
+ for (unsigned int i = 0; i < inputs_required.size(); i++)
+ inputs_required[i] = items;
+}
+
+int pager_flex_deframer::index_avg(int start, int end)
+{
+ // modulo average
+ if (start < end)
+ return (end + start)/2;
+ else
+ return ((end + start)/2 + d_spb/2) % d_spb;
+}
+
+bool pager_flex_deframer::test_sync(unsigned char sym)
+{
+ // 64-bit FLEX sync code:
+ // AAAA:BBBBBBBB:CCCC
+ //
+ // Where BBBBBBBB is always 0xA6C6AAAA
+ // and AAAA^CCCC is 0xFFFF
+ //
+ // Specific values of AAAA determine what bps and encoding the
+ // packet is beyond the frame information word
+ //
+ // First we match on the marker field with a hamming distance < 4
+ // Then we match on the outer code with a hamming distance < 4
+
+ d_sync[d_index] = (d_sync[d_index] << 1) | (sym < 2);
+ gr_int64 val = d_sync[d_index];
+ gr_int32 marker = ((val & 0x0000FFFFFFFF0000ULL)) >> 16;
+
+ if (gr_count_bits32(marker^FLEX_SYNC_MARKER) < 4) {
+ gr_int32 code = ((val & 0xFFFF000000000000ULL) >> 32) |
+ (val & 0x000000000000FFFFULL);
+
+ for (int i = 0; i < num_flex_modes; i++) {
+ if (gr_count_bits32(code^flex_modes[i].sync) < 4) {
+ d_mode = i;
+ return true;
+ }
+ }
+
+ // Marker received but doesn't match known codes
+ // All codes have high word inverted to low word
+ unsigned short high = (code & 0xFFFF0000) >> 16;
+ unsigned short low = code & 0x0000FFFF;
+ unsigned short syn = high^low;
+ if (syn == 0xFFFF)
+ fprintf(stderr, "Unknown sync code detected: %08X\n", code);
+ }
+
+ return false;
+}
+
+void pager_flex_deframer::enter_idle()
+{
+ d_state = ST_IDLE;
+ d_index = 0;
+ d_start = 0;
+ d_center = 0;
+ d_end = 0;
+ d_count = 0;
+ d_mode = 0;
+ d_baudrate = 1600;
+ d_levels = 2;
+ d_spb = d_rate/d_baudrate;
+ d_hibit = false;
+ d_cdi = 0;
+ d_cdw = 0;
+ d_blk = 0;
+}
+
+void pager_flex_deframer::enter_syncing()
+{
+ d_start = d_index;
+ d_state = ST_SYNCING;
+}
+
+void pager_flex_deframer::enter_sync1()
+{
+ d_state = ST_SYNC1;
+ d_end = d_index;
+ d_center = index_avg(d_start, d_end);
+ d_count = 0;
+ fprintf(stderr, "SYNC1=%08X\n", flex_modes[d_mode].sync);
+}
+
+void pager_flex_deframer::enter_sync2()
+{
+ d_state = ST_SYNC2;
+ d_count = 0;
+ d_baudrate = flex_modes[d_mode].baud;
+ d_levels = flex_modes[d_mode].levels;
+ d_spb = d_rate/d_baudrate;
+
+ if (d_baudrate == 3200) {
+ // Oversampling buffer just got halved
+ d_center = d_center/2;
+ d_index = d_index/2-d_spb/2; // We're here at the center of a 1600 baud bit
+ d_count = -1; // So this hack gets us in the right place for 3200
+ }
+}
+
+void pager_flex_deframer::enter_data()
+{
+ d_state = ST_DATA;
+ d_count = 0;
+}
+
+void pager_flex_deframer::enter_output()
+{
+ d_state = ST_OUTPUT;
+ d_count = flex_modes[d_mode].phases*88; // Now d_count will count codewords, not bits
+ d_output_phase = 0; // Always phase A
+ d_output_index = 0;
+}
+
+void pager_flex_deframer::accumulate_frames(unsigned char sym)
+{
+ // Bits are encoded with 2-bit gray code
+ //
+ // SYM Bit1 Bit2
+ // --- ---- ----
+ // 0 1 1
+ // 1 1 0
+ // 2 0 0
+ // 3 0 1
+
+ // Codewords are interleaved in blocks of 8
+ //
+ // ABCDEFGH
+ // ABCDEFGH
+ // ABCDEFGH
+ // ABCDEFGH
+ // ...
+ // etc., for all 32 bits. So each successive incoming bit is multiplexed
+ // into a different d_frames[][], indexed by d_cdw
+
+ d_cdw = d_blk*8+d_cdi;
+ assert(d_cdw < 88);
+
+ if (d_baudrate == 1600) {
+ d_frames[0][d_cdw] <<= 1;
+ d_frames[0][d_cdw] |= (sym < 2);
+
+ if (d_levels == 4) {
+ d_frames[1][d_cdw] <<= 1;
+ d_frames[1][d_cdw] |= (sym == 0 || sym == 3);
+ }
+ }
+ else {
+ if (!d_hibit) {
+ d_frames[0][d_cdw] <<= 1;
+ d_frames[0][d_cdw] |= (sym < 2);
+
+ if (d_levels == 4) {
+ d_frames[1][d_cdw] <<= 1;
+ d_frames[1][d_cdw] |= (sym == 0 || sym == 3);
+ }
+ d_hibit = true;
+ }
+ else {
+ d_frames[2][d_cdw] <<= 1;
+ d_frames[2][d_cdw] |= (sym < 2);
+
+ if (d_levels == 4) {
+ d_frames[3][d_cdw] <<= 1;
+ d_frames[3][d_cdw] |= (sym == 0 || sym == 3);
+ }
+ d_hibit = false;
+ }
+ }
+
+ d_cdi = ++d_cdi % 8;
+ if (++d_count % (d_baudrate*4/25) == 0)
+ d_blk++;
+}
+
+int pager_flex_deframer::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const unsigned char *in = (const unsigned char *)input_items[0];
+ gr_int32 *out = (gr_int32 *)output_items[0];
+
+ int i = 0, j = 0;
+ int ninputs = ninput_items[0];
+
+ while (i < ninputs && j < noutput_items) {
+ unsigned char sym = 0;
+ if (d_state != ST_OUTPUT) {
+ sym = *in++; i++;
+ d_index = ++d_index % d_spb;
+ }
+
+ switch (d_state) {
+ case ST_IDLE:
+ if (test_sync(sym))
+ enter_syncing();
+ break;
+
+ case ST_SYNCING:
+ if (!test_sync(sym)) {
+ enter_sync1();
+ // Output sync code
+ *out++ = flex_modes[d_mode].sync; j++;
+ }
+ break;
+
+ case ST_SYNC1:
+ if (d_index == d_center) {
+ d_sync[d_index] = (d_sync[d_index] << 1) | (sym < 2);
+ if (++d_count == 48) { // Skip 16 bits of dotting
+ // Output frame information word
+ *out++ = (gr_int32)(d_sync[d_index] & 0x00000000FFFFFFFFULL); j++;
+ enter_sync2();
+ }
+ }
+ break;
+
+ case ST_SYNC2:
+ if (d_index == d_center) {
+ // Skip 25 ms = 40 bits @ 1600 bps, 80 @ 3200 bps
+ if (++d_count == d_baudrate/40)
+ enter_data();
+ }
+ break;
+
+ case ST_DATA:
+ if (d_index == d_center) {
+ accumulate_frames(sym);
+ if (d_count == d_baudrate*1760/1000)
+ enter_output();
+ }
+ break;
+
+ case ST_OUTPUT:
+ output_codeword(out++); j++;
+ if (--d_count == 0)
+ enter_idle();
+ break;
+
+ default:
+ assert(0); // memory corruption of d_state if ever gets here
+ break;
+
+ }
+ }
+
+ consume_each(i);
+ return j;
+}
+
+void pager_flex_deframer::output_codeword(gr_int32 *out)
+{
+ *out = d_frames[d_output_phase][d_output_index++];
+
+ if (d_output_index == 88) {
+ d_output_index = 0;
+ d_output_phase++;
+ if (d_output_phase == 1 && !flex_modes[d_mode].phase_b)
+ d_output_phase++;
+ if (d_output_phase == 2 && !flex_modes[d_mode].phase_c)
+ d_output_phase++;
+ if (d_output_phase == 3 && !flex_modes[d_mode].phase_d)
+ d_output_phase++;
+ }
+}
diff --git a/gr-pager/src/pager_flex_deframer.h b/gr-pager/src/pager_flex_deframer.h
new file mode 100644
index 000000000..43e6ef7b7
--- /dev/null
+++ b/gr-pager/src/pager_flex_deframer.h
@@ -0,0 +1,95 @@
+/*
+ * 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 2, 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.
+ */
+
+#ifndef INCLUDED_PAGER_FLEX_DEFRAMER_H
+#define INCLUDED_PAGER_FLEX_DEFRAMER_H
+
+#include <gr_block.h>
+
+class pager_flex_deframer;
+typedef boost::shared_ptr<pager_flex_deframer> pager_flex_deframer_sptr;
+typedef std::vector<gr_int64> gr_int64_vector;
+
+pager_flex_deframer_sptr pgr_make_flex_deframer(int rate);
+
+/*!
+ * \brief flex deframer description
+ * \ingroup block
+ */
+
+class pager_flex_deframer : public gr_block
+{
+private:
+ // Constructors
+ friend pager_flex_deframer_sptr pager_make_flex_deframer(int rate);
+ pager_flex_deframer(int rate);
+
+ // State machine transitions
+ void enter_idle();
+ void enter_syncing();
+ void enter_sync1();
+ void enter_sync2();
+ void enter_data();
+ void enter_output();
+
+ int index_avg(int start, int end);
+ bool test_sync(unsigned char sym);
+ void accumulate_frames(unsigned char sym);
+ void output_codeword(gr_int32 *out);
+
+ // Simple state machine
+ enum state_t { ST_IDLE, ST_SYNCING, ST_SYNC1, ST_SYNC2, ST_DATA, ST_OUTPUT };
+ state_t d_state;
+
+ int d_rate; // Incoming sample rate
+ int d_index; // Index into current baud
+ int d_start; // Start of good sync
+ int d_center; // Center of bit
+ int d_end; // End of good sync
+ int d_count; // Bit counter
+
+ int d_mode; // Current packet mode
+ int d_baudrate; // Current decoding baud rate
+ int d_levels; // Current decoding levels
+ int d_spb; // Current samples per baud
+ bool d_hibit; // Current bit is high bit when 3200 baud
+
+ gr_int64_vector d_sync; // Trial synchronizers
+
+ int d_cdi; // 0-7 code word index for deinterleave
+ int d_cdw; // 0-87 code word index for frame
+ int d_blk; // 0-10 block index
+
+ int d_output_phase; // Indexes d_frames[][] during output
+ int d_output_index; // indexes d_frames[][] during output
+
+ gr_int32 d_frames[4][88]; // Frame accumulators for each phase
+
+public:
+ void forecast(int noutput_items, gr_vector_int &inputs_required);
+
+ int general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_PAGER_FLEX_DEFRAMER_H */
diff --git a/gr-pager/src/pager_slicer_fb.cc b/gr-pager/src/pager_slicer_fb.cc
new file mode 100644
index 000000000..98e8a2b00
--- /dev/null
+++ b/gr-pager/src/pager_slicer_fb.cc
@@ -0,0 +1,100 @@
+/*
+ * 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 2, 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pager_slicer_fb.h>
+#include <gr_io_signature.h>
+
+pager_slicer_fb_sptr pager_make_slicer_fb(float alpha, float beta)
+{
+ return pager_slicer_fb_sptr(new pager_slicer_fb(alpha, beta));
+}
+
+pager_slicer_fb::pager_slicer_fb(float alpha, float beta) :
+ gr_sync_block ("slicer_fb",
+ gr_make_io_signature (1, 1, sizeof(float)),
+ gr_make_io_signature (1, 1, sizeof(unsigned char)))
+{
+ d_alpha = alpha;
+ d_beta = beta;
+ d_max = 0.0;
+ d_hi = 0.0;
+ d_avg = 0.0;
+ d_lo = 0.0;
+ d_min = 0.0;
+}
+
+// Tracks average, minimum, and peak, then converts input into one of:
+//
+// [0, 1, 2, 3]
+unsigned char pager_slicer_fb::slice(float sample)
+{
+ unsigned char decision;
+
+ // Update DC level and remove
+ d_avg = d_avg*(1.0-d_alpha)+sample*d_alpha;
+ sample -= d_avg;
+
+ if (sample > 0) {
+ if (sample > d_hi) { // In max region
+ d_max = d_max*(1.0-d_alpha) + sample*d_alpha;
+ decision = 3;
+ }
+ else {
+ d_max -= (d_max-d_avg)*d_beta; // decay otherwise
+ decision = 2;
+ }
+ }
+ else {
+ if (sample < d_lo) { // In min region
+ d_min = d_min*(1.0-d_alpha) + sample*d_alpha;
+ decision = 0;
+ }
+ else {
+ d_min -= (d_min-d_avg)*d_beta; // decay otherwise
+ decision = 1;
+ }
+ }
+
+ d_hi = d_max*2.0/3.0;
+ d_lo = d_min*2.0/3.0;
+
+ //fprintf(stderr, "%f %d\n", sample, decision);
+ return decision;
+}
+
+int pager_slicer_fb::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ float *iptr = (float *) input_items[0];
+ unsigned char *optr = (unsigned char *) output_items[0];
+
+ int size = noutput_items;
+
+ for (int i = 0; i < size; i++)
+ *optr++ = slice(*iptr++);
+
+ return noutput_items;
+}
diff --git a/gr-pager/src/pager_slicer_fb.h b/gr-pager/src/pager_slicer_fb.h
new file mode 100644
index 000000000..052cb8263
--- /dev/null
+++ b/gr-pager/src/pager_slicer_fb.h
@@ -0,0 +1,58 @@
+/*
+ * 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 2, 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.
+ */
+
+#ifndef INCLUDED_PAGER_SLICER_FB_H
+#define INCLUDED_PAGER_SLICER_FB_H
+
+#include <gr_sync_block.h>
+
+class pager_slicer_fb;
+typedef boost::shared_ptr<pager_slicer_fb> pager_slicer_fb_sptr;
+
+pager_slicer_fb_sptr pgr_make_slicer_fb(float alpha, float beta);
+
+/*!
+ * \brief slicer description
+ * \ingroup block
+ */
+class pager_slicer_fb : public gr_sync_block
+{
+private:
+ friend pager_slicer_fb_sptr pager_make_slicer_fb(float alpha, float beta);
+ pager_slicer_fb(float alpha, float beta);
+
+ unsigned char slice(float sample);
+
+ float d_alpha; // Attack constant
+ float d_beta; // Decay constant
+ float d_max; // Maximum value for symbol comparison
+ float d_hi; // High side decision boundary
+ float d_avg; // Average value for DC offset subtraction
+ float d_lo; // Low side decision boundary
+ float d_min; // Minimum value for symbol comparison
+
+public:
+ int work (int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_PAGER_SLICER_FB_H */
diff --git a/gr-pager/src/pageri_bch3221.cc b/gr-pager/src/pageri_bch3221.cc
new file mode 100644
index 000000000..7e2e28978
--- /dev/null
+++ b/gr-pager/src/pageri_bch3221.cc
@@ -0,0 +1,31 @@
+/*
+ * 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 2, 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pageri_bch3221.h>
+
+int pageri_bch3221(gr_int32 &data)
+{
+ return 0;
+}
diff --git a/gr-pager/src/pageri_bch3221.h b/gr-pager/src/pageri_bch3221.h
new file mode 100644
index 000000000..c4767b231
--- /dev/null
+++ b/gr-pager/src/pageri_bch3221.h
@@ -0,0 +1,31 @@
+/*
+ * 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 2, 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.
+ */
+
+#ifndef INCLUDED_PAGERI_BCH3221_H
+#define INCLUDED_PAGERI_BCH3221_H
+
+#include <gr_types.h>
+
+// Perform BCH (32,21) error correction on supplied data
+// Return number of errors found/corrected (0, 1, or 2)
+int pageri_bch3221(gr_int32 &data);
+
+#endif /* INCLUDED_PAGERI_BCH3221_H */
diff --git a/gr-pager/src/pageri_flex_modes.cc b/gr-pager/src/pageri_flex_modes.cc
new file mode 100644
index 000000000..a846643a7
--- /dev/null
+++ b/gr-pager/src/pageri_flex_modes.cc
@@ -0,0 +1,33 @@
+/*
+ * 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 2, 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 "pageri_flex_modes.h"
+
+const flex_mode_t flex_modes[] =
+{
+ { 0x870C78F3, 1600, 2, true, false, false, false, 1 },
+ { 0xB0684F97, 1600, 4, true, true, false, false, 2 },
+// { 0xUNKNOWN, 3200, 2, true, false, true, false, 2 },
+ { 0xDEA0215F, 3200, 4, true, true, true, true, 4 },
+ { 0x4C7CB383, 3200, 4, true, true, true, true, 4 }
+};
+
+const int num_flex_modes = sizeof(flex_modes);
diff --git a/gr-pager/src/pageri_flex_modes.h b/gr-pager/src/pageri_flex_modes.h
new file mode 100644
index 000000000..ab8b10683
--- /dev/null
+++ b/gr-pager/src/pageri_flex_modes.h
@@ -0,0 +1,45 @@
+/*
+ * 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 2, 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.
+ */
+
+#ifndef INCLUDED_PAGERI_FLEX_MODES_H
+#define INCLUDED_PAGERI_FLEX_MODES_H
+
+#include <gr_types.h>
+
+#define FLEX_SYNC_MARKER 0xA6C6AAAA
+
+typedef struct flex_mode
+{
+ gr_int32 sync; // Outer synchronization code
+ unsigned int baud; // Baudrate of SYNC2 and DATA
+ unsigned int levels; // FSK encoding of SYNC2 and DATA
+ bool phase_a; // PHASEA is transmitted
+ bool phase_b; // PHASEB is transmitted
+ bool phase_c; // PHASEC is transmitted
+ bool phase_d; // PHASED is transmitted
+ int phases; // number of phases transmitted
+}
+flex_mode_t;
+
+extern const flex_mode_t flex_modes[];
+extern const int num_flex_modes;
+
+#endif // INCLUDED_PAGERI_FLEX_MODES_H
diff --git a/gr-pager/src/qa_pager.py b/gr-pager/src/qa_pager.py
new file mode 100755
index 000000000..5b9a3996c
--- /dev/null
+++ b/gr-pager/src/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 2, 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.fg = gr.flow_graph ()
+
+ def tearDown (self):
+ self.fg = None
+
+if __name__ == '__main__':
+ gr_unittest.main ()
diff --git a/gr-pager/src/run_tests.in b/gr-pager/src/run_tests.in
new file mode 100644
index 000000000..6bb0c3980
--- /dev/null
+++ b/gr-pager/src/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@
diff --git a/gr-pager/src/usrp_flex.py b/gr-pager/src/usrp_flex.py
new file mode 100755
index 000000000..ae455fde0
--- /dev/null
+++ b/gr-pager/src/usrp_flex.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gru, usrp, optfir, eng_notation, blks
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import time, os, sys
+
+from flex_demod import flex_demod
+
+"""
+This example application demonstrates receiving and demodulating the
+FLEX pager protocol.
+
+A receive chain is built up of the following signal processing
+blocks:
+
+USRP - Daughter board source generating complex baseband signal.
+CHAN - Low pass filter to select channel bandwidth
+RFSQL - RF squelch zeroing output when input power below threshold
+AGC - Automatic gain control leveling signal at [-1.0, +1.0]
+FLEX - FLEX pager protocol decoder
+SINK - File sink for decoded output
+
+The following are required command line parameters:
+
+-f FREQ USRP receive frequency
+
+The following are optional command line parameters:
+
+-R SUBDEV Daughter board specification, defaults to first found
+-c FREQ Calibration offset. Gets added to receive frequency.
+ Defaults to 0.0 Hz.
+-g GAIN Daughterboard gain setting. Defaults to mid-range.
+-r RFSQL RF squelch in db. Defaults to -50.0.
+
+Once the program is running, ctrl-break (Ctrl-C) stops operation.
+"""
+
+def make_filename(dir, freq):
+ t = time.strftime('%Y%m%d-%H%M%S')
+ f = 'r%s-%s.dat' % (t, eng_notation.num_to_str(freq))
+ return os.path.join(dir, f)
+
+class usrp_source_c(gr.hier_block):
+ """
+ Create a USRP source object supplying complex floats.
+
+ Selects user supplied subdevice or chooses first available one.
+
+ Calibration value is the offset from the tuned frequency to
+ the actual frequency.
+ """
+ def __init__(self, fg, subdev_spec, decim, gain=None, calibration=0.0):
+ self._decim = decim
+ self._src = usrp.source_c()
+ if subdev_spec is None:
+ subdev_spec = usrp.pick_rx_subdevice(self._src)
+ self._subdev = usrp.selected_subdev(self._src, subdev_spec)
+ self._src.set_mux(usrp.determine_rx_mux_value(self._src, subdev_spec))
+ self._src.set_decim_rate(self._decim)
+
+ # If no gain specified, set to midrange
+ if gain is None:
+ g = self._subdev.gain_range()
+ gain = (g[0]+g[1])/2.0
+
+ self._subdev.set_gain(gain)
+ self._cal = calibration
+
+ gr.hier_block.__init__(self, fg, self._src, self._src)
+
+ def tune(self, freq):
+ result = usrp.tune(self._src, 0, self._subdev, freq+self._cal)
+ # TODO: deal with residual
+
+ def rate(self):
+ return self._src.adc_rate()/self._decim
+
+class app_flow_graph(gr.flow_graph):
+ def __init__(self, options, args):
+ gr.flow_graph.__init__(self)
+ self.options = options
+ self.args = args
+
+ USRP = usrp_source_c(self, # Flow graph
+ options.rx_subdev_spec, # Daugherboard spec
+ 250, # IF decimation ratio gets 256K if_rate
+ options.gain, # Receiver gain
+ options.calibration) # Frequency offset
+ USRP.tune(options.frequency)
+
+ if_rate = USRP.rate()
+ channel_rate = 32000 # Oversampled by 10 or 20
+ channel_decim = if_rate // channel_rate
+
+ CHAN_taps = optfir.low_pass(1.0, # Filter gain
+ if_rate, # Sample rate
+ 8000, # One sided modulation bandwidth
+ 10000, # One sided channel bandwidth
+ 0.1, # Passband ripple
+ 60) # Stopband attenuation
+
+ CHAN = gr.freq_xlating_fir_filter_ccf(channel_decim, # Decimation rate
+ CHAN_taps, # Filter taps
+ 0.0, # Offset frequency
+ if_rate) # Sample rate
+
+ RFSQL = gr.pwr_squelch_cc(options.rf_squelch, # Power threshold
+ 125.0/channel_rate, # Time constant
+ channel_rate/20, # 50ms rise/fall
+ False) # Zero, not gate output
+
+ AGC = gr.agc_cc(1.0/channel_rate, # Time constant
+ 1.0, # Reference power
+ 1.0, # Initial gain
+ 1.0) # Maximum gain
+
+ FLEX = flex_demod(self, 32000)
+
+ SINK = gr.file_sink(4, options.filename)
+
+ self.connect(USRP, CHAN)
+ self.connect(CHAN, RFSQL)
+ self.connect(RFSQL, AGC)
+ self.connect(AGC, FLEX)
+ self.connect(FLEX, SINK)
+
+def main():
+ parser = OptionParser(option_class=eng_option)
+ parser.add_option("-f", "--frequency", type="eng_float",
+ help="set receive frequency to Hz", metavar="Hz")
+ parser.add_option("-R", "--rx-subdev-spec", type="subdev",
+ help="select USRP Rx side A or B", metavar="SUBDEV")
+ parser.add_option("-c", "--calibration", type="eng_float", default=0.0,
+ help="set frequency offset to Hz", metavar="Hz")
+ parser.add_option("-g", "--gain", type="int", default=None,
+ help="set RF gain", metavar="dB")
+ parser.add_option("-r", "--rf-squelch", type="eng_float", default=-50.0,
+ help="set RF squelch to dB", metavar="dB")
+ parser.add_option("-F", "--filename", default=None)
+ parser.add_option("-D", "--dir", default=None)
+ (options, args) = parser.parse_args()
+
+ if options.frequency < 1e6:
+ options.frequency *= 1e6
+
+ if options.filename is None and options.dir is None:
+ sys.stderr.write('Must specify either -F FILENAME or -D DIR\n')
+ parser.print_help()
+ sys.exit(1)
+
+ if options.filename is None:
+ options.filename = make_filename(options.dir, options.frequency)
+
+ fg = app_flow_graph(options, args)
+ try:
+ fg.run()
+ except KeyboardInterrupt:
+ pass
+
+if __name__ == "__main__":
+ main()