summaryrefslogtreecommitdiff
path: root/gr-noaa/lib
diff options
context:
space:
mode:
authorJohnathan Corgan2009-09-08 21:08:29 -0700
committerJohnathan Corgan2009-09-20 09:39:27 -0700
commitce9a41e69f5e3b9e0280d22fa778d167c3982db7 (patch)
treed385419a096a3cbb19964a76652791ea31c7d1b5 /gr-noaa/lib
parentb7d1c551fb374a0e5219fbb4d118f3f19f448393 (diff)
downloadgnuradio-ce9a41e69f5e3b9e0280d22fa778d167c3982db7.tar.gz
gnuradio-ce9a41e69f5e3b9e0280d22fa778d167c3982db7.tar.bz2
gnuradio-ce9a41e69f5e3b9e0280d22fa778d167c3982db7.zip
Added HRPT deframer block
Diffstat (limited to 'gr-noaa/lib')
-rw-r--r--gr-noaa/lib/Makefile.am2
-rw-r--r--gr-noaa/lib/noaa_hrpt_deframer.cc102
-rw-r--r--gr-noaa/lib/noaa_hrpt_deframer.h52
3 files changed, 156 insertions, 0 deletions
diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am
index 1b758871a..578c98ada 100644
--- a/gr-noaa/lib/Makefile.am
+++ b/gr-noaa/lib/Makefile.am
@@ -29,6 +29,7 @@ lib_LTLIBRARIES = \
libgnuradio-noaa.la
libgnuradio_noaa_la_SOURCES = \
+ noaa_hrpt_deframer.cc \
noaa_hrpt_pll_cf.cc \
noaa_hrpt_sync_fb.cc
@@ -38,5 +39,6 @@ libgnuradio_noaa_la_LIBADD = \
libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0
grinclude_HEADERS = \
+ noaa_hrpt_deframer.h \
noaa_hrpt_pll_cf.h \
noaa_hrpt_sync_fb.h
diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc
new file mode 100644
index 000000000..71712277b
--- /dev/null
+++ b/gr-noaa/lib/noaa_hrpt_deframer.cc
@@ -0,0 +1,102 @@
+/* -*- 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>
+
+#define ST_IDLE 0
+#define ST_SYNCED 1
+
+#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL
+#define HRPT_BITS_PER_MINOR_FRAME 11090*10
+#define HRPT_SYNC_LENGTH 6*10
+
+static int frames_seen = 0;
+
+noaa_hrpt_deframer_sptr
+noaa_make_hrpt_deframer()
+{
+ return gnuradio::get_initial_sptr(new noaa_hrpt_deframer());
+}
+
+noaa_hrpt_deframer::noaa_hrpt_deframer()
+ : gr_sync_block("noaa_hrpt_deframer",
+ gr_make_io_signature(1, 1, sizeof(char)),
+ gr_make_io_signature(0, 0, 0))
+{
+ enter_idle();
+}
+
+void
+noaa_hrpt_deframer::enter_idle()
+{
+ d_state = ST_IDLE;
+}
+
+void
+noaa_hrpt_deframer::enter_synced()
+{
+ d_state = ST_SYNCED;
+ d_count = HRPT_BITS_PER_MINOR_FRAME-HRPT_SYNC_LENGTH;
+}
+
+int
+noaa_hrpt_deframer::work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
+{
+ const char *in = (const char *)input_items[0];
+
+ int i = 0;
+ while (i < noutput_items) {
+ char bit = in[i++];
+ if (d_state != ST_SYNCED)
+ fprintf(stderr, ".");
+
+ switch (d_state) {
+ case ST_IDLE:
+ d_shifter = (d_shifter << 1) | bit; // MSB transmitted first
+
+ if ((d_shifter & 0x0FFFFFFFFFFFFFFF) == HRPT_MINOR_FRAME_SYNC) {
+ fprintf(stderr, "\nSYNC #%i...", frames_seen++);
+ enter_synced();
+ }
+ break;
+
+ case ST_SYNCED:
+ if (--d_count == 0) {
+ fprintf(stderr, "done.");
+ enter_idle();
+ }
+ break;
+
+ default:
+ throw std::runtime_error("noaa_hrpt_deframer: bad state\n");
+ }
+ }
+
+ return i;
+}
diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h
new file mode 100644
index 000000000..bc91bc89c
--- /dev/null
+++ b/gr-noaa/lib/noaa_hrpt_deframer.h
@@ -0,0 +1,52 @@
+/* -*- 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 <gr_sync_block.h>
+
+class noaa_hrpt_deframer;
+typedef boost::shared_ptr<noaa_hrpt_deframer> noaa_hrpt_deframer_sptr;
+
+noaa_hrpt_deframer_sptr
+noaa_make_hrpt_deframer();
+
+class noaa_hrpt_deframer : public gr_sync_block
+{
+ friend noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer();
+ noaa_hrpt_deframer();
+
+ unsigned int d_state;
+ unsigned int d_count;
+ unsigned long long d_shifter; // 60 bit sync word
+
+ void enter_idle();
+ void enter_synced();
+
+public:
+ int work(int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items);
+};
+
+#endif /* INCLUDED_NOAA_HRPT_DEFRAMER_H */