From: Johnathan Corgan Date: Fri, 6 Nov 2009 19:21:08 +0000 (-0800) Subject: gr-noaa: added HRPT minor frame parsing, renamed scripts X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=4e0c8a37c3574f59e34186996cef0c44ff50bd16;p=debian%2Fgnuradio 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 --- diff --git a/gr-noaa/README b/gr-noaa/README index 29d11f59..f00d2d28 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 6bd1ab99..cd8d543c 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 961b09af..e246ba76 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 3c5e3efa..00000000 --- a/gr-noaa/apps/demod_hrpt_file.grc +++ /dev/null @@ -1,774 +0,0 @@ - - - Mon Nov 2 07:06:57 2009 - - options - - id - demod_hrpt_file - - - _enabled - True - - - title - - - - author - - - - description - - - - window_size - 4096,4096 - - - generate_options - no_gui - - - category - Custom - - - run_options - run - - - run - True - - - realtime_scheduling - - - - _coordinate - (10, 10) - - - _rotation - 0 - - - - variable - - id - max_carrier_offset - - - _enabled - True - - - value - 2*math.pi*100e3/sample_rate - - - _coordinate - (575, 19) - - - _rotation - 0 - - - - variable - - id - sym_rate - - - _enabled - True - - - value - 600*1109 - - - _coordinate - (301, 19) - - - _rotation - 0 - - - - variable - - id - sps - - - _enabled - True - - - value - sample_rate/sym_rate - - - _coordinate - (397, 19) - - - _rotation - 0 - - - - variable - - id - hs - - - _enabled - True - - - value - int(sps/2.0) - - - _coordinate - (499, 19) - - - _rotation - 0 - - - - variable - - id - sample_rate - - - _enabled - True - - - value - 64e6/decim - - - _coordinate - (198, 17) - - - _rotation - 0 - - - - variable - - id - max_clock_offset - - - _enabled - True - - - value - 0.1 - - - _coordinate - (710, 17) - - - _rotation - 0 - - - - import - - id - import_0 - - - _enabled - True - - - import - import math, os - - - _coordinate - (11, 103) - - - _rotation - 0 - - - - parameter - - id - decim - - - _enabled - True - - - label - decim - - - value - 16 - - - type - intx - - - short_id - d - - - _coordinate - (202, 102) - - - _rotation - 0 - - - - parameter - - id - pll_alpha - - - _enabled - True - - - label - pll_alpha - - - value - 0.05 - - - type - eng_float - - - short_id - p - - - _coordinate - (294, 101) - - - _rotation - 0 - - - - parameter - - id - clock_alpha - - - _enabled - True - - - label - clock_alpha - - - value - 0.05 - - - type - eng_float - - - short_id - a - - - _coordinate - (395, 101) - - - _rotation - 0 - - - - parameter - - id - sync_alpha - - - _enabled - True - - - label - sync_alpha - - - value - 0.05 - - - type - eng_float - - - short_id - s - - - _coordinate - (508, 102) - - - _rotation - 0 - - - - parameter - - id - input_filename - - - _enabled - True - - - label - input_filename - - - value - usrp.dat - - - type - string - - - short_id - F - - - _coordinate - (618, 102) - - - _rotation - 0 - - - - parameter - - id - output_filename - - - _enabled - True - - - label - output_filename - - - value - frames.dat - - - type - string - - - short_id - o - - - _coordinate - (726, 102) - - - _rotation - 180 - - - - gr_file_source - - id - file_source - - - _enabled - True - - - file - input_filename - - - type - short - - - repeat - False - - - vlen - 1 - - - _coordinate - (62, 306) - - - _rotation - 0 - - - - gr_interleaved_short_to_complex - - id - cs2cf - - - _enabled - True - - - _coordinate - (297, 318) - - - _rotation - 0 - - - - gr_agc_xx - - id - agc - - - _enabled - True - - - type - complex - - - rate - 1e-5 - - - reference - 1.0 - - - gain - 1.0/32768.0 - - - max_gain - 1.0 - - - _coordinate - (538, 290) - - - _rotation - 0 - - - - noaa_hrpt_pll_cf - - id - pll - - - _enabled - True - - - alpha - pll_alpha - - - beta - pll_alpha**2/4.0 - - - max_offset - max_carrier_offset - - - _coordinate - (720, 297) - - - _rotation - 0 - - - - gr_moving_average_xx - - id - gr_moving_average_xx_0 - - - _enabled - True - - - type - float - - - length - hs - - - scale - 1.0/hs - - - max_iter - 4000 - - - _coordinate - (949, 297) - - - _rotation - 0 - - - - gr_clock_recovery_mm_xx - - id - gr_clock_recovery_mm_xx_0 - - - _enabled - True - - - type - float - - - omega - sps/2.0 - - - gain_omega - clock_alpha**2/4.0 - - - mu - 0.5 - - - gain_mu - clock_alpha - - - omega_relative_limit - max_clock_offset - - - _coordinate - (1158, 281) - - - _rotation - 0 - - - - gr_file_sink - - id - gr_file_sink_0 - - - _enabled - True - - - file - output_filename - - - type - short - - - vlen - 1 - - - _coordinate - (732, 615) - - - _rotation - 0 - - - - noaa_hrpt_decoder - - id - noaa_hrpt_decoder_0 - - - _enabled - True - - - _coordinate - (730, 537) - - - _rotation - 0 - - - - gr_binary_slicer_fb - - id - gr_binary_slicer_fb_0 - - - _enabled - True - - - _coordinate - (112, 537) - - - _rotation - 0 - - - - noaa_hrpt_deframer - - id - noaa_hrpt_deframer_0 - - - _enabled - True - - - _coordinate - (536, 537) - - - _rotation - 0 - - - - file_source - cs2cf - 0 - 0 - - - gr_clock_recovery_mm_xx_0 - gr_binary_slicer_fb_0 - 0 - 0 - - - gr_moving_average_xx_0 - gr_clock_recovery_mm_xx_0 - 0 - 0 - - - pll - gr_moving_average_xx_0 - 0 - 0 - - - cs2cf - agc - 0 - 0 - - - agc - pll - 0 - 0 - - - noaa_hrpt_deframer_0 - gr_file_sink_0 - 0 - 0 - - - noaa_hrpt_deframer_0 - noaa_hrpt_decoder_0 - 0 - 0 - - - gr_binary_slicer_fb_0 - noaa_hrpt_deframer_0 - 0 - 0 - - diff --git a/gr-noaa/apps/demod_hrpt_file.py b/gr-noaa/apps/demod_hrpt_file.py deleted file mode 100755 index d8665017..00000000 --- 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 f3414375..e3cccd39 100644 --- a/gr-noaa/apps/file_rx_hrpt.grc +++ b/gr-noaa/apps/file_rx_hrpt.grc @@ -1,6 +1,6 @@ - Mon Nov 2 08:30:47 2009 + Mon Nov 9 07:47:17 2009 options @@ -56,29 +56,6 @@ 0 - - variable - - id - max_carrier_offset - - - _enabled - True - - - value - 2*math.pi*100e3/sample_rate - - - _coordinate - (575, 19) - - - _rotation - 0 - - variable @@ -125,29 +102,6 @@ 0 - - variable - - id - hs - - - _enabled - True - - - value - int(sps/2.0) - - - _coordinate - (499, 19) - - - _rotation - 0 - - variable @@ -171,103 +125,6 @@ 0 - - variable - - id - max_clock_offset - - - _enabled - True - - - value - 0.1 - - - _coordinate - (705, 19) - - - _rotation - 0 - - - - variable_config - - id - side - - - _enabled - True - - - value - 'A' - - - type - string - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'side' - - - writeback - side - - - _coordinate - (194, 253) - - - _rotation - 0 - - - - gr_file_sink - - id - frame_sink - - - _enabled - True - - - file - output_filename - - - type - short - - - vlen - 1 - - - _coordinate - (973, 1024) - - - _rotation - 0 - - virtual_source @@ -490,25 +347,6 @@ 0 - - noaa_hrpt_decoder - - id - decoder - - - _enabled - True - - - _coordinate - (974, 925) - - - _rotation - 0 - - variable @@ -614,22 +452,26 @@ - gr_throttle + gr_file_source id - throttle + gr_file_source_0 _enabled True + + file + input_filename + type short - samples_per_second - sample_rate + repeat + False vlen @@ -637,46 +479,183 @@ _coordinate - (75, 679) + (76, 613) _rotation - 180 + 0 - gr_file_source + notebook id - gr_file_source_0 + displays _enabled True - file - input_filename + style + wx.NB_TOP + + + labels + ['Spectrum','Demod'] + + + grid_pos + 1,0,1,2 + + + notebook + + + + _coordinate + (12, 249) + + + _rotation + 0 + + + + wxgui_fftsink2 + + id + rx_fft + + + _enabled + True type - short + complex - repeat + title + RX Spectrum + + + samp_rate + sample_rate + + + baseband_freq + 0 + + + y_per_div + 5 + + + y_divs + 8 + + + ref_level + -5 + + + ref_scale + 2.0 + + + fft_size + 1024 + + + fft_rate + 15 + + + peak_hold False + + average + True + + + avg_alpha + 0.1 + + + win + None + + + win_size + 640, 360 + + + grid_pos + 0, 0, 1, 1 + + + notebook + displays, 0 + + + _coordinate + (471, 450) + + + _rotation + 0 + + + + gr_binary_slicer_fb + + id + gr_binary_slicer_fb_0 + + + _enabled + True + + + _coordinate + (393, 975) + + + _rotation + 0 + + + + gr_throttle + + id + throttle + + + _enabled + True + + + type + short + + + samples_per_second + 2*sample_rate + vlen 1 _coordinate - (76, 613) + (75, 679) _rotation - 0 + 180 @@ -695,7 +674,7 @@ value - 'usrp.dat' + usrp.dat type @@ -707,7 +686,7 @@ _coordinate - (198, 107) + (196, 98) _rotation @@ -730,7 +709,7 @@ value - 16 + 32 type @@ -742,7 +721,7 @@ _coordinate - (308, 107) + (307, 98) _rotation @@ -797,7 +776,7 @@ _coordinate - (397, 108) + (397, 98) _rotation @@ -852,7 +831,7 @@ _coordinate - (539, 105) + (540, 98) _rotation @@ -860,10 +839,10 @@ - variable_config + variable id - saved_pll_alpha + hs _enabled @@ -871,31 +850,11 @@ value - 0.05 - - - type - real - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'pll_alpha' - - - writeback - pll_alpha + int(sps/2.0) _coordinate - (363, 254) + (499, 19) _rotation @@ -903,10 +862,10 @@ - variable_config + variable id - saved_clock_alpha + max_carrier_offset _enabled @@ -914,31 +873,34 @@ value - 0.05 + 2*math.pi*100e3/sample_rate - type - real + _coordinate + (575, 19) - config_file - config_filename + _rotation + 0 + + + variable - section - 'usrp_rx_hrpt' + id + max_clock_offset - option - 'clock_alpha' + _enabled + True - writeback - clock_alpha + value + 100e-6 _coordinate - (527, 256) + (705, 19) _rotation @@ -957,7 +919,7 @@ value - 'frames.dat' + 'frames.hrpt' type @@ -981,7 +943,7 @@ _coordinate - (689, 257) + (521, 254) _rotation @@ -989,34 +951,42 @@ - notebook + variable_config id - displays + saved_pll_alpha _enabled True - style - wx.NB_TOP + value + 0.01 - labels - ['Spectrum','Demod'] + type + real - grid_pos - 1,0,1,2 + config_file + config_filename - notebook - + section + 'usrp_rx_hrpt' + + + option + 'pll_alpha' + + + writeback + pll_alpha _coordinate - (12, 249) + (195, 253) _rotation @@ -1024,86 +994,88 @@ - wxgui_fftsink2 + variable_config id - rx_fft + saved_clock_alpha _enabled True - type - complex - - - title - RX Spectrum + value + 0.01 - samp_rate - sample_rate + type + real - baseband_freq - 0 + config_file + config_filename - y_per_div - 5 + section + 'usrp_rx_hrpt' - y_divs - 8 + option + 'clock_alpha' - ref_level - -5 + writeback + clock_alpha - ref_scale - 2.0 + _coordinate + (360, 255) - fft_size - 1024 + _rotation + 0 + + + noaa_hrpt_deframer - fft_rate - 15 + id + deframer - peak_hold - False + _enabled + True - average - True + _coordinate + (579, 975) - avg_alpha - 0.1 + _rotation + 0 + + + noaa_hrpt_decoder - win - None + id + decoder - win_size - 640, 360 + _enabled + True - grid_pos - 0, 0, 1, 1 + verbose + True - notebook - displays, 0 + output + False _coordinate - (471, 450) + (849, 925) _rotation @@ -1111,37 +1083,30 @@ - gr_binary_slicer_fb + gr_file_sink id - gr_binary_slicer_fb_0 + frame_sink _enabled True - _coordinate - (393, 975) - - - _rotation - 0 + file + output_filename - - - noaa_hrpt_deframer - id - deframer + type + short - _enabled - True + vlen + 1 _coordinate - (762, 975) + (848, 1007) _rotation diff --git a/gr-noaa/apps/file_rx_hrpt.py b/gr-noaa/apps/file_rx_hrpt.py index 1513141e..13b88763 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 00000000..39fe195d --- /dev/null +++ b/gr-noaa/apps/hrpt_decode.grc @@ -0,0 +1,428 @@ + + + Sun Nov 8 10:48:59 2009 + + options + + id + hrpt_decode + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 4096,4096 + + + generate_options + no_gui + + + category + Custom + + + run_options + run + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + max_carrier_offset + + + _enabled + True + + + value + 2*math.pi*100e3/sample_rate + + + _coordinate + (575, 19) + + + _rotation + 0 + + + + variable + + id + hs + + + _enabled + True + + + value + int(sps/2.0) + + + _coordinate + (499, 19) + + + _rotation + 0 + + + + variable + + id + sample_rate + + + _enabled + True + + + value + 64e6/decim + + + _coordinate + (198, 17) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + import math, os + + + _coordinate + (11, 103) + + + _rotation + 0 + + + + variable + + id + max_clock_offset + + + _enabled + True + + + value + 100e-6 + + + _coordinate + (710, 17) + + + _rotation + 0 + + + + variable + + id + sym_rate + + + _enabled + True + + + value + 600*1109 + + + _coordinate + (307, 18) + + + _rotation + 0 + + + + variable + + id + sps + + + _enabled + True + + + value + sample_rate/sym_rate + + + _coordinate + (400, 17) + + + _rotation + 0 + + + + parameter + + id + decim + + + _enabled + True + + + label + decim + + + value + 32 + + + type + intx + + + short_id + d + + + _coordinate + (202, 102) + + + _rotation + 0 + + + + parameter + + id + pll_alpha + + + _enabled + True + + + label + pll_alpha + + + value + 0.01 + + + type + eng_float + + + short_id + p + + + _coordinate + (294, 101) + + + _rotation + 0 + + + + parameter + + id + clock_alpha + + + _enabled + True + + + label + clock_alpha + + + value + 0.01 + + + type + eng_float + + + short_id + s + + + _coordinate + (395, 101) + + + _rotation + 0 + + + + gr_file_source + + id + file_source + + + _enabled + True + + + file + input_filename + + + type + short + + + repeat + False + + + vlen + 1 + + + _coordinate + (231, 419) + + + _rotation + 0 + + + + noaa_hrpt_decoder + + id + decoder + + + _enabled + True + + + verbose + True + + + output + True + + + _coordinate + (462, 419) + + + _rotation + 0 + + + + parameter + + id + input_filename + + + _enabled + True + + + label + input_filename + + + value + frames.hrpt + + + type + string + + + short_id + F + + + _coordinate + (522, 100) + + + _rotation + 0 + + + + file_source + decoder + 0 + 0 + + diff --git a/gr-noaa/apps/hrpt_decode.py b/gr-noaa/apps/hrpt_decode.py new file mode 100755 index 00000000..158780b1 --- /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 00000000..8af3d82d --- /dev/null +++ b/gr-noaa/apps/hrpt_demod.grc @@ -0,0 +1,747 @@ + + + Sun Nov 8 10:41:07 2009 + + options + + id + hrpt_demod + + + _enabled + True + + + title + + + + author + + + + description + + + + window_size + 4096,4096 + + + generate_options + no_gui + + + category + Custom + + + run_options + run + + + run + True + + + realtime_scheduling + + + + _coordinate + (10, 10) + + + _rotation + 0 + + + + variable + + id + max_carrier_offset + + + _enabled + True + + + value + 2*math.pi*100e3/sample_rate + + + _coordinate + (575, 19) + + + _rotation + 0 + + + + variable + + id + hs + + + _enabled + True + + + value + int(sps/2.0) + + + _coordinate + (499, 19) + + + _rotation + 0 + + + + variable + + id + sample_rate + + + _enabled + True + + + value + 64e6/decim + + + _coordinate + (198, 17) + + + _rotation + 0 + + + + import + + id + import_0 + + + _enabled + True + + + import + import math, os + + + _coordinate + (11, 103) + + + _rotation + 0 + + + + parameter + + id + input_filename + + + _enabled + True + + + label + input_filename + + + value + usrp.dat + + + type + string + + + short_id + F + + + _coordinate + (618, 102) + + + _rotation + 0 + + + + parameter + + id + output_filename + + + _enabled + True + + + label + output_filename + + + value + frames.dat + + + type + string + + + short_id + o + + + _coordinate + (726, 102) + + + _rotation + 180 + + + + gr_file_source + + id + file_source + + + _enabled + True + + + file + input_filename + + + type + short + + + repeat + False + + + vlen + 1 + + + _coordinate + (63, 277) + + + _rotation + 0 + + + + gr_interleaved_short_to_complex + + id + cs2cf + + + _enabled + True + + + _coordinate + (275, 289) + + + _rotation + 0 + + + + gr_agc_xx + + id + agc + + + _enabled + True + + + type + complex + + + rate + 1e-5 + + + reference + 1.0 + + + gain + 1.0/32768.0 + + + max_gain + 1.0 + + + _coordinate + (117, 394) + + + _rotation + 0 + + + + noaa_hrpt_pll_cf + + id + pll + + + _enabled + True + + + alpha + pll_alpha + + + beta + pll_alpha**2/4.0 + + + max_offset + max_carrier_offset + + + _coordinate + (292, 402) + + + _rotation + 0 + + + + gr_moving_average_xx + + id + gr_moving_average_xx_0 + + + _enabled + True + + + type + float + + + length + hs + + + scale + 1.0/hs + + + max_iter + 4000 + + + _coordinate + (504, 402) + + + _rotation + 0 + + + + gr_clock_recovery_mm_xx + + id + gr_clock_recovery_mm_xx_0 + + + _enabled + True + + + type + float + + + omega + sps/2.0 + + + gain_omega + clock_alpha**2/4.0 + + + mu + 0.5 + + + gain_mu + clock_alpha + + + omega_relative_limit + max_clock_offset + + + _coordinate + (703, 386) + + + _rotation + 0 + + + + noaa_hrpt_deframer + + id + noaa_hrpt_deframer_0 + + + _enabled + True + + + _coordinate + (1142, 422) + + + _rotation + 0 + + + + gr_binary_slicer_fb + + id + gr_binary_slicer_fb_0 + + + _enabled + True + + + _coordinate + (960, 422) + + + _rotation + 0 + + + + variable + + id + max_clock_offset + + + _enabled + True + + + value + 100e-6 + + + _coordinate + (710, 17) + + + _rotation + 0 + + + + variable + + id + sym_rate + + + _enabled + True + + + value + 600*1109 + + + _coordinate + (307, 18) + + + _rotation + 0 + + + + variable + + id + sps + + + _enabled + True + + + value + sample_rate/sym_rate + + + _coordinate + (400, 17) + + + _rotation + 0 + + + + parameter + + id + decim + + + _enabled + True + + + label + decim + + + value + 32 + + + type + intx + + + short_id + d + + + _coordinate + (202, 102) + + + _rotation + 0 + + + + parameter + + id + pll_alpha + + + _enabled + True + + + label + pll_alpha + + + value + 0.01 + + + type + eng_float + + + short_id + p + + + _coordinate + (294, 101) + + + _rotation + 0 + + + + parameter + + id + clock_alpha + + + _enabled + True + + + label + clock_alpha + + + value + 0.01 + + + type + eng_float + + + short_id + s + + + _coordinate + (395, 101) + + + _rotation + 0 + + + + noaa_hrpt_decoder + + id + decoder + + + _enabled + True + + + verbose + True + + + output + False + + + _coordinate + (1150, 341) + + + _rotation + 180 + + + + gr_file_sink + + id + gr_file_sink_0 + + + _enabled + True + + + file + output_filename + + + type + short + + + vlen + 1 + + + _coordinate + (1144, 489) + + + _rotation + 180 + + + + file_source + cs2cf + 0 + 0 + + + gr_clock_recovery_mm_xx_0 + gr_binary_slicer_fb_0 + 0 + 0 + + + gr_moving_average_xx_0 + gr_clock_recovery_mm_xx_0 + 0 + 0 + + + pll + gr_moving_average_xx_0 + 0 + 0 + + + cs2cf + agc + 0 + 0 + + + agc + pll + 0 + 0 + + + noaa_hrpt_deframer_0 + gr_file_sink_0 + 0 + 0 + + + noaa_hrpt_deframer_0 + decoder + 0 + 0 + + + gr_binary_slicer_fb_0 + noaa_hrpt_deframer_0 + 0 + 0 + + diff --git a/gr-noaa/apps/hrpt_demod.py b/gr-noaa/apps/hrpt_demod.py new file mode 100755 index 00000000..38d03168 --- /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 ac7a87a1..990855f6 100644 --- a/gr-noaa/apps/usrp_rx_hrpt.grc +++ b/gr-noaa/apps/usrp_rx_hrpt.grc @@ -1,6 +1,6 @@ - Mon Nov 2 08:31:09 2009 + Mon Nov 9 07:56:11 2009 options @@ -542,72 +542,6 @@ 0 - - variable_config - - id - output_filename - - - _enabled - True - - - value - 'frames.dat' - - - type - string - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'filename' - - - writeback - output_filename - - - _coordinate - (1139, 259) - - - _rotation - 0 - - - - variable - - id - max_clock_offset - - - _enabled - True - - - value - 0.1 - - - _coordinate - (705, 19) - - - _rotation - 0 - - variable_slider @@ -663,135 +597,6 @@ 0 - - variable_config - - id - saved_pll_alpha - - - _enabled - True - - - value - 0.05 - - - type - real - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'pll_alpha' - - - writeback - pll_alpha - - - _coordinate - (823, 258) - - - _rotation - 0 - - - - variable_config - - id - saved_clock_alpha - - - _enabled - True - - - value - 0.05 - - - type - real - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'clock_alpha' - - - writeback - clock_alpha - - - _coordinate - (981, 258) - - - _rotation - 0 - - - - variable_config - - id - decim - - - _enabled - True - - - value - 16 - - - type - real - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'decim' - - - writeback - decim - - - _coordinate - (351, 255) - - - _rotation - 0 - - variable_config @@ -1123,25 +928,6 @@ 0 - - noaa_hrpt_decoder - - id - decoder - - - _enabled - True - - - _coordinate - (974, 925) - - - _rotation - 0 - - gr_agc_xx @@ -1365,6 +1151,228 @@ 0 + + variable_config + + id + decim + + + _enabled + True + + + value + 32 + + + type + real + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'decim' + + + writeback + decim + + + _coordinate + (351, 255) + + + _rotation + 0 + + + + variable_config + + id + saved_pll_alpha + + + _enabled + True + + + value + 0.01 + + + type + real + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'pll_alpha' + + + writeback + pll_alpha + + + _coordinate + (823, 258) + + + _rotation + 0 + + + + variable_config + + id + saved_clock_alpha + + + _enabled + True + + + value + 0.01 + + + type + real + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'clock_alpha' + + + writeback + clock_alpha + + + _coordinate + (981, 258) + + + _rotation + 0 + + + + variable_config + + id + output_filename + + + _enabled + True + + + value + 'frames.hrpt' + + + type + string + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'filename' + + + writeback + output_filename + + + _coordinate + (1139, 259) + + + _rotation + 0 + + + + noaa_hrpt_decoder + + id + decoder + + + _enabled + True + + + verbose + True + + + output + True + + + _coordinate + (974, 925) + + + _rotation + 0 + + + + variable + + id + max_clock_offset + + + _enabled + True + + + value + 100e-6 + + + _coordinate + (705, 19) + + + _rotation + 0 + + virtual_source_0 gr_binary_slicer_fb_0 diff --git a/gr-noaa/apps/usrp_rx_hrpt.py b/gr-noaa/apps/usrp_rx_hrpt.py index a5f9a8e9..48c5f9d2 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 02d509f0..22bd3bdc 100644 --- a/gr-noaa/apps/usrp_rx_hrpt_nogui.grc +++ b/gr-noaa/apps/usrp_rx_hrpt_nogui.grc @@ -1,6 +1,6 @@ - Mon Nov 2 08:31:35 2009 + Mon Nov 9 08:03:25 2009 options @@ -171,29 +171,6 @@ 0 - - variable - - id - max_clock_offset - - - _enabled - True - - - value - 0.1 - - - _coordinate - (705, 19) - - - _rotation - 0 - - variable @@ -240,49 +217,6 @@ 0 - - variable_config - - id - clock_alpha - - - _enabled - True - - - value - 0.05 - - - type - real - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'clock_alpha' - - - writeback - clock_alpha - - - _coordinate - (986, 101) - - - _rotation - 0 - - variable_config @@ -369,135 +303,6 @@ 0 - - variable_config - - id - decim - - - _enabled - True - - - value - 16 - - - type - real - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'decim' - - - writeback - decim - - - _coordinate - (355, 97) - - - _rotation - 0 - - - - variable_config - - id - output_filename - - - _enabled - True - - - value - 'frames.dat' - - - type - string - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'filename' - - - writeback - output_filename - - - _coordinate - (1143, 101) - - - _rotation - 0 - - - - variable_config - - id - pll_alpha - - - _enabled - True - - - value - 0.05 - - - type - real - - - config_file - config_filename - - - section - 'usrp_rx_hrpt' - - - option - 'pll_alpha' - - - writeback - pll_alpha - - - _coordinate - (827, 100) - - - _rotation - 0 - - variable_config @@ -826,10 +631,10 @@ - noaa_hrpt_decoder + gr_binary_slicer_fb id - decoder + gr_binary_slicer_fb_0 _enabled @@ -837,7 +642,7 @@ _coordinate - (1027, 623) + (446, 673) _rotation @@ -845,10 +650,10 @@ - gr_binary_slicer_fb + noaa_hrpt_deframer id - gr_binary_slicer_fb_0 + deframer _enabled @@ -856,7 +661,7 @@ _coordinate - (446, 673) + (815, 673) _rotation @@ -864,18 +669,221 @@ - noaa_hrpt_deframer + variable_config id - deframer + decim _enabled True + + value + 32 + + + type + real + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'decim' + + + writeback + decim + _coordinate - (815, 673) + (355, 97) + + + _rotation + 0 + + + + variable_config + + id + pll_alpha + + + _enabled + True + + + value + 0.01 + + + type + real + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'pll_alpha' + + + writeback + pll_alpha + + + _coordinate + (827, 100) + + + _rotation + 0 + + + + variable_config + + id + clock_alpha + + + _enabled + True + + + value + 0.01 + + + type + real + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'clock_alpha' + + + writeback + clock_alpha + + + _coordinate + (986, 101) + + + _rotation + 0 + + + + variable_config + + id + output_filename + + + _enabled + True + + + value + 'frames.hrpt' + + + type + string + + + config_file + config_filename + + + section + 'usrp_rx_hrpt' + + + option + 'filename' + + + writeback + output_filename + + + _coordinate + (1143, 101) + + + _rotation + 0 + + + + variable + + id + max_clock_offset + + + _enabled + True + + + value + 100e-6 + + + _coordinate + (705, 19) + + + _rotation + 0 + + + + noaa_hrpt_decoder + + id + decoder + + + _enabled + True + + + verbose + True + + + output + True + + + _coordinate + (1027, 623) _rotation diff --git a/gr-noaa/apps/usrp_rx_hrpt_nogui.py b/gr-noaa/apps/usrp_rx_hrpt_nogui.py index 4dc32dbd..1b510bdb 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 183d72ab..2d6e98c5 100644 --- a/gr-noaa/grc/noaa_hrpt_decoder.xml +++ b/gr-noaa/grc/noaa_hrpt_decoder.xml @@ -4,7 +4,20 @@ noaa_hrpt_decoder NOAA from gnuradio import noaa - noaa.hrpt_decoder() + noaa.hrpt_decoder($verbose,$output) + + + Verbose + verbose + bool + + + + Output Files + output + bool + + in short diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index 4ef4eb87..f01bbfab 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 00000000..3812e936 --- /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 8cfaa913..24331008 100644 --- a/gr-noaa/lib/noaa_hrpt_decoder.cc +++ b/gr-noaa/lib/noaa_hrpt_decoder.cc @@ -25,27 +25,52 @@ #endif #include +#include #include +#include -#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 305243b0..9d67d710 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_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 e7989486..1a2af6c3 100644 --- a/gr-noaa/lib/noaa_hrpt_deframer.cc +++ b/gr-noaa/lib/noaa_hrpt_deframer.cc @@ -26,23 +26,13 @@ #include #include +#include #include #include #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 43abba0e..b11d0fa2 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 class noaa_hrpt_deframer; diff --git a/gr-noaa/oct/frames_to_ppm.m b/gr-noaa/oct/frames_to_ppm.m index aeb22faa..73842f0a 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 ddf181c2..220a5714 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 {