summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-pager/CMakeLists.txt10
-rw-r--r--gr-pager/include/pager/CMakeLists.txt32
-rw-r--r--gr-pager/include/pager/api.h (renamed from gr-pager/lib/pager_api.h)0
-rw-r--r--gr-pager/include/pager/flex_deinterleave.h (renamed from gr-pager/lib/pager_flex_deinterleave.h)52
-rw-r--r--gr-pager/include/pager/flex_frame.h (renamed from gr-pager/lib/pager_flex_frame.h)38
-rw-r--r--gr-pager/include/pager/flex_parse.h52
-rw-r--r--gr-pager/include/pager/flex_sync.h49
-rw-r--r--gr-pager/include/pager/slicer_fb.h (renamed from gr-pager/lib/pageri_flex_modes.cc)58
-rw-r--r--gr-pager/lib/CMakeLists.txt37
-rw-r--r--gr-pager/lib/bch3221.cc (renamed from gr-pager/lib/pager_flex_frame.cc)29
-rw-r--r--gr-pager/lib/bch3221.h (renamed from gr-pager/swig/pager_flex_frame.i)25
-rw-r--r--gr-pager/lib/flex_deinterleave_impl.cc107
-rw-r--r--gr-pager/lib/flex_deinterleave_impl.h54
-rw-r--r--gr-pager/lib/flex_frame_impl.cc48
-rw-r--r--gr-pager/lib/flex_frame_impl.h (renamed from gr-pager/lib/pageri_util.h)25
-rw-r--r--gr-pager/lib/flex_modes.cc66
-rw-r--r--gr-pager/lib/flex_modes.h79
-rw-r--r--gr-pager/lib/flex_parse_impl.cc258
-rw-r--r--gr-pager/lib/flex_parse_impl.h70
-rw-r--r--gr-pager/lib/flex_sync_impl.cc365
-rw-r--r--gr-pager/lib/flex_sync_impl.h95
-rw-r--r--gr-pager/lib/pager_flex_deinterleave.cc94
-rw-r--r--gr-pager/lib/pager_flex_parse.cc240
-rw-r--r--gr-pager/lib/pager_flex_parse.h73
-rw-r--r--gr-pager/lib/pager_flex_sync.cc340
-rw-r--r--gr-pager/lib/pager_flex_sync.h101
-rw-r--r--gr-pager/lib/pager_slicer_fb.cc84
-rw-r--r--gr-pager/lib/pager_slicer_fb.h57
-rw-r--r--gr-pager/lib/pageri_bch3221.h31
-rw-r--r--gr-pager/lib/pageri_flex_modes.h74
-rw-r--r--gr-pager/lib/pageri_util.cc46
-rw-r--r--gr-pager/lib/slicer_fb_impl.cc99
-rw-r--r--gr-pager/lib/slicer_fb_impl.h54
-rw-r--r--gr-pager/lib/util.cc55
-rw-r--r--gr-pager/lib/util.h (renamed from gr-pager/lib/pageri_bch3221.cc)27
-rwxr-xr-xgr-pager/python/qa_pager.py2
-rw-r--r--gr-pager/swig/CMakeLists.txt5
-rw-r--r--gr-pager/swig/gnuradio/pager.scm28
-rw-r--r--gr-pager/swig/pager_flex_deinterleave.i11
-rw-r--r--gr-pager/swig/pager_flex_parse.i11
-rw-r--r--gr-pager/swig/pager_flex_sync.i11
-rw-r--r--gr-pager/swig/pager_slicer_fb.i12
-rw-r--r--gr-pager/swig/pager_swig.i30
43 files changed, 1653 insertions, 1381 deletions
diff --git a/gr-pager/CMakeLists.txt b/gr-pager/CMakeLists.txt
index 3feae16e02..d25e842b48 100644
--- a/gr-pager/CMakeLists.txt
+++ b/gr-pager/CMakeLists.txt
@@ -34,9 +34,16 @@ GR_REGISTER_COMPONENT("gr-pager" ENABLE_GR_PAGER
)
GR_SET_GLOBAL(GR_PAGER_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_BINARY_DIR}/include
)
+GR_SET_GLOBAL(GR_PAGER_SWIG_INCLUDE_DIRS
+ ${CMAKE_CURRENT_SOURCE_DIR}/swig
+)
+
+SET(GR_PKG_PAGER_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/pager)
+
########################################################################
# Begin conditional configuration
########################################################################
@@ -79,6 +86,7 @@ CPACK_COMPONENT("pager_swig"
########################################################################
# Add subdirectories
########################################################################
+add_subdirectory(include/pager)
add_subdirectory(lib)
if(ENABLE_PYTHON)
add_subdirectory(python)
diff --git a/gr-pager/include/pager/CMakeLists.txt b/gr-pager/include/pager/CMakeLists.txt
new file mode 100644
index 0000000000..57b96199bf
--- /dev/null
+++ b/gr-pager/include/pager/CMakeLists.txt
@@ -0,0 +1,32 @@
+# Copyright 2012,2013 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.
+
+########################################################################
+# Install header files
+########################################################################
+install(FILES
+ api.h
+ flex_frame.h
+ slicer_fb.h
+ flex_deinterleave.h
+ flex_parse.h
+ flex_sync.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/noaa
+ COMPONENT "noaa_devel"
+)
diff --git a/gr-pager/lib/pager_api.h b/gr-pager/include/pager/api.h
index 4312c5ae38..4312c5ae38 100644
--- a/gr-pager/lib/pager_api.h
+++ b/gr-pager/include/pager/api.h
diff --git a/gr-pager/lib/pager_flex_deinterleave.h b/gr-pager/include/pager/flex_deinterleave.h
index c702da23d7..75e1ec5f99 100644
--- a/gr-pager/lib/pager_flex_deinterleave.h
+++ b/gr-pager/include/pager/flex_deinterleave.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,34 +23,29 @@
#ifndef INCLUDED_PAGER_FLEX_DEINTERLEAVE_H
#define INCLUDED_PAGER_FLEX_DEINTERLEAVE_H
-#include <pager_api.h>
+#include <pager/api.h>
#include <gr_sync_decimator.h>
-class pager_flex_deinterleave;
-typedef boost::shared_ptr<pager_flex_deinterleave> pager_flex_deinterleave_sptr;
-
-PAGER_API pager_flex_deinterleave_sptr pager_make_flex_deinterleave();
-
-/*!
- * \brief flex deinterleave description
- * \ingroup pager_blk
- */
-
-class PAGER_API pager_flex_deinterleave : public gr_sync_decimator
-{
-private:
- // Constructors
- friend PAGER_API pager_flex_deinterleave_sptr pager_make_flex_deinterleave();
- pager_flex_deinterleave();
-
- // One FLEX block of deinterleaved data
- gr_int32 d_codewords[8];
-
-public:
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
+namespace gr {
+ namespace pager {
+
+ /*!
+ * \brief flex deinterleave description
+ * \ingroup pager_blk
+ */
+ class PAGER_API flex_deinterleave : virtual public gr_sync_decimator
+ {
+ public:
+ // gr::pager::flex_deinterleave::sptr
+ typedef boost::shared_ptr<flex_deinterleave> sptr;
+
+ /*!
+ * \brief Make flex deinterleaver
+ */
+ static sptr make();
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
#endif /* INCLUDED_PAGER_FLEX_DEINTERLEAVE_H */
diff --git a/gr-pager/lib/pager_flex_frame.h b/gr-pager/include/pager/flex_frame.h
index 61973f7229..d8c190d1d4 100644
--- a/gr-pager/lib/pager_flex_frame.h
+++ b/gr-pager/include/pager/flex_frame.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -18,30 +19,29 @@
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
+
#ifndef INCLUDED_PAGER_FLEX_FRAME_H
#define INCLUDED_PAGER_FLEX_FRAME_H
-#include <pager_api.h>
+#include <pager/api.h>
#include <boost/shared_ptr.hpp>
-class pager_flex_frame;
-typedef boost::shared_ptr<pager_flex_frame> pager_flex_frame_sptr;
-
-/*!
- * \brief public constructor for pager_flex_frame
- */
-PAGER_API pager_flex_frame_sptr pager_make_flex_frame();
+namespace gr {
+ namespace pager {
+
+ /*!
+ * \brief flex_frame.
+ */
+ class PAGER_API flex_frame
+ {
+ public:
+ // gr::pager::flex_frame::sptr
+ typedef boost::shared_ptr<flex_frame> sptr;
-/*!
- * \brief flex_frame.
- */
-class PAGER_API pager_flex_frame {
- // Constructor is private to force use of shared_ptr
- pager_flex_frame();
- friend PAGER_API pager_flex_frame_sptr pager_make_flex_frame();
+ static sptr make();
+ };
-public:
- ~pager_flex_frame();
-};
+ } /* namespace pager */
+} /* namespace gr */
#endif /* INCLUDED_PAGER_FLEX_FRAME_H */
diff --git a/gr-pager/include/pager/flex_parse.h b/gr-pager/include/pager/flex_parse.h
new file mode 100644
index 0000000000..a8cd4c0f5c
--- /dev/null
+++ b/gr-pager/include/pager/flex_parse.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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.
+ */
+
+#ifndef INCLUDED_PAGER_FLEX_PARSE_H
+#define INCLUDED_PAGER_FLEX_PARSE_H
+
+#include <pager/api.h>
+#include <gr_sync_block.h>
+#include <gr_msg_queue.h>
+#include <sstream>
+
+namespace gr {
+ namespace pager {
+
+#define FIELD_DELIM ((unsigned char)128)
+
+ /*!
+ * \brief flex parse description
+ * \ingroup pager_blk
+ */
+ class PAGER_API flex_parse : virtual public gr_sync_block
+ {
+ public:
+ // gr::pager::flex_parse::sptr
+ typedef boost::shared_ptr<flex_parse> sptr;
+
+ static sptr make(gr_msg_queue_sptr queue, float freq);
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_FLEX_PARSE_H */
diff --git a/gr-pager/include/pager/flex_sync.h b/gr-pager/include/pager/flex_sync.h
new file mode 100644
index 0000000000..fb1c7ca8b2
--- /dev/null
+++ b/gr-pager/include/pager/flex_sync.h
@@ -0,0 +1,49 @@
+/* -*- c++ -*- */
+/*
+ * 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.
+ */
+
+#ifndef INCLUDED_PAGER_FLEX_SYNC_H
+#define INCLUDED_PAGER_FLEX_SYNC_H
+
+#include <pager/api.h>
+#include <gr_block.h>
+
+namespace gr {
+ namespace pager {
+
+ /*!
+ * \brief flex sync description
+ * \ingroup pager_blk
+ */
+ class PAGER_API flex_sync : virtual public gr_block
+ {
+ public:
+ // gr::pager::flex_sync::sptr
+ typedef boost::shared_ptr<flex_sync> sptr;
+
+ static sptr make();
+
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_FLEX_SYNC_H */
diff --git a/gr-pager/lib/pageri_flex_modes.cc b/gr-pager/include/pager/slicer_fb.h
index ad424fda19..452c0cbb92 100644
--- a/gr-pager/lib/pageri_flex_modes.cc
+++ b/gr-pager/include/pager/slicer_fb.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2006,2007 Free Software Foundation, Inc.
+ * Copyright 2006,2007,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -19,39 +20,34 @@
* Boston, MA 02110-1301, USA.
*/
-#include "pageri_flex_modes.h"
+#ifndef INCLUDED_PAGER_SLICER_FB_H
+#define INCLUDED_PAGER_SLICER_FB_H
-const flex_mode_t flex_modes[] =
-{
- { 0x870C78F3, 1600, 2 },
- { 0xB0684F97, 1600, 4 },
-// { 0xUNKNOWN, 3200, 2 },
- { 0xDEA0215F, 3200, 4 },
- { 0x4C7CB383, 3200, 4 }
-};
+#include <pager/api.h>
+#include <gr_sync_block.h>
-const int num_flex_modes = sizeof(flex_modes)/sizeof(flex_modes[0]);
+namespace gr {
+ namespace pager {
+
+ /*!
+ * \brief slicer description
+ * \ingroup pager_blk
+ */
+ class PAGER_API slicer_fb : virtual public gr_sync_block
+ {
+ public:
+ // gr::pager::slicer_fb::sptr
+ typedef boost::shared_ptr<slicer_fb> sptr;
-unsigned char flex_bcd[17] = "0123456789 U -][";
+ /*!
+ * \brief Make a pager slicer
+ */
+ static sptr make(float alpha);
-const char *flex_page_desc[] =
-{
- "ENC",
- "UNK",
- "TON",
- "NUM",
- "SPN",
- "ALN",
- "BIN",
- "NNM"
-};
+ virtual float dc_offset() const = 0;
+ };
-int find_flex_mode(gr_int32 sync_code)
-{
- for (int i = 0; i < num_flex_modes; i++)
- if (flex_modes[i].sync == sync_code)
- return i;
+ } /* namespace pager */
+} /* namespace gr */
- // Not found
- return -1;
-}
+#endif /* INCLUDED_PAGER_SLICER_FB_H */
diff --git a/gr-pager/lib/CMakeLists.txt b/gr-pager/lib/CMakeLists.txt
index cb62bcc752..b35553a696 100644
--- a/gr-pager/lib/CMakeLists.txt
+++ b/gr-pager/lib/CMakeLists.txt
@@ -32,15 +32,15 @@ link_directories(${Boost_LIBRARY_DIRS})
########################################################################
# Setup library
########################################################################
-list(APPEND gr_pager_sources
- pager_flex_frame.cc
- pager_slicer_fb.cc
- pager_flex_sync.cc
- pager_flex_deinterleave.cc
- pager_flex_parse.cc
- pageri_bch3221.cc
- pageri_flex_modes.cc
- pageri_util.cc
+list(APPEND pager_sources
+ flex_deinterleave_impl.cc
+ flex_frame_impl.cc
+ flex_parse_impl.cc
+ flex_sync_impl.cc
+ slicer_fb_impl.cc
+ bch3221.cc
+ flex_modes.cc
+ util.cc
)
list(APPEND pager_libs
@@ -48,23 +48,6 @@ list(APPEND pager_libs
${Boost_LIBRARIES}
)
-add_library(gnuradio-pager SHARED ${gr_pager_sources})
+add_library(gnuradio-pager SHARED ${pager_sources})
target_link_libraries(gnuradio-pager ${pager_libs})
GR_LIBRARY_FOO(gnuradio-pager RUNTIME_COMPONENT "pager_runtime" DEVEL_COMPONENT "pager_devel")
-
-########################################################################
-# Install header files
-########################################################################
-install(FILES
- pager_api.h
- pager_slicer_fb.h
- pager_flex_sync.h
- pager_flex_deinterleave.h
- pager_flex_parse.h
- pager_flex_frame.h
- pageri_bch3221.h
- pageri_flex_modes.h
- pageri_util.h
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio
- COMPONENT "pager_devel"
-)
diff --git a/gr-pager/lib/pager_flex_frame.cc b/gr-pager/lib/bch3221.cc
index 949f603208..46722611a3 100644
--- a/gr-pager/lib/pager_flex_frame.cc
+++ b/gr-pager/lib/bch3221.cc
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -22,17 +23,21 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
-#include <pager_flex_frame.h>
-pager_flex_frame_sptr pager_make_flex_frame()
-{
- return pager_flex_frame_sptr(new pager_flex_frame());
-}
+#include "bch3221.h"
-pager_flex_frame::pager_flex_frame()
-{
-}
+namespace gr {
+ namespace pager {
-pager_flex_frame::~pager_flex_frame()
-{
-}
+ // Corrects supplied data word according to BCH3221 encoding and
+ // returns the number of errors detected/corrected.
+ //
+ // Not implemented yet
+
+ int bch3221(int &data)
+ {
+ return 0;
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/swig/pager_flex_frame.i b/gr-pager/lib/bch3221.h
index 0ea996500d..24f39e39d7 100644
--- a/gr-pager/swig/pager_flex_frame.i
+++ b/gr-pager/lib/bch3221.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -19,19 +20,17 @@
* Boston, MA 02110-1301, USA.
*/
-class pager_flex_frame;
-typedef boost::shared_ptr<pager_flex_frame> pager_flex_frame_sptr;
-%template(pager_flex_frame_sptr) boost::shared_ptr<pager_flex_frame>;
+#ifndef INCLUDED_PAGER_BCH3221_H
+#define INCLUDED_PAGER_BCH3221_H
-%rename(flex_frame) pager_make_flex_frame;
-pager_flex_frame_sptr pager_make_flex_frame();
+namespace gr {
+ namespace pager {
-/*!
- * \brief flex_frame.
- */
-class pager_flex_frame {
- pager_flex_frame();
+ // Perform BCH (32,21) error correction on supplied data
+ // Return number of errors found/corrected (0, 1, or 2)
+ int bch3221(int &data);
-public:
-};
+ } /* namespace pager */
+} /* namespace gr */
+#endif /* INCLUDED_PAGER_BCH3221_H */
diff --git a/gr-pager/lib/flex_deinterleave_impl.cc b/gr-pager/lib/flex_deinterleave_impl.cc
new file mode 100644
index 0000000000..01557c49ed
--- /dev/null
+++ b/gr-pager/lib/flex_deinterleave_impl.cc
@@ -0,0 +1,107 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2010,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "flex_deinterleave_impl.h"
+#include "bch3221.h"
+#include "util.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace pager {
+
+ flex_deinterleave::sptr
+ flex_deinterleave::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new flex_deinterleave_impl());
+ }
+
+ flex_deinterleave_impl::flex_deinterleave_impl() :
+ gr_sync_decimator("flex_deinterleave",
+ gr_make_io_signature(1, 1, sizeof(unsigned char)),
+ gr_make_io_signature(1, 1, sizeof(int)), 32)
+ {
+ set_output_multiple(8); // One FLEX block at a time
+ }
+
+ flex_deinterleave_impl::~flex_deinterleave_impl()
+ {
+ }
+
+ int flex_deinterleave_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned char *in = (const unsigned char *)input_items[0];
+ int *out = (int *)output_items[0];
+
+ // FLEX codewords are interleaved in blocks of 256 bits or 8, 32
+ // bit codes. To deinterleave we parcel each incoming bit into
+ // the MSB of each codeword, then switch to MSB-1, etc. This is
+ // done by shifting in the bits from the right on each codeword
+ // as the bits come in. When we are done we have a FLEX block of
+ // eight codewords, ready for conversion to data words.
+ //
+ // FLEX data words are recovered by reversing the bit order of
+ // the code word, masking off the (reversed) ECC, and inverting
+ // the remainder of the bits (!).
+ //
+ // The data portion of a FLEX frame consists of 11 of these
+ // deinterleaved and converted blocks.
+ //
+ // set_output_multiple garauntees we have output space for at
+ // least eight data words, and 256 bits are supplied on input
+
+ int i, j;
+ for(i = 0; i < 32; i++) {
+ for(j = 0; j < 8; j++) {
+ d_codewords[j] <<= 1;
+ d_codewords[j] |= *in++;
+ }
+ }
+
+ // Now convert code words into data words
+ for(j = 0; j < 8; j++) {
+ int codeword = d_codewords[j];
+
+ // Apply BCH 32,21 error correction
+ // TODO: mark dataword when codeword fails ECC
+ bch3221(codeword);
+
+ // Reverse bit order
+ codeword = reverse_bits32(codeword);
+
+ // Mask off ECC then invert lower 21 bits
+ codeword = (codeword & 0x001FFFFF)^0x001FFFFF;
+
+ *out++ = codeword;
+ }
+
+ return j;
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/lib/flex_deinterleave_impl.h b/gr-pager/lib/flex_deinterleave_impl.h
new file mode 100644
index 0000000000..7cce86b6e9
--- /dev/null
+++ b/gr-pager/lib/flex_deinterleave_impl.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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.
+ */
+
+#ifndef INCLUDED_PAGER_FLEX_DEINTERLEAVE_IMPL_H
+#define INCLUDED_PAGER_FLEX_DEINTERLEAVE_IMPL_H
+
+#include <pager/flex_deinterleave.h>
+#include <gr_sync_decimator.h>
+
+namespace gr {
+ namespace pager {
+
+ /*!
+ * \brief flex deinterleave description
+ * \ingroup pager_blk
+ */
+ class flex_deinterleave_impl : public flex_deinterleave
+ {
+ private:
+ // One FLEX block of deinterleaved data
+ int d_codewords[8];
+
+ public:
+ flex_deinterleave_impl();
+ ~flex_deinterleave_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_FLEX_DEINTERLEAVE_IMPL_H */
diff --git a/gr-pager/lib/flex_frame_impl.cc b/gr-pager/lib/flex_frame_impl.cc
new file mode 100644
index 0000000000..869a03c551
--- /dev/null
+++ b/gr-pager/lib/flex_frame_impl.cc
@@ -0,0 +1,48 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "flex_frame_impl.h"
+
+namespace gr {
+ namespace pager {
+
+ flex_frame::sptr
+ flex_frame::make()
+ {
+ return flex_frame::sptr
+ (new flex_frame_impl());
+ }
+
+ flex_frame_impl::flex_frame_impl()
+ {
+ }
+
+ flex_frame_impl::~flex_frame_impl()
+ {
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/lib/pageri_util.h b/gr-pager/lib/flex_frame_impl.h
index b90cddcce9..0a6ec80293 100644
--- a/gr-pager/lib/pageri_util.h
+++ b/gr-pager/lib/flex_frame_impl.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -19,12 +20,22 @@
* Boston, MA 02110-1301, USA.
*/
-#ifndef INCLUDED_PAGERI_UTIL_H
-#define INCLUDED_PAGERI_UTIL_H
+#ifndef INCLUDED_PAGER_FLEX_FRAME_IMPL_H
+#define INCLUDED_PAGER_FLEX_FRAME_IMPL_H
-#include <gr_types.h>
+#include <pager/flex_frame.h>
-unsigned char pageri_reverse_bits8(unsigned char val);
-gr_int32 pageri_reverse_bits32(gr_int32 val);
+namespace gr {
+ namespace pager {
-#endif /* INCLUDED_PAGERI_UTIL_H */
+ class flex_frame_impl : public flex_frame
+ {
+ public:
+ flex_frame_impl();
+ ~flex_frame_impl();
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_FLEX_FRAME_IMPL_H */
diff --git a/gr-pager/lib/flex_modes.cc b/gr-pager/lib/flex_modes.cc
new file mode 100644
index 0000000000..5daaae7948
--- /dev/null
+++ b/gr-pager/lib/flex_modes.cc
@@ -0,0 +1,66 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2007,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 "flex_modes.h"
+
+namespace gr {
+ namespace pager {
+
+ const flex_mode_t
+ flex_modes[] =
+ {
+ { 0x870C78F3, 1600, 2 },
+ { 0xB0684F97, 1600, 4 },
+ // { 0xUNKNOWN, 3200, 2 },
+ { 0xDEA0215F, 3200, 4 },
+ { 0x4C7CB383, 3200, 4 }
+ };
+
+ const int num_flex_modes = sizeof(flex_modes)/sizeof(flex_modes[0]);
+
+ unsigned char flex_bcd[17] = "0123456789 U -][";
+
+ const char *flex_page_desc[] =
+ {
+ "ENC",
+ "UNK",
+ "TON",
+ "NUM",
+ "SPN",
+ "ALN",
+ "BIN",
+ "NNM"
+ };
+
+ int
+ find_flex_mode(int32_t sync_code)
+ {
+ for(int i = 0; i < num_flex_modes; i++)
+ if(flex_modes[i].sync == sync_code)
+ return i;
+
+ // Not found
+ return -1;
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/lib/flex_modes.h b/gr-pager/lib/flex_modes.h
new file mode 100644
index 0000000000..9cb06fffb4
--- /dev/null
+++ b/gr-pager/lib/flex_modes.h
@@ -0,0 +1,79 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2007,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.
+ */
+
+#ifndef INCLUDED_PAGER_FLEX_MODES_H
+#define INCLUDED_PAGER_FLEX_MODES_H
+
+#include <stdint.h>
+
+namespace gr {
+ namespace pager {
+
+#define FLEX_SYNC_MARKER 0xA6C6AAAA
+
+ typedef struct flex_mode
+ {
+ int32_t sync; // Outer synchronization code
+ unsigned int baud; // Baudrate of SYNC2 and DATA
+ unsigned int levels; // FSK encoding of SYNC2 and DATA
+ } flex_mode_t;
+
+ extern const flex_mode_t flex_modes[];
+ extern const char *flex_page_desc[];
+ extern const int num_flex_modes;
+ int find_flex_mode(int32_t sync_code);
+ extern unsigned char flex_bcd[];
+
+ typedef enum {
+ FLEX_SECURE,
+ FLEX_UNKNOWN,
+ FLEX_TONE,
+ FLEX_STANDARD_NUMERIC,
+ FLEX_SPECIAL_NUMERIC,
+ FLEX_ALPHANUMERIC,
+ FLEX_BINARY,
+ FLEX_NUMBERED_NUMERIC,
+ NUM_FLEX_PAGE_TYPES
+ } page_type_t;
+
+ inline bool is_alphanumeric_page(page_type_t type)
+ {
+ return (type == FLEX_ALPHANUMERIC ||
+ type == FLEX_SECURE);
+ }
+
+ inline bool is_numeric_page(page_type_t type)
+ {
+ return (type == FLEX_STANDARD_NUMERIC ||
+ type == FLEX_SPECIAL_NUMERIC ||
+ type == FLEX_NUMBERED_NUMERIC);
+ }
+
+ inline bool is_tone_page(page_type_t type)
+ {
+ return (type == FLEX_TONE);
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif // INCLUDED_PAGER_FLEX_MODES_H
diff --git a/gr-pager/lib/flex_parse_impl.cc b/gr-pager/lib/flex_parse_impl.cc
new file mode 100644
index 0000000000..8cf0503de7
--- /dev/null
+++ b/gr-pager/lib/flex_parse_impl.cc
@@ -0,0 +1,258 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2007,2010,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "flex_parse_impl.h"
+#include "bch3221.h"
+#include <gr_io_signature.h>
+#include <ctype.h>
+#include <iostream>
+#include <iomanip>
+
+namespace gr {
+ namespace pager {
+
+ flex_parse::sptr
+ flex_parse::make(gr_msg_queue_sptr queue, float freq)
+ {
+ return gnuradio::get_initial_sptr
+ (new flex_parse_impl(queue, freq));
+ }
+
+ flex_parse_impl::flex_parse_impl(gr_msg_queue_sptr queue, float freq) :
+ gr_sync_block("flex_parse",
+ gr_make_io_signature(1, 1, sizeof(gr_int32)),
+ gr_make_io_signature(0, 0, 0)),
+ d_queue(queue),
+ d_freq(freq)
+ {
+ d_count = 0;
+ }
+
+ flex_parse_impl::~flex_parse_impl()
+ {
+ }
+
+ int flex_parse_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const gr_int32 *in = (const gr_int32 *)input_items[0];
+
+ int i = 0;
+ while(i < noutput_items) {
+ // Accumulate one whole frame's worth of data words (88 of them)
+ d_datawords[d_count] = *in++; i++;
+ if(++d_count == 88) {
+ parse_data();
+ d_count = 0;
+ }
+ }
+
+ return i;
+ }
+
+ /* FLEX data frames (that is, 88 data words per phase recovered
+ after sync, symbol decoding, dephasing, deinterleaving, error
+ correction, and conversion from codewords to data words) start
+ with a block information word containing indices of the page
+ address field and page vector fields. */
+ void
+ flex_parse_impl::parse_capcode(int aw1, int aw2)
+ {
+ d_laddr = (aw1 < 0x008001L) ||
+ (aw1 > 0x1E0000L) ||
+ (aw1 > 0x1E7FFEL);
+
+ if(d_laddr)
+ d_capcode = aw1+((aw2^0x001FFFFF)<<15)+0x1F9000; // Don't ask
+ else
+ d_capcode = aw1-0x8000;
+ }
+
+ void
+ flex_parse_impl::parse_data()
+ {
+ // Block information word is the first data word in frame
+ int biw = d_datawords[0];
+
+ // Nothing to see here, please move along
+ if(biw == 0 || biw == 0x001FFFFF)
+ return;
+
+ // Vector start index is bits 15-10
+ // Address start address is bits 9-8, plus one for offset
+ int voffset = (biw >> 10) & 0x3f;
+ int aoffset = ((biw >> 8) & 0x03) + 1;
+
+ //printf("BIW:%08X AW:%02i-%02i\n", biw, aoffset, voffset);
+
+ // Iterate through pages and dispatch to appropriate handler
+ for(int i = aoffset; i < voffset; i++) {
+ int j = voffset+i-aoffset; // Start of vector field for address @ i
+
+ if(d_datawords[i] == 0x00000000 ||
+ d_datawords[i] == 0x001FFFFF)
+ continue; // Idle codewords, invalid address
+
+ parse_capcode(d_datawords[i], d_datawords[i+1]);
+ if(d_laddr)
+ i++;
+
+ if(d_capcode < 0) // Invalid address, skip
+ continue;
+
+ // Parse vector information word for address @ offset 'i'
+ int viw = d_datawords[j];
+ d_type = (page_type_t)((viw >> 4) & 0x00000007);
+ int mw1 = (viw >> 7) & 0x00000007F;
+ int len = (viw >> 14) & 0x0000007F;
+
+ if(is_numeric_page(d_type))
+ len &= 0x07;
+ int mw2 = mw1+len;
+
+ if(mw1 == 0 && mw2 == 0)
+ continue; // Invalid VIW
+
+ if(is_tone_page(d_type))
+ mw1 = mw2 = 0;
+
+ if(mw1 > 87 || mw2 > 87)
+ continue; // Invalid offsets
+
+ d_payload.str("");
+ d_payload.setf(std::ios::showpoint);
+ d_payload << std::setprecision(6) << std::setw(7)
+ << d_freq/1e6 << FIELD_DELIM
+ << std::setw(10) << d_capcode << FIELD_DELIM
+ << flex_page_desc[d_type] << FIELD_DELIM;
+
+ if(is_alphanumeric_page(d_type))
+ parse_alphanumeric(mw1, mw2-1, j);
+ else if(is_numeric_page(d_type))
+ parse_numeric(mw1, mw2, j);
+ else if(is_tone_page(d_type))
+ parse_tone_only();
+ else
+ parse_unknown(mw1, mw2);
+
+ gr_message_sptr msg = gr_make_message_from_string(std::string(d_payload.str()));
+ d_queue->handle(msg);
+ }
+ }
+
+ void
+ flex_parse_impl::parse_alphanumeric(int mw1, int mw2, int j)
+ {
+ int frag;
+ //bool cont;
+
+ if(!d_laddr) {
+ frag = (d_datawords[mw1] >> 11) & 0x03;
+ //cont = (d_datawords[mw1] >> 10) & 0x01;
+ mw1++;
+ }
+ else {
+ frag = (d_datawords[j+1] >> 11) & 0x03;
+ //cont = (d_datawords[j+1] >> 10) & 0x01;
+ mw2--;
+ }
+
+ //d_payload << frag << FIELD_DELIM;
+ //d_payload << cont << FIELD_DELIM;
+
+ for(int i = mw1; i <= mw2; i++) {
+ int dw = d_datawords[i];
+ unsigned char ch;
+
+ if(i > mw1 || frag != 0x03) {
+ ch = dw & 0x7F;
+ if(ch != 0x03)
+ d_payload << ch;
+ }
+
+ ch = (dw >> 7) & 0x7F;
+ if(ch != 0x03) // Fill
+ d_payload << ch;
+
+ ch = (dw >> 14) & 0x7F;
+ if(ch != 0x03) // Fill
+ d_payload << ch;
+ }
+ }
+
+ void
+ flex_parse_impl::parse_numeric(int mw1, int mw2, int j)
+ {
+ // Get first dataword from message field or from second
+ // vector word if long address
+ int dw;
+ if(!d_laddr) {
+ dw = d_datawords[mw1];
+ mw1++;
+ mw2++;
+ }
+ else {
+ dw = d_datawords[j+1];
+ }
+
+ unsigned char digit = 0;
+ int count = 4;
+ if(d_type == FLEX_NUMBERED_NUMERIC)
+ count += 10; // Skip 10 header bits for numbered numeric pages
+ else
+ count += 2; // Otherwise skip 2
+
+ for(int i = mw1; i <= mw2; i++) {
+ for(int k = 0; k < 21; k++) {
+ // Shift LSB from data word into digit
+ digit = (digit >> 1) & 0x0F;
+ if(dw & 0x01)
+ digit ^= 0x08;
+ dw >>= 1;
+ if(--count == 0) {
+ if(digit != 0x0C) // Fill
+ d_payload << flex_bcd[digit];
+ count = 4;
+ }
+ }
+
+ dw = d_datawords[i];
+ }
+ }
+
+ void
+ flex_parse_impl::parse_tone_only()
+ {
+ }
+
+ void
+ flex_parse_impl::parse_unknown(int mw1, int mw2)
+ {
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/lib/flex_parse_impl.h b/gr-pager/lib/flex_parse_impl.h
new file mode 100644
index 0000000000..a4fcf03d42
--- /dev/null
+++ b/gr-pager/lib/flex_parse_impl.h
@@ -0,0 +1,70 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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.
+ */
+
+#ifndef INCLUDED_PAGER_FLEX_PARSE_IMPL_H
+#define INCLUDED_PAGER_FLEX_PARSE_IMPL_H
+
+#include <pager/flex_parse.h>
+#include <gr_sync_block.h>
+#include <gr_msg_queue.h>
+#include "flex_modes.h"
+#include <sstream>
+
+namespace gr {
+ namespace pager {
+
+#define FIELD_DELIM ((unsigned char)128)
+
+ class flex_parse_impl : public flex_parse
+ {
+ private:
+ std::ostringstream d_payload;
+ gr_msg_queue_sptr d_queue; // Destination for decoded pages
+
+ int d_count; // Count of received codewords
+ int d_datawords[88]; // 11 blocks of 8 32-bit words
+
+ page_type_t d_type; // Current page type
+ int d_capcode; // Current page destination address
+ bool d_laddr; // Current page has long address
+ float d_freq; // Channel frequency
+
+ void parse_data(); // Handle a frame's worth of data
+ void parse_capcode(int32_t aw1, int32_t aw2);
+ void parse_alphanumeric(int mw1, int mw2, int j);
+ void parse_numeric(int mw1, int mw2, int j);
+ void parse_tone_only();
+ void parse_unknown(int mw1, int mw2);
+
+ public:
+ flex_parse_impl(gr_msg_queue_sptr queue, float freq);
+ ~flex_parse_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_FLEX_PARSE_IMPL_H */
diff --git a/gr-pager/lib/flex_sync_impl.cc b/gr-pager/lib/flex_sync_impl.cc
new file mode 100644
index 0000000000..cdf68f0381
--- /dev/null
+++ b/gr-pager/lib/flex_sync_impl.cc
@@ -0,0 +1,365 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2010,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "flex_sync_impl.h"
+#include "flex_modes.h"
+#include "bch3221.h"
+#include "util.h"
+#include <gr_io_signature.h>
+#include <gr_count_bits.h>
+#include <cstdio>
+
+namespace gr {
+ namespace pager {
+
+ flex_sync::sptr
+ flex_sync::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new flex_sync_impl());
+ }
+
+ // FLEX sync block takes input from sliced baseband stream [0-3]
+ // at specified channel rate. Symbol timing is established based
+ // on receiving one of the defined FLEX protocol synchronization
+ // words. The block outputs one FLEX frame worth of bits on each
+ // output phase for the data portion of the frame. Unused phases
+ // get all zeros, which are considered idle code words.
+
+ flex_sync_impl::flex_sync_impl() :
+ gr_block("flex_sync",
+ gr_make_io_signature(1, 1, sizeof(unsigned char)),
+ gr_make_io_signature(4, 4, sizeof(unsigned char))),
+ d_sync(10) // Fixed at 10 samples per baud (@ 1600 baud)
+ {
+ enter_idle();
+ }
+
+ flex_sync_impl::~flex_sync_impl()
+ {
+ }
+
+ void
+ flex_sync_impl::forecast(int noutput_items, gr_vector_int &inputs_required)
+ {
+ // samples per bit X number of outputs needed
+ int items = noutput_items*d_spb;
+ for(unsigned int i = 0; i < inputs_required.size(); i++)
+ inputs_required[i] = items;
+ }
+
+ int
+ flex_sync_impl::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
+ flex_sync_impl::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);
+ int64_t val = d_sync[d_index];
+ int32_t marker = ((val & 0x0000FFFFFFFF0000ULL)) >> 16;
+
+ if(gr_count_bits32(marker^FLEX_SYNC_MARKER) < 4) {
+ int32_t 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
+ flex_sync_impl::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 = 16000/d_baudrate;
+ d_bit_a = 0;
+ d_bit_b = 0;
+ d_bit_c = 0;
+ d_bit_d = 0;
+ d_hibit = false;
+ fflush(stdout);
+ }
+
+ void
+ flex_sync_impl::enter_syncing()
+ {
+ d_start = d_index;
+ d_state = ST_SYNCING;
+ }
+
+ void
+ flex_sync_impl::enter_sync1()
+ {
+ d_state = ST_SYNC1;
+ d_end = d_index;
+ d_center = index_avg(d_start, d_end); // Center of goodness
+ d_count = 0;
+ }
+
+ void
+ flex_sync_impl::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 = 16000/d_baudrate;
+
+ if(d_baudrate == 3200) {
+ // Oversampling buffer just got halved
+ d_center = d_center/2;
+
+ // We're here at the center of a 1600 baud bit
+ // So this hack puts the index and bit counter
+ // in the right place for 3200 bps.
+ d_index = d_index/2-d_spb/2;
+ d_count = -1;
+ }
+ }
+
+ void
+ flex_sync_impl::enter_data()
+ {
+ d_state = ST_DATA;
+ d_count = 0;
+ }
+
+ void
+ flex_sync_impl::parse_fiw()
+ {
+ // Nothing is done with these now, but these will end up getting
+ // passed as metadata when mblocks are available
+
+ // Bits 31-28 are frame number related, but unknown function
+ // This might be a checksum
+ d_unknown2 = reverse_bits8((d_fiw >> 24) & 0xF0);
+
+ // Cycle is bits 27-24, reversed
+ d_cycle = reverse_bits8((d_fiw >> 20) & 0xF0);
+
+ // Frame is bits 23-17, reversed
+ d_frame = reverse_bits8((d_fiw >> 16) & 0xFE);
+
+ // Bits 16-11 are some sort of marker, usually identical across
+ // many frames but sometimes changes between frames or modes
+ d_unknown1 = (d_fiw >> 11) & 0x3F;
+
+ //printf("CYC:%02i FRM:%03i\n", d_cycle, d_frame);
+ }
+
+ int
+ flex_sync_impl::output_symbol(unsigned char sym)
+ {
+ // Here is where we output a 1 or 0 on each phase according
+ // to current FLEX mode and symbol value. Unassigned phases
+ // are zero from the enter_idle() initialization.
+ //
+ // FLEX can transmit the data portion of the frame at either
+ // 1600 bps or 3200 bps, and can use either two- or four-level
+ // FSK encoding.
+ //
+ // At 1600 bps, 2-level, a single "phase" is transmitted with bit
+ // value '0' using level '3' and bit value '1' using level '0'.
+ //
+ // At 1600 bps, 4-level, a second "phase" is transmitted, and the
+ // di-bits are encoded with a gray code:
+ //
+ // Symbol Phase 1 Phase 2
+ // ------ ------- -------
+ // 0 1 1
+ // 1 1 0
+ // 2 0 0
+ // 3 0 1
+ //
+ // At 1600 bps, 4-level, these are called PHASE A and PHASE B.
+ //
+ // At 3200 bps, the same 1 or 2 bit encoding occurs, except that
+ // additionally two streams are interleaved on alternating symbols.
+ // Thus, PHASE A (and PHASE B if 4-level) are decoded on one symbol,
+ // then PHASE C (and PHASE D if 4-level) are decoded on the next.
+
+ int bits = 0;
+
+ if(d_baudrate == 1600) {
+ d_bit_a = (sym < 2);
+ if(d_levels == 4)
+ d_bit_b = (sym == 0) || (sym == 3);
+
+ *d_phase_a++ = d_bit_a;
+ *d_phase_b++ = d_bit_b;
+ *d_phase_c++ = d_bit_c;
+ *d_phase_d++ = d_bit_d;
+ bits++;
+ }
+ else {
+ if(!d_hibit) {
+ d_bit_a = (sym < 2);
+ if(d_levels == 4)
+ d_bit_b = (sym == 0) || (sym == 3);
+ d_hibit = true;
+ }
+ else {
+ d_bit_c = (sym < 2);
+ if(d_levels == 4)
+ d_bit_d = (sym == 0) || (sym == 3);
+ d_hibit = false;
+
+ *d_phase_a++ = d_bit_a;
+ *d_phase_b++ = d_bit_b;
+ *d_phase_c++ = d_bit_c;
+ *d_phase_d++ = d_bit_d;
+ bits++;
+ }
+ }
+
+ return bits;
+ }
+
+ int
+ flex_sync_impl::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];
+ d_phase_a = (unsigned char *)output_items[0];
+ d_phase_b = (unsigned char *)output_items[1];
+ d_phase_c = (unsigned char *)output_items[2];
+ d_phase_d = (unsigned char *)output_items[3];
+
+ int i = 0, j = 0;
+ int ninputs = ninput_items[0];
+
+ while(i < ninputs && j < noutput_items) {
+ unsigned char sym = *in++; i++;
+ d_index = (d_index+1) % d_spb;
+
+ switch(d_state) {
+ case ST_IDLE:
+ // Continually compare the received symbol stream
+ // against the known FLEX sync words.
+ if(test_sync(sym))
+ enter_syncing();
+ break;
+
+ case ST_SYNCING:
+ // Wait until we stop seeing sync, then calculate
+ // the center of the bit period (d_center)
+ if(!test_sync(sym))
+ enter_sync1();
+ break;
+
+ case ST_SYNC1:
+ // Skip 16 bits of dotting, then accumulate 32 bits
+ // of Frame Information Word.
+ if(d_index == d_center) {
+ d_fiw = (d_fiw << 1) | (sym > 1);
+ if(++d_count == 48) {
+ // FIW is accumulated, call BCH to error correct it
+ bch3221(d_fiw);
+ parse_fiw();
+ enter_sync2();
+ }
+ }
+ break;
+
+ case ST_SYNC2:
+ // This part and the remainder of the frame are transmitted
+ // at either 1600 bps or 3200 bps based on the received
+ // FLEX sync word. The second SYNC header is 25ms of idle bits
+ // at either speed.
+ 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:
+ // The data portion of the frame is 1760 ms long at either
+ // baudrate. This is 2816 bits @ 1600 bps and 5632 bits @ 3200 bps.
+ // The output_symbol() routine decodes and doles out the bits
+ // to each of the four transmitted phases of FLEX interleaved codes.
+ if(d_index == d_center) {
+ j += output_symbol(sym);
+ if(++d_count == d_baudrate*1760/1000)
+ enter_idle();
+ }
+ break;
+
+ default:
+ assert(0); // memory corruption of d_state if ever gets here
+ break;
+ }
+ }
+
+ consume_each(i);
+ return j;
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/lib/flex_sync_impl.h b/gr-pager/lib/flex_sync_impl.h
new file mode 100644
index 0000000000..ba18c147dc
--- /dev/null
+++ b/gr-pager/lib/flex_sync_impl.h
@@ -0,0 +1,95 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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.
+ */
+
+#ifndef INCLUDED_PAGER_FLEX_SYNC_IMPL_H
+#define INCLUDED_PAGER_FLEX_SYNC_IMPL_H
+
+#include <pager/flex_sync.h>
+
+namespace gr {
+ namespace pager {
+
+ class flex_sync_impl : public flex_sync
+ {
+ private:
+ // State machine transitions
+ void enter_idle();
+ void enter_syncing();
+ void enter_sync1();
+ void enter_sync2();
+ void enter_data();
+
+ int index_avg(int start, int end);
+ bool test_sync(unsigned char sym);
+ void parse_fiw();
+ int output_symbol(unsigned char sym);
+
+ // Simple state machine
+ enum state_t { ST_IDLE, ST_SYNCING, ST_SYNC1, ST_SYNC2, ST_DATA };
+ state_t d_state;
+
+ 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; // Alternating bit indicator for 3200 bps
+
+ int d_fiw; // Frame information word
+ int d_frame; // Current FLEX frame
+ int d_cycle; // Current FLEX cycle
+ int d_unknown1;
+ int d_unknown2;
+
+ unsigned char d_bit_a;
+ unsigned char d_bit_b;
+ unsigned char d_bit_c;
+ unsigned char d_bit_d;
+
+ unsigned char *d_phase_a;
+ unsigned char *d_phase_b;
+ unsigned char *d_phase_c;
+ unsigned char *d_phase_d;
+
+ std::vector<int64_t> d_sync; // Trial synchronizers
+
+ public:
+ flex_sync_impl();
+ ~flex_sync_impl();
+
+ 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);
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_FLEX_SYNC_IMPL_H */
diff --git a/gr-pager/lib/pager_flex_deinterleave.cc b/gr-pager/lib/pager_flex_deinterleave.cc
deleted file mode 100644
index f7f1d9f695..0000000000
--- a/gr-pager/lib/pager_flex_deinterleave.cc
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <pager_flex_deinterleave.h>
-#include <pageri_bch3221.h>
-#include <pageri_util.h>
-#include <gr_io_signature.h>
-
-pager_flex_deinterleave_sptr pager_make_flex_deinterleave()
-{
- return gnuradio::get_initial_sptr(new pager_flex_deinterleave());
-}
-
-pager_flex_deinterleave::pager_flex_deinterleave() :
- gr_sync_decimator("flex_deinterleave",
- gr_make_io_signature(1, 1, sizeof(unsigned char)),
- gr_make_io_signature(1, 1, sizeof(gr_int32)), 32)
-{
- set_output_multiple(8); // One FLEX block at a time
-}
-
-int pager_flex_deinterleave::work(int noutput_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];
-
- // FLEX codewords are interleaved in blocks of 256 bits or 8, 32 bit
- // codes. To deinterleave we parcel each incoming bit into the MSB
- // of each codeword, then switch to MSB-1, etc. This is done by shifting
- // in the bits from the right on each codeword as the bits come in.
- // When we are done we have a FLEX block of eight codewords, ready for
- // conversion to data words.
- //
- // FLEX data words are recovered by reversing the bit order of the code
- // word, masking off the (reversed) ECC, and inverting the remainder of
- // the bits (!).
- //
- // The data portion of a FLEX frame consists of 11 of these deinterleaved
- // and converted blocks.
- //
- // set_output_multiple garauntees we have output space for at least
- // eight data words, and 256 bits are supplied on input
-
- int i, j;
- for (i = 0; i < 32; i++) {
- for (j = 0; j < 8; j++) {
- d_codewords[j] <<= 1;
- d_codewords[j] |= *in++;
- }
- }
-
- // Now convert code words into data words
- for (j = 0; j < 8; j++) {
- gr_int32 codeword = d_codewords[j];
-
- // Apply BCH 32,21 error correction
- // TODO: mark dataword when codeword fails ECC
- pageri_bch3221(codeword);
-
- // Reverse bit order
- codeword = pageri_reverse_bits32(codeword);
-
- // Mask off ECC then invert lower 21 bits
- codeword = (codeword & 0x001FFFFF)^0x001FFFFF;
-
- *out++ = codeword;
- }
-
- return j;
-}
diff --git a/gr-pager/lib/pager_flex_parse.cc b/gr-pager/lib/pager_flex_parse.cc
deleted file mode 100644
index d7c308ddb6..0000000000
--- a/gr-pager/lib/pager_flex_parse.cc
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright 2004,2006,2007,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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <pager_flex_parse.h>
-#include <pageri_bch3221.h>
-#include <gr_io_signature.h>
-#include <ctype.h>
-#include <iostream>
-#include <iomanip>
-
-pager_flex_parse_sptr pager_make_flex_parse(gr_msg_queue_sptr queue, float freq)
-{
- return gnuradio::get_initial_sptr(new pager_flex_parse(queue, freq));
-}
-
-pager_flex_parse::pager_flex_parse(gr_msg_queue_sptr queue, float freq) :
- gr_sync_block("flex_parse",
- gr_make_io_signature(1, 1, sizeof(gr_int32)),
- gr_make_io_signature(0, 0, 0)),
- d_queue(queue),
- d_freq(freq)
-{
- d_count = 0;
-}
-
-int pager_flex_parse::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const gr_int32 *in = (const gr_int32 *)input_items[0];
-
- int i = 0;
- while (i < noutput_items) {
- // Accumulate one whole frame's worth of data words (88 of them)
- d_datawords[d_count] = *in++; i++;
- if (++d_count == 88) {
- parse_data();
- d_count = 0;
- }
- }
-
- return i;
-}
-
-/* FLEX data frames (that is, 88 data words per phase recovered after sync,
- symbol decoding, dephasing, deinterleaving, error correction, and conversion
- from codewords to data words) start with a block information word containing
- indices of the page address field and page vector fields.
-*/
-
-void pager_flex_parse::parse_capcode(gr_int32 aw1, gr_int32 aw2)
-{
- d_laddr = (aw1 < 0x008001L) ||
- (aw1 > 0x1E0000L) ||
- (aw1 > 0x1E7FFEL);
-
- if (d_laddr)
- d_capcode = aw1+((aw2^0x001FFFFF)<<15)+0x1F9000; // Don't ask
- else
- d_capcode = aw1-0x8000;
-}
-
-void pager_flex_parse::parse_data()
-{
- // Block information word is the first data word in frame
- gr_int32 biw = d_datawords[0];
-
- // Nothing to see here, please move along
- if (biw == 0 || biw == 0x001FFFFF)
- return;
-
- // Vector start index is bits 15-10
- // Address start address is bits 9-8, plus one for offset
- int voffset = (biw >> 10) & 0x3f;
- int aoffset = ((biw >> 8) & 0x03) + 1;
-
- //printf("BIW:%08X AW:%02i-%02i\n", biw, aoffset, voffset);
-
- // Iterate through pages and dispatch to appropriate handler
- for (int i = aoffset; i < voffset; i++) {
- int j = voffset+i-aoffset; // Start of vector field for address @ i
-
- if (d_datawords[i] == 0x00000000 ||
- d_datawords[i] == 0x001FFFFF)
- continue; // Idle codewords, invalid address
-
- parse_capcode(d_datawords[i], d_datawords[i+1]);
- if (d_laddr)
- i++;
-
- if (d_capcode < 0) // Invalid address, skip
- continue;
-
- // Parse vector information word for address @ offset 'i'
- gr_int32 viw = d_datawords[j];
- d_type = (page_type_t)((viw >> 4) & 0x00000007);
- int mw1 = (viw >> 7) & 0x00000007F;
- int len = (viw >> 14) & 0x0000007F;
-
- if (is_numeric_page(d_type))
- len &= 0x07;
- int mw2 = mw1+len;
-
- if (mw1 == 0 && mw2 == 0)
- continue; // Invalid VIW
-
- if (is_tone_page(d_type))
- mw1 = mw2 = 0;
-
- if (mw1 > 87 || mw2 > 87)
- continue; // Invalid offsets
-
- d_payload.str("");
- d_payload.setf(std::ios::showpoint);
- d_payload << std::setprecision(6) << std::setw(7)
- << d_freq/1e6 << FIELD_DELIM
- << std::setw(10) << d_capcode << FIELD_DELIM
- << flex_page_desc[d_type] << FIELD_DELIM;
-
- if (is_alphanumeric_page(d_type))
- parse_alphanumeric(mw1, mw2-1, j);
- else if (is_numeric_page(d_type))
- parse_numeric(mw1, mw2, j);
- else if (is_tone_page(d_type))
- parse_tone_only();
- else
- parse_unknown(mw1, mw2);
-
- gr_message_sptr msg = gr_make_message_from_string(std::string(d_payload.str()));
- d_queue->handle(msg);
- }
-}
-
-void pager_flex_parse::parse_alphanumeric(int mw1, int mw2, int j)
-{
- int frag;
- //bool cont;
-
- if (!d_laddr) {
- frag = (d_datawords[mw1] >> 11) & 0x03;
- //cont = (d_datawords[mw1] >> 10) & 0x01;
- mw1++;
- }
- else {
- frag = (d_datawords[j+1] >> 11) & 0x03;
- //cont = (d_datawords[j+1] >> 10) & 0x01;
- mw2--;
- }
-
- //d_payload << frag << FIELD_DELIM;
- //d_payload << cont << FIELD_DELIM;
-
- for (int i = mw1; i <= mw2; i++) {
- gr_int32 dw = d_datawords[i];
- unsigned char ch;
-
- if (i > mw1 || frag != 0x03) {
- ch = dw & 0x7F;
- if (ch != 0x03)
- d_payload << ch;
- }
-
- ch = (dw >> 7) & 0x7F;
- if (ch != 0x03) // Fill
- d_payload << ch;
-
- ch = (dw >> 14) & 0x7F;
- if (ch != 0x03) // Fill
- d_payload << ch;
- }
-}
-
-void pager_flex_parse::parse_numeric(int mw1, int mw2, int j)
-{
- // Get first dataword from message field or from second
- // vector word if long address
- gr_int32 dw;
- if (!d_laddr) {
- dw = d_datawords[mw1];
- mw1++;
- mw2++;
- }
- else {
- dw = d_datawords[j+1];
- }
-
- unsigned char digit = 0;
- int count = 4;
- if (d_type == FLEX_NUMBERED_NUMERIC)
- count += 10; // Skip 10 header bits for numbered numeric pages
- else
- count += 2; // Otherwise skip 2
-
- for (int i = mw1; i <= mw2; i++) {
- for (int k = 0; k < 21; k++) {
- // Shift LSB from data word into digit
- digit = (digit >> 1) & 0x0F;
- if (dw & 0x01)
- digit ^= 0x08;
- dw >>= 1;
- if (--count == 0) {
- if (digit != 0x0C) // Fill
- d_payload << flex_bcd[digit];
- count = 4;
- }
- }
-
- dw = d_datawords[i];
- }
-}
-
-void pager_flex_parse::parse_tone_only()
-{
-}
-
-void pager_flex_parse::parse_unknown(int mw1, int mw2)
-{
-}
diff --git a/gr-pager/lib/pager_flex_parse.h b/gr-pager/lib/pager_flex_parse.h
deleted file mode 100644
index 499be299a5..0000000000
--- a/gr-pager/lib/pager_flex_parse.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef INCLUDED_PAGER_FLEX_PARSE_H
-#define INCLUDED_PAGER_FLEX_PARSE_H
-
-#include <pager_api.h>
-#include <gr_sync_block.h>
-#include <gr_msg_queue.h>
-#include <pageri_flex_modes.h>
-#include <sstream>
-
-class pager_flex_parse;
-typedef boost::shared_ptr<pager_flex_parse> pager_flex_parse_sptr;
-
-PAGER_API pager_flex_parse_sptr pager_make_flex_parse(gr_msg_queue_sptr queue, float freq);
-
-#define FIELD_DELIM ((unsigned char)128)
-
-/*!
- * \brief flex parse description
- * \ingroup pager_blk
- */
-class PAGER_API pager_flex_parse : public gr_sync_block
-{
-private:
- // Constructors
- friend PAGER_API pager_flex_parse_sptr pager_make_flex_parse(gr_msg_queue_sptr queue, float freq);
- pager_flex_parse(gr_msg_queue_sptr queue, float freq);
-
- std::ostringstream d_payload;
- gr_msg_queue_sptr d_queue; // Destination for decoded pages
-
- int d_count; // Count of received codewords
- gr_int32 d_datawords[88]; // 11 blocks of 8 32-bit words
-
- page_type_t d_type; // Current page type
- int d_capcode; // Current page destination address
- bool d_laddr; // Current page has long address
- float d_freq; // Channel frequency
-
- void parse_data(); // Handle a frame's worth of data
- void parse_capcode(gr_int32 aw1, gr_int32 aw2);
- void parse_alphanumeric(int mw1, int mw2, int j);
- void parse_numeric(int mw1, int mw2, int j);
- void parse_tone_only();
- void parse_unknown(int mw1, int mw2);
-
-public:
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_PAGER_FLEX_PARSE_H */
diff --git a/gr-pager/lib/pager_flex_sync.cc b/gr-pager/lib/pager_flex_sync.cc
deleted file mode 100644
index c31acd7d2f..0000000000
--- a/gr-pager/lib/pager_flex_sync.cc
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <pager_flex_sync.h>
-#include <pageri_flex_modes.h>
-#include <pageri_bch3221.h>
-#include <pageri_util.h>
-#include <gr_io_signature.h>
-#include <gr_count_bits.h>
-#include <cstdio>
-
-pager_flex_sync_sptr pager_make_flex_sync()
-{
- return gnuradio::get_initial_sptr(new pager_flex_sync());
-}
-
-// FLEX sync block takes input from sliced baseband stream [0-3] at specified
-// channel rate. Symbol timing is established based on receiving one of the
-// defined FLEX protocol synchronization words. The block outputs one FLEX frame
-// worth of bits on each output phase for the data portion of the frame. Unused phases
-// get all zeros, which are considered idle code words.
-
-pager_flex_sync::pager_flex_sync() :
- gr_block ("flex_sync",
- gr_make_io_signature (1, 1, sizeof(unsigned char)),
- gr_make_io_signature (4, 4, sizeof(unsigned char))),
- d_sync(10) // Fixed at 10 samples per baud (@ 1600 baud)
-{
- enter_idle();
-}
-
-void pager_flex_sync::forecast(int noutput_items, gr_vector_int &inputs_required)
-{
- // samples per bit X number of outputs needed
- int items = noutput_items*d_spb;
- for (unsigned int i = 0; i < inputs_required.size(); i++)
- inputs_required[i] = items;
-}
-
-int pager_flex_sync::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_sync::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_sync::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 = 16000/d_baudrate;
- d_bit_a = 0;
- d_bit_b = 0;
- d_bit_c = 0;
- d_bit_d = 0;
- d_hibit = false;
- fflush(stdout);
-}
-
-void pager_flex_sync::enter_syncing()
-{
- d_start = d_index;
- d_state = ST_SYNCING;
-}
-
-void pager_flex_sync::enter_sync1()
-{
- d_state = ST_SYNC1;
- d_end = d_index;
- d_center = index_avg(d_start, d_end); // Center of goodness
- d_count = 0;
-}
-
-void pager_flex_sync::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 = 16000/d_baudrate;
-
- if (d_baudrate == 3200) {
- // Oversampling buffer just got halved
- d_center = d_center/2;
-
- // We're here at the center of a 1600 baud bit
- // So this hack puts the index and bit counter
- // in the right place for 3200 bps.
- d_index = d_index/2-d_spb/2;
- d_count = -1;
- }
-}
-
-void pager_flex_sync::enter_data()
-{
- d_state = ST_DATA;
- d_count = 0;
-}
-
-void pager_flex_sync::parse_fiw()
-{
- // Nothing is done with these now, but these will end up getting
- // passed as metadata when mblocks are available
-
- // Bits 31-28 are frame number related, but unknown function
- // This might be a checksum
- d_unknown2 = pageri_reverse_bits8((d_fiw >> 24) & 0xF0);
-
- // Cycle is bits 27-24, reversed
- d_cycle = pageri_reverse_bits8((d_fiw >> 20) & 0xF0);
-
- // Frame is bits 23-17, reversed
- d_frame = pageri_reverse_bits8((d_fiw >> 16) & 0xFE);
-
- // Bits 16-11 are some sort of marker, usually identical across
- // many frames but sometimes changes between frames or modes
- d_unknown1 = (d_fiw >> 11) & 0x3F;
-
- //printf("CYC:%02i FRM:%03i\n", d_cycle, d_frame);
-}
-
-int pager_flex_sync::output_symbol(unsigned char sym)
-{
- // Here is where we output a 1 or 0 on each phase according
- // to current FLEX mode and symbol value. Unassigned phases
- // are zero from the enter_idle() initialization.
- //
- // FLEX can transmit the data portion of the frame at either
- // 1600 bps or 3200 bps, and can use either two- or four-level
- // FSK encoding.
- //
- // At 1600 bps, 2-level, a single "phase" is transmitted with bit
- // value '0' using level '3' and bit value '1' using level '0'.
- //
- // At 1600 bps, 4-level, a second "phase" is transmitted, and the
- // di-bits are encoded with a gray code:
- //
- // Symbol Phase 1 Phase 2
- // ------ ------- -------
- // 0 1 1
- // 1 1 0
- // 2 0 0
- // 3 0 1
- //
- // At 1600 bps, 4-level, these are called PHASE A and PHASE B.
- //
- // At 3200 bps, the same 1 or 2 bit encoding occurs, except that
- // additionally two streams are interleaved on alternating symbols.
- // Thus, PHASE A (and PHASE B if 4-level) are decoded on one symbol,
- // then PHASE C (and PHASE D if 4-level) are decoded on the next.
-
- int bits = 0;
-
- if (d_baudrate == 1600) {
- d_bit_a = (sym < 2);
- if (d_levels == 4)
- d_bit_b = (sym == 0) || (sym == 3);
-
- *d_phase_a++ = d_bit_a;
- *d_phase_b++ = d_bit_b;
- *d_phase_c++ = d_bit_c;
- *d_phase_d++ = d_bit_d;
- bits++;
- }
- else {
- if (!d_hibit) {
- d_bit_a = (sym < 2);
- if (d_levels == 4)
- d_bit_b = (sym == 0) || (sym == 3);
- d_hibit = true;
- }
- else {
- d_bit_c = (sym < 2);
- if (d_levels == 4)
- d_bit_d = (sym == 0) || (sym == 3);
- d_hibit = false;
-
- *d_phase_a++ = d_bit_a;
- *d_phase_b++ = d_bit_b;
- *d_phase_c++ = d_bit_c;
- *d_phase_d++ = d_bit_d;
- bits++;
- }
- }
-
- return bits;
-}
-
-int pager_flex_sync::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];
- d_phase_a = (unsigned char *)output_items[0];
- d_phase_b = (unsigned char *)output_items[1];
- d_phase_c = (unsigned char *)output_items[2];
- d_phase_d = (unsigned char *)output_items[3];
-
- int i = 0, j = 0;
- int ninputs = ninput_items[0];
-
- while (i < ninputs && j < noutput_items) {
- unsigned char sym = *in++; i++;
- d_index = (d_index+1) % d_spb;
-
- switch (d_state) {
- case ST_IDLE:
- // Continually compare the received symbol stream
- // against the known FLEX sync words.
- if (test_sync(sym))
- enter_syncing();
- break;
-
- case ST_SYNCING:
- // Wait until we stop seeing sync, then calculate
- // the center of the bit period (d_center)
- if (!test_sync(sym))
- enter_sync1();
- break;
-
- case ST_SYNC1:
- // Skip 16 bits of dotting, then accumulate 32 bits
- // of Frame Information Word.
- if (d_index == d_center) {
- d_fiw = (d_fiw << 1) | (sym > 1);
- if (++d_count == 48) {
- // FIW is accumulated, call BCH to error correct it
- pageri_bch3221(d_fiw);
- parse_fiw();
- enter_sync2();
- }
- }
- break;
-
- case ST_SYNC2:
- // This part and the remainder of the frame are transmitted
- // at either 1600 bps or 3200 bps based on the received
- // FLEX sync word. The second SYNC header is 25ms of idle bits
- // at either speed.
- 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:
- // The data portion of the frame is 1760 ms long at either
- // baudrate. This is 2816 bits @ 1600 bps and 5632 bits @ 3200 bps.
- // The output_symbol() routine decodes and doles out the bits
- // to each of the four transmitted phases of FLEX interleaved codes.
- if (d_index == d_center) {
- j += output_symbol(sym);
- if (++d_count == d_baudrate*1760/1000)
- enter_idle();
- }
- break;
-
- default:
- assert(0); // memory corruption of d_state if ever gets here
- break;
- }
- }
-
- consume_each(i);
- return j;
-}
diff --git a/gr-pager/lib/pager_flex_sync.h b/gr-pager/lib/pager_flex_sync.h
deleted file mode 100644
index b53737d121..0000000000
--- a/gr-pager/lib/pager_flex_sync.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef INCLUDED_PAGER_FLEX_SYNC_H
-#define INCLUDED_PAGER_FLEX_SYNC_H
-
-#include <pager_api.h>
-#include <gr_block.h>
-
-class pager_flex_sync;
-typedef boost::shared_ptr<pager_flex_sync> pager_flex_sync_sptr;
-typedef std::vector<gr_int64> gr_int64_vector;
-
-PAGER_API pager_flex_sync_sptr pager_make_flex_sync();
-
-/*!
- * \brief flex sync description
- * \ingroup pager_blk
- */
-
-class PAGER_API pager_flex_sync : public gr_block
-{
-private:
- // Constructors
- friend PAGER_API pager_flex_sync_sptr pager_make_flex_sync();
- pager_flex_sync();
-
- // State machine transitions
- void enter_idle();
- void enter_syncing();
- void enter_sync1();
- void enter_sync2();
- void enter_data();
-
- int index_avg(int start, int end);
- bool test_sync(unsigned char sym);
- void parse_fiw();
- int output_symbol(unsigned char sym);
-
- // Simple state machine
- enum state_t { ST_IDLE, ST_SYNCING, ST_SYNC1, ST_SYNC2, ST_DATA };
- state_t d_state;
-
- 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; // Alternating bit indicator for 3200 bps
-
- gr_int32 d_fiw; // Frame information word
- int d_frame; // Current FLEX frame
- int d_cycle; // Current FLEX cycle
- int d_unknown1;
- int d_unknown2;
-
- unsigned char d_bit_a;
- unsigned char d_bit_b;
- unsigned char d_bit_c;
- unsigned char d_bit_d;
-
- unsigned char *d_phase_a;
- unsigned char *d_phase_b;
- unsigned char *d_phase_c;
- unsigned char *d_phase_d;
-
- gr_int64_vector d_sync; // Trial synchronizers
-
-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_SYNC_H */
diff --git a/gr-pager/lib/pager_slicer_fb.cc b/gr-pager/lib/pager_slicer_fb.cc
deleted file mode 100644
index 415e898cd1..0000000000
--- a/gr-pager/lib/pager_slicer_fb.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2004,2006,2007,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.
- */
-
-#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)
-{
- return gnuradio::get_initial_sptr(new pager_slicer_fb(alpha));
-}
-
-pager_slicer_fb::pager_slicer_fb(float alpha) :
- 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 = 1.0-alpha;
- d_avg = 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*d_beta+sample*d_alpha;
- sample -= d_avg;
-
- if (sample > 0) {
- if (sample > 2.0)
- decision = 3;
- else
- decision = 2;
- }
- else {
- if (sample < -2.0)
- decision = 0;
- else
- decision = 1;
- }
-
- 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/lib/pager_slicer_fb.h b/gr-pager/lib/pager_slicer_fb.h
deleted file mode 100644
index cbbf9cd222..0000000000
--- a/gr-pager/lib/pager_slicer_fb.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef INCLUDED_PAGER_SLICER_FB_H
-#define INCLUDED_PAGER_SLICER_FB_H
-
-#include <pager_api.h>
-#include <gr_sync_block.h>
-
-class pager_slicer_fb;
-typedef boost::shared_ptr<pager_slicer_fb> pager_slicer_fb_sptr;
-
-PAGER_API pager_slicer_fb_sptr pager_make_slicer_fb(float alpha);
-
-/*!
- * \brief slicer description
- * \ingroup pager_blk
- */
-class PAGER_API pager_slicer_fb : public gr_sync_block
-{
-private:
- friend PAGER_API pager_slicer_fb_sptr pager_make_slicer_fb(float alpha);
- pager_slicer_fb(float alpha);
-
- unsigned char slice(float sample);
-
- float d_alpha; // DC removal time constant
- float d_beta; // 1.0-d_alpha
- float d_avg; // Average value for DC offset subtraction
-
-public:
- int work (int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- float dc_offset() const { return d_avg; }
-};
-
-#endif /* INCLUDED_PAGER_SLICER_FB_H */
diff --git a/gr-pager/lib/pageri_bch3221.h b/gr-pager/lib/pageri_bch3221.h
deleted file mode 100644
index 54227e438b..0000000000
--- a/gr-pager/lib/pageri_bch3221.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.
- */
-
-#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/lib/pageri_flex_modes.h b/gr-pager/lib/pageri_flex_modes.h
deleted file mode 100644
index 6d81613d75..0000000000
--- a/gr-pager/lib/pageri_flex_modes.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.
- */
-
-#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
-}
-flex_mode_t;
-
-extern const flex_mode_t flex_modes[];
-extern const char *flex_page_desc[];
-extern const int num_flex_modes;
-int find_flex_mode(gr_int32 sync_code);
-extern unsigned char flex_bcd[];
-
-typedef enum {
- FLEX_SECURE,
- FLEX_UNKNOWN,
- FLEX_TONE,
- FLEX_STANDARD_NUMERIC,
- FLEX_SPECIAL_NUMERIC,
- FLEX_ALPHANUMERIC,
- FLEX_BINARY,
- FLEX_NUMBERED_NUMERIC,
- NUM_FLEX_PAGE_TYPES
-}
-page_type_t;
-
-inline bool is_alphanumeric_page(page_type_t type)
-{
- return (type == FLEX_ALPHANUMERIC ||
- type == FLEX_SECURE);
-}
-
-inline bool is_numeric_page(page_type_t type)
-{
- return (type == FLEX_STANDARD_NUMERIC ||
- type == FLEX_SPECIAL_NUMERIC ||
- type == FLEX_NUMBERED_NUMERIC);
-}
-
-inline bool is_tone_page(page_type_t type)
-{
- return (type == FLEX_TONE);
-}
-
-#endif // INCLUDED_PAGERI_FLEX_MODES_H
diff --git a/gr-pager/lib/pageri_util.cc b/gr-pager/lib/pageri_util.cc
deleted file mode 100644
index 7fa85e6ed7..0000000000
--- a/gr-pager/lib/pageri_util.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <pageri_util.h>
-
-unsigned char pageri_reverse_bits8(unsigned char val)
-{
- // This method was attributed to Rich Schroeppel in the Programming
- // Hacks section of Beeler, M., Gosper, R. W., and Schroeppel, R.
- // HAKMEM. MIT AI Memo 239, Feb. 29, 1972.
- //
- // Reverses 8 bits in 5 machine operations with 64 bit arch
- return (val * 0x0202020202ULL & 0x010884422010ULL) % 1023;
-}
-
-gr_int32 pageri_reverse_bits32(gr_int32 val)
-{
- gr_int32 out = 0x00000000;
- out |= (pageri_reverse_bits8((val >> 24) & 0x000000FF) );
- out |= (pageri_reverse_bits8((val >> 16) & 0x000000FF) << 8);
- out |= (pageri_reverse_bits8((val >> 8) & 0x000000FF) << 16);
- out |= (pageri_reverse_bits8((val ) & 0x000000FF) << 24);
- return out;
-}
diff --git a/gr-pager/lib/slicer_fb_impl.cc b/gr-pager/lib/slicer_fb_impl.cc
new file mode 100644
index 0000000000..e6c5fcc1d5
--- /dev/null
+++ b/gr-pager/lib/slicer_fb_impl.cc
@@ -0,0 +1,99 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2004,2006,2007,2010,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "slicer_fb_impl.h"
+#include <gr_io_signature.h>
+
+namespace gr {
+ namespace pager {
+
+ slicer_fb::sptr
+ slicer_fb::make(float alpha)
+ {
+ return gnuradio::get_initial_sptr
+ (new slicer_fb_impl(alpha));
+ }
+
+ slicer_fb_impl::slicer_fb_impl(float alpha) :
+ 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 = 1.0-alpha;
+ d_avg = 0.0;
+ }
+
+ slicer_fb_impl::~slicer_fb_impl()
+ {
+ }
+
+ // Tracks average, minimum, and peak, then converts input into one of:
+ //
+ // [0, 1, 2, 3]
+ unsigned char
+ slicer_fb_impl::slice(float sample)
+ {
+ unsigned char decision;
+
+ // Update DC level and remove
+ d_avg = d_avg*d_beta+sample*d_alpha;
+ sample -= d_avg;
+
+ if(sample > 0) {
+ if(sample > 2.0)
+ decision = 3;
+ else
+ decision = 2;
+ }
+ else {
+ if(sample < -2.0)
+ decision = 0;
+ else
+ decision = 1;
+ }
+
+ return decision;
+ }
+
+ int
+ slicer_fb_impl::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;
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/lib/slicer_fb_impl.h b/gr-pager/lib/slicer_fb_impl.h
new file mode 100644
index 0000000000..c758a4b160
--- /dev/null
+++ b/gr-pager/lib/slicer_fb_impl.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,2007,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.
+ */
+
+#ifndef INCLUDED_PAGER_SLICER_FB_IMPL_H
+#define INCLUDED_PAGER_SLICER_FB_IMPL_H
+
+#include <pager/slicer_fb.h>
+
+namespace gr {
+ namespace pager {
+
+ class slicer_fb_impl : public slicer_fb
+ {
+ private:
+ unsigned char slice(float sample);
+
+ float d_alpha; // DC removal time constant
+ float d_beta; // 1.0-d_alpha
+ float d_avg; // Average value for DC offset subtraction
+
+ public:
+ slicer_fb_impl(float alpha);
+ ~slicer_fb_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ float dc_offset() const { return d_avg; }
+ };
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_SLICER_FB_IMPL_H */
diff --git a/gr-pager/lib/util.cc b/gr-pager/lib/util.cc
new file mode 100644
index 0000000000..8db4e5ca11
--- /dev/null
+++ b/gr-pager/lib/util.cc
@@ -0,0 +1,55 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2006,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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "util.h"
+
+namespace gr {
+ namespace pager {
+
+ unsigned char
+ reverse_bits8(unsigned char val)
+ {
+ // This method was attributed to Rich Schroeppel in the Programming
+ // Hacks section of Beeler, M., Gosper, R. W., and Schroeppel, R.
+ // HAKMEM. MIT AI Memo 239, Feb. 29, 1972.
+ //
+ // Reverses 8 bits in 5 machine operations with 64 bit arch
+ return (val * 0x0202020202ULL & 0x010884422010ULL) % 1023;
+ }
+
+ int32_t
+ reverse_bits32(int32_t val)
+ {
+ int32_t out = 0x00000000;
+ out |= (reverse_bits8((val >> 24) & 0x000000FF) );
+ out |= (reverse_bits8((val >> 16) & 0x000000FF) << 8);
+ out |= (reverse_bits8((val >> 8) & 0x000000FF) << 16);
+ out |= (reverse_bits8((val ) & 0x000000FF) << 24);
+ return out;
+ }
+
+ } /* namespace pager */
+} /* namespace gr */
diff --git a/gr-pager/lib/pageri_bch3221.cc b/gr-pager/lib/util.h
index 9c6dd81484..db33e66b95 100644
--- a/gr-pager/lib/pageri_bch3221.cc
+++ b/gr-pager/lib/util.h
@@ -1,5 +1,6 @@
+/* -*- c++ -*- */
/*
- * Copyright 2006 Free Software Foundation, Inc.
+ * Copyright 2006,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -19,18 +20,18 @@
* Boston, MA 02110-1301, USA.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
+#ifndef INCLUDED_PAGER_UTIL_H
+#define INCLUDED_PAGER_UTIL_H
-#include <pageri_bch3221.h>
+#include <stdint.h>
-// Corrects supplied data word according to BCH3221 encoding and
-// returns the number of errors detected/corrected.
-//
-// Not implemented yet
+namespace gr {
+ namespace pager {
-int pageri_bch3221(gr_int32 &data)
-{
- return 0;
-}
+ unsigned char reverse_bits8(unsigned char val);
+ int32_t reverse_bits32(int32_t val);
+
+ } /* namespace pager */
+} /* namespace gr */
+
+#endif /* INCLUDED_PAGER_UTIL_H */
diff --git a/gr-pager/python/qa_pager.py b/gr-pager/python/qa_pager.py
index 87f0d00265..e07291966f 100755
--- a/gr-pager/python/qa_pager.py
+++ b/gr-pager/python/qa_pager.py
@@ -21,7 +21,7 @@
#
from gnuradio import gr, gr_unittest
-import pager_swig
+import pager_swig as pager
class test_pager(gr_unittest.TestCase):
diff --git a/gr-pager/swig/CMakeLists.txt b/gr-pager/swig/CMakeLists.txt
index c98369a365..b6eee8b1eb 100644
--- a/gr-pager/swig/CMakeLists.txt
+++ b/gr-pager/swig/CMakeLists.txt
@@ -46,11 +46,6 @@ GR_SWIG_INSTALL(
install(
FILES
pager_swig.i
- pager_flex_deinterleave.i
- pager_flex_frame.i
- pager_flex_parse.i
- pager_flex_sync.i
- pager_slicer_fb.i
${CMAKE_CURRENT_BINARY_DIR}/pager_swig_doc.i
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
COMPONENT "pager_swig"
diff --git a/gr-pager/swig/gnuradio/pager.scm b/gr-pager/swig/gnuradio/pager.scm
deleted file mode 100644
index 99331b09c5..0000000000
--- a/gr-pager/swig/gnuradio/pager.scm
+++ /dev/null
@@ -1,28 +0,0 @@
-;;;
-;;; Copyright 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 this program. If not, see <http://www.gnu.org/licenses/>.
-;;;
-
-;;; Module that just re-exports the pager_swig module
-
-(define-module (gnuradio pager)
- #:use-module (gnuradio export-safely)
- #:use-module (gnuradio pager_swig)
- #:duplicates (merge-generics replace check))
-
-(re-export-all '(gnuradio pager_swig))
-
diff --git a/gr-pager/swig/pager_flex_deinterleave.i b/gr-pager/swig/pager_flex_deinterleave.i
deleted file mode 100644
index f34951a8a5..0000000000
--- a/gr-pager/swig/pager_flex_deinterleave.i
+++ /dev/null
@@ -1,11 +0,0 @@
-GR_SWIG_BLOCK_MAGIC(pager,flex_deinterleave);
-
-pager_flex_deinterleave_sptr pager_make_flex_deinterleave();
-
-class pager_flex_deinterleave : public gr_sync_decimator
-{
-private:
- pager_flex_deinterleave();
-
-public:
-};
diff --git a/gr-pager/swig/pager_flex_parse.i b/gr-pager/swig/pager_flex_parse.i
deleted file mode 100644
index 21e0245cba..0000000000
--- a/gr-pager/swig/pager_flex_parse.i
+++ /dev/null
@@ -1,11 +0,0 @@
-GR_SWIG_BLOCK_MAGIC(pager,flex_parse);
-
-pager_flex_parse_sptr pager_make_flex_parse(gr_msg_queue_sptr queue, float freq);
-
-class pager_flex_parse : public gr_block
-{
-private:
- pager_flex_parse(gr_msg_queue_sptr queue, float freq);
-
-public:
-};
diff --git a/gr-pager/swig/pager_flex_sync.i b/gr-pager/swig/pager_flex_sync.i
deleted file mode 100644
index 49823db06f..0000000000
--- a/gr-pager/swig/pager_flex_sync.i
+++ /dev/null
@@ -1,11 +0,0 @@
-GR_SWIG_BLOCK_MAGIC(pager,flex_sync);
-
-pager_flex_sync_sptr pager_make_flex_sync();
-
-class pager_flex_sync : public gr_block
-{
-private:
- pager_flex_sync();
-
-public:
-};
diff --git a/gr-pager/swig/pager_slicer_fb.i b/gr-pager/swig/pager_slicer_fb.i
deleted file mode 100644
index 4ffb5b73b1..0000000000
--- a/gr-pager/swig/pager_slicer_fb.i
+++ /dev/null
@@ -1,12 +0,0 @@
-GR_SWIG_BLOCK_MAGIC(pager,slicer_fb);
-
-pager_slicer_fb_sptr pager_make_slicer_fb(float alpha);
-
-class pager_slicer_fb : public gr_sync_block
-{
-private:
- pager_slicer_fb(float alpha);
-
-public:
- float dc_offset() const { return d_avg; }
-};
diff --git a/gr-pager/swig/pager_swig.i b/gr-pager/swig/pager_swig.i
index 04f8041570..ac4fa0278e 100644
--- a/gr-pager/swig/pager_swig.i
+++ b/gr-pager/swig/pager_swig.i
@@ -1,5 +1,5 @@
/*
- * Copyright 2005,2006,2009 Free Software Foundation, Inc.
+ * Copyright 2005,2006,2009,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -19,21 +19,29 @@
* Boston, MA 02110-1301, USA.
*/
+#define PAGER_API
+
%include "gnuradio.i"
//load generated python docstrings
%include "pager_swig_doc.i"
%{
-#include "pager_flex_frame.h"
-#include "pager_slicer_fb.h"
-#include "pager_flex_sync.h"
-#include "pager_flex_deinterleave.h"
-#include "pager_flex_parse.h"
+#include "pager/flex_frame.h"
+#include "pager/slicer_fb.h"
+#include "pager/flex_sync.h"
+#include "pager/flex_deinterleave.h"
+#include "pager/flex_parse.h"
%}
-%include "pager_flex_frame.i"
-%include "pager_slicer_fb.i"
-%include "pager_flex_sync.i"
-%include "pager_flex_deinterleave.i"
-%include "pager_flex_parse.i"
+%include "pager/flex_frame.h"
+%include "pager/slicer_fb.h"
+%include "pager/flex_sync.h"
+%include "pager/flex_deinterleave.h"
+%include "pager/flex_parse.h"
+
+GR_SWIG_BLOCK_MAGIC2(pager, flex_frame);
+GR_SWIG_BLOCK_MAGIC2(pager, slicer_fb);
+GR_SWIG_BLOCK_MAGIC2(pager, flex_sync);
+GR_SWIG_BLOCK_MAGIC2(pager, flex_deinterleave);
+GR_SWIG_BLOCK_MAGIC2(pager, flex_parse);