From 36e3aa66a65d247d8e5b8bc23690c6e28234fddb Mon Sep 17 00:00:00 2001 From: George Vardakis Date: Mon, 7 Aug 2017 14:28:40 +0300 Subject: [PATCH] Change filename on noaa to match new satnogs-client naming --- .../satellites/noaa_apt_decoder.grc | 230 +++++++++++++++++- .../satellites/satnogs_noaa_apt_decoder.py | 51 +++- lib/noaa_apt_sink_impl.cc | 25 +- lib/noaa_apt_sink_impl.h | 1 + 4 files changed, 277 insertions(+), 30 deletions(-) diff --git a/apps/flowgraphs/satellites/noaa_apt_decoder.grc b/apps/flowgraphs/satellites/noaa_apt_decoder.grc index 92c2ea8..f8f3334 100644 --- a/apps/flowgraphs/satellites/noaa_apt_decoder.grc +++ b/apps/flowgraphs/satellites/noaa_apt_decoder.grc @@ -521,7 +521,7 @@ TX sampling rate _coordinate - (1014, 263) + (1040, 360) _rotation @@ -544,6 +544,49 @@ TX sampling rate 1 + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (183, 547) + + + _rotation + 0 + + + id + decoded_data_file_path + + + label + + + + short_id + + + + type + string + + + value + /tmp/.satnogs/data/noaa + + parameter @@ -630,6 +673,49 @@ TX sampling rate 20 + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (184, 796) + + + _rotation + 0 + + + id + enable_iq_dump + + + label + + + + short_id + + + + type + intx + + + value + 0 + + fft_filter_xxx @@ -650,7 +736,7 @@ TX sampling rate _enabled - True + 1 _coordinate @@ -854,7 +940,7 @@ TX sampling rate _enabled - True + 1 _coordinate @@ -913,7 +999,7 @@ TX sampling rate _coordinate - (1262, 259) + (1264, 356) _rotation @@ -999,7 +1085,7 @@ TX sampling rate _coordinate - (183, 547) + (296, 796) _rotation @@ -1007,7 +1093,7 @@ TX sampling rate id - image_file_path + iq_file_path label @@ -1023,7 +1109,7 @@ TX sampling rate value - /tmp/noaa.png + /tmp/iq.dat @@ -2607,7 +2693,7 @@ we shift the LO a little further _coordinate - (815, 239) + (824, 336) _rotation @@ -2658,7 +2744,7 @@ we shift the LO a little further _enabled - True + 1 fbw @@ -2697,6 +2783,65 @@ we shift the LO a little further fff + + rational_resampler_xxx + + alias + + + + comment + + + + affinity + + + + decim + int(samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation) + + + _enabled + True + + + fbw + 0 + + + _coordinate + (896, 232) + + + _rotation + 0 + + + id + rational_resampler_xxx_2 + + + interp + 48000 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + taps + + + + type + ccc + + parameter @@ -2916,6 +3061,53 @@ we shift the LO a little further rx_freq + + satnogs_iq_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + filename + iq_file_path + + + _coordinate + (1112, 236) + + + _rotation + 0 + + + id + satnogs_iq_sink_0 + + + scale + 32767 + + + status + enable_iq_dump + + satnogs_noaa_apt_sink @@ -2940,7 +3132,7 @@ we shift the LO a little further _coordinate - (575, 243) + (520, 320) _rotation @@ -2952,7 +3144,7 @@ we shift the LO a little further filename_png - image_file_path + decoded_data_file_path height @@ -2987,7 +3179,7 @@ we shift the LO a little further _enabled - True + 1 filename @@ -3093,7 +3285,7 @@ we shift the LO a little further _enabled - True + 1 fft_size @@ -3287,6 +3479,12 @@ we shift the LO a little further 0 0 + + fft_filter_xxx_0 + rational_resampler_xxx_2 + 0 + 0 + fir_filter_xxx_1 rational_resampler_xxx_0 @@ -3329,6 +3527,12 @@ we shift the LO a little further 0 0 + + rational_resampler_xxx_2 + satnogs_iq_sink_0 + 0 + 0 + satnogs_coarse_doppler_correction_cc_0 fft_filter_xxx_0 diff --git a/apps/flowgraphs/satellites/satnogs_noaa_apt_decoder.py b/apps/flowgraphs/satellites/satnogs_noaa_apt_decoder.py index dd51513..eb90877 100755 --- a/apps/flowgraphs/satellites/satnogs_noaa_apt_decoder.py +++ b/apps/flowgraphs/satellites/satnogs_noaa_apt_decoder.py @@ -5,7 +5,7 @@ # Title: NOAA APT Decoder # Author: Manolis Surligas, George Vardakis # Description: A NOAA APT Decoder with automatic image synchronization -# Generated: Fri Aug 4 19:19:48 2017 +# Generated: Wed Aug 9 18:06:52 2017 ################################################## from gnuradio import analog @@ -23,7 +23,7 @@ import time class satnogs_noaa_apt_decoder(gr.top_block): - def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, file_path='/tmp/test.ogg', flip_images=0, if_gain=satnogs.not_set_rx_if_gain, image_file_path='/tmp/noaa.png', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=90.4e6, rx_sdr_device='usrpb200', split_images=0, sync=1, waterfall_file_path='/tmp/waterfall.dat'): + def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/tmp/.satnogs/data/noaa', dev_args=satnogs.not_set_dev_args, doppler_correction_per_sec=20, enable_iq_dump=0, file_path='/tmp/test.ogg', flip_images=0, if_gain=satnogs.not_set_rx_if_gain, iq_file_path='/tmp/iq.dat', lo_offset=100e3, ppm=0, rf_gain=satnogs.not_set_rx_rf_gain, rigctl_port=4532, rx_freq=90.4e6, rx_sdr_device='usrpb200', split_images=0, sync=1, waterfall_file_path='/tmp/waterfall.dat'): gr.top_block.__init__(self, "NOAA APT Decoder") ################################################## @@ -31,12 +31,14 @@ class satnogs_noaa_apt_decoder(gr.top_block): ################################################## self.antenna = antenna self.bb_gain = bb_gain + self.decoded_data_file_path = decoded_data_file_path self.dev_args = dev_args self.doppler_correction_per_sec = doppler_correction_per_sec + self.enable_iq_dump = enable_iq_dump self.file_path = file_path self.flip_images = flip_images self.if_gain = if_gain - self.image_file_path = image_file_path + self.iq_file_path = iq_file_path self.lo_offset = lo_offset self.ppm = ppm self.rf_gain = rf_gain @@ -67,8 +69,15 @@ class satnogs_noaa_apt_decoder(gr.top_block): self.satnogs_waterfall_sink_0 = satnogs.waterfall_sink(samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)), 0.0, 8, 1024, waterfall_file_path, 0) self.satnogs_tcp_rigctl_msg_source_0 = satnogs.tcp_rigctl_msg_source("127.0.0.1", rigctl_port, False, 1000/doppler_correction_per_sec, 1500) self.satnogs_ogg_encoder_0 = satnogs.ogg_encoder(file_path, 48000, 0.8) - self.satnogs_noaa_apt_sink_0 = satnogs.noaa_apt_sink(image_file_path, 2080, 1500, bool(split_images), bool(sync), bool(flip_images)) + self.satnogs_noaa_apt_sink_0 = satnogs.noaa_apt_sink(decoded_data_file_path, 2080, 1500, bool(split_images), bool(sync), bool(flip_images)) + self.satnogs_iq_sink_0 = satnogs.iq_sink(32767, iq_file_path, False, enable_iq_dump) self.satnogs_coarse_doppler_correction_cc_0 = satnogs.coarse_doppler_correction_cc(rx_freq, samp_rate_rx /first_stage_decimation) + self.rational_resampler_xxx_2 = filter.rational_resampler_ccc( + interpolation=48000, + decimation=int(samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation), + taps=None, + fractional_bw=None, + ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=48000, decimation=int(samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation), @@ -123,6 +132,7 @@ class satnogs_noaa_apt_decoder(gr.top_block): self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.analog_wfm_rcv_0, 0)) + self.connect((self.fft_filter_xxx_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.satnogs_coarse_doppler_correction_cc_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_mag_0, 0)) @@ -130,6 +140,7 @@ class satnogs_noaa_apt_decoder(gr.top_block): self.connect((self.rational_resampler_xxx_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.satnogs_noaa_apt_sink_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.satnogs_ogg_encoder_0, 0)) + self.connect((self.rational_resampler_xxx_2, 0), (self.satnogs_iq_sink_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.satnogs_coarse_doppler_correction_cc_0, 0), (self.satnogs_waterfall_sink_0, 0)) @@ -147,6 +158,12 @@ class satnogs_noaa_apt_decoder(gr.top_block): self.bb_gain = bb_gain self.osmosdr_source_0.set_bb_gain(satnogs.handle_rx_bb_gain(self.rx_sdr_device, self.bb_gain), 0) + def get_decoded_data_file_path(self): + return self.decoded_data_file_path + + def set_decoded_data_file_path(self, decoded_data_file_path): + self.decoded_data_file_path = decoded_data_file_path + def get_dev_args(self): return self.dev_args @@ -159,6 +176,12 @@ class satnogs_noaa_apt_decoder(gr.top_block): def set_doppler_correction_per_sec(self, doppler_correction_per_sec): self.doppler_correction_per_sec = doppler_correction_per_sec + def get_enable_iq_dump(self): + return self.enable_iq_dump + + def set_enable_iq_dump(self, enable_iq_dump): + self.enable_iq_dump = enable_iq_dump + def get_file_path(self): return self.file_path @@ -178,11 +201,11 @@ class satnogs_noaa_apt_decoder(gr.top_block): self.if_gain = if_gain self.osmosdr_source_0.set_if_gain(satnogs.handle_rx_if_gain(self.rx_sdr_device, self.if_gain), 0) - def get_image_file_path(self): - return self.image_file_path + def get_iq_file_path(self): + return self.iq_file_path - def set_image_file_path(self, image_file_path): - self.image_file_path = image_file_path + def set_iq_file_path(self, iq_file_path): + self.iq_file_path = iq_file_path def get_lo_offset(self): return self.lo_offset @@ -303,12 +326,18 @@ def argument_parser(): parser.add_option( "", "--bb-gain", dest="bb_gain", type="eng_float", default=eng_notation.num_to_str(satnogs.not_set_rx_bb_gain), help="Set bb_gain [default=%default]") + parser.add_option( + "", "--decoded-data-file-path", dest="decoded_data_file_path", type="string", default='/tmp/.satnogs/data/noaa', + help="Set decoded_data_file_path [default=%default]") parser.add_option( "", "--dev-args", dest="dev_args", type="string", default=satnogs.not_set_dev_args, help="Set dev_args [default=%default]") parser.add_option( "", "--doppler-correction-per-sec", dest="doppler_correction_per_sec", type="intx", default=20, help="Set doppler_correction_per_sec [default=%default]") + parser.add_option( + "", "--enable-iq-dump", dest="enable_iq_dump", type="intx", default=0, + help="Set enable_iq_dump [default=%default]") parser.add_option( "", "--file-path", dest="file_path", type="string", default='/tmp/test.ogg', help="Set file_path [default=%default]") @@ -319,8 +348,8 @@ def argument_parser(): "", "--if-gain", dest="if_gain", type="eng_float", default=eng_notation.num_to_str(satnogs.not_set_rx_if_gain), help="Set if_gain [default=%default]") parser.add_option( - "", "--image-file-path", dest="image_file_path", type="string", default='/tmp/noaa.png', - help="Set image_file_path [default=%default]") + "", "--iq-file-path", dest="iq_file_path", type="string", default='/tmp/iq.dat', + help="Set iq_file_path [default=%default]") parser.add_option( "", "--lo-offset", dest="lo_offset", type="eng_float", default=eng_notation.num_to_str(100e3), help="Set lo_offset [default=%default]") @@ -355,7 +384,7 @@ def main(top_block_cls=satnogs_noaa_apt_decoder, options=None): if options is None: options, _ = argument_parser().parse_args() - tb = top_block_cls(antenna=options.antenna, bb_gain=options.bb_gain, dev_args=options.dev_args, doppler_correction_per_sec=options.doppler_correction_per_sec, file_path=options.file_path, flip_images=options.flip_images, if_gain=options.if_gain, image_file_path=options.image_file_path, lo_offset=options.lo_offset, ppm=options.ppm, rf_gain=options.rf_gain, rigctl_port=options.rigctl_port, rx_freq=options.rx_freq, rx_sdr_device=options.rx_sdr_device, split_images=options.split_images, sync=options.sync, waterfall_file_path=options.waterfall_file_path) + tb = top_block_cls(antenna=options.antenna, bb_gain=options.bb_gain, decoded_data_file_path=options.decoded_data_file_path, dev_args=options.dev_args, doppler_correction_per_sec=options.doppler_correction_per_sec, enable_iq_dump=options.enable_iq_dump, file_path=options.file_path, flip_images=options.flip_images, if_gain=options.if_gain, iq_file_path=options.iq_file_path, lo_offset=options.lo_offset, ppm=options.ppm, rf_gain=options.rf_gain, rigctl_port=options.rigctl_port, rx_freq=options.rx_freq, rx_sdr_device=options.rx_sdr_device, split_images=options.split_images, sync=options.sync, waterfall_file_path=options.waterfall_file_path) tb.start() tb.wait() diff --git a/lib/noaa_apt_sink_impl.cc b/lib/noaa_apt_sink_impl.cc index 3fd1a68..2c0c3b5 100644 --- a/lib/noaa_apt_sink_impl.cc +++ b/lib/noaa_apt_sink_impl.cc @@ -92,14 +92,27 @@ namespace gr void noaa_apt_sink_impl::init_png () { + /* check for the current UTC time */ + std::chrono::system_clock::time_point p2 = + std::chrono::system_clock::now (); + + char buffer[30]; + std::time_t t2 = std::chrono::system_clock::to_time_t (p2); + struct tm * timeinfo; + timeinfo = std::gmtime (&t2); + + std::strftime (buffer, 30, "%FT%H-%M-%S", timeinfo); + std::string fn (d_filename_png); + fn.append("_"); + fn.append(buffer); + fn.append(".png"); if (d_split) { d_images_per_frame = 2; d_png_fd = new FILE*[2]; d_png_ptr = new png_structp[2]; d_info_ptr = new png_infop[2]; - std::string fn (d_filename_png); - std::string fn_left (d_filename_png); - std::string fn_right (d_filename_png); + std::string fn_left = fn; + std::string fn_right = fn; std::size_t found = fn.find_last_of ("."); if (d_num_images == 0) { if (found == std::string::npos) { @@ -162,11 +175,11 @@ namespace gr d_png_ptr = new png_structp[2]; d_info_ptr = new png_infop[2]; if (d_num_images == 0) { - d_png_fd[0] = fopen (d_filename_png, "wb"); - d_png_fn[0] = std::string (d_filename_png); + d_png_fd[0] = fopen (fn.c_str (), "wb"); + d_png_fn[0] = fn;//std::string (d_filename_png); } else { - std::string fn (d_filename_png); + //std::string fn (d_filename_png); std::size_t found = fn.find ("."); if (found == std::string::npos) { fn.append (std::to_string (d_num_images)); diff --git a/lib/noaa_apt_sink_impl.h b/lib/noaa_apt_sink_impl.h index 6dab2a8..4612419 100644 --- a/lib/noaa_apt_sink_impl.h +++ b/lib/noaa_apt_sink_impl.h @@ -24,6 +24,7 @@ #include #define PNG_DEBUG 3 #include +#include namespace gr {