summaryrefslogtreecommitdiff
path: root/gr-noaa
diff options
context:
space:
mode:
authorTom Rondeau <trondeau@vt.edu>2013-01-13 18:32:43 -0500
committerTom Rondeau <trondeau@vt.edu>2013-01-13 18:33:04 -0500
commitcfa793daa722e910c2d54b691c99efcbb9efc252 (patch)
tree52053ae878051c5d3de56bac47cb4027cc4ab113 /gr-noaa
parent977e8924d4bbd4d28342053f575242b9f0ae1e54 (diff)
noaa: converting to new API structure.
Diffstat (limited to 'gr-noaa')
-rw-r--r--gr-noaa/CMakeLists.txt11
-rw-r--r--gr-noaa/include/noaa/CMakeLists.txt31
-rw-r--r--gr-noaa/include/noaa/api.h (renamed from gr-noaa/lib/noaa_api.h)0
-rw-r--r--gr-noaa/include/noaa/hrpt.h (renamed from gr-noaa/lib/noaa_hrpt.h)0
-rw-r--r--gr-noaa/include/noaa/hrpt_decoder.h (renamed from gr-noaa/swig/noaa_hrpt_decoder.i)33
-rw-r--r--gr-noaa/include/noaa/hrpt_deframer.h (renamed from gr-noaa/swig/noaa_hrpt_pll_cf.i)36
-rw-r--r--gr-noaa/include/noaa/hrpt_pll_cf.h (renamed from gr-noaa/swig/noaa_hrpt_deframer.i)34
-rw-r--r--gr-noaa/lib/CMakeLists.txt24
-rw-r--r--gr-noaa/lib/hrpt_decoder_impl.cc206
-rw-r--r--gr-noaa/lib/hrpt_decoder_impl.h75
-rw-r--r--gr-noaa/lib/hrpt_deframer_impl.cc137
-rw-r--r--gr-noaa/lib/hrpt_deframer_impl.h58
-rw-r--r--gr-noaa/lib/hrpt_pll_cf_impl.cc93
-rw-r--r--gr-noaa/lib/hrpt_pll_cf_impl.h56
-rw-r--r--gr-noaa/lib/noaa_hrpt_decoder.cc200
-rw-r--r--gr-noaa/lib/noaa_hrpt_decoder.h77
-rw-r--r--gr-noaa/lib/noaa_hrpt_deframer.cc126
-rw-r--r--gr-noaa/lib/noaa_hrpt_deframer.h58
-rw-r--r--gr-noaa/lib/noaa_hrpt_pll_cf.cc83
-rw-r--r--gr-noaa/lib/noaa_hrpt_pll_cf.h56
-rw-r--r--gr-noaa/python/CMakeLists.txt50
-rw-r--r--gr-noaa/python/__init__.py (renamed from gr-noaa/swig/__init__.py)23
-rwxr-xr-xgr-noaa/python/qa_noaa.py41
-rw-r--r--gr-noaa/swig/CMakeLists.txt12
-rw-r--r--gr-noaa/swig/gnuradio/noaa.scm27
-rw-r--r--gr-noaa/swig/noaa_swig.i20
26 files changed, 857 insertions, 710 deletions
diff --git a/gr-noaa/CMakeLists.txt b/gr-noaa/CMakeLists.txt
index ac8aac5a93..3da763c7f8 100644
--- a/gr-noaa/CMakeLists.txt
+++ b/gr-noaa/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -33,7 +33,12 @@ GR_REGISTER_COMPONENT("gr-noaa" ENABLE_GR_NOAA
)
GR_SET_GLOBAL(GR_NOAA_INCLUDE_DIRS
- ${CMAKE_CURRENT_SOURCE_DIR}/lib
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_BINARY_DIR}/include
+)
+
+GR_SET_GLOBAL(GR_NOAA_SWIG_INCLUDE_DIRS
+ ${CMAKE_CURRENT_SOURCE_DIR}/swig
)
SET(GR_PKG_NOAA_EXAMPLES_DIR ${GR_PKG_DATA_DIR}/examples/noaa)
@@ -80,9 +85,11 @@ CPACK_COMPONENT("noaa_swig"
########################################################################
# Add subdirectories
########################################################################
+add_subdirectory(include/noaa)
add_subdirectory(lib)
if(ENABLE_PYTHON)
add_subdirectory(swig)
+ add_subdirectory(python)
add_subdirectory(grc)
add_subdirectory(examples)
endif(ENABLE_PYTHON)
diff --git a/gr-noaa/include/noaa/CMakeLists.txt b/gr-noaa/include/noaa/CMakeLists.txt
new file mode 100644
index 0000000000..a3a18d2c26
--- /dev/null
+++ b/gr-noaa/include/noaa/CMakeLists.txt
@@ -0,0 +1,31 @@
+# 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
+ hrpt_decoder.h
+ hrpt_deframer.h
+ hrpt.h
+ hrpt_pll_cf.h
+ DESTINATION ${GR_INCLUDE_DIR}/gnuradio/noaa
+ COMPONENT "noaa_devel"
+)
diff --git a/gr-noaa/lib/noaa_api.h b/gr-noaa/include/noaa/api.h
index d3c3fbf2d0..d3c3fbf2d0 100644
--- a/gr-noaa/lib/noaa_api.h
+++ b/gr-noaa/include/noaa/api.h
diff --git a/gr-noaa/lib/noaa_hrpt.h b/gr-noaa/include/noaa/hrpt.h
index f0f0e53f4d..f0f0e53f4d 100644
--- a/gr-noaa/lib/noaa_hrpt.h
+++ b/gr-noaa/include/noaa/hrpt.h
diff --git a/gr-noaa/swig/noaa_hrpt_decoder.i b/gr-noaa/include/noaa/hrpt_decoder.h
index a3f8f48c33..bfc9b79be6 100644
--- a/gr-noaa/swig/noaa_hrpt_decoder.i
+++ b/gr-noaa/include/noaa/hrpt_decoder.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,13 +20,28 @@
* Boston, MA 02110-1301, USA.
*/
-GR_SWIG_BLOCK_MAGIC(noaa,hrpt_decoder)
+#ifndef INCLUDED_NOAA_HRPT_DECODER_H
+#define INCLUDED_NOAA_HRPT_DECODER_H
-noaa_hrpt_decoder_sptr
-noaa_make_hrpt_decoder(bool verbose, bool output_files);
+#include <noaa/api.h>
+#include <gr_sync_block.h>
-class noaa_hrpt_decoder : public gr_sync_block
-{
-private:
- noaa_hrpt_decoder();
-};
+namespace gr {
+ namespace noaa {
+
+ class NOAA_API hrpt_decoder : virtual public gr_sync_block
+ {
+ public:
+ // gr::noaa::hrpt_decoder::sptr
+ typedef boost::shared_ptr<hrpt_decoder> sptr;
+
+ /*!
+ * \brief Make NOAA HRPT Decoder
+ */
+ static sptr make(bool verbose, bool output_files);
+ };
+
+ } /* namespace noaa */
+} /* namespace gr */
+
+#endif /* INCLUDED_NOAA_HRPT_DECODER_H */
diff --git a/gr-noaa/swig/noaa_hrpt_pll_cf.i b/gr-noaa/include/noaa/hrpt_deframer.h
index 2a5f524b37..53a051ede2 100644
--- a/gr-noaa/swig/noaa_hrpt_pll_cf.i
+++ b/gr-noaa/include/noaa/hrpt_deframer.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,18 +20,28 @@
* Boston, MA 02110-1301, USA.
*/
-GR_SWIG_BLOCK_MAGIC(noaa,hrpt_pll_cf)
+#ifndef INCLUDED_NOAA_HRPT_DEFRAMER_H
+#define INCLUDED_NOAA_HRPT_DEFRAMER_H
-noaa_hrpt_pll_cf_sptr
-noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset);
+#include <noaa/api.h>
+#include <gr_block.h>
-class noaa_hrpt_pll_cf : public gr_sync_block
-{
-private:
- noaa_hrpt_pll_cf();
+namespace gr {
+ namespace noaa {
-public:
- void set_alpha(float alpha);
- void set_beta(float beta);
- void set_max_offset(float min_freq);
-};
+ class NOAA_API hrpt_deframer : virtual public gr_block
+ {
+ public:
+ // gr::noaa::hrpt_deframer::sptr
+ typedef boost::shared_ptr<hrpt_deframer> sptr;
+
+ /*!
+ * \brief Make NOAA HRPT Deframer
+ */
+ static sptr make();
+ };
+
+ } /* namespace noaa */
+} /* namespace gr */
+
+#endif /* INCLUDED_NOAA_HRPT_DEFRAMER_H */
diff --git a/gr-noaa/swig/noaa_hrpt_deframer.i b/gr-noaa/include/noaa/hrpt_pll_cf.h
index 833ad18ade..0e13c01ddd 100644
--- a/gr-noaa/swig/noaa_hrpt_deframer.i
+++ b/gr-noaa/include/noaa/hrpt_pll_cf.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,13 +20,29 @@
* Boston, MA 02110-1301, USA.
*/
-GR_SWIG_BLOCK_MAGIC(noaa,hrpt_deframer)
+#ifndef INCLUDED_NOAA_HRPT_PLL_CF_H
+#define INCLUDED_NOAA_HRPT_PLL_CF_H
-noaa_hrpt_deframer_sptr
-noaa_make_hrpt_deframer();
+#include <noaa/api.h>
+#include <gr_sync_block.h>
-class noaa_hrpt_deframer : public gr_block
-{
-private:
- noaa_hrpt_deframer();
-};
+namespace gr {
+ namespace noaa {
+
+ class NOAA_API hrpt_pll_cf : virtual public gr_sync_block
+ {
+ public:
+ // gr::noaa::hrpt_pll_cf::sptr
+ typedef boost::shared_ptr<hrpt_pll_cf> sptr;
+
+ static sptr make(float alpha, float beta, float max_offset);
+
+ virtual void set_alpha(float alpha) = 0;
+ virtual void set_beta(float beta) = 0;
+ virtual void set_max_offset(float max_offset) = 0;
+ };
+
+ } /* namespace noaa */
+} /* namespace gr */
+
+#endif /* INCLUDED_NOAA_HRPT_PLL_CF_H */
diff --git a/gr-noaa/lib/CMakeLists.txt b/gr-noaa/lib/CMakeLists.txt
index 3f369f8aff..0241a42fb0 100644
--- a/gr-noaa/lib/CMakeLists.txt
+++ b/gr-noaa/lib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -32,10 +32,10 @@ link_directories(${Boost_LIBRARY_DIRS})
########################################################################
# Setup library
########################################################################
-list(APPEND gr_noaa_sources
- noaa_hrpt_decoder.cc
- noaa_hrpt_deframer.cc
- noaa_hrpt_pll_cf.cc
+list(APPEND noaa_sources
+ hrpt_decoder_impl.cc
+ hrpt_deframer_impl.cc
+ hrpt_pll_cf_impl.cc
)
list(APPEND noaa_libs
@@ -43,18 +43,6 @@ list(APPEND noaa_libs
${Boost_LIBRARIES}
)
-add_library(gnuradio-noaa SHARED ${gr_noaa_sources})
+add_library(gnuradio-noaa SHARED ${noaa_sources})
target_link_libraries(gnuradio-noaa ${noaa_libs})
GR_LIBRARY_FOO(gnuradio-noaa RUNTIME_COMPONENT "noaa_runtime" DEVEL_COMPONENT "noaa_devel")
-
-########################################################################
-# Install header files
-########################################################################
-install(FILES
- noaa_api.h
- noaa_hrpt_decoder.h
- noaa_hrpt_deframer.h
- noaa_hrpt_pll_cf.h
- DESTINATION ${GR_INCLUDE_DIR}/gnuradio
- COMPONENT "noaa_devel"
-)
diff --git a/gr-noaa/lib/hrpt_decoder_impl.cc b/gr-noaa/lib/hrpt_decoder_impl.cc
new file mode 100644
index 0000000000..76155ac547
--- /dev/null
+++ b/gr-noaa/lib/hrpt_decoder_impl.cc
@@ -0,0 +1,206 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009,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 "hrpt_decoder_impl.h"
+#include <noaa/hrpt.h>
+#include <gr_io_signature.h>
+#include <cstdio>
+
+namespace gr {
+ namespace noaa {
+
+ static const char *hrpt_ids[] = {
+ "000000",
+ "NOAA11",
+ "000002",
+ "NOAA16",
+ "000004",
+ "000005",
+ "000006",
+ "NOAA15",
+ "000008",
+ "NOAA12",
+ "000010",
+ "NOAA17",
+ "000012",
+ "NOAA18",
+ "000014",
+ "NOAA19"
+ };
+
+ hrpt_decoder::sptr
+ hrpt_decoder::make(bool verbose, bool output_files)
+ {
+ return gnuradio::get_initial_sptr
+ (new hrpt_decoder_impl(verbose, output_files));
+ }
+
+ hrpt_decoder_impl::hrpt_decoder_impl(bool verbose, bool output_files)
+ : gr_sync_block("noaa_hrpt_decoder",
+ gr_make_io_signature(1, 1, sizeof(short)),
+ gr_make_io_signature(0, 0, 0)),
+ d_verbose(verbose),
+ d_output_files(output_files),
+ d_word_num(0),
+ d_frames_seen(0),
+ d_current_mfnum(0),
+ d_expected_mfnum(0),
+ d_seq_errs(0),
+ d_address(0),
+ d_day_of_year(0),
+ d_milliseconds(0),
+ d_last_time(0)
+ {
+ // Start of capture processing here
+ }
+
+ hrpt_decoder_impl::~hrpt_decoder_impl()
+ {
+ // End of capture processing here
+
+ if(d_verbose) {
+ fprintf(stderr, "Frames seen: %10i\n", d_frames_seen);
+ fprintf(stderr, "Sequence errors: %10i\n", d_seq_errs);
+ }
+ }
+
+ int
+ hrpt_decoder_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const unsigned short *in = (const unsigned short*)input_items[0];
+
+ int i = 0;
+ while(i < noutput_items) {
+ d_current_word = in[i++] & 0x3FF;
+ d_word_num++;
+
+ // Per HRPT word processing here
+
+ switch(d_word_num) {
+ case 7:
+ process_mfnum();
+ process_address();
+ break;
+
+ case 9:
+ process_day_of_year();
+ break;
+
+ case 10:
+ process_milli1();
+ break;
+
+ case 11:
+ process_milli2();
+ break;
+
+ case 12:
+ process_milli3();
+ break;
+
+ default:
+ break;
+ }
+
+ if(d_word_num == HRPT_MINOR_FRAME_WORDS) {
+ // End of minor frame processing here
+ d_frames_seen++;
+ d_word_num = 0;
+ fprintf(stderr, "\n");
+ }
+ }
+
+ return i;
+ }
+
+ void
+ hrpt_decoder_impl::process_mfnum()
+ {
+ d_current_mfnum = (d_current_word & 0x180) >> 7;
+
+ if(d_verbose)
+ fprintf(stderr, "MF:");
+
+ if(d_current_mfnum != d_expected_mfnum && d_frames_seen > 0) {
+ d_seq_errs++;
+
+ if(d_verbose)
+ fprintf(stderr, "*");
+ }
+ else
+ if(d_verbose)
+ fprintf(stderr, " ");
+
+ if(d_verbose)
+ fprintf(stderr, "%i ", d_current_mfnum);
+ d_expected_mfnum = (d_current_mfnum == 3) ? 1 : d_current_mfnum+1;
+ }
+
+ void
+ hrpt_decoder_impl::process_address()
+ {
+ d_address = ((d_current_word & 0x078) >> 3) & 0x000F;
+
+ if(d_verbose)
+ fprintf(stderr, "SA: %s ", hrpt_ids[d_address]);
+ }
+
+ void
+ hrpt_decoder_impl::process_day_of_year()
+ {
+ d_day_of_year = d_current_word >> 1;
+
+ if(d_verbose)
+ fprintf(stderr, "DOY: %3i ", d_day_of_year);
+ }
+
+ void
+ hrpt_decoder_impl::process_milli1()
+ {
+ d_milliseconds = (d_current_word & 0x7F) << 20;
+ }
+
+ void
+ hrpt_decoder_impl::process_milli2()
+ {
+ d_milliseconds |= (d_current_word << 10);
+ }
+
+ void
+ hrpt_decoder_impl::process_milli3()
+ {
+ d_milliseconds |= d_current_word;
+ int delta = d_milliseconds - d_last_time;
+ d_last_time = d_milliseconds;
+
+ if(d_verbose)
+ fprintf(stderr, "MS: %8i DT: %8i", d_milliseconds, delta);
+ }
+
+ } /* namespace noaa */
+} /* namespace gr */
diff --git a/gr-noaa/lib/hrpt_decoder_impl.h b/gr-noaa/lib/hrpt_decoder_impl.h
new file mode 100644
index 0000000000..e242c48e0c
--- /dev/null
+++ b/gr-noaa/lib/hrpt_decoder_impl.h
@@ -0,0 +1,75 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009,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_NOAA_HRPT_DECODER_IMPL_H
+#define INCLUDED_NOAA_HRPT_DECODER_IMPL_H
+
+#include <noaa/hrpt_decoder.h>
+
+namespace gr {
+ namespace noaa {
+
+ class hrpt_decoder_impl : public hrpt_decoder
+ {
+ private:
+ // Configuration
+ bool d_verbose;
+ bool d_output_files;
+
+ // Frame-level state
+ unsigned short d_current_word;
+ unsigned int d_word_num;
+ int d_frames_seen;
+
+ // Minor frame number
+ int d_current_mfnum;
+ int d_expected_mfnum;
+ int d_seq_errs;
+
+ // Spacecraft address
+ int d_address;
+
+ // Minor frame timestamp
+ int d_day_of_year;
+ int d_milliseconds;
+ int d_last_time;
+
+ void process_mfnum();
+ void process_address();
+ void process_day_of_year();
+ void process_milli1();
+ void process_milli2();
+ void process_milli3();
+
+ public:
+ hrpt_decoder_impl(bool verbose, bool output_files);
+ ~hrpt_decoder_impl();
+
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+ };
+
+ } /* namespace noaa */
+} /* namespace gr */
+
+#endif /* INCLUDED_NOAA_HRPT_DECODER_IMPL_H */
diff --git a/gr-noaa/lib/hrpt_deframer_impl.cc b/gr-noaa/lib/hrpt_deframer_impl.cc
new file mode 100644
index 0000000000..cd6d0800db
--- /dev/null
+++ b/gr-noaa/lib/hrpt_deframer_impl.cc
@@ -0,0 +1,137 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009,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 "hrpt_deframer_impl.h"
+#include <gr_io_signature.h>
+#include <noaa/hrpt.h>
+#include <cstring>
+#include <cstdio>
+
+namespace gr {
+ namespace noaa {
+
+#define ST_IDLE 0
+#define ST_SYNCED 1
+
+ hrpt_deframer::sptr
+ hrpt_deframer::make()
+ {
+ return gnuradio::get_initial_sptr
+ (new hrpt_deframer_impl());
+ }
+
+ hrpt_deframer_impl::hrpt_deframer_impl()
+ : gr_block("noaa_hrpt_deframer",
+ gr_make_io_signature(1, 1, sizeof(char)),
+ gr_make_io_signature(1, 1, sizeof(short)))
+ {
+ set_output_multiple(6); // room for writing full sync when received
+ d_mid_bit = true;
+ d_last_bit = 0;
+ enter_idle();
+ }
+
+ hrpt_deframer_impl::~hrpt_deframer_impl()
+ {
+ }
+
+ void
+ hrpt_deframer_impl::enter_idle()
+ {
+ d_state = ST_IDLE;
+ }
+
+ void
+ hrpt_deframer_impl::enter_synced()
+ {
+ d_state = ST_SYNCED;
+ d_bit_count = HRPT_BITS_PER_WORD;
+ d_word_count = HRPT_MINOR_FRAME_WORDS-HRPT_SYNC_WORDS;
+ d_word = 0;
+ }
+
+ int
+ hrpt_deframer_impl::general_work(int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ int ninputs = ninput_items[0];
+ const char *in = (const char *)input_items[0];
+ unsigned short *out = (unsigned short *)output_items[0];
+
+ int i = 0, j = 0;
+ while(i < ninputs && j < noutput_items) {
+ char bit = in[i++];
+ char diff = bit^d_last_bit;
+ d_last_bit = bit;
+
+ // Wait for transition if not synced, otherwise, alternate bits
+ if(d_mid_bit && (diff | (d_state == ST_SYNCED))) {
+ switch(d_state) {
+ case ST_IDLE:
+ d_shifter = (d_shifter << 1) | bit; // MSB transmitted first
+
+ if((d_shifter & 0x0FFFFFFFFFFFFFFFLL) == HRPT_MINOR_FRAME_SYNC) {
+ out[j++] = HRPT_SYNC1;
+ out[j++] = HRPT_SYNC2;
+ out[j++] = HRPT_SYNC3;
+ out[j++] = HRPT_SYNC4;
+ out[j++] = HRPT_SYNC5;
+ out[j++] = HRPT_SYNC6;
+ enter_synced();
+ }
+ break;
+
+ case ST_SYNCED:
+ d_word = (d_word << 1) | bit; // MSB transmitted first
+ if(--d_bit_count == 0) {
+ out[j++] = d_word;
+ d_word = 0;
+ d_bit_count = HRPT_BITS_PER_WORD;
+ if(--d_word_count == 0) {
+ enter_idle();
+ }
+ }
+ break;
+
+ default:
+ throw std::runtime_error("hrpt_deframer_impl: bad state\n");
+ }
+
+ d_mid_bit = false;
+ }
+ else {
+ d_mid_bit = true;
+ }
+ }
+
+ consume_each(i);
+ return j;
+ }
+
+ } /* namespace noaa */
+} /* namespace gr */
diff --git a/gr-noaa/lib/hrpt_deframer_impl.h b/gr-noaa/lib/hrpt_deframer_impl.h
new file mode 100644
index 0000000000..9bad0b87bf
--- /dev/null
+++ b/gr-noaa/lib/hrpt_deframer_impl.h
@@ -0,0 +1,58 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009,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_NOAA_HRPT_DEFRAMER_IMPL_H
+#define INCLUDED_NOAA_HRPT_DEFRAMER_IMPL_H
+
+#include <noaa/hrpt_deframer.h>
+
+namespace gr {
+ namespace noaa {
+
+ class hrpt_deframer_impl : public hrpt_deframer
+ {
+ private:
+ unsigned int d_state;
+ bool d_mid_bit;
+ unsigned char d_last_bit;
+ unsigned int d_bit_count;
+ unsigned int d_word_count;
+ unsigned long long d_shifter; // 60 bit sync word
+ unsigned short d_word; // 10 bit HRPT word
+
+ void enter_idle();
+ void enter_synced();
+
+ public:
+ hrpt_deframer_impl();
+ ~hrpt_deframer_impl();
+
+ 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 noaa */
+} /* namespace gr */
+
+#endif /* INCLUDED_NOAA_HRPT_DEFRAMER_IMPL_H */
diff --git a/gr-noaa/lib/hrpt_pll_cf_impl.cc b/gr-noaa/lib/hrpt_pll_cf_impl.cc
new file mode 100644
index 0000000000..17114ef302
--- /dev/null
+++ b/gr-noaa/lib/hrpt_pll_cf_impl.cc
@@ -0,0 +1,93 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009,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 "hrpt_pll_cf_impl.h"
+#include <gr_io_signature.h>
+#include <gr_math.h>
+#include <gr_sincos.h>
+
+namespace gr {
+ namespace noaa {
+
+#define M_TWOPI (2*M_PI)
+
+ float
+ phase_wrap(float phase)
+ {
+ while (phase < -M_PI)
+ phase += M_TWOPI;
+ while (phase > M_PI)
+ phase -= M_TWOPI;
+
+ return phase;
+ }
+
+ hrpt_pll_cf::sptr
+ hrpt_pll_cf::make(float alpha, float beta, float max_offset)
+ {
+ return gnuradio::get_initial_sptr
+ (new hrpt_pll_cf_impl(alpha, beta, max_offset));
+ }
+
+ hrpt_pll_cf_impl::hrpt_pll_cf_impl(float alpha, float beta, float max_offset)
+ : gr_sync_block("noaa_hrpt_pll_cf",
+ gr_make_io_signature(1, 1, sizeof(gr_complex)),
+ gr_make_io_signature(1, 1, sizeof(float))),
+ d_alpha(alpha), d_beta(beta), d_max_offset(max_offset),
+ d_phase(0.0), d_freq(0.0)
+ {
+ }
+
+ hrpt_pll_cf_impl::~hrpt_pll_cf_impl()
+ {
+ }
+
+ int
+ hrpt_pll_cf_impl::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+ {
+ const gr_complex *in = (const gr_complex *)input_items[0];
+ float *out = (float *)output_items[0];
+
+ for(int i = 0; i < noutput_items; i++) {
+
+ // Generate and mix out carrier
+ float re, im;
+ gr_sincosf(d_phase, &im, &re);
+ out[i] = (in[i]*gr_complex(re, -im)).imag();
+
+ // Adjust PLL phase/frequency
+ float error = phase_wrap(gr_fast_atan2f(in[i].imag(), in[i].real()) - d_phase);
+ d_freq = gr_branchless_clip(d_freq + error*d_beta, d_max_offset);
+ d_phase = phase_wrap(d_phase + error*d_alpha + d_freq);
+ }
+
+ return noutput_items;
+ }
+
+ } /* namespace noaa */
+} /* namespace gr */
diff --git a/gr-noaa/lib/hrpt_pll_cf_impl.h b/gr-noaa/lib/hrpt_pll_cf_impl.h
new file mode 100644
index 0000000000..cc0c36137e
--- /dev/null
+++ b/gr-noaa/lib/hrpt_pll_cf_impl.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2009,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_NOAA_HRPT_PLL_CF_IMPL_H
+#define INCLUDED_NOAA_HRPT_PLL_CF_IMPL_H
+
+#include <noaa/hrpt_pll_cf.h>
+
+namespace gr {
+ namespace noaa {
+
+ class hrpt_pll_cf_impl : public hrpt_pll_cf
+ {
+ private:
+ float d_alpha; // 1st order loop constant
+ float d_beta; // 2nd order loop constant
+ float d_max_offset; // Maximum frequency offset, radians/sample
+ float d_phase; // Instantaneous carrier phase
+ float d_freq; // Instantaneous carrier frequency, radians/sample
+
+ public:
+ hrpt_pll_cf_impl(float alpha, float beta, float max_offset);
+ ~hrpt_pll_cf_impl();
+
+ virtual int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+
+ void set_alpha(float alpha) { d_alpha = alpha; }
+ void set_beta(float beta) { d_beta = beta; }
+ void set_max_offset(float max_offset) { d_max_offset = max_offset; }
+ };
+
+ } /* namespace noaa */
+} /* namespace gr */
+
+#endif /* INCLUDED_NOAA_HRPT_PLL_CF_IMPL_H */
diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc
deleted file mode 100644
index d6a063285d..0000000000
--- a/gr-noaa/lib/noaa_hrpt_decoder.cc
+++ /dev/null
@@ -1,200 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <noaa_hrpt_decoder.h>
-#include <noaa_hrpt.h>
-#include <gr_io_signature.h>
-#include <cstdio>
-
-static const char *hrpt_ids[] = {
- "000000",
- "NOAA11",
- "000002",
- "NOAA16",
- "000004",
- "000005",
- "000006",
- "NOAA15",
- "000008",
- "NOAA12",
- "000010",
- "NOAA17",
- "000012",
- "NOAA18",
- "000014",
- "NOAA19"
-};
-
-noaa_hrpt_decoder_sptr
-noaa_make_hrpt_decoder(bool verbose, bool output_files)
-{
- return gnuradio::get_initial_sptr(new noaa_hrpt_decoder(verbose, output_files));
-}
-
-noaa_hrpt_decoder::noaa_hrpt_decoder(bool verbose, bool output_files)
- : gr_sync_block("noaa_hrpt_decoder",
- gr_make_io_signature(1, 1, sizeof(short)),
- gr_make_io_signature(0, 0, 0)),
- d_verbose(verbose),
- d_output_files(output_files),
- d_word_num(0),
- d_frames_seen(0),
- d_current_mfnum(0),
- d_expected_mfnum(0),
- d_seq_errs(0),
- d_address(0),
- d_day_of_year(0),
- d_milliseconds(0),
- d_last_time(0)
-{
- // Start of capture processing here
-}
-
-int
-noaa_hrpt_decoder::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const unsigned short *in = (const unsigned short*)input_items[0];
-
- int i = 0;
- while (i < noutput_items) {
- d_current_word = in[i++] & 0x3FF;
- d_word_num++;
-
- // Per HRPT word processing here
-
- switch (d_word_num) {
- case 7:
- process_mfnum();
- process_address();
- break;
-
- case 9:
- process_day_of_year();
- break;
-
- case 10:
- process_milli1();
- break;
-
- case 11:
- process_milli2();
- break;
-
- case 12:
- process_milli3();
- break;
-
- default:
- break;
- }
-
- if (d_word_num == HRPT_MINOR_FRAME_WORDS) {
-
- // End of minor frame processing here
- d_frames_seen++;
- d_word_num = 0;
- fprintf(stderr, "\n");
- }
- }
-
- return i;
-}
-
-void
-noaa_hrpt_decoder::process_mfnum()
-{
- d_current_mfnum = (d_current_word & 0x180) >> 7;
-
- if (d_verbose)
- fprintf(stderr, "MF:");
-
- if (d_current_mfnum != d_expected_mfnum && d_frames_seen > 0) {
- d_seq_errs++;
-
- if (d_verbose)
- fprintf(stderr, "*");
- }
- else
- if (d_verbose)
- fprintf(stderr, " ");
-
- if (d_verbose)
- fprintf(stderr, "%i ", d_current_mfnum);
- d_expected_mfnum = (d_current_mfnum == 3) ? 1 : d_current_mfnum+1;
-}
-
-void
-noaa_hrpt_decoder::process_address()
-{
- d_address = ((d_current_word & 0x078) >> 3) & 0x000F;
-
- if (d_verbose)
- fprintf(stderr, "SA: %s ", hrpt_ids[d_address]);
-}
-
-void
-noaa_hrpt_decoder::process_day_of_year()
-{
- d_day_of_year = d_current_word >> 1;
-
- if (d_verbose)
- fprintf(stderr, "DOY: %3i ", d_day_of_year);
-}
-
-void
-noaa_hrpt_decoder::process_milli1()
-{
- d_milliseconds = (d_current_word & 0x7F) << 20;
-}
-
-void
-noaa_hrpt_decoder::process_milli2()
-{
- d_milliseconds |= (d_current_word << 10);
-}
-
-void
-noaa_hrpt_decoder::process_milli3()
-{
- d_milliseconds |= d_current_word;
- int delta = d_milliseconds - d_last_time;
- d_last_time = d_milliseconds;
-
- if (d_verbose)
- fprintf(stderr, "MS: %8i DT: %8i", d_milliseconds, delta);
-}
-
-noaa_hrpt_decoder::~noaa_hrpt_decoder()
-{
- // End of capture processing here
-
- if (d_verbose) {
- fprintf(stderr, "Frames seen: %10i\n", d_frames_seen);
- fprintf(stderr, "Sequence errors: %10i\n", d_seq_errs);
- }
-}
diff --git a/gr-noaa/lib/noaa_hrpt_decoder.h b/gr-noaa/lib/noaa_hrpt_decoder.h
deleted file mode 100644
index 3b3214b721..0000000000
--- a/gr-noaa/lib/noaa_hrpt_decoder.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_NOAA_HRPT_DECODER_H
-#define INCLUDED_NOAA_HRPT_DECODER_H
-
-#include <noaa_api.h>
-#include <gr_sync_block.h>
-
-class noaa_hrpt_decoder;
-typedef boost::shared_ptr<noaa_hrpt_decoder> noaa_hrpt_decoder_sptr;
-
-NOAA_API noaa_hrpt_decoder_sptr
-noaa_make_hrpt_decoder(bool verbose, bool output_files);
-
-class NOAA_API noaa_hrpt_decoder : public gr_sync_block
-{
- friend NOAA_API noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(bool verbose, bool output_files);
- noaa_hrpt_decoder(bool verbose, bool output_files);
-
- // Configuration
- bool d_verbose;
- bool d_output_files;
-
- // Frame-level state
- unsigned short d_current_word;
- unsigned int d_word_num;
- int d_frames_seen;
-
- // Minor frame number
- int d_current_mfnum;
- int d_expected_mfnum;
- int d_seq_errs;
-
- // Spacecraft address
- int d_address;
-
- // Minor frame timestamp
- int d_day_of_year;
- int d_milliseconds;
- int d_last_time;
-
- void process_mfnum();
- void process_address();
- void process_day_of_year();
- void process_milli1();
- void process_milli2();
- void process_milli3();
-
-public:
- ~noaa_hrpt_decoder();
-
- int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-};
-
-#endif /* INCLUDED_NOAA_HRPT_DECODER_H */
diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc
deleted file mode 100644
index d668ccad35..0000000000
--- a/gr-noaa/lib/noaa_hrpt_deframer.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <noaa_hrpt_deframer.h>
-#include <gr_io_signature.h>
-#include <noaa_hrpt.h>
-#include <cstring>
-#include <cstdio>
-
-#define ST_IDLE 0
-#define ST_SYNCED 1
-
-noaa_hrpt_deframer_sptr
-noaa_make_hrpt_deframer()
-{
- return gnuradio::get_initial_sptr(new noaa_hrpt_deframer());
-}
-
-noaa_hrpt_deframer::noaa_hrpt_deframer()
- : gr_block("noaa_hrpt_deframer",
- gr_make_io_signature(1, 1, sizeof(char)),
- gr_make_io_signature(1, 1, sizeof(short)))
-{
- set_output_multiple(6); // room for writing full sync when received
- d_mid_bit = true;
- d_last_bit = 0;
- enter_idle();
-}
-
-void
-noaa_hrpt_deframer::enter_idle()
-{
- d_state = ST_IDLE;
-}
-
-void
-noaa_hrpt_deframer::enter_synced()
-{
- d_state = ST_SYNCED;
- d_bit_count = HRPT_BITS_PER_WORD;
- d_word_count = HRPT_MINOR_FRAME_WORDS-HRPT_SYNC_WORDS;
- d_word = 0;
-}
-
-int
-noaa_hrpt_deframer::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- int ninputs = ninput_items[0];
- const char *in = (const char *)input_items[0];
- unsigned short *out = (unsigned short *)output_items[0];
-
- int i = 0, j = 0;
- while (i < ninputs && j < noutput_items) {
- char bit = in[i++];
- char diff = bit^d_last_bit;
- d_last_bit = bit;
-
- // Wait for transition if not synced, otherwise, alternate bits
- if (d_mid_bit && (diff | (d_state == ST_SYNCED))) {
- switch (d_state) {
- case ST_IDLE:
- d_shifter = (d_shifter << 1) | bit; // MSB transmitted first
-
- if ((d_shifter & 0x0FFFFFFFFFFFFFFFLL) == HRPT_MINOR_FRAME_SYNC) {
- out[j++] = HRPT_SYNC1;
- out[j++] = HRPT_SYNC2;
- out[j++] = HRPT_SYNC3;
- out[j++] = HRPT_SYNC4;
- out[j++] = HRPT_SYNC5;
- out[j++] = HRPT_SYNC6;
- enter_synced();
- }
- break;
-
- case ST_SYNCED:
- d_word = (d_word << 1) | bit; // MSB transmitted first
- if (--d_bit_count == 0) {
- out[j++] = d_word;
- d_word = 0;
- d_bit_count = HRPT_BITS_PER_WORD;
- if (--d_word_count == 0) {
- enter_idle();
- }
- }
- break;
-
- default:
- throw std::runtime_error("noaa_hrpt_deframer: bad state\n");
- }
-
- d_mid_bit = false;
- }
- else {
- d_mid_bit = true;
- }
- }
-
- consume_each(i);
- return j;
-}
diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h
deleted file mode 100644
index 475ad90f61..0000000000
--- a/gr-noaa/lib/noaa_hrpt_deframer.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_NOAA_HRPT_DEFRAMER_H
-#define INCLUDED_NOAA_HRPT_DEFRAMER_H
-
-#include <noaa_api.h>
-#include <gr_block.h>
-
-class noaa_hrpt_deframer;
-typedef boost::shared_ptr<noaa_hrpt_deframer> noaa_hrpt_deframer_sptr;
-
-NOAA_API noaa_hrpt_deframer_sptr
-noaa_make_hrpt_deframer();
-
-class NOAA_API noaa_hrpt_deframer : public gr_block
-{
- friend NOAA_API noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer();
- noaa_hrpt_deframer();
-
- unsigned int d_state;
- bool d_mid_bit;
- unsigned char d_last_bit;
- unsigned int d_bit_count;
- unsigned int d_word_count;
- unsigned long long d_shifter; // 60 bit sync word
- unsigned short d_word; // 10 bit HRPT word
-
- void enter_idle();
- void enter_synced();
-
-public:
- 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_NOAA_HRPT_DEFRAMER_H */
diff --git a/gr-noaa/lib/noaa_hrpt_pll_cf.cc b/gr-noaa/lib/noaa_hrpt_pll_cf.cc
deleted file mode 100644
index ea948f04b8..0000000000
--- a/gr-noaa/lib/noaa_hrpt_pll_cf.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <noaa_hrpt_pll_cf.h>
-#include <gr_io_signature.h>
-#include <gr_math.h>
-#include <gr_sincos.h>
-
-#define M_TWOPI (2*M_PI)
-
-noaa_hrpt_pll_cf_sptr
-noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset)
-{
- return gnuradio::get_initial_sptr(new noaa_hrpt_pll_cf(alpha, beta, max_offset));
-}
-
-noaa_hrpt_pll_cf::noaa_hrpt_pll_cf(float alpha, float beta, float max_offset)
- : gr_sync_block("noaa_hrpt_pll_cf",
- gr_make_io_signature(1, 1, sizeof(gr_complex)),
- gr_make_io_signature(1, 1, sizeof(float))),
- d_alpha(alpha), d_beta(beta), d_max_offset(max_offset),
- d_phase(0.0), d_freq(0.0)
-{
-}
-
-float
-phase_wrap(float phase)
-{
- while (phase < -M_PI)
- phase += M_TWOPI;
- while (phase > M_PI)
- phase -= M_TWOPI;
-
- return phase;
-}
-
-int
-noaa_hrpt_pll_cf::work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
-{
- const gr_complex *in = (const gr_complex *) input_items[0];
- float *out = (float *) output_items[0];
-
- for (int i = 0; i < noutput_items; i++) {
-
- // Generate and mix out carrier
- float re, im;
- gr_sincosf(d_phase, &im, &re);
- out[i] = (in[i]*gr_complex(re, -im)).imag();
-
- // Adjust PLL phase/frequency
- float error = phase_wrap(gr_fast_atan2f(in[i].imag(), in[i].real()) - d_phase);
- d_freq = gr_branchless_clip(d_freq + error*d_beta, d_max_offset);
- d_phase = phase_wrap(d_phase + error*d_alpha + d_freq);
-
- }
-
- return noutput_items;
-}
diff --git a/gr-noaa/lib/noaa_hrpt_pll_cf.h b/gr-noaa/lib/noaa_hrpt_pll_cf.h
deleted file mode 100644
index 178dccfb33..0000000000
--- a/gr-noaa/lib/noaa_hrpt_pll_cf.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2009 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef INCLUDED_NOAA_HRPT_PLL_CF_H
-#define INCLUDED_NOAA_HRPT_PLL_CF_H
-
-#include <noaa_api.h>
-#include <gr_sync_block.h>
-
-class noaa_hrpt_pll_cf;
-typedef boost::shared_ptr<noaa_hrpt_pll_cf> noaa_hrpt_pll_cf_sptr;
-
-NOAA_API noaa_hrpt_pll_cf_sptr
-noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset);
-
-class NOAA_API noaa_hrpt_pll_cf : public gr_sync_block
-{
- friend NOAA_API noaa_hrpt_pll_cf_sptr noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset);
- noaa_hrpt_pll_cf(float alpha, float beta, float max_offset);
-
- float d_alpha; // 1st order loop constant
- float d_beta; // 2nd order loop constant
- float d_max_offset; // Maximum frequency offset, radians/sample
- float d_phase; // Instantaneous carrier phase
- float d_freq; // Instantaneous carrier frequency, radians/sample
-
- public:
- virtual int work(int noutput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items);
-
- void set_alpha(float alpha) { d_alpha = alpha; }
- void set_beta(float beta) { d_beta = beta; }
- void set_max_offset(float max_offset) { d_max_offset = max_offset; }
-};
-
-#endif /* INCLUDED_NOAA_HRPT_PLL_CF_H */
diff --git a/gr-noaa/python/CMakeLists.txt b/gr-noaa/python/CMakeLists.txt
new file mode 100644
index 0000000000..306b8d981b
--- /dev/null
+++ b/gr-noaa/python/CMakeLists.txt
@@ -0,0 +1,50 @@
+# Copyright 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.
+
+########################################################################
+# Setup python install
+########################################################################
+include(GrPython)
+
+GR_PYTHON_INSTALL(
+ FILES
+ __init__.py
+ DESTINATION ${GR_PYTHON_DIR}/gnuradio/noaa
+ COMPONENT "noaa_python"
+)
+
+########################################################################
+# Handle the unit tests
+########################################################################
+if(ENABLE_TESTING)
+
+list(APPEND GR_TEST_PYTHON_DIRS
+ ${CMAKE_BINARY_DIR}/gr-noaa/python
+ ${CMAKE_BINARY_DIR}/gr-noaa/swig
+)
+
+list(APPEND GR_TEST_TARGET_DEPS gnuradio-noaa)
+
+include(GrTest)
+file(GLOB py_qa_test_files "qa_*.py")
+foreach(py_qa_test_file ${py_qa_test_files})
+ get_filename_component(py_qa_test_name ${py_qa_test_file} NAME_WE)
+ GR_ADD_TEST(${py_qa_test_name} ${PYTHON_EXECUTABLE} ${PYTHON_DASH_B} ${py_qa_test_file})
+endforeach(py_qa_test_file)
+endif(ENABLE_TESTING)
diff --git a/gr-noaa/swig/__init__.py b/gr-noaa/python/__init__.py
index 5ea4d934c5..646120c83e 100644
--- a/gr-noaa/swig/__init__.py
+++ b/gr-noaa/python/__init__.py
@@ -1,32 +1,27 @@
-#
-# Copyright 2009 Free Software Foundation, Inc.
-#
+# Copyright 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.
-#
-
-# The presence of this file turns this directory into a Python package
+#
'''
-The GNU Radio NOAA package.
+Blocks and utilities for NOAA app.
'''
-# Add SWIG generated code to this namespace
-from noaa_swig import *
-
-# Add other content from pure-Python modules here
+# The presence of this file turns this directory into a Python package
+from noaa_swig import *
diff --git a/gr-noaa/python/qa_noaa.py b/gr-noaa/python/qa_noaa.py
new file mode 100755
index 0000000000..e55debd771
--- /dev/null
+++ b/gr-noaa/python/qa_noaa.py
@@ -0,0 +1,41 @@
+#!/usr/bin/env python
+#
+# Copyright 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.
+#
+
+from gnuradio import gr, gr_unittest
+import noaa_swig as noaa
+
+class test_noaa(gr_unittest.TestCase):
+
+ def setUp(self):
+ self.tb = gr.top_block()
+
+ def tearDown(self):
+ self.tb = None
+
+ def test_000_nop(self):
+ """
+ Just see if we can import the module...
+ """
+ pass
+
+if __name__ == '__main__':
+ gr_unittest.run(test_noaa, "test_noaa.xml")
diff --git a/gr-noaa/swig/CMakeLists.txt b/gr-noaa/swig/CMakeLists.txt
index 5329840368..b89b3a7680 100644
--- a/gr-noaa/swig/CMakeLists.txt
+++ b/gr-noaa/swig/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2011 Free Software Foundation, Inc.
+# Copyright 2011,2012 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@@ -46,17 +46,7 @@ GR_SWIG_INSTALL(
install(
FILES
noaa_swig.i
- noaa_hrpt_decoder.i
- noaa_hrpt_deframer.i
- noaa_hrpt_pll_cf.i
${CMAKE_CURRENT_BINARY_DIR}/noaa_swig_doc.i
DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig
COMPONENT "noaa_swig"
)
-
-GR_PYTHON_INSTALL(
- FILES
- __init__.py
- DESTINATION ${GR_PYTHON_DIR}/gnuradio/noaa
- COMPONENT "noaa_python"
-)
diff --git a/gr-noaa/swig/gnuradio/noaa.scm b/gr-noaa/swig/gnuradio/noaa.scm
deleted file mode 100644
index 0bb4725ce2..0000000000
--- a/gr-noaa/swig/gnuradio/noaa.scm
+++ /dev/null
@@ -1,27 +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 noaa_swig module
-
-(define-module (gnuradio noaa)
- #:use-module (gnuradio export-safely)
- #:use-module (gnuradio noaa_swig)
- #:duplicates (merge-generics replace check))
-
-(re-export-all '(gnuradio noaa_swig))
diff --git a/gr-noaa/swig/noaa_swig.i b/gr-noaa/swig/noaa_swig.i
index 3c4d196505..63859103e6 100644
--- a/gr-noaa/swig/noaa_swig.i
+++ b/gr-noaa/swig/noaa_swig.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2009 Free Software Foundation, Inc.
+ * Copyright 2009,2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -20,17 +20,23 @@
* Boston, MA 02110-1301, USA.
*/
+#define NOAA_API
+
%include "gnuradio.i"
//load generated python docstrings
%include "noaa_swig_doc.i"
%{
-#include <noaa_hrpt_decoder.h>
-#include <noaa_hrpt_deframer.h>
-#include <noaa_hrpt_pll_cf.h>
+#include "noaa/hrpt_decoder.h"
+#include "noaa/hrpt_deframer.h"
+#include "noaa/hrpt_pll_cf.h"
%}
-%include "noaa_hrpt_decoder.i"
-%include "noaa_hrpt_deframer.i"
-%include "noaa_hrpt_pll_cf.i"
+%include "noaa/hrpt_decoder.h"
+%include "noaa/hrpt_deframer.h"
+%include "noaa/hrpt_pll_cf.h"
+
+GR_SWIG_BLOCK_MAGIC2(noaa, hrpt_decoder);
+GR_SWIG_BLOCK_MAGIC2(noaa, hrpt_deframer);
+GR_SWIG_BLOCK_MAGIC2(noaa, hrpt_pll_cf);