diff options
author | Johnathan Corgan | 2009-09-23 18:17:15 -0700 |
---|---|---|
committer | Johnathan Corgan | 2009-09-23 18:17:15 -0700 |
commit | d3a651aa194620d83dc61cac23f6887b6e4fd23e (patch) | |
tree | e92497af81512bce1b0d965dcf1dc5be2975413a /gr-noaa/lib | |
parent | 18cd6228abbd66d5be283745b5e8f8fca94c3ad2 (diff) | |
parent | 2afcae4f01e19d3973f3fc0eb6db50dc9dcb7098 (diff) | |
download | gnuradio-d3a651aa194620d83dc61cac23f6887b6e4fd23e.tar.gz gnuradio-d3a651aa194620d83dc61cac23f6887b6e4fd23e.tar.bz2 gnuradio-d3a651aa194620d83dc61cac23f6887b6e4fd23e.zip |
Merge branch 'wip/gr-noaa' of http://gnuradio.org/git/jcorgan into master
* 'wip/gr-noaa' of http://gnuradio.org/git/jcorgan:
Added README and updated configuration requirements
Split HRPT script into live receive and post-processing
Dumps HRPT frames to text file similar to specification document
Added skeleton HRPT decoder block
Updated HRPT receiver to read files recorded as shorts
Add HRPT word output to deframer
Reorganization of directories
Added HRPT deframer block
Changed synchronizer to output sliced bits.
Updated HRPT blocks/scripts for testing. Seeing good minor frame sync's.
Implemented crude timing recovery using zero crossings but no resampling
Work in progress, incomplete
Update rx_poes script to filter prior to PLL.
Created new gr-noaa top-level component.
Diffstat (limited to 'gr-noaa/lib')
-rw-r--r-- | gr-noaa/lib/.gitignore | 4 | ||||
-rw-r--r-- | gr-noaa/lib/Makefile.am | 46 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_decoder.cc | 77 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_decoder.h | 47 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_deframer.cc | 125 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_deframer.h | 59 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_pll_cf.cc | 82 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_pll_cf.h | 55 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_sync_fb.cc | 90 | ||||
-rw-r--r-- | gr-noaa/lib/noaa_hrpt_sync_fb.h | 58 |
10 files changed, 643 insertions, 0 deletions
diff --git a/gr-noaa/lib/.gitignore b/gr-noaa/lib/.gitignore new file mode 100644 index 000000000..02b052397 --- /dev/null +++ b/gr-noaa/lib/.gitignore @@ -0,0 +1,4 @@ +Makefile +Makefile.in +.deps +.libs diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am new file mode 100644 index 000000000..6435d192e --- /dev/null +++ b/gr-noaa/lib/Makefile.am @@ -0,0 +1,46 @@ +# +# 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. +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = \ + $(STD_DEFINES_AND_INCLUDES) \ + $(WITH_INCLUDES) + +lib_LTLIBRARIES = \ + libgnuradio-noaa.la + +libgnuradio_noaa_la_SOURCES = \ + noaa_hrpt_decoder.cc \ + noaa_hrpt_deframer.cc \ + noaa_hrpt_pll_cf.cc \ + noaa_hrpt_sync_fb.cc + +libgnuradio_noaa_la_LIBADD = \ + $(GNURADIO_CORE_LA) + +libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 + +grinclude_HEADERS = \ + noaa_hrpt_decoder.h \ + noaa_hrpt_deframer.h \ + noaa_hrpt_pll_cf.h \ + noaa_hrpt_sync_fb.h diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc new file mode 100644 index 000000000..8cfaa913c --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -0,0 +1,77 @@ +/* -*- 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 <gr_io_signature.h> + +#define SYNC1 0x0284 +#define SYNC2 0x016F +#define SYNC3 0x035C +#define SYNC4 0x019D +#define SYNC5 0x020F +#define SYNC6 0x0095 + +noaa_hrpt_decoder_sptr +noaa_make_hrpt_decoder() +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_decoder()); +} + +noaa_hrpt_decoder::noaa_hrpt_decoder() + : gr_sync_block("noaa_hrpt_decoder", + gr_make_io_signature(1, 1, sizeof(short)), + gr_make_io_signature(0, 0, 0)) +{ + d_word_count = 0; +} + +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) { + unsigned short word = in[i++]; + d_word_count++; + //fprintf(stderr, "%5u: ", d_word_count); + for (int pos = 0; pos < 10; pos++) { + char ch = (word & (1 << 9)) ? '1' : '0'; + word = word << 1; + //fprintf(stderr, "%c ", ch); + } + //fprintf(stderr, "\n"); + + if (d_word_count == 11090) { + d_word_count = 0; + //fprintf(stderr, "\n"); + } + } + + return i; +} diff --git a/gr-noaa/lib/noaa_hrpt_decoder.h b/gr-noaa/lib/noaa_hrpt_decoder.h new file mode 100644 index 000000000..305243b09 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_decoder.h @@ -0,0 +1,47 @@ +/* -*- 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 <gr_sync_block.h> + +class noaa_hrpt_decoder; +typedef boost::shared_ptr<noaa_hrpt_decoder> noaa_hrpt_decoder_sptr; + +noaa_hrpt_decoder_sptr +noaa_make_hrpt_decoder(); + +class noaa_hrpt_decoder : public gr_sync_block +{ + friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(); + noaa_hrpt_decoder(); + + unsigned int d_word_count; + +public: + 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 new file mode 100644 index 000000000..b0de09c91 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -0,0 +1,125 @@ +/* -*- 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 <cstring> + +#define ST_IDLE 0 +#define ST_SYNCED 1 + +#define SYNC1 0x0284 +#define SYNC2 0x016F +#define SYNC3 0x035C +#define SYNC4 0x019D +#define SYNC5 0x020F +#define SYNC6 0x0095 + +#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL + +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_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 + 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++]; + + 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, "SYNC #%i", frames_seen++); + out[j++] = SYNC1; + out[j++] = SYNC2; + out[j++] = SYNC3; + out[j++] = SYNC4; + out[j++] = SYNC5; + out[j++] = 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) { + fprintf(stderr, "...done\n"); + enter_idle(); + } + } + break; + + default: + throw std::runtime_error("noaa_hrpt_deframer: bad state\n"); + } + } + + consume_each(i); + return j; +} diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h new file mode 100644 index 000000000..0aeb16a2d --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -0,0 +1,59 @@ +/* -*- 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 + +#define HRPT_SYNC_WORDS 6 +#define HRPT_MINOR_FRAME_WORDS 11090 +#define HRPT_BITS_PER_WORD 10 + +#include <gr_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_block +{ + friend noaa_hrpt_deframer_sptr noaa_make_hrpt_deframer(); + noaa_hrpt_deframer(); + + unsigned int d_state; + 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 new file mode 100644 index 000000000..08ab1d15f --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_pll_cf.cc @@ -0,0 +1,82 @@ +/* -*- 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++) { + + // 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); + + // Generate and mix out carrier + float re, im; + gr_sincosf(d_phase, &im, &re); + out[i] = (in[i]*gr_complex(re, -im)).imag(); + } + + return noutput_items; +} diff --git a/gr-noaa/lib/noaa_hrpt_pll_cf.h b/gr-noaa/lib/noaa_hrpt_pll_cf.h new file mode 100644 index 000000000..507d47fe7 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_pll_cf.h @@ -0,0 +1,55 @@ +/* -*- 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 <gr_sync_block.h> + +class noaa_hrpt_pll_cf; +typedef boost::shared_ptr<noaa_hrpt_pll_cf> noaa_hrpt_pll_cf_sptr; + +noaa_hrpt_pll_cf_sptr +noaa_make_hrpt_pll_cf(float alpha, float beta, float max_offset); + +class noaa_hrpt_pll_cf : public gr_sync_block +{ + friend 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/lib/noaa_hrpt_sync_fb.cc b/gr-noaa/lib/noaa_hrpt_sync_fb.cc new file mode 100644 index 000000000..f99947f82 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_fb.cc @@ -0,0 +1,90 @@ +/* -*- 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_sync_fb.h> +#include <gr_io_signature.h> + +inline int signum(float f) +{ + return f >= 0.0 ? 1 : -1; +} + +noaa_hrpt_sync_fb_sptr +noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset) +{ + return gnuradio::get_initial_sptr(new noaa_hrpt_sync_fb(alpha, beta, sps, max_offset)); +} + +noaa_hrpt_sync_fb::noaa_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset) + : gr_block("noaa_hrpt_sync_fb", + gr_make_io_signature(1, 1, sizeof(float)), + gr_make_io_signature(1, 1, sizeof(char))), + d_alpha(alpha), d_beta(beta), + d_sps(sps), d_max_offset(max_offset), + d_phase(0.0), d_freq(1.0/sps), + d_last_sign(1) +{ +} + +int +noaa_hrpt_sync_fb::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 float *in = (const float *)input_items[0]; + char *out = (char *)output_items[0]; + + int i = 0, j = 0; + while (i < ninputs && j < noutput_items) { + float sample = in[i++]; + int sign = signum(sample); + d_phase += d_freq; + + // Train on zero crossings in center region of symbol + if (sign != d_last_sign) { + if (d_phase > 0.25 && d_phase < 0.75) { + float phase_err = d_phase-0.5; + d_phase -= phase_err*d_alpha; // 1st order phase adjustment + d_freq -= phase_err*d_beta; // 2nd order frequency adjustment + } + + d_last_sign = sign; + } + + if (d_phase > 1.0) { + if (sample < 0.0) + out[j++] = 1; + else + out[j++] = 0; + d_phase -= 1.0; + } + } + + consume_each(i); + return j; +} diff --git a/gr-noaa/lib/noaa_hrpt_sync_fb.h b/gr-noaa/lib/noaa_hrpt_sync_fb.h new file mode 100644 index 000000000..a9416b9ea --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt_sync_fb.h @@ -0,0 +1,58 @@ +/* -*- 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_SYNC_FB_H +#define INCLUDED_NOAA_HRPT_SYNC_FB_H + +#include <gr_block.h> + +class noaa_hrpt_sync_fb; +typedef boost::shared_ptr<noaa_hrpt_sync_fb> noaa_hrpt_sync_fb_sptr; + +noaa_hrpt_sync_fb_sptr +noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset); + +class noaa_hrpt_sync_fb : public gr_block +{ + friend noaa_hrpt_sync_fb_sptr noaa_make_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset); + noaa_hrpt_sync_fb(float alpha, float beta, float sps, float max_offset); + + float d_alpha; // 1st order loop constant + float d_beta; // 2nd order loop constant + float d_sps; // samples per symbol + float d_max_offset; // Maximum frequency offset for d_sps, samples/symbol + float d_phase; // Instantaneous symbol phase + float d_freq; // Instantaneous symbol frequency, samples/symbol + int d_last_sign; // Tracks zero crossings + + 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); + + 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_SYNC_FB_H */ |