From 4e0c8a37c3574f59e34186996cef0c44ff50bd16 Mon Sep 17 00:00:00 2001 From: Johnathan Corgan Date: Fri, 6 Nov 2009 11:21:08 -0800 Subject: gr-noaa: added HRPT minor frame parsing, renamed scripts implemented start of minor frame parsing renamed demod_rx_hrpt to hrpt_demod, new defaults added configuration flags to hrpt_decoder added hrpt_decode app updated file_rx_hrpt with new defaults updated usrp_rx_hrpt_* with new defaults --- gr-noaa/README | 2 +- gr-noaa/apps/.gitignore | 3 +- gr-noaa/apps/Makefile.am | 6 +- gr-noaa/apps/demod_hrpt_file.grc | 774 ------------------------------------ gr-noaa/apps/demod_hrpt_file.py | 133 ------- gr-noaa/apps/file_rx_hrpt.grc | 543 ++++++++++++------------- gr-noaa/apps/file_rx_hrpt.py | 56 +-- gr-noaa/apps/hrpt_decode.grc | 428 ++++++++++++++++++++ gr-noaa/apps/hrpt_decode.py | 98 +++++ gr-noaa/apps/hrpt_demod.grc | 747 ++++++++++++++++++++++++++++++++++ gr-noaa/apps/hrpt_demod.py | 127 ++++++ gr-noaa/apps/usrp_rx_hrpt.grc | 438 ++++++++++---------- gr-noaa/apps/usrp_rx_hrpt.py | 60 +-- gr-noaa/apps/usrp_rx_hrpt_nogui.grc | 418 +++++++++---------- gr-noaa/apps/usrp_rx_hrpt_nogui.py | 60 +-- gr-noaa/grc/noaa_hrpt_decoder.xml | 15 +- gr-noaa/lib/Makefile.am | 3 + gr-noaa/lib/noaa_hrpt.h | 39 ++ gr-noaa/lib/noaa_hrpt_decoder.cc | 167 +++++++- gr-noaa/lib/noaa_hrpt_decoder.h | 39 +- gr-noaa/lib/noaa_hrpt_deframer.cc | 26 +- gr-noaa/lib/noaa_hrpt_deframer.h | 4 - gr-noaa/oct/frames_to_ppm.m | 2 +- gr-noaa/swig/noaa_hrpt_decoder.i | 2 +- 24 files changed, 2419 insertions(+), 1771 deletions(-) delete mode 100644 gr-noaa/apps/demod_hrpt_file.grc delete mode 100755 gr-noaa/apps/demod_hrpt_file.py create mode 100644 gr-noaa/apps/hrpt_decode.grc create mode 100755 gr-noaa/apps/hrpt_decode.py create mode 100644 gr-noaa/apps/hrpt_demod.grc create mode 100755 gr-noaa/apps/hrpt_demod.py create mode 100644 gr-noaa/lib/noaa_hrpt.h (limited to 'gr-noaa') diff --git a/gr-noaa/README b/gr-noaa/README index 29d11f593..f00d2d28d 100644 --- a/gr-noaa/README +++ b/gr-noaa/README @@ -40,7 +40,7 @@ be set in the configuration file prior to running. It has no command-line parameters, and works identically to the GUI scripts. -demod_hrpt_file.py +hrpt_demod_file.py ------------------ This non-GUI script will operate on a file generated with diff --git a/gr-noaa/apps/.gitignore b/gr-noaa/apps/.gitignore index 6bd1ab995..cd8d543cc 100644 --- a/gr-noaa/apps/.gitignore +++ b/gr-noaa/apps/.gitignore @@ -1,2 +1,3 @@ *.dat -*.txt \ No newline at end of file +*.txt +*.hrpt diff --git a/gr-noaa/apps/Makefile.am b/gr-noaa/apps/Makefile.am index 961b09afa..e246ba76a 100644 --- a/gr-noaa/apps/Makefile.am +++ b/gr-noaa/apps/Makefile.am @@ -24,15 +24,17 @@ include $(top_srcdir)/Makefile.common if PYTHON dist_bin_SCRIPTS = \ - demod_hrpt_file.py \ + hrpt_decode.py \ + hrpt_demod.py \ file_rx_hrpt.py \ usrp_rx_hrpt.py \ usrp_rx_hrpt_nogui.py \ usrp_rx_lrit.py EXTRA_DIST = \ + hrpt_decode.grc \ + hrpt_demod.grc \ file_rx_hrpt.grc \ - demod_hrpt_file.grc \ usrp_rx_hrpt.grc \ usrp_rx_hrpt_nogui.grc \ usrp_rx_lrit.grc diff --git a/gr-noaa/apps/demod_hrpt_file.grc b/gr-noaa/apps/demod_hrpt_file.grc deleted file mode 100644 index 3c5e3efa4..000000000 --- a/gr-noaa/apps/demod_hrpt_file.grc +++ /dev/null @@ -1,774 +0,0 @@ -<?xml version='1.0' encoding='ASCII'?> -<flow_graph> - <timestamp>Mon Nov 2 07:06:57 2009</timestamp> - <block> - <key>options</key> - <param> - <key>id</key> - <value>demod_hrpt_file</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>title</key> - <value></value> - </param> - <param> - <key>author</key> - <value></value> - </param> - <param> - <key>description</key> - <value></value> - </param> - <param> - <key>window_size</key> - <value>4096,4096</value> - </param> - <param> - <key>generate_options</key> - <value>no_gui</value> - </param> - <param> - <key>category</key> - <value>Custom</value> - </param> - <param> - <key>run_options</key> - <value>run</value> - </param> - <param> - <key>run</key> - <value>True</value> - </param> - <param> - <key>realtime_scheduling</key> - <value></value> - </param> - <param> - <key>_coordinate</key> - <value>(10, 10)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_carrier_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>2*math.pi*100e3/sample_rate</value> - </param> - <param> - <key>_coordinate</key> - <value>(575, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>sym_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>600*1109</value> - </param> - <param> - <key>_coordinate</key> - <value>(301, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>sps</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>sample_rate/sym_rate</value> - </param> - <param> - <key>_coordinate</key> - <value>(397, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>hs</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>int(sps/2.0)</value> - </param> - <param> - <key>_coordinate</key> - <value>(499, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>sample_rate</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>64e6/decim</value> - </param> - <param> - <key>_coordinate</key> - <value>(198, 17)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(710, 17)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>import</key> - <param> - <key>id</key> - <value>import_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>import</key> - <value>import math, os</value> - </param> - <param> - <key>_coordinate</key> - <value>(11, 103)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> - <value>decim</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>decim</value> - </param> - <param> - <key>value</key> - <value>16</value> - </param> - <param> - <key>type</key> - <value>intx</value> - </param> - <param> - <key>short_id</key> - <value>d</value> - </param> - <param> - <key>_coordinate</key> - <value>(202, 102)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> - <value>pll_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>pll_alpha</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>eng_float</value> - </param> - <param> - <key>short_id</key> - <value>p</value> - </param> - <param> - <key>_coordinate</key> - <value>(294, 101)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> - <value>clock_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>clock_alpha</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>eng_float</value> - </param> - <param> - <key>short_id</key> - <value>a</value> - </param> - <param> - <key>_coordinate</key> - <value>(395, 101)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> - <value>sync_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>sync_alpha</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>eng_float</value> - </param> - <param> - <key>short_id</key> - <value>s</value> - </param> - <param> - <key>_coordinate</key> - <value>(508, 102)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> - <value>input_filename</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>input_filename</value> - </param> - <param> - <key>value</key> - <value>usrp.dat</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>short_id</key> - <value>F</value> - </param> - <param> - <key>_coordinate</key> - <value>(618, 102)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>parameter</key> - <param> - <key>id</key> - <value>output_filename</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>label</key> - <value>output_filename</value> - </param> - <param> - <key>value</key> - <value>frames.dat</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>short_id</key> - <value>o</value> - </param> - <param> - <key>_coordinate</key> - <value>(726, 102)</value> - </param> - <param> - <key>_rotation</key> - <value>180</value> - </param> - </block> - <block> - <key>gr_file_source</key> - <param> - <key>id</key> - <value>file_source</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>file</key> - <value>input_filename</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>repeat</key> - <value>False</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(62, 306)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_interleaved_short_to_complex</key> - <param> - <key>id</key> - <value>cs2cf</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(297, 318)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_agc_xx</key> - <param> - <key>id</key> - <value>agc</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>rate</key> - <value>1e-5</value> - </param> - <param> - <key>reference</key> - <value>1.0</value> - </param> - <param> - <key>gain</key> - <value>1.0/32768.0</value> - </param> - <param> - <key>max_gain</key> - <value>1.0</value> - </param> - <param> - <key>_coordinate</key> - <value>(538, 290)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>noaa_hrpt_pll_cf</key> - <param> - <key>id</key> - <value>pll</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>alpha</key> - <value>pll_alpha</value> - </param> - <param> - <key>beta</key> - <value>pll_alpha**2/4.0</value> - </param> - <param> - <key>max_offset</key> - <value>max_carrier_offset</value> - </param> - <param> - <key>_coordinate</key> - <value>(720, 297)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_moving_average_xx</key> - <param> - <key>id</key> - <value>gr_moving_average_xx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>length</key> - <value>hs</value> - </param> - <param> - <key>scale</key> - <value>1.0/hs</value> - </param> - <param> - <key>max_iter</key> - <value>4000</value> - </param> - <param> - <key>_coordinate</key> - <value>(949, 297)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_clock_recovery_mm_xx</key> - <param> - <key>id</key> - <value>gr_clock_recovery_mm_xx_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>type</key> - <value>float</value> - </param> - <param> - <key>omega</key> - <value>sps/2.0</value> - </param> - <param> - <key>gain_omega</key> - <value>clock_alpha**2/4.0</value> - </param> - <param> - <key>mu</key> - <value>0.5</value> - </param> - <param> - <key>gain_mu</key> - <value>clock_alpha</value> - </param> - <param> - <key>omega_relative_limit</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_coordinate</key> - <value>(1158, 281)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_file_sink</key> - <param> - <key>id</key> - <value>gr_file_sink_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>file</key> - <value>output_filename</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(732, 615)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>noaa_hrpt_decoder</key> - <param> - <key>id</key> - <value>noaa_hrpt_decoder_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(730, 537)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_binary_slicer_fb</key> - <param> - <key>id</key> - <value>gr_binary_slicer_fb_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(112, 537)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>noaa_hrpt_deframer</key> - <param> - <key>id</key> - <value>noaa_hrpt_deframer_0</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(536, 537)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <connection> - <source_block_id>file_source</source_block_id> - <sink_block_id>cs2cf</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>gr_clock_recovery_mm_xx_0</source_block_id> - <sink_block_id>gr_binary_slicer_fb_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>gr_moving_average_xx_0</source_block_id> - <sink_block_id>gr_clock_recovery_mm_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>pll</source_block_id> - <sink_block_id>gr_moving_average_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>cs2cf</source_block_id> - <sink_block_id>agc</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>agc</source_block_id> - <sink_block_id>pll</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>noaa_hrpt_deframer_0</source_block_id> - <sink_block_id>gr_file_sink_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>noaa_hrpt_deframer_0</source_block_id> - <sink_block_id>noaa_hrpt_decoder_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>gr_binary_slicer_fb_0</source_block_id> - <sink_block_id>noaa_hrpt_deframer_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> -</flow_graph> diff --git a/gr-noaa/apps/demod_hrpt_file.py b/gr-noaa/apps/demod_hrpt_file.py deleted file mode 100755 index d86650171..000000000 --- a/gr-noaa/apps/demod_hrpt_file.py +++ /dev/null @@ -1,133 +0,0 @@ -#!/usr/bin/env python -################################################## -# Gnuradio Python Flow Graph -# Title: Demod Hrpt File -# Generated: Mon Nov 2 07:06:57 2009 -################################################## - -from gnuradio import eng_notation -from gnuradio import gr -from gnuradio import noaa -from gnuradio.eng_option import eng_option -from gnuradio.gr import firdes -from optparse import OptionParser -import math, os - -class demod_hrpt_file(gr.top_block): - - def __init__(self, decim=16, pll_alpha=0.05, clock_alpha=0.05, sync_alpha=0.05, input_filename="usrp.dat", output_filename="frames.dat"): - gr.top_block.__init__(self, "Demod Hrpt File") - - ################################################## - # Parameters - ################################################## - self.decim = decim - self.pll_alpha = pll_alpha - self.clock_alpha = clock_alpha - self.sync_alpha = sync_alpha - self.input_filename = input_filename - self.output_filename = output_filename - - ################################################## - # Variables - ################################################## - self.sym_rate = sym_rate = 600*1109 - self.sample_rate = sample_rate = 64e6/decim - self.sps = sps = sample_rate/sym_rate - self.max_clock_offset = max_clock_offset = 0.1 - self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate - self.hs = hs = int(sps/2.0) - - ################################################## - # Blocks - ################################################## - self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) - self.cs2cf = gr.interleaved_short_to_complex() - self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False) - 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_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_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) - - ################################################## - # Connections - ################################################## - self.connect((self.file_source, 0), (self.cs2cf, 0)) - 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.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.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0)) - - def set_decim(self, decim): - self.decim = decim - self.set_sample_rate(64e6/self.decim) - - def set_pll_alpha(self, pll_alpha): - self.pll_alpha = pll_alpha - self.pll.set_alpha(self.pll_alpha) - self.pll.set_beta(self.pll_alpha**2/4.0) - - def set_clock_alpha(self, clock_alpha): - self.clock_alpha = clock_alpha - self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) - self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) - - def set_sync_alpha(self, sync_alpha): - self.sync_alpha = sync_alpha - - def set_input_filename(self, input_filename): - self.input_filename = input_filename - - def set_output_filename(self, output_filename): - self.output_filename = output_filename - - def set_sym_rate(self, sym_rate): - self.sym_rate = sym_rate - self.set_sps(self.sample_rate/self.sym_rate) - - def set_sample_rate(self, sample_rate): - self.sample_rate = sample_rate - self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) - self.set_sps(self.sample_rate/self.sym_rate) - - def set_sps(self, sps): - self.sps = sps - self.set_hs(int(self.sps/2.0)) - self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0) - - def set_max_clock_offset(self, max_clock_offset): - self.max_clock_offset = max_clock_offset - - def set_max_carrier_offset(self, max_carrier_offset): - self.max_carrier_offset = max_carrier_offset - self.pll.set_max_offset(self.max_carrier_offset) - - def set_hs(self, hs): - self.hs = hs - self.gr_moving_average_xx_0.set_length_and_scale(self.hs, 1.0/self.hs) - -if __name__ == '__main__': - parser = OptionParser(option_class=eng_option, usage="%prog: [options]") - parser.add_option("-d", "--decim", dest="decim", type="intx", default=16, - help="Set decim [default=%default]") - parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), - help="Set pll_alpha [default=%default]") - parser.add_option("-a", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), - help="Set clock_alpha [default=%default]") - parser.add_option("-s", "--sync-alpha", dest="sync_alpha", type="eng_float", default=eng_notation.num_to_str(0.05), - help="Set sync_alpha [default=%default]") - parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat", - help="Set usrp.dat [default=%default]") - parser.add_option("-o", "--output-filename", dest="output_filename", type="string", default="frames.dat", - help="Set frames.dat [default=%default]") - (options, args) = parser.parse_args() - tb = demod_hrpt_file(decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha, sync_alpha=options.sync_alpha, input_filename=options.input_filename, output_filename=options.output_filename) - tb.run() - diff --git a/gr-noaa/apps/file_rx_hrpt.grc b/gr-noaa/apps/file_rx_hrpt.grc index f34143756..e3cccd393 100644 --- a/gr-noaa/apps/file_rx_hrpt.grc +++ b/gr-noaa/apps/file_rx_hrpt.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Nov 2 08:30:47 2009</timestamp> + <timestamp>Mon Nov 9 07:47:17 2009</timestamp> <block> <key>options</key> <param> @@ -56,29 +56,6 @@ <value>0</value> </param> </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_carrier_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>2*math.pi*100e3/sample_rate</value> - </param> - <param> - <key>_coordinate</key> - <value>(575, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable</key> <param> @@ -125,29 +102,6 @@ <value>0</value> </param> </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>hs</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>int(sps/2.0)</value> - </param> - <param> - <key>_coordinate</key> - <value>(499, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable</key> <param> @@ -171,103 +125,6 @@ <value>0</value> </param> </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(705, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>side</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>'A'</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'side'</value> - </param> - <param> - <key>writeback</key> - <value>side</value> - </param> - <param> - <key>_coordinate</key> - <value>(194, 253)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>gr_file_sink</key> - <param> - <key>id</key> - <value>frame_sink</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>file</key> - <value>output_filename</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - <param> - <key>_coordinate</key> - <value>(973, 1024)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>virtual_source</key> <param> @@ -490,25 +347,6 @@ <value>0</value> </param> </block> - <block> - <key>noaa_hrpt_decoder</key> - <param> - <key>id</key> - <value>decoder</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(974, 925)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable</key> <param> @@ -614,22 +452,26 @@ </param> </block> <block> - <key>gr_throttle</key> + <key>gr_file_source</key> <param> <key>id</key> - <value>throttle</value> + <value>gr_file_source_0</value> </param> <param> <key>_enabled</key> <value>True</value> </param> + <param> + <key>file</key> + <value>input_filename</value> + </param> <param> <key>type</key> <value>short</value> </param> <param> - <key>samples_per_second</key> - <value>sample_rate</value> + <key>repeat</key> + <value>False</value> </param> <param> <key>vlen</key> @@ -637,46 +479,183 @@ </param> <param> <key>_coordinate</key> - <value>(75, 679)</value> + <value>(76, 613)</value> </param> <param> <key>_rotation</key> - <value>180</value> + <value>0</value> </param> </block> <block> - <key>gr_file_source</key> + <key>notebook</key> <param> <key>id</key> - <value>gr_file_source_0</value> + <value>displays</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>file</key> - <value>input_filename</value> + <key>style</key> + <value>wx.NB_TOP</value> + </param> + <param> + <key>labels</key> + <value>['Spectrum','Demod']</value> + </param> + <param> + <key>grid_pos</key> + <value>1,0,1,2</value> + </param> + <param> + <key>notebook</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(12, 249)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>wxgui_fftsink2</key> + <param> + <key>id</key> + <value>rx_fft</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> </param> <param> <key>type</key> - <value>short</value> + <value>complex</value> </param> <param> - <key>repeat</key> + <key>title</key> + <value>RX Spectrum</value> + </param> + <param> + <key>samp_rate</key> + <value>sample_rate</value> + </param> + <param> + <key>baseband_freq</key> + <value>0</value> + </param> + <param> + <key>y_per_div</key> + <value>5</value> + </param> + <param> + <key>y_divs</key> + <value>8</value> + </param> + <param> + <key>ref_level</key> + <value>-5</value> + </param> + <param> + <key>ref_scale</key> + <value>2.0</value> + </param> + <param> + <key>fft_size</key> + <value>1024</value> + </param> + <param> + <key>fft_rate</key> + <value>15</value> + </param> + <param> + <key>peak_hold</key> <value>False</value> </param> + <param> + <key>average</key> + <value>True</value> + </param> + <param> + <key>avg_alpha</key> + <value>0.1</value> + </param> + <param> + <key>win</key> + <value>None</value> + </param> + <param> + <key>win_size</key> + <value>640, 360</value> + </param> + <param> + <key>grid_pos</key> + <value>0, 0, 1, 1</value> + </param> + <param> + <key>notebook</key> + <value>displays, 0</value> + </param> + <param> + <key>_coordinate</key> + <value>(471, 450)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_binary_slicer_fb</key> + <param> + <key>id</key> + <value>gr_binary_slicer_fb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(393, 975)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_throttle</key> + <param> + <key>id</key> + <value>throttle</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>short</value> + </param> + <param> + <key>samples_per_second</key> + <value>2*sample_rate</value> + </param> <param> <key>vlen</key> <value>1</value> </param> <param> <key>_coordinate</key> - <value>(76, 613)</value> + <value>(75, 679)</value> </param> <param> <key>_rotation</key> - <value>0</value> + <value>180</value> </param> </block> <block> @@ -695,7 +674,7 @@ </param> <param> <key>value</key> - <value>'usrp.dat'</value> + <value>usrp.dat</value> </param> <param> <key>type</key> @@ -707,7 +686,7 @@ </param> <param> <key>_coordinate</key> - <value>(198, 107)</value> + <value>(196, 98)</value> </param> <param> <key>_rotation</key> @@ -730,7 +709,7 @@ </param> <param> <key>value</key> - <value>16</value> + <value>32</value> </param> <param> <key>type</key> @@ -742,7 +721,7 @@ </param> <param> <key>_coordinate</key> - <value>(308, 107)</value> + <value>(307, 98)</value> </param> <param> <key>_rotation</key> @@ -797,7 +776,7 @@ </param> <param> <key>_coordinate</key> - <value>(397, 108)</value> + <value>(397, 98)</value> </param> <param> <key>_rotation</key> @@ -852,7 +831,7 @@ </param> <param> <key>_coordinate</key> - <value>(539, 105)</value> + <value>(540, 98)</value> </param> <param> <key>_rotation</key> @@ -860,10 +839,10 @@ </param> </block> <block> - <key>variable_config</key> + <key>variable</key> <param> <key>id</key> - <value>saved_pll_alpha</value> + <value>hs</value> </param> <param> <key>_enabled</key> @@ -871,31 +850,11 @@ </param> <param> <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'pll_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>pll_alpha</value> + <value>int(sps/2.0)</value> </param> <param> <key>_coordinate</key> - <value>(363, 254)</value> + <value>(499, 19)</value> </param> <param> <key>_rotation</key> @@ -903,10 +862,10 @@ </param> </block> <block> - <key>variable_config</key> + <key>variable</key> <param> <key>id</key> - <value>saved_clock_alpha</value> + <value>max_carrier_offset</value> </param> <param> <key>_enabled</key> @@ -914,31 +873,34 @@ </param> <param> <key>value</key> - <value>0.05</value> + <value>2*math.pi*100e3/sample_rate</value> </param> <param> - <key>type</key> - <value>real</value> + <key>_coordinate</key> + <value>(575, 19)</value> </param> <param> - <key>config_file</key> - <value>config_filename</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>variable</key> <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> + <key>id</key> + <value>max_clock_offset</value> </param> <param> - <key>option</key> - <value>'clock_alpha'</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>writeback</key> - <value>clock_alpha</value> + <key>value</key> + <value>100e-6</value> </param> <param> <key>_coordinate</key> - <value>(527, 256)</value> + <value>(705, 19)</value> </param> <param> <key>_rotation</key> @@ -957,7 +919,7 @@ </param> <param> <key>value</key> - <value>'frames.dat'</value> + <value>'frames.hrpt'</value> </param> <param> <key>type</key> @@ -981,7 +943,7 @@ </param> <param> <key>_coordinate</key> - <value>(689, 257)</value> + <value>(521, 254)</value> </param> <param> <key>_rotation</key> @@ -989,34 +951,42 @@ </param> </block> <block> - <key>notebook</key> + <key>variable_config</key> <param> <key>id</key> - <value>displays</value> + <value>saved_pll_alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>style</key> - <value>wx.NB_TOP</value> + <key>value</key> + <value>0.01</value> </param> <param> - <key>labels</key> - <value>['Spectrum','Demod']</value> + <key>type</key> + <value>real</value> </param> <param> - <key>grid_pos</key> - <value>1,0,1,2</value> + <key>config_file</key> + <value>config_filename</value> </param> <param> - <key>notebook</key> - <value></value> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'pll_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>pll_alpha</value> </param> <param> <key>_coordinate</key> - <value>(12, 249)</value> + <value>(195, 253)</value> </param> <param> <key>_rotation</key> @@ -1024,86 +994,88 @@ </param> </block> <block> - <key>wxgui_fftsink2</key> + <key>variable_config</key> <param> <key>id</key> - <value>rx_fft</value> + <value>saved_clock_alpha</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>type</key> - <value>complex</value> - </param> - <param> - <key>title</key> - <value>RX Spectrum</value> + <key>value</key> + <value>0.01</value> </param> <param> - <key>samp_rate</key> - <value>sample_rate</value> + <key>type</key> + <value>real</value> </param> <param> - <key>baseband_freq</key> - <value>0</value> + <key>config_file</key> + <value>config_filename</value> </param> <param> - <key>y_per_div</key> - <value>5</value> + <key>section</key> + <value>'usrp_rx_hrpt'</value> </param> <param> - <key>y_divs</key> - <value>8</value> + <key>option</key> + <value>'clock_alpha'</value> </param> <param> - <key>ref_level</key> - <value>-5</value> + <key>writeback</key> + <value>clock_alpha</value> </param> <param> - <key>ref_scale</key> - <value>2.0</value> + <key>_coordinate</key> + <value>(360, 255)</value> </param> <param> - <key>fft_size</key> - <value>1024</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>noaa_hrpt_deframer</key> <param> - <key>fft_rate</key> - <value>15</value> + <key>id</key> + <value>deframer</value> </param> <param> - <key>peak_hold</key> - <value>False</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>average</key> - <value>True</value> + <key>_coordinate</key> + <value>(579, 975)</value> </param> <param> - <key>avg_alpha</key> - <value>0.1</value> + <key>_rotation</key> + <value>0</value> </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> <param> - <key>win</key> - <value>None</value> + <key>id</key> + <value>decoder</value> </param> <param> - <key>win_size</key> - <value>640, 360</value> + <key>_enabled</key> + <value>True</value> </param> <param> - <key>grid_pos</key> - <value>0, 0, 1, 1</value> + <key>verbose</key> + <value>True</value> </param> <param> - <key>notebook</key> - <value>displays, 0</value> + <key>output</key> + <value>False</value> </param> <param> <key>_coordinate</key> - <value>(471, 450)</value> + <value>(849, 925)</value> </param> <param> <key>_rotation</key> @@ -1111,37 +1083,30 @@ </param> </block> <block> - <key>gr_binary_slicer_fb</key> + <key>gr_file_sink</key> <param> <key>id</key> - <value>gr_binary_slicer_fb_0</value> + <value>frame_sink</value> </param> <param> <key>_enabled</key> <value>True</value> </param> <param> - <key>_coordinate</key> - <value>(393, 975)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> + <key>file</key> + <value>output_filename</value> </param> - </block> - <block> - <key>noaa_hrpt_deframer</key> <param> - <key>id</key> - <value>deframer</value> + <key>type</key> + <value>short</value> </param> <param> - <key>_enabled</key> - <value>True</value> + <key>vlen</key> + <value>1</value> </param> <param> <key>_coordinate</key> - <value>(762, 975)</value> + <value>(848, 1007)</value> </param> <param> <key>_rotation</key> diff --git a/gr-noaa/apps/file_rx_hrpt.py b/gr-noaa/apps/file_rx_hrpt.py index 1513141ec..13b887635 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: Mon Nov 2 08:30:47 2009 +# Generated: Mon Nov 9 07:47:17 2009 ################################################## from gnuradio import eng_notation @@ -22,7 +22,7 @@ import wx class file_rx_hrpt(grc_wxgui.top_block_gui): - def __init__(self, input_filename='usrp.dat', decim=16): + def __init__(self, input_filename="usrp.dat", decim=32): grc_wxgui.top_block_gui.__init__(self, title="USRP HRPT Receiver") ################################################## @@ -41,25 +41,20 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') - except: saved_pll_alpha = 0.05 + except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') - except: saved_clock_alpha = 0.05 + except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(config_filename) - try: side = self._side_config.get('usrp_rx_hrpt', 'side') - except: side = 'A' - self.side = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') - except: output_filename = 'frames.dat' + except: output_filename = 'frames.hrpt' self.output_filename = output_filename - self.max_clock_offset = max_clock_offset = 0.1 + self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self.clock_alpha = clock_alpha = saved_clock_alpha @@ -126,7 +121,7 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) - self.decoder = noaa.hrpt_decoder() + self.decoder = noaa.hrpt_decoder(True,False) self.deframer = noaa.hrpt_deframer() self.demod_scope = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), @@ -164,7 +159,7 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): size=(640, 360), ) self.displays.GetPage(0).GridAdd(self.rx_fft.win, 0, 0, 1, 1) - self.throttle = gr.throttle(gr.sizeof_short*1, sample_rate) + self.throttle = gr.throttle(gr.sizeof_short*1, 2*sample_rate) ################################################## # Connections @@ -196,18 +191,18 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): def set_sample_rate(self, sample_rate): self.sample_rate = sample_rate - self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) self.set_sps(self.sample_rate/self.sym_rate) self.rx_fft.set_sample_rate(self.sample_rate) + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) def set_config_filename(self, config_filename): self.config_filename = config_filename - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) + self._output_filename_config = ConfigParser.ConfigParser() + self._output_filename_config.read(self.config_filename) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) + self._output_filename_config.write(open(self.config_filename, 'w')) self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(self.config_filename) if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'): @@ -220,17 +215,11 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self._saved_clock_alpha_config.add_section('usrp_rx_hrpt') self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._saved_clock_alpha_config.write(open(self.config_filename, 'w')) - self._output_filename_config = ConfigParser.ConfigParser() - self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('usrp_rx_hrpt'): - self._output_filename_config.add_section('usrp_rx_hrpt') - self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) - self._output_filename_config.write(open(self.config_filename, 'w')) def set_sps(self, sps): self.sps = sps - self.set_hs(int(self.sps/2.0)) self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0) + self.set_hs(int(self.sps/2.0)) def set_saved_pll_alpha(self, saved_pll_alpha): self.saved_pll_alpha = saved_pll_alpha @@ -240,15 +229,6 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): self.saved_clock_alpha = saved_clock_alpha self.set_clock_alpha(self.saved_clock_alpha) - def set_side(self, side): - self.side = side - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) - def set_pll_alpha(self, pll_alpha): self.pll_alpha = pll_alpha self.pll.set_alpha(self.pll_alpha) @@ -297,9 +277,9 @@ class file_rx_hrpt(grc_wxgui.top_block_gui): if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") - parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default='usrp.dat', + parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat", help="Set usrp.dat [default=%default]") - parser.add_option("-d", "--decim", dest="decim", type="intx", default=16, + parser.add_option("-d", "--decim", dest="decim", type="intx", default=32, help="Set decim [default=%default]") (options, args) = parser.parse_args() tb = file_rx_hrpt(input_filename=options.input_filename, decim=options.decim) diff --git a/gr-noaa/apps/hrpt_decode.grc b/gr-noaa/apps/hrpt_decode.grc new file mode 100644 index 000000000..39fe195d1 --- /dev/null +++ b/gr-noaa/apps/hrpt_decode.grc @@ -0,0 +1,428 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Sun Nov 8 10:48:59 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>hrpt_decode</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>4096,4096</value> + </param> + <param> + <key>generate_options</key> + <value>no_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>run</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_carrier_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>2*math.pi*100e3/sample_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(575, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>hs</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>int(sps/2.0)</value> + </param> + <param> + <key>_coordinate</key> + <value>(499, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sample_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>64e6/decim</value> + </param> + <param> + <key>_coordinate</key> + <value>(198, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import math, os</value> + </param> + <param> + <key>_coordinate</key> + <value>(11, 103)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100e-6</value> + </param> + <param> + <key>_coordinate</key> + <value>(710, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sym_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>600*1109</value> + </param> + <param> + <key>_coordinate</key> + <value>(307, 18)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sps</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>sample_rate/sym_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(400, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>decim</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>decim</value> + </param> + <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>type</key> + <value>intx</value> + </param> + <param> + <key>short_id</key> + <value>d</value> + </param> + <param> + <key>_coordinate</key> + <value>(202, 102)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>pll_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>pll_alpha</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>eng_float</value> + </param> + <param> + <key>short_id</key> + <value>p</value> + </param> + <param> + <key>_coordinate</key> + <value>(294, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>clock_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>clock_alpha</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>eng_float</value> + </param> + <param> + <key>short_id</key> + <value>s</value> + </param> + <param> + <key>_coordinate</key> + <value>(395, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_file_source</key> + <param> + <key>id</key> + <value>file_source</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>file</key> + <value>input_filename</value> + </param> + <param> + <key>type</key> + <value>short</value> + </param> + <param> + <key>repeat</key> + <value>False</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(231, 419)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> + <param> + <key>id</key> + <value>decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(462, 419)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>input_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>input_filename</value> + </param> + <param> + <key>value</key> + <value>frames.hrpt</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>F</value> + </param> + <param> + <key>_coordinate</key> + <value>(522, 100)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <connection> + <source_block_id>file_source</source_block_id> + <sink_block_id>decoder</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-noaa/apps/hrpt_decode.py b/gr-noaa/apps/hrpt_decode.py new file mode 100755 index 000000000..158780b17 --- /dev/null +++ b/gr-noaa/apps/hrpt_decode.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Hrpt Decode +# Generated: Sun Nov 8 10:49:01 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import noaa +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from optparse import OptionParser +import math, os + +class hrpt_decode(gr.top_block): + + def __init__(self, decim=32, pll_alpha=0.01, clock_alpha=0.01, input_filename="frames.hrpt"): + gr.top_block.__init__(self, "Hrpt Decode") + + ################################################## + # Parameters + ################################################## + self.decim = decim + self.pll_alpha = pll_alpha + self.clock_alpha = clock_alpha + self.input_filename = input_filename + + ################################################## + # Variables + ################################################## + self.sym_rate = sym_rate = 600*1109 + self.sample_rate = sample_rate = 64e6/decim + self.sps = sps = sample_rate/sym_rate + self.max_clock_offset = max_clock_offset = 100e-6 + self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate + self.hs = hs = int(sps/2.0) + + ################################################## + # Blocks + ################################################## + self.decoder = noaa.hrpt_decoder(True,True) + self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False) + + ################################################## + # Connections + ################################################## + self.connect((self.file_source, 0), (self.decoder, 0)) + + def set_decim(self, decim): + self.decim = decim + self.set_sample_rate(64e6/self.decim) + + def set_pll_alpha(self, pll_alpha): + self.pll_alpha = pll_alpha + + def set_clock_alpha(self, clock_alpha): + self.clock_alpha = clock_alpha + + def set_input_filename(self, input_filename): + self.input_filename = input_filename + + def set_sym_rate(self, sym_rate): + self.sym_rate = sym_rate + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sample_rate(self, sample_rate): + self.sample_rate = sample_rate + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sps(self, sps): + self.sps = sps + self.set_hs(int(self.sps/2.0)) + + def set_max_clock_offset(self, max_clock_offset): + self.max_clock_offset = max_clock_offset + + def set_max_carrier_offset(self, max_carrier_offset): + self.max_carrier_offset = max_carrier_offset + + def set_hs(self, hs): + self.hs = hs + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + parser.add_option("-d", "--decim", dest="decim", type="intx", default=32, + help="Set decim [default=%default]") + parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set pll_alpha [default=%default]") + parser.add_option("-s", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set clock_alpha [default=%default]") + parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="frames.hrpt", + help="Set frames.hrpt [default=%default]") + (options, args) = parser.parse_args() + tb = hrpt_decode(decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha, input_filename=options.input_filename) + tb.run() + diff --git a/gr-noaa/apps/hrpt_demod.grc b/gr-noaa/apps/hrpt_demod.grc new file mode 100644 index 000000000..8af3d82dd --- /dev/null +++ b/gr-noaa/apps/hrpt_demod.grc @@ -0,0 +1,747 @@ +<?xml version='1.0' encoding='ASCII'?> +<flow_graph> + <timestamp>Sun Nov 8 10:41:07 2009</timestamp> + <block> + <key>options</key> + <param> + <key>id</key> + <value>hrpt_demod</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>title</key> + <value></value> + </param> + <param> + <key>author</key> + <value></value> + </param> + <param> + <key>description</key> + <value></value> + </param> + <param> + <key>window_size</key> + <value>4096,4096</value> + </param> + <param> + <key>generate_options</key> + <value>no_gui</value> + </param> + <param> + <key>category</key> + <value>Custom</value> + </param> + <param> + <key>run_options</key> + <value>run</value> + </param> + <param> + <key>run</key> + <value>True</value> + </param> + <param> + <key>realtime_scheduling</key> + <value></value> + </param> + <param> + <key>_coordinate</key> + <value>(10, 10)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_carrier_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>2*math.pi*100e3/sample_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(575, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>hs</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>int(sps/2.0)</value> + </param> + <param> + <key>_coordinate</key> + <value>(499, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sample_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>64e6/decim</value> + </param> + <param> + <key>_coordinate</key> + <value>(198, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>import</key> + <param> + <key>id</key> + <value>import_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>import</key> + <value>import math, os</value> + </param> + <param> + <key>_coordinate</key> + <value>(11, 103)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>input_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>input_filename</value> + </param> + <param> + <key>value</key> + <value>usrp.dat</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>F</value> + </param> + <param> + <key>_coordinate</key> + <value>(618, 102)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>output_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>output_filename</value> + </param> + <param> + <key>value</key> + <value>frames.dat</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>short_id</key> + <value>o</value> + </param> + <param> + <key>_coordinate</key> + <value>(726, 102)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>gr_file_source</key> + <param> + <key>id</key> + <value>file_source</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>file</key> + <value>input_filename</value> + </param> + <param> + <key>type</key> + <value>short</value> + </param> + <param> + <key>repeat</key> + <value>False</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(63, 277)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_interleaved_short_to_complex</key> + <param> + <key>id</key> + <value>cs2cf</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(275, 289)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_agc_xx</key> + <param> + <key>id</key> + <value>agc</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>complex</value> + </param> + <param> + <key>rate</key> + <value>1e-5</value> + </param> + <param> + <key>reference</key> + <value>1.0</value> + </param> + <param> + <key>gain</key> + <value>1.0/32768.0</value> + </param> + <param> + <key>max_gain</key> + <value>1.0</value> + </param> + <param> + <key>_coordinate</key> + <value>(117, 394)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_pll_cf</key> + <param> + <key>id</key> + <value>pll</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>alpha</key> + <value>pll_alpha</value> + </param> + <param> + <key>beta</key> + <value>pll_alpha**2/4.0</value> + </param> + <param> + <key>max_offset</key> + <value>max_carrier_offset</value> + </param> + <param> + <key>_coordinate</key> + <value>(292, 402)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_moving_average_xx</key> + <param> + <key>id</key> + <value>gr_moving_average_xx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>length</key> + <value>hs</value> + </param> + <param> + <key>scale</key> + <value>1.0/hs</value> + </param> + <param> + <key>max_iter</key> + <value>4000</value> + </param> + <param> + <key>_coordinate</key> + <value>(504, 402)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_clock_recovery_mm_xx</key> + <param> + <key>id</key> + <value>gr_clock_recovery_mm_xx_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>type</key> + <value>float</value> + </param> + <param> + <key>omega</key> + <value>sps/2.0</value> + </param> + <param> + <key>gain_omega</key> + <value>clock_alpha**2/4.0</value> + </param> + <param> + <key>mu</key> + <value>0.5</value> + </param> + <param> + <key>gain_mu</key> + <value>clock_alpha</value> + </param> + <param> + <key>omega_relative_limit</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_coordinate</key> + <value>(703, 386)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_deframer</key> + <param> + <key>id</key> + <value>noaa_hrpt_deframer_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(1142, 422)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>gr_binary_slicer_fb</key> + <param> + <key>id</key> + <value>gr_binary_slicer_fb_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(960, 422)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100e-6</value> + </param> + <param> + <key>_coordinate</key> + <value>(710, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sym_rate</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>600*1109</value> + </param> + <param> + <key>_coordinate</key> + <value>(307, 18)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>sps</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>sample_rate/sym_rate</value> + </param> + <param> + <key>_coordinate</key> + <value>(400, 17)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>decim</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>decim</value> + </param> + <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>type</key> + <value>intx</value> + </param> + <param> + <key>short_id</key> + <value>d</value> + </param> + <param> + <key>_coordinate</key> + <value>(202, 102)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>pll_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>pll_alpha</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>eng_float</value> + </param> + <param> + <key>short_id</key> + <value>p</value> + </param> + <param> + <key>_coordinate</key> + <value>(294, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>parameter</key> + <param> + <key>id</key> + <value>clock_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>label</key> + <value>clock_alpha</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>eng_float</value> + </param> + <param> + <key>short_id</key> + <value>s</value> + </param> + <param> + <key>_coordinate</key> + <value>(395, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> + <param> + <key>id</key> + <value>decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>False</value> + </param> + <param> + <key>_coordinate</key> + <value>(1150, 341)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <block> + <key>gr_file_sink</key> + <param> + <key>id</key> + <value>gr_file_sink_0</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>file</key> + <value>output_filename</value> + </param> + <param> + <key>type</key> + <value>short</value> + </param> + <param> + <key>vlen</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(1144, 489)</value> + </param> + <param> + <key>_rotation</key> + <value>180</value> + </param> + </block> + <connection> + <source_block_id>file_source</source_block_id> + <sink_block_id>cs2cf</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>gr_clock_recovery_mm_xx_0</source_block_id> + <sink_block_id>gr_binary_slicer_fb_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>gr_moving_average_xx_0</source_block_id> + <sink_block_id>gr_clock_recovery_mm_xx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>pll</source_block_id> + <sink_block_id>gr_moving_average_xx_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>cs2cf</source_block_id> + <sink_block_id>agc</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>agc</source_block_id> + <sink_block_id>pll</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>noaa_hrpt_deframer_0</source_block_id> + <sink_block_id>gr_file_sink_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>noaa_hrpt_deframer_0</source_block_id> + <sink_block_id>decoder</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>gr_binary_slicer_fb_0</source_block_id> + <sink_block_id>noaa_hrpt_deframer_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> +</flow_graph> diff --git a/gr-noaa/apps/hrpt_demod.py b/gr-noaa/apps/hrpt_demod.py new file mode 100755 index 000000000..38d031686 --- /dev/null +++ b/gr-noaa/apps/hrpt_demod.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python +################################################## +# Gnuradio Python Flow Graph +# Title: Hrpt Demod +# Generated: Sun Nov 8 10:41:08 2009 +################################################## + +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio import noaa +from gnuradio.eng_option import eng_option +from gnuradio.gr import firdes +from optparse import OptionParser +import math, os + +class hrpt_demod(gr.top_block): + + def __init__(self, input_filename="usrp.dat", output_filename="frames.dat", decim=32, pll_alpha=0.01, clock_alpha=0.01): + gr.top_block.__init__(self, "Hrpt Demod") + + ################################################## + # Parameters + ################################################## + self.input_filename = input_filename + self.output_filename = output_filename + self.decim = decim + self.pll_alpha = pll_alpha + self.clock_alpha = clock_alpha + + ################################################## + # Variables + ################################################## + self.sym_rate = sym_rate = 600*1109 + self.sample_rate = sample_rate = 64e6/decim + self.sps = sps = sample_rate/sym_rate + self.max_clock_offset = max_clock_offset = 100e-6 + self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate + self.hs = hs = int(sps/2.0) + + ################################################## + # Blocks + ################################################## + self.agc = gr.agc_cc(1e-5, 1.0, 1.0/32768.0, 1.0) + self.cs2cf = gr.interleaved_short_to_complex() + self.decoder = noaa.hrpt_decoder(True,False) + self.file_source = gr.file_source(gr.sizeof_short*1, input_filename, False) + 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_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_deframer_0 = noaa.hrpt_deframer() + self.pll = noaa.hrpt_pll_cf(pll_alpha, pll_alpha**2/4.0, max_carrier_offset) + + ################################################## + # Connections + ################################################## + self.connect((self.file_source, 0), (self.cs2cf, 0)) + 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.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.decoder, 0)) + self.connect((self.gr_binary_slicer_fb_0, 0), (self.noaa_hrpt_deframer_0, 0)) + + def set_input_filename(self, input_filename): + self.input_filename = input_filename + + def set_output_filename(self, output_filename): + self.output_filename = output_filename + + def set_decim(self, decim): + self.decim = decim + self.set_sample_rate(64e6/self.decim) + + def set_pll_alpha(self, pll_alpha): + self.pll_alpha = pll_alpha + self.pll.set_alpha(self.pll_alpha) + self.pll.set_beta(self.pll_alpha**2/4.0) + + def set_clock_alpha(self, clock_alpha): + self.clock_alpha = clock_alpha + self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) + self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) + + def set_sym_rate(self, sym_rate): + self.sym_rate = sym_rate + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sample_rate(self, sample_rate): + self.sample_rate = sample_rate + self.set_max_carrier_offset(2*math.pi*100e3/self.sample_rate) + self.set_sps(self.sample_rate/self.sym_rate) + + def set_sps(self, sps): + self.sps = sps + self.set_hs(int(self.sps/2.0)) + self.gr_clock_recovery_mm_xx_0.set_omega(self.sps/2.0) + + def set_max_clock_offset(self, max_clock_offset): + self.max_clock_offset = max_clock_offset + + def set_max_carrier_offset(self, max_carrier_offset): + self.max_carrier_offset = max_carrier_offset + self.pll.set_max_offset(self.max_carrier_offset) + + def set_hs(self, hs): + self.hs = hs + self.gr_moving_average_xx_0.set_length_and_scale(self.hs, 1.0/self.hs) + +if __name__ == '__main__': + parser = OptionParser(option_class=eng_option, usage="%prog: [options]") + parser.add_option("-F", "--input-filename", dest="input_filename", type="string", default="usrp.dat", + help="Set usrp.dat [default=%default]") + parser.add_option("-o", "--output-filename", dest="output_filename", type="string", default="frames.dat", + help="Set frames.dat [default=%default]") + parser.add_option("-d", "--decim", dest="decim", type="intx", default=32, + help="Set decim [default=%default]") + parser.add_option("-p", "--pll-alpha", dest="pll_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set pll_alpha [default=%default]") + parser.add_option("-s", "--clock-alpha", dest="clock_alpha", type="eng_float", default=eng_notation.num_to_str(0.01), + help="Set clock_alpha [default=%default]") + (options, args) = parser.parse_args() + tb = hrpt_demod(input_filename=options.input_filename, output_filename=options.output_filename, decim=options.decim, pll_alpha=options.pll_alpha, clock_alpha=options.clock_alpha) + tb.run() + diff --git a/gr-noaa/apps/usrp_rx_hrpt.grc b/gr-noaa/apps/usrp_rx_hrpt.grc index ac7a87a16..990855f69 100644 --- a/gr-noaa/apps/usrp_rx_hrpt.grc +++ b/gr-noaa/apps/usrp_rx_hrpt.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Nov 2 08:31:09 2009</timestamp> + <timestamp>Mon Nov 9 07:56:11 2009</timestamp> <block> <key>options</key> <param> @@ -542,72 +542,6 @@ <value>0</value> </param> </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>output_filename</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>'frames.dat'</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'filename'</value> - </param> - <param> - <key>writeback</key> - <value>output_filename</value> - </param> - <param> - <key>_coordinate</key> - <value>(1139, 259)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(705, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable_slider</key> <param> @@ -663,135 +597,6 @@ <value>0</value> </param> </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>saved_pll_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'pll_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>pll_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(823, 258)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>saved_clock_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'clock_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>clock_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(981, 258)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>decim</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>16</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'decim'</value> - </param> - <param> - <key>writeback</key> - <value>decim</value> - </param> - <param> - <key>_coordinate</key> - <value>(351, 255)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable_config</key> <param> @@ -1123,25 +928,6 @@ <value>0</value> </param> </block> - <block> - <key>noaa_hrpt_decoder</key> - <param> - <key>id</key> - <value>decoder</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(974, 925)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>gr_agc_xx</key> <param> @@ -1365,6 +1151,228 @@ <value>0</value> </param> </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>decim</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'decim'</value> + </param> + <param> + <key>writeback</key> + <value>decim</value> + </param> + <param> + <key>_coordinate</key> + <value>(351, 255)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_pll_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'pll_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>pll_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(823, 258)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>saved_clock_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'clock_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>clock_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(981, 258)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>output_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>'frames.hrpt'</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'filename'</value> + </param> + <param> + <key>writeback</key> + <value>output_filename</value> + </param> + <param> + <key>_coordinate</key> + <value>(1139, 259)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> + <param> + <key>id</key> + <value>decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(974, 925)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100e-6</value> + </param> + <param> + <key>_coordinate</key> + <value>(705, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> <connection> <source_block_id>virtual_source_0</source_block_id> <sink_block_id>gr_binary_slicer_fb_0</sink_block_id> diff --git a/gr-noaa/apps/usrp_rx_hrpt.py b/gr-noaa/apps/usrp_rx_hrpt.py index a5f9a8e94..48c5f9d29 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: Mon Nov 2 08:31:10 2009 +# Generated: Mon Nov 9 07:56:11 2009 ################################################## from gnuradio import eng_notation @@ -33,7 +33,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') - except: decim = 16 + except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim @@ -46,7 +46,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(config_filename) try: saved_pll_alpha = self._saved_pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') - except: saved_pll_alpha = 0.05 + except: saved_pll_alpha = 0.01 self.saved_pll_alpha = saved_pll_alpha self._saved_gain_config = ConfigParser.ConfigParser() self._saved_gain_config.read(config_filename) @@ -61,16 +61,16 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(config_filename) try: saved_clock_alpha = self._saved_clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') - except: saved_clock_alpha = 0.05 + except: saved_clock_alpha = 0.01 self.saved_clock_alpha = saved_clock_alpha self.side_text = side_text = side self.pll_alpha = pll_alpha = saved_pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') - except: output_filename = 'frames.dat' + except: output_filename = 'frames.hrpt' self.output_filename = output_filename - self.max_clock_offset = max_clock_offset = 0.1 + self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self.gain = gain = saved_gain @@ -187,7 +187,7 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) - self.decoder = noaa.hrpt_decoder() + self.decoder = noaa.hrpt_decoder(True,True) self.deframer = noaa.hrpt_deframer() self.demod_scope = scopesink2.scope_sink_f( self.displays.GetPage(1).GetWin(), @@ -256,12 +256,18 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_gain_config.add_section('usrp_rx_hrpt') self._saved_gain_config.set('usrp_rx_hrpt', 'gain', str(self.gain)) self._saved_gain_config.write(open(self.config_filename, 'w')) - self._output_filename_config = ConfigParser.ConfigParser() - self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('usrp_rx_hrpt'): - self._output_filename_config.add_section('usrp_rx_hrpt') - self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) - self._output_filename_config.write(open(self.config_filename, 'w')) + self._side_config = ConfigParser.ConfigParser() + self._side_config.read(self.config_filename) + if not self._side_config.has_section('usrp_rx_hrpt'): + self._side_config.add_section('usrp_rx_hrpt') + self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) + self._side_config.write(open(self.config_filename, 'w')) + self._decim_config = ConfigParser.ConfigParser() + self._decim_config.read(self.config_filename) + if not self._decim_config.has_section('usrp_rx_hrpt'): + self._decim_config.add_section('usrp_rx_hrpt') + self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) + self._decim_config.write(open(self.config_filename, 'w')) self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(self.config_filename) if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'): @@ -274,30 +280,24 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self._saved_clock_alpha_config.add_section('usrp_rx_hrpt') self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._saved_clock_alpha_config.write(open(self.config_filename, 'w')) - self._decim_config = ConfigParser.ConfigParser() - self._decim_config.read(self.config_filename) - if not self._decim_config.has_section('usrp_rx_hrpt'): - self._decim_config.add_section('usrp_rx_hrpt') - self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) - self._decim_config.write(open(self.config_filename, 'w')) - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) + self._output_filename_config = ConfigParser.ConfigParser() + self._output_filename_config.read(self.config_filename) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) + self._output_filename_config.write(open(self.config_filename, 'w')) def set_decim(self, decim): self.decim = decim self.set_sample_rate(64e6/self.decim) self.set_decim_text(self.decim) + self.usrp_source.set_decim_rate(self.decim) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) if not self._decim_config.has_section('usrp_rx_hrpt'): self._decim_config.add_section('usrp_rx_hrpt') self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) - self.usrp_source.set_decim_rate(self.decim) def set_sym_rate(self, sym_rate): self.sym_rate = sym_rate @@ -349,14 +349,14 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.pll_alpha = pll_alpha self._pll_alpha_slider.set_value(self.pll_alpha) self._pll_alpha_text_box.set_value(self.pll_alpha) + self.pll.set_alpha(self.pll_alpha) + self.pll.set_beta(self.pll_alpha**2/4.0) self._saved_pll_alpha_config = ConfigParser.ConfigParser() self._saved_pll_alpha_config.read(self.config_filename) if not self._saved_pll_alpha_config.has_section('usrp_rx_hrpt'): self._saved_pll_alpha_config.add_section('usrp_rx_hrpt') self._saved_pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) self._saved_pll_alpha_config.write(open(self.config_filename, 'w')) - self.pll.set_alpha(self.pll_alpha) - self.pll.set_beta(self.pll_alpha**2/4.0) def set_output_filename(self, output_filename): self.output_filename = output_filename @@ -410,14 +410,14 @@ class usrp_rx_hrpt(grc_wxgui.top_block_gui): self.clock_alpha = clock_alpha self._clock_alpha_slider.set_value(self.clock_alpha) self._clock_alpha_text_box.set_value(self.clock_alpha) + self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) + self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) self._saved_clock_alpha_config = ConfigParser.ConfigParser() self._saved_clock_alpha_config.read(self.config_filename) if not self._saved_clock_alpha_config.has_section('usrp_rx_hrpt'): self._saved_clock_alpha_config.add_section('usrp_rx_hrpt') self._saved_clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._saved_clock_alpha_config.write(open(self.config_filename, 'w')) - self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) - self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc index 02d509f08..22bd3bdc3 100644 --- a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc @@ -1,6 +1,6 @@ <?xml version='1.0' encoding='ASCII'?> <flow_graph> - <timestamp>Mon Nov 2 08:31:35 2009</timestamp> + <timestamp>Mon Nov 9 08:03:25 2009</timestamp> <block> <key>options</key> <param> @@ -171,29 +171,6 @@ <value>0</value> </param> </block> - <block> - <key>variable</key> - <param> - <key>id</key> - <value>max_clock_offset</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.1</value> - </param> - <param> - <key>_coordinate</key> - <value>(705, 19)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable</key> <param> @@ -240,49 +217,6 @@ <value>0</value> </param> </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>clock_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'clock_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>clock_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(986, 101)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable_config</key> <param> @@ -369,135 +303,6 @@ <value>0</value> </param> </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>decim</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>16</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'decim'</value> - </param> - <param> - <key>writeback</key> - <value>decim</value> - </param> - <param> - <key>_coordinate</key> - <value>(355, 97)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>output_filename</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>'frames.dat'</value> - </param> - <param> - <key>type</key> - <value>string</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'filename'</value> - </param> - <param> - <key>writeback</key> - <value>output_filename</value> - </param> - <param> - <key>_coordinate</key> - <value>(1143, 101)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> - <block> - <key>variable_config</key> - <param> - <key>id</key> - <value>pll_alpha</value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>value</key> - <value>0.05</value> - </param> - <param> - <key>type</key> - <value>real</value> - </param> - <param> - <key>config_file</key> - <value>config_filename</value> - </param> - <param> - <key>section</key> - <value>'usrp_rx_hrpt'</value> - </param> - <param> - <key>option</key> - <value>'pll_alpha'</value> - </param> - <param> - <key>writeback</key> - <value>pll_alpha</value> - </param> - <param> - <key>_coordinate</key> - <value>(827, 100)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - </block> <block> <key>variable_config</key> <param> @@ -826,10 +631,10 @@ </param> </block> <block> - <key>noaa_hrpt_decoder</key> + <key>gr_binary_slicer_fb</key> <param> <key>id</key> - <value>decoder</value> + <value>gr_binary_slicer_fb_0</value> </param> <param> <key>_enabled</key> @@ -837,7 +642,7 @@ </param> <param> <key>_coordinate</key> - <value>(1027, 623)</value> + <value>(446, 673)</value> </param> <param> <key>_rotation</key> @@ -845,10 +650,10 @@ </param> </block> <block> - <key>gr_binary_slicer_fb</key> + <key>noaa_hrpt_deframer</key> <param> <key>id</key> - <value>gr_binary_slicer_fb_0</value> + <value>deframer</value> </param> <param> <key>_enabled</key> @@ -856,7 +661,7 @@ </param> <param> <key>_coordinate</key> - <value>(446, 673)</value> + <value>(815, 673)</value> </param> <param> <key>_rotation</key> @@ -864,18 +669,221 @@ </param> </block> <block> - <key>noaa_hrpt_deframer</key> + <key>variable_config</key> <param> <key>id</key> - <value>deframer</value> + <value>decim</value> </param> <param> <key>_enabled</key> <value>True</value> </param> + <param> + <key>value</key> + <value>32</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'decim'</value> + </param> + <param> + <key>writeback</key> + <value>decim</value> + </param> <param> <key>_coordinate</key> - <value>(815, 673)</value> + <value>(355, 97)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>pll_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'pll_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>pll_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(827, 100)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>clock_alpha</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>0.01</value> + </param> + <param> + <key>type</key> + <value>real</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'clock_alpha'</value> + </param> + <param> + <key>writeback</key> + <value>clock_alpha</value> + </param> + <param> + <key>_coordinate</key> + <value>(986, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable_config</key> + <param> + <key>id</key> + <value>output_filename</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>'frames.hrpt'</value> + </param> + <param> + <key>type</key> + <value>string</value> + </param> + <param> + <key>config_file</key> + <value>config_filename</value> + </param> + <param> + <key>section</key> + <value>'usrp_rx_hrpt'</value> + </param> + <param> + <key>option</key> + <value>'filename'</value> + </param> + <param> + <key>writeback</key> + <value>output_filename</value> + </param> + <param> + <key>_coordinate</key> + <value>(1143, 101)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>variable</key> + <param> + <key>id</key> + <value>max_clock_offset</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>value</key> + <value>100e-6</value> + </param> + <param> + <key>_coordinate</key> + <value>(705, 19)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + </block> + <block> + <key>noaa_hrpt_decoder</key> + <param> + <key>id</key> + <value>decoder</value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>verbose</key> + <value>True</value> + </param> + <param> + <key>output</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(1027, 623)</value> </param> <param> <key>_rotation</key> diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.py b/gr-noaa/apps/usrp_rx_hrpt_nogui.py index 4dc32dbda..1b510bdb2 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: Mon Nov 2 08:31:35 2009 +# Generated: Mon Nov 9 08:03:25 2009 ################################################## from gnuradio import eng_notation @@ -27,7 +27,7 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(config_filename) try: decim = self._decim_config.getfloat('usrp_rx_hrpt', 'decim') - except: decim = 16 + except: decim = 32 self.decim = decim self.sym_rate = sym_rate = 600*1109 self.sample_rate = sample_rate = 64e6/decim @@ -40,14 +40,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(config_filename) try: pll_alpha = self._pll_alpha_config.getfloat('usrp_rx_hrpt', 'pll_alpha') - except: pll_alpha = 0.05 + except: pll_alpha = 0.01 self.pll_alpha = pll_alpha self._output_filename_config = ConfigParser.ConfigParser() self._output_filename_config.read(config_filename) try: output_filename = self._output_filename_config.get('usrp_rx_hrpt', 'filename') - except: output_filename = 'frames.dat' + except: output_filename = 'frames.hrpt' self.output_filename = output_filename - self.max_clock_offset = max_clock_offset = 0.1 + self.max_clock_offset = max_clock_offset = 100e-6 self.max_carrier_offset = max_carrier_offset = 2*math.pi*100e3/sample_rate self.hs = hs = int(sps/2.0) self._gain_config = ConfigParser.ConfigParser() @@ -63,14 +63,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._clock_alpha_config = ConfigParser.ConfigParser() self._clock_alpha_config.read(config_filename) try: clock_alpha = self._clock_alpha_config.getfloat('usrp_rx_hrpt', 'clock_alpha') - except: clock_alpha = 0.05 + except: clock_alpha = 0.01 self.clock_alpha = clock_alpha ################################################## # Blocks ################################################## self.agc = gr.agc_cc(1e-6, 1.0, 1.0, 1.0) - self.decoder = noaa.hrpt_decoder() + self.decoder = noaa.hrpt_decoder(True,True) self.deframer = noaa.hrpt_deframer() self.frame_sink = gr.file_sink(gr.sizeof_short*1, output_filename) self.gr_binary_slicer_fb_0 = gr.binary_slicer_fb() @@ -96,12 +96,6 @@ class usrp_rx_hrpt_nogui(gr.top_block): def set_config_filename(self, config_filename): self.config_filename = config_filename - self._clock_alpha_config = ConfigParser.ConfigParser() - self._clock_alpha_config.read(self.config_filename) - if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): - self._clock_alpha_config.add_section('usrp_rx_hrpt') - self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) - self._clock_alpha_config.write(open(self.config_filename, 'w')) self._gain_config = ConfigParser.ConfigParser() self._gain_config.read(self.config_filename) if not self._gain_config.has_section('usrp_rx_hrpt'): @@ -114,41 +108,47 @@ class usrp_rx_hrpt_nogui(gr.top_block): self._freq_config.add_section('usrp_rx_hrpt') self._freq_config.set('usrp_rx_hrpt', 'freq', str(self.freq)) self._freq_config.write(open(self.config_filename, 'w')) + self._side_config = ConfigParser.ConfigParser() + self._side_config.read(self.config_filename) + if not self._side_config.has_section('usrp_rx_hrpt'): + self._side_config.add_section('usrp_rx_hrpt') + self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) + self._side_config.write(open(self.config_filename, 'w')) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) if not self._decim_config.has_section('usrp_rx_hrpt'): self._decim_config.add_section('usrp_rx_hrpt') self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) - self._output_filename_config = ConfigParser.ConfigParser() - self._output_filename_config.read(self.config_filename) - if not self._output_filename_config.has_section('usrp_rx_hrpt'): - self._output_filename_config.add_section('usrp_rx_hrpt') - self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) - self._output_filename_config.write(open(self.config_filename, 'w')) self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(self.config_filename) if not self._pll_alpha_config.has_section('usrp_rx_hrpt'): self._pll_alpha_config.add_section('usrp_rx_hrpt') self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) self._pll_alpha_config.write(open(self.config_filename, 'w')) - self._side_config = ConfigParser.ConfigParser() - self._side_config.read(self.config_filename) - if not self._side_config.has_section('usrp_rx_hrpt'): - self._side_config.add_section('usrp_rx_hrpt') - self._side_config.set('usrp_rx_hrpt', 'side', str(self.side)) - self._side_config.write(open(self.config_filename, 'w')) + self._clock_alpha_config = ConfigParser.ConfigParser() + self._clock_alpha_config.read(self.config_filename) + if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): + self._clock_alpha_config.add_section('usrp_rx_hrpt') + self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) + self._clock_alpha_config.write(open(self.config_filename, 'w')) + self._output_filename_config = ConfigParser.ConfigParser() + self._output_filename_config.read(self.config_filename) + if not self._output_filename_config.has_section('usrp_rx_hrpt'): + self._output_filename_config.add_section('usrp_rx_hrpt') + self._output_filename_config.set('usrp_rx_hrpt', 'filename', str(self.output_filename)) + self._output_filename_config.write(open(self.config_filename, 'w')) def set_decim(self, decim): self.decim = decim self.set_sample_rate(64e6/self.decim) + self.usrp_source.set_decim_rate(self.decim) self._decim_config = ConfigParser.ConfigParser() self._decim_config.read(self.config_filename) if not self._decim_config.has_section('usrp_rx_hrpt'): self._decim_config.add_section('usrp_rx_hrpt') self._decim_config.set('usrp_rx_hrpt', 'decim', str(self.decim)) self._decim_config.write(open(self.config_filename, 'w')) - self.usrp_source.set_decim_rate(self.decim) def set_sym_rate(self, sym_rate): self.sym_rate = sym_rate @@ -175,14 +175,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): def set_pll_alpha(self, pll_alpha): self.pll_alpha = pll_alpha + self.pll.set_alpha(self.pll_alpha) + self.pll.set_beta(self.pll_alpha**2/4.0) self._pll_alpha_config = ConfigParser.ConfigParser() self._pll_alpha_config.read(self.config_filename) if not self._pll_alpha_config.has_section('usrp_rx_hrpt'): self._pll_alpha_config.add_section('usrp_rx_hrpt') self._pll_alpha_config.set('usrp_rx_hrpt', 'pll_alpha', str(self.pll_alpha)) self._pll_alpha_config.write(open(self.config_filename, 'w')) - self.pll.set_alpha(self.pll_alpha) - self.pll.set_beta(self.pll_alpha**2/4.0) def set_output_filename(self, output_filename): self.output_filename = output_filename @@ -226,14 +226,14 @@ class usrp_rx_hrpt_nogui(gr.top_block): def set_clock_alpha(self, clock_alpha): self.clock_alpha = clock_alpha + self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) + self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) self._clock_alpha_config = ConfigParser.ConfigParser() self._clock_alpha_config.read(self.config_filename) if not self._clock_alpha_config.has_section('usrp_rx_hrpt'): self._clock_alpha_config.add_section('usrp_rx_hrpt') self._clock_alpha_config.set('usrp_rx_hrpt', 'clock_alpha', str(self.clock_alpha)) self._clock_alpha_config.write(open(self.config_filename, 'w')) - self.gr_clock_recovery_mm_xx_0.set_gain_omega(self.clock_alpha**2/4.0) - self.gr_clock_recovery_mm_xx_0.set_gain_mu(self.clock_alpha) if __name__ == '__main__': parser = OptionParser(option_class=eng_option, usage="%prog: [options]") diff --git a/gr-noaa/grc/noaa_hrpt_decoder.xml b/gr-noaa/grc/noaa_hrpt_decoder.xml index 183d72aba..2d6e98c53 100644 --- a/gr-noaa/grc/noaa_hrpt_decoder.xml +++ b/gr-noaa/grc/noaa_hrpt_decoder.xml @@ -4,7 +4,20 @@ <key>noaa_hrpt_decoder</key> <category>NOAA</category> <import>from gnuradio import noaa</import> - <make>noaa.hrpt_decoder()</make> + <make>noaa.hrpt_decoder($verbose,$output)</make> + + <param> + <name>Verbose</name> + <key>verbose</key> + <type>bool</type> + </param> + + <param> + <name>Output Files</name> + <key>output</key> + <type>bool</type> + </param> + <sink> <name>in</name> <type>short</type> diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 4ef4eb87b..f01bbfab8 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -33,6 +33,9 @@ libgnuradio_noaa_la_SOURCES = \ noaa_hrpt_deframer.cc \ noaa_hrpt_pll_cf.cc +noinst_HEADERS = \ + noaa_hrpt.h + libgnuradio_noaa_la_LIBADD = \ $(GNURADIO_CORE_LA) diff --git a/gr-noaa/lib/noaa_hrpt.h b/gr-noaa/lib/noaa_hrpt.h new file mode 100644 index 000000000..3812e9368 --- /dev/null +++ b/gr-noaa/lib/noaa_hrpt.h @@ -0,0 +1,39 @@ +/* -*- 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_H +#define INCLUDED_NOAA_HRPT_H + +#define HRPT_SYNC1 0x0284 +#define HRPT_SYNC2 0x016F +#define HRPT_SYNC3 0x035C +#define HRPT_SYNC4 0x019D +#define HRPT_SYNC5 0x020F +#define HRPT_SYNC6 0x0095 + +#define HRPT_MINOR_FRAME_SYNC 0x0A116FD719D83C95LL + +#define HRPT_SYNC_WORDS 6 +#define HRPT_MINOR_FRAME_WORDS 11090 +#define HRPT_BITS_PER_WORD 10 + +#endif /* INCLUDED_NOAA_HRPT_H */ diff --git a/gr-noaa/lib/noaa_hrpt_decoder.cc b/gr-noaa/lib/noaa_hrpt_decoder.cc index 8cfaa913c..243310089 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.cc +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -25,27 +25,52 @@ #endif #include <noaa_hrpt_decoder.h> +#include <noaa_hrpt.h> #include <gr_io_signature.h> +#include <cstdio> -#define SYNC1 0x0284 -#define SYNC2 0x016F -#define SYNC3 0x035C -#define SYNC4 0x019D -#define SYNC5 0x020F -#define SYNC6 0x0095 +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() +noaa_make_hrpt_decoder(bool verbose, bool output_files) { - return gnuradio::get_initial_sptr(new noaa_hrpt_decoder()); + return gnuradio::get_initial_sptr(new noaa_hrpt_decoder(verbose, output_files)); } -noaa_hrpt_decoder::noaa_hrpt_decoder() +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)) + 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) { - d_word_count = 0; + // Start of capture processing here } int @@ -57,21 +82,119 @@ noaa_hrpt_decoder::work(int noutput_items, 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); + 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; } - //fprintf(stderr, "\n"); - if (d_word_count == 11090) { - d_word_count = 0; - //fprintf(stderr, "\n"); + 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 index 305243b09..9d67d7108 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.h +++ b/gr-noaa/lib/noaa_hrpt_decoder.h @@ -29,16 +29,45 @@ class noaa_hrpt_decoder; typedef boost::shared_ptr<noaa_hrpt_decoder> noaa_hrpt_decoder_sptr; noaa_hrpt_decoder_sptr -noaa_make_hrpt_decoder(); +noaa_make_hrpt_decoder(bool verbose, bool output_files); class noaa_hrpt_decoder : public gr_sync_block { - friend noaa_hrpt_decoder_sptr noaa_make_hrpt_decoder(); - noaa_hrpt_decoder(); + friend 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(); - unsigned int d_word_count; - public: + ~noaa_hrpt_decoder(); + int work(int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); diff --git a/gr-noaa/lib/noaa_hrpt_deframer.cc b/gr-noaa/lib/noaa_hrpt_deframer.cc index e79894869..1a2af6c37 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -26,23 +26,13 @@ #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 -#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() { @@ -98,13 +88,12 @@ noaa_hrpt_deframer::general_work(int noutput_items, 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; + 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; @@ -116,7 +105,6 @@ noaa_hrpt_deframer::general_work(int noutput_items, d_word = 0; d_bit_count = HRPT_BITS_PER_WORD; if (--d_word_count == 0) { - fprintf(stderr, "...done\n"); enter_idle(); } } diff --git a/gr-noaa/lib/noaa_hrpt_deframer.h b/gr-noaa/lib/noaa_hrpt_deframer.h index 43abba0e9..b11d0fa2b 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.h +++ b/gr-noaa/lib/noaa_hrpt_deframer.h @@ -23,10 +23,6 @@ #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; diff --git a/gr-noaa/oct/frames_to_ppm.m b/gr-noaa/oct/frames_to_ppm.m index aeb22faac..73842f0a9 100644 --- a/gr-noaa/oct/frames_to_ppm.m +++ b/gr-noaa/oct/frames_to_ppm.m @@ -23,7 +23,7 @@ % Extract AVHRR images from HRPT frames.dat clear -fid = fopen('frames.dat'); +fid = fopen('frames.hrpt'); dat = fread(fid, 'uint16'); frame_len = 11090; diff --git a/gr-noaa/swig/noaa_hrpt_decoder.i b/gr-noaa/swig/noaa_hrpt_decoder.i index ddf181c28..220a5714d 100644 --- a/gr-noaa/swig/noaa_hrpt_decoder.i +++ b/gr-noaa/swig/noaa_hrpt_decoder.i @@ -23,7 +23,7 @@ GR_SWIG_BLOCK_MAGIC(noaa,hrpt_decoder) noaa_hrpt_decoder_sptr -noaa_make_hrpt_decoder(); +noaa_make_hrpt_decoder(bool verbose, bool output_files); class noaa_hrpt_decoder : public gr_sync_block { -- cgit