From: Johnathan Corgan Date: Mon, 2 Nov 2009 17:57:32 +0000 (-0800) Subject: gr-noaa: Combined noaa_hrpt_bit_sync into noaa_hrpt_deframer X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=1530b6153fe21bf8c77f76c5d854108dd47069f6;p=debian%2Fgnuradio gr-noaa: Combined noaa_hrpt_bit_sync into noaa_hrpt_deframer Added Octave script to convert from frame data to AVHRR channel images Removed noaa_hrpt_bit_sync block --- diff --git a/gr-noaa/apps/demod_hrpt_file.grc b/gr-noaa/apps/demod_hrpt_file.grc index a5df8786..3c5e3efa 100644 --- a/gr-noaa/apps/demod_hrpt_file.grc +++ b/gr-noaa/apps/demod_hrpt_file.grc @@ -1,6 +1,6 @@ - Sun Nov 1 18:39:07 2009 + Mon Nov 2 07:06:57 2009 options @@ -629,25 +629,6 @@ 0 - - gr_binary_slicer_fb - - id - gr_binary_slicer_fb_0 - - - _enabled - True - - - _coordinate - (112, 537) - - - _rotation - 0 - - gr_file_sink @@ -699,10 +680,10 @@ - noaa_hrpt_bit_sync + gr_binary_slicer_fb id - noaa_hrpt_bit_sync_0 + gr_binary_slicer_fb_0 _enabled @@ -710,7 +691,7 @@ _coordinate - (330, 537) + (112, 537) _rotation @@ -760,12 +741,6 @@ 0 0 - - gr_binary_slicer_fb_0 - noaa_hrpt_bit_sync_0 - 0 - 0 - cs2cf agc @@ -791,7 +766,7 @@ 0 - noaa_hrpt_bit_sync_0 + gr_binary_slicer_fb_0 noaa_hrpt_deframer_0 0 0 diff --git a/gr-noaa/apps/demod_hrpt_file.py b/gr-noaa/apps/demod_hrpt_file.py index 84672318..d8665017 100755 --- a/gr-noaa/apps/demod_hrpt_file.py +++ b/gr-noaa/apps/demod_hrpt_file.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: Demod Hrpt File -# Generated: Sun Nov 1 18:39:07 2009 +# Generated: Mon Nov 2 07:06:57 2009 ################################################## from gnuradio import eng_notation @@ -48,7 +48,6 @@ class demod_hrpt_file(gr.top_block): self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.gr_file_sink_0 = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) - self.noaa_hrpt_bit_sync_0 = noaa.hrpt_bit_sync() self.noaa_hrpt_decoder_0 = noaa.hrpt_decoder() self.noaa_hrpt_deframer_0 = noaa.hrpt_deframer() self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) @@ -60,12 +59,11 @@ class demod_hrpt_file(gr.top_block): self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) - self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_bit_sync_0, 0)) self.connect((self.cs2cf, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.noaa_hrpt_deframer_0, 0), (self.gr_file_sink_0, 0)) self.connect((self.noaa_hrpt_deframer_0, 0), (self.noaa_hrpt_decoder_0, 0)) - self.connect((self.noaa_hrpt_bit_sync_0, 0), (self.noaa_hrpt_deframer_0, 0)) + self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0)) def set_decim(self, decim): self.decim = decim diff --git a/gr-noaa/apps/file_rx_hrpt.grc b/gr-noaa/apps/file_rx_hrpt.grc index fea53f80..f3414375 100644 --- a/gr-noaa/apps/file_rx_hrpt.grc +++ b/gr-noaa/apps/file_rx_hrpt.grc @@ -1,6 +1,6 @@ - Sun Nov 1 19:26:11 2009 + Mon Nov 2 08:30:47 2009 options @@ -237,25 +237,6 @@ 0 - - noaa_hrpt_deframer - - id - deframer - - - _enabled - True - - - _coordinate - (762, 975) - - - _rotation - 0 - - gr_file_sink @@ -287,44 +268,6 @@ 0 - - noaa_hrpt_bit_sync - - id - noaa_hrpt_bit_sync_0 - - - _enabled - True - - - _coordinate - (571, 975) - - - _rotation - 0 - - - - gr_binary_slicer_fb - - id - gr_binary_slicer_fb_0 - - - _enabled - True - - - _coordinate - (393, 975) - - - _rotation - 0 - - virtual_source @@ -1167,18 +1110,44 @@ 0 - - noaa_hrpt_bit_sync_0 - deframer - 0 - 0 - - - gr_binary_slicer_fb_0 - noaa_hrpt_bit_sync_0 - 0 - 0 - + + gr_binary_slicer_fb + + id + gr_binary_slicer_fb_0 + + + _enabled + True + + + _coordinate + (393, 975) + + + _rotation + 0 + + + + noaa_hrpt_deframer + + id + deframer + + + _enabled + True + + + _coordinate + (762, 975) + + + _rotation + 0 + + virtual_source_0 gr_binary_slicer_fb_0 @@ -1251,4 +1220,10 @@ 0 0 + + gr_binary_slicer_fb_0 + deframer + 0 + 0 + diff --git a/gr-noaa/apps/file_rx_hrpt.py b/gr-noaa/apps/file_rx_hrpt.py index c1491ca0..1513141e 100755 --- a/gr-noaa/apps/file_rx_hrpt.py +++ b/gr-noaa/apps/file_rx_hrpt.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: USRP HRPT Receiver -# Generated: Sun Nov 1 19:26:11 2009 +# Generated: Mon Nov 2 08:30:47 2009 ################################################## from gnuradio import eng_notation @@ -146,7 +146,6 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self.gr_file_source_0 = gr.file_source(gr.sizeof_short*1, input_filename, False) self.gr_interleaved_short_to_complex_0 = gr.interleaved_short_to_complex() self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) - self.noaa_hrpt_bit_sync_0 = noaa.hrpt_bit_sync() self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.rx_fft = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), @@ -170,8 +169,6 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): ################################################## # Connections ################################################## - self.connect((self.noaa_hrpt_bit_sync_0, 0), (self.deframer, 0)) - self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_bit_sync_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) @@ -183,6 +180,7 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self.connect((self.gr_interleaved_short_to_complex_0, 0), (self.agc, 0)) self.connect((self.throttle, 0), (self.gr_interleaved_short_to_complex_0, 0)) self.connect((self.gr_file_source_0, 0), (self.throttle, 0)) + self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0)) def set_input_filename(self, input_filename): self.input_filename = input_filename diff --git a/gr-noaa/apps/usrp_rx_hrpt.grc b/gr-noaa/apps/usrp_rx_hrpt.grc index da2f4178..ac7a87a1 100644 --- a/gr-noaa/apps/usrp_rx_hrpt.grc +++ b/gr-noaa/apps/usrp_rx_hrpt.grc @@ -1,6 +1,6 @@ - Sun Nov 1 19:28:12 2009 + Mon Nov 2 08:31:09 2009 options @@ -870,25 +870,6 @@ 0 - - noaa_hrpt_deframer - - id - deframer - - - _enabled - True - - - _coordinate - (762, 975) - - - _rotation - 0 - - gr_file_sink @@ -920,44 +901,6 @@ 0 - - noaa_hrpt_bit_sync - - id - noaa_hrpt_bit_sync_0 - - - _enabled - True - - - _coordinate - (571, 975) - - - _rotation - 0 - - - - gr_binary_slicer_fb - - id - gr_binary_slicer_fb_0 - - - _enabled - True - - - _coordinate - (393, 975) - - - _rotation - 0 - - virtual_source @@ -1384,18 +1327,44 @@ 0 - - noaa_hrpt_bit_sync_0 - deframer - 0 - 0 - - - gr_binary_slicer_fb_0 - noaa_hrpt_bit_sync_0 - 0 - 0 - + + gr_binary_slicer_fb + + id + gr_binary_slicer_fb_0 + + + _enabled + True + + + _coordinate + (393, 975) + + + _rotation + 0 + + + + noaa_hrpt_deframer + + id + deframer + + + _enabled + True + + + _coordinate + (762, 975) + + + _rotation + 0 + + virtual_source_0 gr_binary_slicer_fb_0 @@ -1456,4 +1425,10 @@ 0 0 + + gr_binary_slicer_fb_0 + deframer + 0 + 0 + diff --git a/gr-noaa/apps/usrp_rx_hrpt.py b/gr-noaa/apps/usrp_rx_hrpt.py index c1d0fd6e..a5f9a8e9 100755 --- a/gr-noaa/apps/usrp_rx_hrpt.py +++ b/gr-noaa/apps/usrp_rx_hrpt.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: USRP HRPT Receiver -# Generated: Sun Nov 1 19:28:13 2009 +# Generated: Mon Nov 2 08:31:10 2009 ################################################## from gnuradio import eng_notation @@ -205,7 +205,6 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) - self.noaa_hrpt_bit_sync_0 = noaa.hrpt_bit_sync() self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.rx_fft = fftsink2.fft_sink_c( self.displays.GetPage(0).GetWin(), @@ -232,8 +231,6 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): ################################################## # Connections ################################################## - self.connect((self.noaa_hrpt_bit_sync_0, 0), (self.deframer, 0)) - self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_bit_sync_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) @@ -243,6 +240,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.usrp_source, 0), (self.agc, 0)) self.connect((self.agc, 0), (self.rx_fft, 0)) + self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0)) def set_config_filename(self, config_filename): self.config_filename = config_filename diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc index 918a954b..02d509f0 100644 --- a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc @@ -1,6 +1,6 @@ - Sun Nov 1 19:32:32 2009 + Mon Nov 2 08:31:35 2009 options @@ -771,25 +771,6 @@ 0 - - noaa_hrpt_deframer - - id - deframer - - - _enabled - True - - - _coordinate - (815, 673) - - - _rotation - 0 - - gr_file_sink @@ -822,18 +803,22 @@ - noaa_hrpt_bit_sync + virtual_source id - noaa_hrpt_bit_sync_0 + virtual_source_0 _enabled True + + stream_id + baseband + _coordinate - (624, 673) + (226, 669) _rotation @@ -841,10 +826,10 @@ - gr_binary_slicer_fb + noaa_hrpt_decoder id - gr_binary_slicer_fb_0 + decoder _enabled @@ -852,7 +837,7 @@ _coordinate - (446, 673) + (1027, 623) _rotation @@ -860,22 +845,18 @@ - virtual_source + gr_binary_slicer_fb id - virtual_source_0 + gr_binary_slicer_fb_0 _enabled True - - stream_id - baseband - _coordinate - (226, 669) + (446, 673) _rotation @@ -883,10 +864,10 @@ - noaa_hrpt_decoder + noaa_hrpt_deframer id - decoder + deframer _enabled @@ -894,7 +875,7 @@ _coordinate - (1027, 623) + (815, 673) _rotation @@ -931,18 +912,6 @@ 0 0 - - noaa_hrpt_bit_sync_0 - deframer - 0 - 0 - - - gr_binary_slicer_fb_0 - noaa_hrpt_bit_sync_0 - 0 - 0 - virtual_source_0 gr_binary_slicer_fb_0 @@ -961,4 +930,10 @@ 0 0 + + gr_binary_slicer_fb_0 + deframer + 0 + 0 + diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.py b/gr-noaa/apps/usrp_rx_hrpt_nogui.py index 33259a23..4dc32dbd 100755 --- a/gr-noaa/apps/usrp_rx_hrpt_nogui.py +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.py @@ -2,7 +2,7 @@ ################################################## # Gnuradio Python Flow Graph # Title: Usrp Rx Hrpt Nogui -# Generated: Sun Nov 1 19:32:32 2009 +# Generated: Mon Nov 2 08:31:35 2009 ################################################## from gnuradio import eng_notation @@ -76,7 +76,6 @@ class usrp_rx_hrpt_nogui(gr.top_block): self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() self.gr_clock_recovery_mm_xx_0 = gr.clock_recovery_mm_ff(sps/2.0, clock_alpha**2/4.0, 0.5, clock_alpha, max_clock_offset) self.gr_moving_average_xx_0 = gr.moving_average_ff(hs, 1.0/hs, 4000) - self.noaa_hrpt_bit_sync_0 = noaa.hrpt_bit_sync() self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) self.usrp_source = grc_usrp.simple_source_c(which=0, side=side, rx_ant="RXA") self.usrp_source.set_decim_rate(decim) @@ -90,11 +89,10 @@ class usrp_rx_hrpt_nogui(gr.top_block): self.connect((self.agc, 0), (self.pll, 0)) self.connect((self.pll, 0), (self.gr_moving_average_xx_0, 0)) self.connect((self.gr_moving_average_xx_0, 0), (self.gr_clock_recovery_mm_xx_0, 0)) - self.connect((self.noaa_hrpt_bit_sync_0, 0), (self.deframer, 0)) - self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_bit_sync_0, 0)) self.connect((self.gr_clock_recovery_mm_xx_0, 0), (self.gr_binary_slicer_fb_0, 0)) self.connect((self.deframer, 0), (self.frame_sink, 0)) self.connect((self.deframer, 0), (self.decoder, 0)) + self.connect((self.gr_binary_slicer_fb_0, 0), (self.deframer, 0)) def set_config_filename(self, config_filename): self.config_filename = config_filename diff --git a/gr-noaa/grc/Makefile.am b/gr-noaa/grc/Makefile.am index 800d9ad6..73a02823 100644 --- a/gr-noaa/grc/Makefile.am +++ b/gr-noaa/grc/Makefile.am @@ -24,7 +24,6 @@ include $(top_srcdir)/Makefile.common grcblocksdir = $(grc_blocksdir) dist_grcblocks_DATA = \ - noaa_hrpt_bit_sync.xml \ noaa_hrpt_decoder.xml \ noaa_hrpt_deframer.xml \ noaa_hrpt_pll_cf.xml diff --git a/gr-noaa/grc/noaa_hrpt_bit_sync.xml b/gr-noaa/grc/noaa_hrpt_bit_sync.xml deleted file mode 100644 index 7dcb8274..00000000 --- a/gr-noaa/grc/noaa_hrpt_bit_sync.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - HRPT Bit Sync - noaa_hrpt_bit_sync - NOAA - from gnuradio import noaa - noaa.hrpt_bit_sync() - - in - byte - - - out - byte - - diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index a4423167..4ef4eb87 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -29,7 +29,6 @@ lib_LTLIBRARIES = \ libgnuradio-noaa.la libgnuradio_noaa_la_SOURCES = \ - noaa_hrpt_bit_sync.cc \ noaa_hrpt_decoder.cc \ noaa_hrpt_deframer.cc \ noaa_hrpt_pll_cf.cc @@ -40,7 +39,6 @@ libgnuradio_noaa_la_LIBADD = \ libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 grinclude_HEADERS = \ - noaa_hrpt_bit_sync.h \ noaa_hrpt_decoder.h \ noaa_hrpt_deframer.h \ noaa_hrpt_pll_cf.h \ No newline at end of file diff --git a/gr-noaa/lib/noaa_hrpt_bit_sync.cc b/gr-noaa/lib/noaa_hrpt_bit_sync.cc deleted file mode 100644 index 53e47d91..00000000 --- a/gr-noaa/lib/noaa_hrpt_bit_sync.cc +++ /dev/null @@ -1,72 +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 -#include -#include - -noaa_hrpt_bit_sync_sptr -noaa_make_hrpt_bit_sync() -{ - return gnuradio::get_initial_sptr(new noaa_hrpt_bit_sync()); -} - -noaa_hrpt_bit_sync::noaa_hrpt_bit_sync() - : gr_block("noaa_hrpt_bit_sync", - gr_make_io_signature(1, 1, sizeof(char)), - gr_make_io_signature(1, 1, sizeof(char))), - d_mid_bit(true), - d_last_bit(0) -{ -} - -int -noaa_hrpt_bit_sync::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]; - char *out = (char *)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; - - if (d_mid_bit && diff) { - out[j++] = bit; - d_mid_bit = false; - } - else - d_mid_bit = true; - } - - consume_each(i); - return j; -} diff --git a/gr-noaa/lib/noaa_hrpt_bit_sync.h b/gr-noaa/lib/noaa_hrpt_bit_sync.h deleted file mode 100644 index 8b8633cd..00000000 --- a/gr-noaa/lib/noaa_hrpt_bit_sync.h +++ /dev/null @@ -1,49 +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_BIT_SYNC_H -#define INCLUDED_NOAA_HRPT_BIT_SYNC_H - -#include - -class noaa_hrpt_bit_sync; -typedef boost::shared_ptr noaa_hrpt_bit_sync_sptr; - -noaa_hrpt_bit_sync_sptr -noaa_make_hrpt_bit_sync(); - -class noaa_hrpt_bit_sync : public gr_block -{ - friend noaa_hrpt_bit_sync_sptr noaa_make_hrpt_bit_sync(); - noaa_hrpt_bit_sync(); - - bool d_mid_bit; - unsigned char d_last_bit; - - 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_BIT_SYNC_H */ diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc index 91c94d2a..e7989486 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -55,6 +55,8 @@ noaa_hrpt_deframer::noaa_hrpt_deframer() 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(); } @@ -86,38 +88,48 @@ noaa_hrpt_deframer::general_work(int noutput_items, 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 & 0x0FFFFFFFFFFFFFFFLL) == 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(); + 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) { + 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"); } - break; - default: - throw std::runtime_error("noaa_hrpt_deframer: bad state\n"); + d_mid_bit = false; + } + else { + d_mid_bit = true; } } diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h index 0aeb16a2..43abba0e 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.h +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -41,6 +41,8 @@ class noaa_hrpt_deframer : public gr_block 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 diff --git a/gr-noaa/swig/Makefile.am b/gr-noaa/swig/Makefile.am index 97056811..73645e92 100644 --- a/gr-noaa/swig/Makefile.am +++ b/gr-noaa/swig/Makefile.am @@ -52,7 +52,6 @@ noaa_swig_python = \ # additional SWIG files to be installed noaa_swig_swiginclude_headers = \ - noaa_hrpt_bit_sync.i \ noaa_hrpt_decoder.i \ noaa_hrpt_deframer.i \ noaa_hrpt_pll_cf.i diff --git a/gr-noaa/swig/noaa_hrpt_bit_sync.i b/gr-noaa/swig/noaa_hrpt_bit_sync.i deleted file mode 100644 index 34b565c2..00000000 --- a/gr-noaa/swig/noaa_hrpt_bit_sync.i +++ /dev/null @@ -1,32 +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. - */ - -GR_SWIG_BLOCK_MAGIC(noaa,hrpt_bit_sync) - -noaa_hrpt_bit_sync_sptr -noaa_make_hrpt_bit_sync(); - -class noaa_hrpt_bit_sync : public gr_sync_block -{ -private: - noaa_hrpt_bit_sync(); -}; diff --git a/gr-noaa/swig/noaa_swig.i b/gr-noaa/swig/noaa_swig.i index efda4f40..8fe814a6 100644 --- a/gr-noaa/swig/noaa_swig.i +++ b/gr-noaa/swig/noaa_swig.i @@ -23,13 +23,11 @@ %include "gnuradio.i" %{ -#include #include #include #include %} -%include "noaa_hrpt_bit_sync.i" %include "noaa_hrpt_decoder.i" %include "noaa_hrpt_deframer.i" %include "noaa_hrpt_pll_cf.i"