def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Blocks ################################################## self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((8e-3, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((8e-3, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/yann/Documents/INSA/5SEC/Drone/Dongle/script_grc/capture.bin", True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/yann/Documents/INSA/5SEC/Drone/Dongle/script_grc/capture.c", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_char*1, 1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-127, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-127, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_add_const_vxx_1, 0))
def __init__(self, options): gr.hier_block2.__init__(self, "ReadByteFile", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) ################################################## # Blocks ################################################## self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, options.source, False) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_char*1) self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((8e-3, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((8e-3, )) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-127, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-127, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, options.rate, True) self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self, 0))
def __init__(self, fname): super(top_block, self).__init__() self._input_filename = fname gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2400000 ################################################## # Blocks ################################################## self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, self._input_filename, False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_gr_complex * 1, self._input_filename + '.raw', False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_char * 1, 1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-127.5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-127.5, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_add_const_vxx_1, 0))
def __init__(self, samp_per_sym=4): gr.hier_block2.__init__( self, "PSK31 Modulator", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) self.samp_per_sym = samp_per_sym self.connect( self, # PSK31 defines 0 as a phase change, opposite the usual # differential encoding which is: out = (next - prev) % 2 blocks.not_bb(), blocks.and_const_bb(1), digital.diff_encoder_bb(2), blocks.char_to_float(1, 1), blocks.add_const_vff((-0.5, )), blocks.multiply_const_vff((2, )), interp_fir_filter_fff(samp_per_sym, self._envelope_taps()), blocks.float_to_complex(1), self, )
def __init__(self, Sps=4, h=[1, 1, 1, 1]): gr.hier_block2.__init__( self, "e_generador_fun_f", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float * 1), ) ################################################## # Parameters ################################################## self.Sps = Sps self.h = h ################################################## # Blocks ################################################## self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_fff(Sps, (h)) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2., )) self.blocks_int_to_float_0 = blocks.int_to_float(1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, )) self.analog_random_source_x_0 = blocks.vector_source_i( map(int, np.random.randint(0, 2, 1000000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_int_to_float_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_int_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self, 0))
def __init__(self): gr.top_block.__init__(self, "Quetzal-1 Receiver") ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.samp_rate = samp_rate = 48000 self.samp_per_sym = samp_per_sym = int(samp_rate/symb_rate) self.log = log = 0 self.homedir = homedir = "" self.hhmmss = hhmmss = "" self.gain_mu = gain_mu = 0.175*3 self.filename_raw_beacon = filename_raw_beacon = "" self.filename_parsed_beacon = filename_parsed_beacon = "" self.filename_image_metadata = filename_image_metadata = "" self.filename_image = filename_image = "" self.do_once = do_once = 0 self.data_rate = data_rate = 4800 self.count = count = 0 self.center_freq = center_freq = 437.2e6 ################################################## # Blocks ################################################## self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, 'tcp://127.0.0.1:1502', 100, False, -1) self.satellites_strip_ax25_header_0 = satellites.strip_ax25_header() self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_deframer_0 = satellites.hdlc_deframer(check_fcs=True, max_length=10000) self.quetzal1_parse = quetzal1_parse.quetzal1_parse(filename_parsed_beacon='', filename_raw_beacon='') self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, 48000, 2400, 2000, firdes.WIN_HAMMING, 6.76)) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(10, 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/dan/Documents/repos/gr-quetzal1/recordings/example_beacon_quetzal1.wav', False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) ################################################## # Connections ################################################## self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self.satellites_strip_ax25_header_0, 'in')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.quetzal1_parse, 'in')) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.satellites_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_descrambler_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.variable_slider_0 = variable_slider_0 = .846 self.test = test = .005 self.shift = shift = .906 self.samp_rate_0 = samp_rate_0 = 1.2e6 self.samp_rate = samp_rate = 1.2e6/4 self.pows = pows = 1.3 self.lpf = lpf = .724 self.go = go = 0.564 self.gm = gm = 1.61 self.centre_freq = centre_freq = 439.95e6 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate_0) self.rtlsdr_source_0.set_center_freq(439.9e6, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(20, 0) self.rtlsdr_source_0.set_if_gain(10, 0) self.rtlsdr_source_0.set_bb_gain(10, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_fff(10, firdes.low_pass( 1, samp_rate, 2.56e3*lpf, (2.56e3/2)*lpf, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(4, (firdes.low_pass_2(1,samp_rate_0,100e3,50e3,40)), 0, samp_rate_0) self.digital_clock_recovery_mm_xx_1 = digital.clock_recovery_mm_ff(11.6439*(1+test), 0.25*0.175*0.175*go, 0.5, 0.175*gm, 0.005*variable_slider_0) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_add_const_vxx_0 = blocks.add_const_vff((-12*shift, )) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=9000, server=False, ) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-40*pows, .001, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_1, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def test_add_const_vff_one(self): src_data = [ 1.0, ] op = blocks.add_const_vff((2.0, )) exp_data = [ 3.0, ] self.help_const_ff(src_data, exp_data, op)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "C:\Program Files\GNURadio-3.7\share\icons\hicolor\scalable/apps\gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.center_freq = center_freq = 315e6 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=1, v_offset=0, t_scale=0.002, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0.win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.blocks_wavfile_sink_0 = blocks.wavfile_sink('S:\\SDROutput\\Screen\\stop.bin', 1, int(samp_rate), 8) self.blocks_threshold_ff_0 = blocks.threshold_ff(0.1, 0.11, 0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0))
def __init__(self, fft_size=256, power_max=0.0, power_min=-100.0, port=6663, frame_rate=5, sample_rate=1e4, ip_address="srvwww.cortexlab.fr"): gr.hier_block2.__init__( self, "fft web", gr.io_signature(1, 1, gr.sizeof_float * fft_size), gr.io_signature(0, 0, 0), ) ################################################## # Parameters ################################################## self.fft_size = fft_size self.power_max = power_max self.power_min = power_min self.port = port self.frame_rate = frame_rate self.sample_rate = sample_rate self.ip_address = ip_address ################################################## # Blocks ################################################## self.digital_simple_framer_0 = digital.simple_framer(fft_size) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_float * 1, fft_size) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1, ip_address, port, 1472, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (-255.0 / (power_min - power_max), )) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff( ((128.0 * power_max + 127.0 * power_min) / (power_min - power_max), )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.digital_simple_framer_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_simple_framer_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self, 0), (self.blocks_vector_to_stream_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.lowpass2 = lowpass2 = 10e3 self.lowpass = lowpass = 10e3 self.base = base = "/home/ali/Documents/UTAT/GNURadio/2018-12-28/es_pipe_U@?U@?U@?" self.samp_rate = samp_rate = 4003200 self.filename_2_0 = filename_2_0 = base+"_mmclock" self.filename_2 = filename_2 = base+"_bits" self.filename_1 = filename_1 = base+"_quaddemod_lpf_"+str((lowpass/1000.0))+"lpf2_"+str((lowpass2/1000.0)) self.filename_0 = filename_0 = base+"_quaddemod_lpf_"+str((lowpass/1000.0)) self.filename = filename = base+"_lpf_"+str((lowpass/1000.0)) ################################################## # Blocks ################################################## self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, lowpass2, lowpass2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, lowpass, lowpass/3, firdes.WIN_HAMMING, 6.76)) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(417*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, base, False) self.blocks_file_sink_0_2 = blocks.file_sink(gr.sizeof_float*1, filename_2_0, False) self.blocks_file_sink_0_2.set_unbuffered(False) self.blocks_file_sink_0_1_0 = blocks.file_sink(gr.sizeof_char*1, filename_2, False) self.blocks_file_sink_0_1_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-15, )) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1e6, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(2123.8262) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_file_sink_0_1_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_file_sink_0_2, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0))
def __init__(self, bias, freq_sample_delay_samps, freq_samps_to_avg, mag_samps_to_avg, resamp_rate, thresh): gr.hier_block2.__init__(self, "Fine Dehopper", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1)) ################################################## # Parameters ################################################## self.bias = bias self.freq_sample_delay_samps = freq_sample_delay_samps self.freq_samps_to_avg = freq_samps_to_avg self.mag_samps_to_avg = mag_samps_to_avg self.resamp_rate = resamp_rate self.thresh = thresh ################################################## # Blocks ################################################## self.s_and_h_detector = s_and_h_detector( freq_sample_delay_samps=freq_sample_delay_samps, freq_samps_to_avg=freq_samps_to_avg, mag_samps_to_avg=mag_samps_to_avg, thresh=thresh, ) self.resamp = pfb.arb_resampler_ccf(resamp_rate * 2.0, taps=None, flt_size=32) self.resamp.declare_sample_delay(0) self.fir = filter.fir_filter_ccc(2, (firdes.low_pass_2(1,1,.25,.05,60))) self.fir.declare_sample_delay(0) self.vco = blocks.vco_c(1, 1, 1) self.mult_conj = blocks.multiply_conjugate_cc(1) self.delay = blocks.delay(gr.sizeof_gr_complex*1, int(freq_samps_to_avg) + freq_sample_delay_samps) self.c2mag = blocks.complex_to_mag(1) self.add_const = blocks.add_const_vff((-1.0 * bias * (resamp_rate), )) self.demod = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.demod, 0), (self.s_and_h_detector, 1)) self.connect((self.add_const, 0), (self.vco, 0)) self.connect((self.c2mag, 0), (self.s_and_h_detector, 0)) self.connect((self.delay, 0), (self.mult_conj, 0)) self.connect((self.mult_conj, 0), (self.fir, 0)) self.connect((self.vco, 0), (self.mult_conj, 1)) self.connect((self.fir, 0), (self.resamp, 0)) self.connect((self, 0), (self.demod, 0)) self.connect((self, 0), (self.c2mag, 0)) self.connect((self, 0), (self.delay, 0)) self.connect((self.resamp, 0), (self, 0)) self.connect((self.s_and_h_detector, 0), (self.add_const, 0))
def __init__(self,delay=0,amplitude=1): """Simple Modulation Block Fixture Keyword Arguments: delay {int} -- Delay to introduce (default: {0}) amplitude {int} -- Amplitude Change (default: {1}) """ valid_mod_block.__init__(self) # Blocks self.b_to_f = blocks.char_to_float(1, 1) self.symbol_map_mult = blocks.multiply_const_vff((2.0, )) self.symbol_map_subtract = blocks.add_const_vff((-1.0,)) self.delay_f = blocks.delay(gr.sizeof_float,delay=delay) self.f_to_c = blocks.float_to_complex(1) self.mult_f = blocks.multiply_const_vff((amplitude, )) self.c_to_r = blocks.complex_to_real(1) self.divide_f = blocks.multiply_const_vff((1.0/amplitude, )) self.symbol_map_add = blocks.add_const_vff((1.0,)) self.symbol_map_divide = blocks.multiply_const_vff((1/2.0,)) self.f_to_b = blocks.float_to_char(1,1) # Connections self.connect((self,0),self.b_to_f) self.connect(self.b_to_f,self.symbol_map_mult) self.connect(self.symbol_map_mult,self.symbol_map_subtract) self.connect(self.symbol_map_subtract,self.mult_f) self.connect(self.mult_f,(self,2)) self.connect(self.mult_f,self.delay_f) self.connect(self.delay_f,self.f_to_c) self.connect(self.f_to_c,(self,1)) self.connect((self,1),self.c_to_r) self.connect(self.c_to_r,self.divide_f) self.connect(self.divide_f,self.symbol_map_add) self.connect(self.symbol_map_add,self.symbol_map_divide) self.connect(self.symbol_map_divide,(self,3)) self.connect(self.symbol_map_divide,self.f_to_b) self.connect(self.f_to_b,(self,0))
def __init__(self, samp_rate_in, samp_rate_out, center_freq, tune_freq, channel_width, transition_width, threshold, iq_filename, dig_out_filename): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.cutoff_freq = channel_width / 2 self.firdes_taps = firdes.low_pass(1, samp_rate_in, self.cutoff_freq, transition_width) ################################################## # Blocks ################################################## self.tuning_filter_0 = filter.freq_xlating_fir_filter_ccc( int(samp_rate_in / samp_rate_out), (self.firdes_taps), tune_freq - center_freq, samp_rate_in) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, iq_filename, False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1 * threshold, )) # message sink is primary method of getting baseband data into waveconverter self.sink_queue = gr.msg_queue() self.blocks_message_sink_0 = blocks.message_sink( gr.sizeof_char * 1, self.sink_queue, False) # if directed, we also dump the baseband data into a file if len(dig_out_filename) > 0: print "Outputing baseband to waveform to " + dig_out_filename self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, dig_out_filename, False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.tuning_filter_0, 0)) self.connect((self.tuning_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_message_sink_0, 0)) if len(dig_out_filename) > 0: self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
def __init__(self, samp_rate_in, samp_rate_out, center_freq, tune_freq, channel_width, transition_width, threshold, fsk_deviation, fskSquelch, iq_filename, dig_out_filename): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.cutoff_freq = channel_width / 2 self.firdes_taps = firdes.low_pass(1, samp_rate_in, self.cutoff_freq, transition_width) ################################################## # Blocks ################################################## self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, iq_filename, False) self.blocks_tuning_filter_0 = filter.freq_xlating_fir_filter_ccc( int(samp_rate_in / samp_rate_out), (self.firdes_taps), tune_freq - center_freq, samp_rate_in) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc( fskSquelch, 1, 1, False) self.blocks_quadrature_demod_0 = analog.quadrature_demod_cf( samp_rate_out / (2 * pi * fsk_deviation / 2)) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1 * threshold, )) self.blocks_digital_binary_slicer_fb_0 = digital.binary_slicer_fb() # swapped message sink for file sink #self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, dig_out_filename, False) #self.blocks_file_sink_0.set_unbuffered(False) self.sink_queue = gr.msg_queue() self.blocks_message_sink_0 = blocks.message_sink( gr.sizeof_char * 1, self.sink_queue, False) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_tuning_filter_0, 0)) self.connect((self.blocks_tuning_filter_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.blocks_quadrature_demod_0, 0)) self.connect((self.blocks_quadrature_demod_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_digital_binary_slicer_fb_0, 0)) #self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_digital_binary_slicer_fb_0, 0), (self.blocks_message_sink_0, 0))
def __init__(self, infile="", outfile=""): gr.top_block.__init__(self, "Demod") ################################################## # Parameters ################################################## self.infile = infile self.outfile = outfile ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2e6 self.offset = offset = 220e3 self.key_freq = key_freq = 433.92e6 ################################################## # Blocks ################################################## self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10000, )) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_gr_complex * 1, infile, False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, outfile, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-0.5, )) self.band_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.band_pass(100, samp_rate, 220e3, 270e3, 50e3, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0, 0))
def slice_ook(burst_object): ## do an auto threshold function here -- mutate burst_object.threshold ### OOK_Demod script ook_slicer = gr.top_block() # Define the container ################################################## # Variables ################################################## ook_slicer.threshold = threshold = burst_object.threshold ook_slicer.filename_raw_rx = filename_raw_rx = burst_object.raw_input_file ook_slicer.filename_sliced = filename_sliced = filename_raw_rx + '.sliced' ################################################## # Blocks ################################################## ook_slicer.file_source = blocks.file_source(gr.sizeof_gr_complex * 1, filename_raw_rx, False) ook_slicer.complex_to_mag_squared = blocks.complex_to_mag_squared(1) ook_slicer.add_const = blocks.add_const_vff((-1 * threshold, )) ook_slicer.digital_binary_slicer = digital.binary_slicer_fb() ook_slicer.blocks_uchar_to_float_0 = blocks.uchar_to_float() ook_slicer.file_sink_0 = blocks.file_sink(gr.sizeof_float * 1, filename_sliced, False) ook_slicer.file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## ook_slicer.connect((ook_slicer.file_source, 0), (ook_slicer.complex_to_mag_squared, 0)) ook_slicer.connect((ook_slicer.complex_to_mag_squared, 0), (ook_slicer.add_const, 0)) ook_slicer.connect((ook_slicer.add_const, 0), (ook_slicer.digital_binary_slicer, 0)) ook_slicer.connect((ook_slicer.digital_binary_slicer, 0), (ook_slicer.blocks_uchar_to_float_0, 0)) ook_slicer.connect((ook_slicer.blocks_uchar_to_float_0, 0), (ook_slicer.file_sink_0, 0)) # This thing now just pumps it out! ook_slicer.start() # Start the flow graph ook_slicer.wait() # wait for it to finish and return burst_object.demodulated_output = filename_sliced dat_sliced = np.fromfile(burst_object.demodulated_output, dtype="float32") sliced_bool = np.array(dat_sliced, np.bool) burst_object.slices = Slices(burst=sliced_bool, samp_rate=burst_object.samp_rate) return burst_object
def __init__(self, fgain=128, fir_interp=512, carrier_freq=530e3, rf_sample_rate=8192000, af_sample_rate=16000, filename="pgm1.wav"): gr.hier_block2.__init__( self, "Am Modulator", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float * 1), ) ################################################## # Parameters ################################################## self.fgain = fgain self.fir_interp = fir_interp self.carrier_freq = carrier_freq self.rf_sample_rate = rf_sample_rate self.af_sample_rate = af_sample_rate self.filename = filename ################################################## # Blocks ################################################## self.low_pass_filter_0 = filter.interp_fir_filter_fff( fir_interp, firdes.low_pass(fgain, rf_sample_rate, 8e3, 4e3, firdes.WIN_HAMMING, 6.76)) self.blocks_wavfile_source_0 = blocks.wavfile_source(filename, True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.analog_sig_source_x_0 = analog.sig_source_f( rf_sample_rate, analog.GR_COS_WAVE, carrier_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_add_const_vxx_0, 0))
def __init__(self, fc=936.6e6, ppm=0, samp_rate_in=1625000.0/6.0*4.0): gr.hier_block2.__init__( self, "Clock offset corrector", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) if version(gr.version()) >= version('3.7.9'): self.message_port_register_hier_in("ppm_in") else: self.message_port_register_hier_out("ppm_in") ################################################## # Parameters ################################################## self.fc = fc self.ppm = ppm self.samp_rate_in = samp_rate_in ################################################## # Variables ################################################## self.samp_rate_out = samp_rate_out = samp_rate_in ################################################## # Blocks ################################################## self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(0,samp_rate_out) self.gsm_controlled_const_source_f_0 = grgsm.controlled_const_source_f(ppm) self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1.0e-6*samp_rate_in/samp_rate_out, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((fc/samp_rate_out*(2*math.pi)/1e6, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((samp_rate_in/samp_rate_out, )) ################################################## # Connections ################################################## self.connect((self, 0), (self.fractional_resampler_xx_0, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.gsm_controlled_rotator_cc_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.fractional_resampler_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.gsm_controlled_rotator_cc_0, 1)) self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0)) self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self, "ppm_in", self.gsm_controlled_const_source_f_0, "constant_msg")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1920000 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title='Scope Plot', sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label='Counts', ) self.Add(self.wxgui_scopesink2_0.win) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) self.analog_sig_source_x_1 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 100000, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, 10000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self, fc=936.6e6, ppm=0, samp_rate_in=1625000.0/6.0*4.0): grgsm.hier_block.__init__( self, "Clock offset corrector", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) self.message_port_register_hier_in("ppm_in") ################################################## # Parameters ################################################## self.fc = fc self.ppm = ppm self.samp_rate_in = samp_rate_in ################################################## # Variables ################################################## self.samp_rate_out = samp_rate_out = samp_rate_in ################################################## # Blocks ################################################## self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(0,samp_rate_out) self.gsm_controlled_const_source_f_0 = grgsm.controlled_const_source_f(ppm) self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1.0e-6*samp_rate_in/samp_rate_out, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((fc/samp_rate_out*(2*math.pi)/1e6, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((samp_rate_in/samp_rate_out, )) ################################################## # Connections ################################################## self.connect((self, 0), (self.fractional_resampler_xx_0, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.gsm_controlled_rotator_cc_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.fractional_resampler_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.gsm_controlled_rotator_cc_0, 1)) self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0)) self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self, "ppm_in", self.gsm_controlled_const_source_f_0, "constant_msg")
def __rebuild(self): overlap_factor = int(math.ceil(_maximum_fft_rate * self.__freq_resolution / self.__sample_rate)) self.__fft_sink = MessageDistributorSink( itemsize=self.__freq_resolution * gr.sizeof_float, context=self.__context, migrate=self.__fft_sink) self.__overlapper = _OverlapGimmick( size=self.__freq_resolution, factor=overlap_factor) self.__logpwrfft = logpwrfft.logpwrfft_c( sample_rate=self.__sample_rate * overlap_factor, fft_size=self.__freq_resolution, ref_scale=2, frame_rate=self.__frame_rate, avg_alpha=1.0, average=False) # adjust units so displayed level is independent of resolution (log power per bandwidth rather than per bin) # TODO work out and document exactly what units we're using self.__fft_rescale = blocks.add_const_vff( [10 * math.log10(self.__freq_resolution)] * self.__freq_resolution)
def __init__(self, bb_params, working_samp_rate): gr.hier_block2.__init__( self, "RX Clock Sync", gr.io_signature(1, 1, gr.sizeof_char * 1), # single in gr.io_signature(1, 1, gr.sizeof_char * 1) # single out ) # parameters self.bb_params = bb_params self.working_samp_rate = working_samp_rate # variables self.nfilts = 32 self.sps = int(self.working_samp_rate * bb_params.symbol_time) self.rrc_taps = firdes.root_raised_cosine(self.nfilts, self.nfilts, 1.0 / float(self.sps), 0.35, 11 * self.sps * self.nfilts) # convert to float and shift down to center around zero self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.connect((self, 0), (self.blocks_uchar_to_float_0, 0)) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5, )) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0_0, 0)) # clock sync block self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_fff( self.sps, 6.28 / 100.0, (self.rrc_taps), self.nfilts, self.nfilts / 2, 1.5, 1) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) # convert back to uchar self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_binary_slicer_fb_0_0, 0)) # connect hier block output self.connect((self.digital_binary_slicer_fb_0_0, 0), (self, 0))
def __init__(self, alpha=0.01): gr.hier_block2.__init__( self, "RMS AGC", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex), ) self.alpha = alpha self.block_rms = blocks.rms_cf(alpha) self.block_divide = blocks.divide_cc(1) self.connect( self, self.block_rms, blocks.add_const_vff((1e-20, )), # to avoid div by 0 blocks.float_to_complex(1), (self.block_divide, 1), ) self.connect(self, (self.block_divide, 0)) self.connect((self.block_divide, 0), self)
def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) sample_rate = 2e6 center_freq = 300e6 filename = '/home/sdr/Desktop/Lab/Labs/Multicode/multi_code_300MHz_2Mss.raw' fsrc = blocks.file_source(gr.sizeof_gr_complex, filename, True) throt = blocks.throttle(gr.sizeof_gr_complex, sample_rate) c_to_m = blocks.complex_to_mag() #scope = scopesink2.scope_sink_f(panel, sample_rate=sample_rate, size=(1200,800)) rat = filter.fir_filter_ccc(100, filter.firdes.low_pass_2(1, sample_rate, 1000000, 500000, 100)) detector = detect_opener_bits() squelch = analog.pwr_squelch_cc(-60,1,0,False) slicer = digital.binary_slicer_fb() add = blocks.add_const_vff((-.003, )) self.connect(fsrc, throt) self.connect(throt, rat) self.connect(rat, c_to_m) self.connect(c_to_m, add) self.connect(add, slicer) #self.connect(c_to_m, scope) self.connect(slicer, detector)
def __init__(self, alpha=1e-2, reference=0.5): gr.hier_block2.__init__( self, "rms_agc", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature ################################################## # Parameters ################################################## self.alpha = alpha self.reference = reference ################################################## # Blocks ################################################## self.blocks_rms_xx_0 = blocks.rms_cf(alpha) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (1.0 / reference, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1e-20, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self, 0), (self.blocks_divide_xx_0, 0)) self.connect((self, 0), (self.blocks_rms_xx_0, 0))
def __init__(self, samp_per_bit, samp_rate, spacing, taps=None): gr.hier_block2.__init__( self, "FM FSK Modulator", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), ) ################################################## # Parameters ################################################## self.samp_per_bit = samp_per_bit self.samp_rate = samp_rate self.spacing = spacing self.taps = taps ################################################## # Blocks ################################################## self._repeat = blocks.repeat(gr.sizeof_char, samp_per_bit) self._char_to_float = blocks.char_to_float(1, 1) self._add = blocks.add_const_vff((-1.0, )) self._filter = interp_fir_filter_fff(1, self._taps()) self._fm_mod = frequency_modulator_fc(self._fm_mod_sensitivity()) ################################################## # Connections ################################################## self.connect( self, self._repeat, self._char_to_float, self._add, self._filter, self._fm_mod, self, )
def __init__(self, sample_rate, ber_threshold=0, # Above which to do search ber_smoothing=0, # Alpha of BER smoother (0.01) ber_duration=0, # Length before trying next combo ber_sample_decimation=1, settling_period=0, pre_lock_duration=0, #ber_sample_skip=0 **kwargs): use_throttle = False base_duration = 1024 if sample_rate > 0: use_throttle = True base_duration *= 4 # Has to be high enough for block-delay if ber_threshold == 0: ber_threshold = 512 * 4 if ber_smoothing == 0: ber_smoothing = 0.01 if ber_duration == 0: ber_duration = base_duration * 2 # 1000ms if settling_period == 0: settling_period = base_duration * 1 # 500ms if pre_lock_duration == 0: pre_lock_duration = base_duration * 2 #1000ms print "Creating Auto-FEC:" print "\tsample_rate:\t\t", sample_rate print "\tber_threshold:\t\t", ber_threshold print "\tber_smoothing:\t\t", ber_smoothing print "\tber_duration:\t\t", ber_duration print "\tber_sample_decimation:\t", ber_sample_decimation print "\tsettling_period:\t", settling_period print "\tpre_lock_duration:\t", pre_lock_duration print "" self.sample_rate = sample_rate self.ber_threshold = ber_threshold #self.ber_smoothing = ber_smoothing self.ber_duration = ber_duration self.settling_period = settling_period self.pre_lock_duration = pre_lock_duration #self.ber_sample_skip = ber_sample_skip self.data_lock = threading.Lock() gr.hier_block2.__init__(self, "auto_fec", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Post MPSK-receiver complex input gr.io_signature3(3, 3, gr.sizeof_char, gr.sizeof_float, gr.sizeof_float)) # Decoded packed bytes, BER metric, lock self.input_watcher = auto_fec_input_watcher(self) default_xform = self.input_watcher.xform_lock self.gr_conjugate_cc_0 = blocks.conjugate_cc() self.conj_add = None try: self.gr_conjugate_cc_0.set(True) except: self.conj_mul_straight = blocks.multiply_const_vcc((0, )) self.conj_mul_conj = blocks.multiply_const_vcc((1, )) self.conj_add = blocks.add_vcc(1) self.connect((self.gr_conjugate_cc_0, 0), (self.conj_mul_conj, 0)) self.connect((self.conj_mul_conj, 0), (self.conj_add, 1)) self.connect((self.conj_mul_straight, 0), (self.conj_add, 0)) self.connect((self, 0), (self.conj_mul_straight, 0)) self.connect((self, 0), (self.gr_conjugate_cc_0, 0)) # Input #self.blks2_selector_0 = grc_blks2.selector( # item_size=gr.sizeof_gr_complex*1, # num_inputs=2, # num_outputs=1, # input_index=default_xform.get_conjugation_index(), # output_index=0, #) #self.connect((self.gr_conjugate_cc_0, 0), (self.blks2_selector_0, 0)) #self.connect((self, 0), (self.blks2_selector_0, 1)) # Input # CHANGED #self.gr_multiply_const_vxx_3 = blocks.multiply_const_vcc((0.707*(1+1j), )) #self.connect((self.blks2_selector_0, 0), (self.gr_multiply_const_vxx_3, 0)) #self.connect((self.gr_conjugate_cc_0, 0), (self.gr_multiply_const_vxx_3, 0)) self.gr_multiply_const_vxx_2 = blocks.multiply_const_vcc((default_xform.get_rotation(), )) # phase_mult #self.connect((self.gr_multiply_const_vxx_3, 0), (self.gr_multiply_const_vxx_2, 0)) # CHANGED if self.conj_add is not None: self.connect((self.conj_add, 0), (self.gr_multiply_const_vxx_2, 0)) else: self.connect((self.gr_conjugate_cc_0, 0), (self.gr_multiply_const_vxx_2, 0)) self.gr_complex_to_float_0_0 = blocks.complex_to_float(1) self.connect((self.gr_multiply_const_vxx_2, 0), (self.gr_complex_to_float_0_0, 0)) self.gr_interleave_1 = blocks.interleave(gr.sizeof_float*1) self.connect((self.gr_complex_to_float_0_0, 1), (self.gr_interleave_1, 1)) self.connect((self.gr_complex_to_float_0_0, 0), (self.gr_interleave_1, 0)) self.gr_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) # invert self.connect((self.gr_interleave_1, 0), (self.gr_multiply_const_vxx_0, 0)) self.baz_delay_2 = baz.delay(gr.sizeof_float*1, default_xform.get_puncture_delay()) # delay_puncture self.connect((self.gr_multiply_const_vxx_0, 0), (self.baz_delay_2, 0)) self.depuncture_ff_0 = baz.depuncture_ff((_puncture_matrices[self.input_watcher.puncture_matrix][1])) # puncture_matrix self.connect((self.baz_delay_2, 0), (self.depuncture_ff_0, 0)) self.baz_delay_1 = baz.delay(gr.sizeof_float*1, default_xform.get_viterbi_delay()) # delay_viterbi self.connect((self.depuncture_ff_0, 0), (self.baz_delay_1, 0)) self.swap_ff_0 = baz.swap_ff(default_xform.get_viterbi_swap()) # swap_viterbi self.connect((self.baz_delay_1, 0), (self.swap_ff_0, 0)) self.gr_decode_ccsds_27_fb_0 = fec.decode_ccsds_27_fb() if use_throttle: print "==> Using throttle at sample rate:", self.sample_rate self.gr_throttle_0 = blocks.throttle(gr.sizeof_float, self.sample_rate) self.connect((self.swap_ff_0, 0), (self.gr_throttle_0, 0)) self.connect((self.gr_throttle_0, 0), (self.gr_decode_ccsds_27_fb_0, 0)) else: self.connect((self.swap_ff_0, 0), (self.gr_decode_ccsds_27_fb_0, 0)) self.connect((self.gr_decode_ccsds_27_fb_0, 0), (self, 0)) # Output bytes self.gr_add_const_vxx_1 = blocks.add_const_vff((-4096, )) self.connect((self.gr_decode_ccsds_27_fb_0, 1), (self.gr_add_const_vxx_1, 0)) self.gr_multiply_const_vxx_1 = blocks.multiply_const_vff((-1, )) self.connect((self.gr_add_const_vxx_1, 0), (self.gr_multiply_const_vxx_1, 0)) self.connect((self.gr_multiply_const_vxx_1, 0), (self, 1)) # Output BER self.gr_single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(ber_smoothing, 1) self.connect((self.gr_multiply_const_vxx_1, 0), (self.gr_single_pole_iir_filter_xx_0, 0)) self.gr_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float, ber_sample_decimation) self.connect((self.gr_single_pole_iir_filter_xx_0, 0), (self.gr_keep_one_in_n_0, 0)) self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) # Last param is const value if use_throttle: lock_throttle_rate = self.sample_rate // 16 print "==> Using lock throttle rate:", lock_throttle_rate self.gr_throttle_1 = blocks.throttle(gr.sizeof_float, lock_throttle_rate) self.connect((self.const_source_x_0, 0), (self.gr_throttle_1, 0)) self.connect((self.gr_throttle_1, 0), (self, 2)) else: self.connect((self.const_source_x_0, 0), (self, 2)) self.msg_q = gr.msg_queue(2*256) # message queue that holds at most 2 messages, increase to speed up process self.msg_sink = blocks.message_sink(gr.sizeof_float, self.msg_q, False) # Block to speed up process self.connect((self.gr_keep_one_in_n_0, 0), self.msg_sink) self.input_watcher.start()
def __init__(self, mode='VOR', zero_point=59, **kwargs): self.channel_rate = channel_rate = 40000 internal_audio_rate = 20000 # TODO over spec'd self.zero_point = zero_point transition = 5000 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=internal_audio_rate, demod_rate=channel_rate, band_filter=fm_subcarrier * 1.25 + fm_deviation + transition / 2, band_filter_transition=transition, **kwargs) self.dir_rate = dir_rate = 10 if internal_audio_rate % dir_rate != 0: raise ValueError( 'Audio rate %s is not a multiple of direction-finding rate %s' % (internal_audio_rate, dir_rate)) self.dir_scale = dir_scale = internal_audio_rate // dir_rate self.audio_scale = audio_scale = channel_rate // internal_audio_rate self.zeroer = blocks.add_const_vff((zero_point * (math.pi / 180), )) self.dir_vector_filter = grfilter.fir_filter_ccf( 1, firdes.low_pass(1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.am_channel_filter_block = grfilter.fir_filter_ccf( 1, firdes.low_pass(1, channel_rate, 5000, 5000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fm = fft.goertzel_fc(channel_rate, dir_scale * audio_scale, 30) self.goertzel_am = fft.goertzel_fc(internal_audio_rate, dir_scale, 30) self.fm_channel_filter_block = grfilter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1.0, channel_rate, fm_subcarrier / 2, fm_subcarrier / 2, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.multiply_conjugate_block = blocks.multiply_conjugate_cc(1) self.complex_to_arg_block = blocks.complex_to_arg(1) self.am_agc_block = analog.feedforward_agc_cc(1024, 1.0) self.am_demod_block = analog.am_demod_cf( channel_rate=channel_rate, audio_decim=audio_scale, audio_pass=5000, audio_stop=5500, ) self.fm_demod_block = analog.quadrature_demod_cf(1) self.phase_agc_fm = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.phase_agc_am = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.probe = blocks.probe_signal_f() self.audio_filter_block = grfilter.fir_filter_fff( 1, design_lofi_audio_filter(internal_audio_rate, False)) ################################################## # Connections ################################################## # Input self.connect(self, self.band_filter_block) # AM chain self.connect(self.band_filter_block, self.am_channel_filter_block, self.am_agc_block, self.am_demod_block) # AM audio self.connect( self.am_demod_block, blocks.multiply_const_ff(1.0 / audio_modulation_index * 0.5), self.audio_filter_block) self.connect_audio_output(self.audio_filter_block) # AM phase self.connect(self.am_demod_block, self.goertzel_am, self.phase_agc_am, (self.multiply_conjugate_block, 0)) # FM phase self.connect(self.band_filter_block, self.fm_channel_filter_block, self.fm_demod_block, self.goertzel_fm, self.phase_agc_fm, (self.multiply_conjugate_block, 1)) # Phase comparison and output self.connect( self.multiply_conjugate_block, self.dir_vector_filter, self.complex_to_arg_block, blocks.multiply_const_ff(-1), # opposite angle conventions self.zeroer, self.probe)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sps = sps = 4 self.ntaps = ntaps = 1408 self.nfilts = nfilts = 32 self.excess_bw = excess_bw = 0.45 self.timing_bw = timing_bw = 2 * pi / 100 self.sr2 = sr2 = 300000 self.samp_rate_0 = samp_rate_0 = 32000 self.samp_rate = samp_rate = 100000 self.s = s = 0.01 self.rx_taps = rx_taps = filter.firdes.root_raised_cosine(nfilts, nfilts * sps, 1.0, excess_bw, ntaps) self.freq_bw = freq_bw = 2 * pi / 100 self.fll_ntaps = fll_ntaps = 55 ################################################## # Blocks ################################################## self.n = self.n = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.n.AddPage(grc_wxgui.Panel(self.n), "tab1") self.n.AddPage(grc_wxgui.Panel(self.n), "tab2") self.n.AddPage(grc_wxgui.Panel(self.n), "tab3") self.Add(self.n) self.wxgui_scopesink2_2 = scopesink2.scope_sink_c( self.n.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.n.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_f( self.n.GetPage(0).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.n.GetPage(0).Add(self.wxgui_scopesink2_1.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.n.GetPage(2).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.n.GetPage(2).Add(self.wxgui_scopesink2_0.win) _s_sizer = wx.BoxSizer(wx.VERTICAL) self._s_text_box = forms.text_box( parent=self.GetWin(), sizer=_s_sizer, value=self.s, callback=self.set_s, label="s", converter=forms.float_converter(), proportion=0, ) self._s_slider = forms.slider( parent=self.GetWin(), sizer=_s_sizer, value=self.s, callback=self.set_s, minimum=-5, maximum=5, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_s_sizer) self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( 4, taps=(firdes.root_raised_cosine(32, 32, 1.0, 0.45, 1408)), flt_size=32 ) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.iir_filter_xxx_0_0 = filter.iir_filter_ffd(([1.0001, -1]), ([-1, 1]), True) self.iir_filter_xxx_0 = filter.iir_filter_ffd((0.01,), ([-1, 0.99]), True) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(4, 2 * pi / 100, (rx_taps), 32, 16, 1.5, 1) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (((1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j))), 1 ) self.blocks_vco_c_0 = blocks.vco_c(samp_rate, -5, 1) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_float * 1, "127.0.0.1", 12345, 1472, True) self.blocks_threshold_ff_0_0 = blocks.threshold_ff(-0.001, 0.001, 0) self.blocks_threshold_ff_0 = blocks.threshold_ff(-0.001, 0.001, 0) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((1,)) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((1.413,)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1.413,)) self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1000) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_imag_0 = blocks.complex_to_imag(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-0.5,)) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5,)) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.blocks_complex_to_imag_0, 0), (self.blocks_threshold_ff_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_delay_0, 0), (self.iir_filter_xxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_multiply_xx_2, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.iir_filter_xxx_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_threshold_ff_0_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_vco_c_0, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.blocks_vco_c_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_imag_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.iir_filter_xxx_0, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.iir_filter_xxx_0_0, 0), (self.blocks_vco_c_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Chu") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1200000 self.upconverter_lo_freq = upconverter_lo_freq = 125000000 self.space_tone = space_tone = 2025 self.offset = offset = 100000 self.mark_tone = mark_tone = 2225 self.gain = gain = 10 self.decimation = decimation = samp_rate / 48000 self.chu_freq = chu_freq = 3330000 self.channel_rate = channel_rate = 4800 ################################################## # Blocks ################################################## self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "48 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "4.8 kHz") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Data scope") self.GridAdd(self.nb, 2, 0, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="USB tuner gain", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=125, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.GridAdd(_gain_sizer, 1, 0, 1, 1) self._chu_freq_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chu_freq, callback=self.set_chu_freq, label="CHU frequency", choices=[3330000, 7850000, 14670000], labels=['3.33 MHz', '7.85 MHz', '14.67 MHz'], style=wx.RA_HORIZONTAL, ) self.GridAdd(self._chu_freq_chooser, 0, 0, 1, 1) self.wxgui_waterfallsink2_1 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(1).GetWin(), baseband_freq=(mark_tone + space_tone) / 2, dynamic_range=50, ref_level=-20, ref_scale=2.0, sample_rate=channel_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.nb.GetPage(1).Add(self.wxgui_waterfallsink2_1.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=chu_freq, dynamic_range=50, ref_level=-60, ref_scale=2.0, sample_rate=samp_rate / decimation, fft_size=2048, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", win=window.hamming, ) self.nb.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(2).GetWin(), title="Scope Plot", sample_rate=channel_rate, v_scale=1, v_offset=0, t_scale=0.050, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(2).Add(self.wxgui_scopesink2_0.win) self.root_raised_cosine_filter_0 = filter.fir_filter_fff(1, firdes.root_raised_cosine( 1, channel_rate, 300, 0.35, 100)) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(chu_freq - offset + upconverter_lo_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(0, 0) self.osmosdr_source_0.set_gain(gain, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.low_pass_filter_1 = filter.fir_filter_ccf(10, firdes.low_pass( 1000, samp_rate / 25, 200, 50, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(decimation, firdes.low_pass( 1, samp_rate, 20000, 5000, firdes.WIN_HAMMING, 6.76)) self.ham_chu_decode_0 = ham.chu_decode() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate / decimation, 200, 2800, 200, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0 = audio.sink(48000, "", True) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate / decimation, analog.GR_COS_WAVE, -(space_tone + mark_tone) / 2, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -offset, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(channel_rate / (3.1416*(mark_tone - space_tone))) self.analog_pll_carriertracking_cc_0 = analog.pll_carriertracking_cc(3.1416 / 500, 1.8, -1.8) self.analog_agc_xx_0 = analog.agc_ff(1e-1, 0.02, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_2, 1)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.blocks_multiply_xx_2, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_pll_carriertracking_cc_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.osmosdr_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.wxgui_waterfallsink2_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_multiply_xx_2, 0), (self.low_pass_filter_1, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.analog_pll_carriertracking_cc_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.ham_chu_decode_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.root_raised_cosine_filter_0, 0))
def __init__(self, clock=100.0e6, dcg=1, decln=-28.0, devid="addr=192.168.10.2", fftsize=8192, frequency=1.406e9, maxg=50, rfgain=0.0, rxant="", spa=1, srate=10.0e6, subdev="A:0", tpint=2.0): grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200 with Filter") ################################################## # Parameters ################################################## self.clock = clock self.dcg = dcg self.decln = decln self.devid = devid self.fftsize = fftsize self.frequency = frequency self.maxg = maxg self.rfgain = rfgain self.rxant = rxant self.spa = spa self.srate = srate self.subdev = subdev self.tpint = tpint ################################################## # Variables ################################################## self.israte = israte = srate self.samp_rate = samp_rate = int(israte) self.prefix = prefix = "tpr_" self.filter_band = filter_band = 500e3 self.variable_static_text_0_0_0_0 = variable_static_text_0_0_0_0 = clock self.variable_static_text_0_0_0 = variable_static_text_0_0_0 = devid self.variable_static_text_0_0 = variable_static_text_0_0 = subdev self.variable_static_text_0 = variable_static_text_0 = israte self.taps = taps = firdes.low_pass(1.0, samp_rate,filter_band, 1000) self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.spavg = spavg = int(spa) self.scope_rate = scope_rate = 2 self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.rec_button_tpr = rec_button_tpr = 1 self.rec_button_iq = rec_button_iq = 1 self.integ = integ = tpint self.idecln = idecln = decln self.gain = gain = 26 self.freq = freq = frequency self.file_rate = file_rate = 2.0 self.fftrate = fftrate = int(samp_rate/fftsize) self.det_rate = det_rate = int(20.0) self.dc_gain = dc_gain = int(dcg) self.calib_2 = calib_2 = -342.774 self.calib_1 = calib_1 = 4.0755e3 self.add_filter = add_filter = 0 ################################################## # Blocks ################################################## self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel") self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements") self.Add(self.Main) _spavg_sizer = wx.BoxSizer(wx.VERTICAL) self._spavg_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, label="Spectral Averaging (Seconds)", converter=forms.int_converter(), proportion=0, ) self._spavg_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, minimum=1, maximum=20, num_steps=20, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1) self._rec_button_tpr_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_tpr, callback=self.set_rec_button_tpr, label="Record TPR Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1) self._rec_button_iq_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_iq, callback=self.set_rec_button_iq, label="Record I/Q Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1) self._israte_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.israte, callback=self.set_israte, label="Sample Rate (BW)", choices=[1e6,2e6,5e6,10e6,25e6], labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._israte_chooser, 1, 3, 1, 1) _integ_sizer = wx.BoxSizer(wx.VERTICAL) self._integ_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, label="Integration Time (Seconds)", converter=forms.float_converter(), proportion=0, ) self._integ_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, minimum=1, maximum=60, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1) self._freq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.freq, callback=self.set_freq, label="Center Frequency (Hz)", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1) self._dc_gain_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.dc_gain, callback=self.set_dc_gain, label="DC Gain", choices=[1, 10, 100, 1000, 10000], labels=[], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1) self._calib_2_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_2, callback=self.set_calib_2, label="Calibration value 2", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1) self._calib_1_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_1, callback=self.set_calib_1, label="Calibration value 1", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1) self._add_filter_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.add_filter, callback=self.set_add_filter, label="Filter On/Off", choices=[0,1], labels=['Off','On'], ) self.Main.GetPage(0).GridAdd(self._add_filter_chooser, 3, 3, 1, 1) self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.Main.GetPage(1).GetWin(), title="Total Power", sample_rate=2, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label="power level", ) self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="", minval=0, maxval=.2, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Raw Power level", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="Kelvin", minval=0, maxval=400, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Calibrated Temperature", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=50, ref_scale=2.0, sample_rate=israte, fft_size=1024, fft_rate=5, average=True, avg_alpha=0.1, title="Spectrum", peak_hold=False, size=(800,400), ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._variable_static_text_0_0_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0_0_0, callback=self.set_variable_static_text_0_0_0_0, label="N200 Clock", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_0_0_static_text, 2, 3, 1, 1) self._variable_static_text_0_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0_0, callback=self.set_variable_static_text_0_0_0, label="Device", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_0_static_text, 2, 2, 1, 1) self._variable_static_text_0_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0_0, callback=self.set_variable_static_text_0_0, label="SubDev", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_0_static_text, 2, 1, 1, 1) self._variable_static_text_0_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.variable_static_text_0, callback=self.set_variable_static_text_0, label="Samp rate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._variable_static_text_0_static_text, 2, 0, 1, 1) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fftsize, ref_scale=2, frame_rate=fftrate, avg_alpha=1.0/float(spavg*fftrate), average=True, ) self._idecln_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.idecln, callback=self.set_idecln, label="Declination", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._idecln_text_box, 1, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain (dB)", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=maxg, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1) _filter_band_sizer = wx.BoxSizer(wx.VERTICAL) self._filter_band_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_filter_band_sizer, value=self.filter_band, callback=self.set_filter_band, label="Filter Bandwidth", converter=forms.float_converter(), proportion=0, ) self._filter_band_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_filter_band_sizer, value=self.filter_band, callback=self.set_filter_band, minimum=100e3, maximum=9e6, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_filter_band_sizer, 3, 2, 1, 1) self.fft_filter_xxx_0 = filter.fft_filter_ccc(1, (taps), 1) self.fft_filter_xxx_0.declare_sample_delay(0) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, )) self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate)) self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False) self.blocks_file_sink_5.set_unbuffered(True) self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False) self.blocks_file_sink_4.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, )) self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr)) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex*1, num_inputs=2, num_outputs=1, input_index=add_filter, output_index=0, ) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, .5, 0) self.TPR_0 = TPR( integ=integ, samp_rate=samp_rate, det_rate=det_rate, ) ################################################## # Connections ################################################## self.connect((self.TPR_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blks2_selector_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.fft_filter_xxx_0, 0)) self.connect((self.blks2_selector_0, 0), (self.TPR_0, 0)) self.connect((self.blks2_selector_0, 0), (self.blks2_valve_2, 0)) self.connect((self.blks2_selector_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.blks2_selector_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0)) self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.fft_filter_xxx_0, 0), (self.blks2_selector_0, 1)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0))
def __init__(self, fm_subcarrier=9960, zero_point=-5): grc_wxgui.top_block_gui.__init__(self, title="VOR Receiver") ################################################## # Parameters ################################################## self.fm_subcarrier = fm_subcarrier self.zero_point = zero_point ################################################## # Variables ################################################## self.rf_rate = rf_rate = 1000000 self.dir_rate = dir_rate = 10 self.channel_rate = channel_rate = 40000 self.audio_rate = audio_rate = 10000 self.vor_freq = vor_freq = 113.9e6 self.volume = volume = 0 self.rf_scale = rf_scale = int(rf_rate/channel_rate) + rf_rate % channel_rate self.offset = offset = fm_subcarrier + 4000 self.dir_scale = dir_scale = int(audio_rate/dir_rate) + audio_rate % dir_rate self.channel = channel = 113.9e6 self.audio_scale = audio_scale = int(channel_rate/audio_rate) + channel_rate % audio_rate ################################################## # Blocks ################################################## _volume_sizer = wx.BoxSizer(wx.VERTICAL) self._volume_text_box = forms.text_box( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, label='volume', converter=forms.float_converter(), proportion=0, ) self._volume_slider = forms.slider( parent=self.GetWin(), sizer=_volume_sizer, value=self.volume, callback=self.set_volume, minimum=-10, maximum=10, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_volume_sizer) self._channel_text_box = forms.text_box( parent=self.GetWin(), value=self.channel, callback=self.set_channel, label="Channel (Hz)", converter=forms.float_converter(), ) self.Add(self._channel_text_box) self.zeroer = blocks.add_const_vff((zero_point*(math.pi/180), )) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="deg", minval=-180, maxval=180, factor=180/math.acos(-1), decimal_places=2, ref_level=0, sample_rate=dir_rate, number_rate=dir_rate, average=True, avg_alpha=.25, label="Direction", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=channel, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=channel_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=0.25, title="Channel", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self._vor_freq_text_box = forms.text_box( parent=self.GetWin(), value=self.vor_freq, callback=self.set_vor_freq, label='vor_freq', converter=forms.float_converter(), ) self.Add(self._vor_freq_text_box) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=40, decimation=1, taps=None, fractional_bw=None, ) self.low_pass_filter_1 = filter.fir_filter_ccf(1, firdes.low_pass( 1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, channel_rate, 10000, 4000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(channel_rate, dir_scale*audio_scale, 30) self.goertzel_fc_0 = fft.goertzel_fc(audio_rate, dir_scale, 30) self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1.0, channel_rate, 500, 100, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(rf_scale, (firdes.low_pass(1.0, rf_rate, channel_rate, channel_rate/2, firdes.WIN_HAMMING)), 900, rf_rate) self.dc_blocker_xx_0 = filter.dc_blocker_ff(128, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, 1e6) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((10**(volume/10), )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/john/apps/aviation_rx/woodside_vor25.dat", True) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, int(channel_rate/30*0.0)) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.audio_sink_0 = audio.sink(audio_rate, "", True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_1.set_max_gain(65536) self.analog_agc2_xx_0_1_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.zeroer, 0)) self.connect((self.zeroer, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.analog_agc2_xx_0_1, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_1, 0)) self.connect((self.analog_agc2_xx_1, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 5 self.afc_gain = 1. self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 1 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## self.src = osmosdr.source( args=options.args ) self.src.set_sample_rate(srate_rx) self.src.set_center_freq(options.frequency, 0) self.src.set_freq_corr(options.ppm, 0) self.src.set_dc_offset_mode(0, 0) self.src.set_iq_balance_mode(0, 0) if options.gain is not None: self.src.set_gain_mode(False, 0) self.src.set_gain(36, 0) else: self.src.set_gain_mode(True, 0) out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.freq_xlating = freq_xlating_fft_filter_ccc(1, (1, ), 0, srate_rx) self.channelizer = pfb.channelizer_ccf( self.channels, (firdes.root_raised_cosine(1, srate_rx, 18000, 0.35, 1024)), 36./25., 100) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): squelch = analog.pwr_squelch_cc(0, 0.001, 0, True) mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) self.connect((self.channelizer, ch), (squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.squelch.append(squelch) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.freq_xlating, 0), (self.channelizer, 0)) ################################################## # signal strenght identification ################################################## self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) self.connect((self.channelizer, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "Power level for squelch % 5.1f" % pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in self.squelch: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() if abs(err) < self.afc_ppm_step: continue freq = self.freq_xlating.center_freq + err * self.afc_gain if self.debug: print "err: %f\tfreq: %f" % (err, freq, ) self.freq_xlating.set_center_freq(freq) self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): self.connect((self.channelizer, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.carrier_freq = carrier_freq = 25e3 ################################################## # Blocks ################################################## self._carrier_freq_layout = Qt.QVBoxLayout() self._carrier_freq_tool_bar = Qt.QToolBar(self) self._carrier_freq_layout.addWidget(self._carrier_freq_tool_bar) self._carrier_freq_tool_bar.addWidget(Qt.QLabel("Carrier Freq"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._carrier_freq_counter = qwt_counter_pyslot() self._carrier_freq_counter.setRange(0, samp_rate/2, 1) self._carrier_freq_counter.setNumButtons(2) self._carrier_freq_counter.setValue(self.carrier_freq) self._carrier_freq_tool_bar.addWidget(self._carrier_freq_counter) self._carrier_freq_counter.valueChanged.connect(self.set_carrier_freq) self._carrier_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._carrier_freq_slider.setRange(0, samp_rate/2, 1) self._carrier_freq_slider.setValue(self.carrier_freq) self._carrier_freq_slider.setMinimumWidth(200) self._carrier_freq_slider.valueChanged.connect(self.set_carrier_freq) self._carrier_freq_layout.addWidget(self._carrier_freq_slider) self.top_layout.addLayout(self._carrier_freq_layout) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1000000, decimation=44100, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(1.0/20) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-160, -40) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 40960, #size samp_rate, #samp_rate "", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["red", "blue", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 0.25, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_wavfile_source_0 = blocks.wavfile_source("/home/student/Desktop/SuzVega-TomsDinerRemix-44100Hz-mono.wav", True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, 44100,True) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, carrier_freq, 1, 0) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_f(analog.GR_GAUSSIAN, 0.0005, 0, 8192) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Nrf") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4000000 self.ch = ch = 25 self.rf_gain = rf_gain = 0 self.if_gain = if_gain = 20 self.fsk_deviation_hz = fsk_deviation_hz = 170000 self.freq_offset = freq_offset = -0 self.fc = fc = 2399000000+ch*1000000 self.bw = bw = samp_rate self.bitrate = bitrate = 250000 self.bb_gain = bb_gain = 30 ################################################## # Blocks ################################################## _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label='rf_gain', converter=forms.int_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_rf_gain_sizer) _if_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, label='if_gain', converter=forms.int_converter(), proportion=0, ) self._if_gain_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_if_gain_sizer) _freq_offset_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_offset_sizer, value=self.freq_offset, callback=self.set_freq_offset, label='freq_offset', converter=forms.float_converter(), proportion=0, ) self._freq_offset_slider = forms.slider( parent=self.GetWin(), sizer=_freq_offset_sizer, value=self.freq_offset, callback=self.set_freq_offset, minimum=-1, maximum=1, num_steps=200, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_offset_sizer) _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._bb_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, label='bb_gain', converter=forms.int_converter(), proportion=0, ) self._bb_gain_slider = forms.slider( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_bb_gain_sizer) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=True, ) self.Add(self.wxgui_fftsink2_0.win) self.osmosdr_source_0_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0_0.set_sample_rate(samp_rate) self.osmosdr_source_0_0.set_center_freq(fc, 0) self.osmosdr_source_0_0.set_freq_corr(0, 0) self.osmosdr_source_0_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0_0.set_gain_mode(True, 0) self.osmosdr_source_0_0.set_gain(rf_gain, 0) self.osmosdr_source_0_0.set_if_gain(if_gain, 0) self.osmosdr_source_0_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0_0.set_antenna("", 0) self.osmosdr_source_0_0.set_bandwidth(samp_rate, 0) self.low_pass_filter_0_0 = filter.fir_filter_fff(samp_rate/bitrate, firdes.low_pass( 1, samp_rate, bitrate, bitrate/2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 2000000, 1000000, firdes.WIN_HAMMING, 6.76)) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() _ch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch_sizer, value=self.ch, callback=self.set_ch, label='ch', converter=forms.int_converter(), proportion=0, ) self._ch_slider = forms.slider( parent=self.GetWin(), sizer=_ch_sizer, value=self.ch, callback=self.set_ch, minimum=0, maximum=128, num_steps=128, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_ch_sizer) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/opt/nrf_analyzer/fifo", False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((freq_offset, )) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1000000, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.osmosdr_source_0_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, buflen=4096, dc_offset_i=0, dc_offset_q=0, instance=0, num_buffers=16, num_xfers=8, rx_bandwidth=1.5e6, rx_frequency=915e6, rx_lna_gain=6, rx_sample_rate=3e6, rx_vga_gain=20, serial="", verbosity="info"): gr.top_block.__init__(self, "Simple bladeRF RX GUI") Qt.QWidget.__init__(self) self.setWindowTitle("Simple bladeRF RX GUI") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "bladeRF_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.buflen = buflen self.dc_offset_i = dc_offset_i self.dc_offset_q = dc_offset_q self.instance = instance self.num_buffers = num_buffers self.num_xfers = num_xfers self.rx_bandwidth = rx_bandwidth self.rx_frequency = rx_frequency self.rx_lna_gain = rx_lna_gain self.rx_sample_rate = rx_sample_rate self.rx_vga_gain = rx_vga_gain self.serial = serial self.verbosity = verbosity ################################################## # Variables ################################################## self.bladerf_selection = bladerf_selection = str(instance) if serial == "" else serial self.bladerf_args = bladerf_args = "bladerf=" + bladerf_selection + ",buffers=" + str(num_buffers) + ",buflen=" + str(buflen) + ",num_xfers=" + str(num_xfers) + ",verbosity="+verbosity self.gui_rx_vga_gain = gui_rx_vga_gain = rx_vga_gain self.gui_rx_sample_rate = gui_rx_sample_rate = rx_sample_rate self.gui_rx_lna_gain = gui_rx_lna_gain = rx_lna_gain self.gui_rx_frequency = gui_rx_frequency = rx_frequency self.gui_rx_bandwidth = gui_rx_bandwidth = rx_bandwidth self.gui_dc_offset_q = gui_dc_offset_q = dc_offset_q self.gui_dc_offset_i = gui_dc_offset_i = dc_offset_i self.gui_bladerf_args = gui_bladerf_args = bladerf_args ################################################## # Blocks ################################################## self._gui_rx_vga_gain_range = Range(5, 60, 1, rx_vga_gain, 200) self._gui_rx_vga_gain_win = RangeWidget(self._gui_rx_vga_gain_range, self.set_gui_rx_vga_gain, "RX VGA1 + VGA2 Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_vga_gain_win, 0, 5, 1, 4) self._gui_rx_sample_rate_range = Range(1.5e6, 40e6, 500e3, rx_sample_rate, 200) self._gui_rx_sample_rate_win = RangeWidget(self._gui_rx_sample_rate_range, self.set_gui_rx_sample_rate, "Sample Rate", "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_sample_rate_win, 1, 0, 1, 2) self._gui_rx_lna_gain_options = (0, 3, 6, ) self._gui_rx_lna_gain_labels = ("0 dB", "3 dB", "6 dB", ) self._gui_rx_lna_gain_tool_bar = Qt.QToolBar(self) self._gui_rx_lna_gain_tool_bar.addWidget(Qt.QLabel("LNA Gain"+": ")) self._gui_rx_lna_gain_combo_box = Qt.QComboBox() self._gui_rx_lna_gain_tool_bar.addWidget(self._gui_rx_lna_gain_combo_box) for label in self._gui_rx_lna_gain_labels: self._gui_rx_lna_gain_combo_box.addItem(label) self._gui_rx_lna_gain_callback = lambda i: Qt.QMetaObject.invokeMethod(self._gui_rx_lna_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._gui_rx_lna_gain_options.index(i))) self._gui_rx_lna_gain_callback(self.gui_rx_lna_gain) self._gui_rx_lna_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_gui_rx_lna_gain(self._gui_rx_lna_gain_options[i])) self.top_grid_layout.addWidget(self._gui_rx_lna_gain_tool_bar, 0, 9, 1, 1) self._gui_rx_frequency_range = Range(0, 3.8e9, 1e6, rx_frequency, 200) self._gui_rx_frequency_win = RangeWidget(self._gui_rx_frequency_range, self.set_gui_rx_frequency, "Frequency", "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_frequency_win, 0, 0, 1, 5) self._gui_rx_bandwidth_range = Range(1.5e6, 28e6, 0.5e6, rx_bandwidth, 200) self._gui_rx_bandwidth_win = RangeWidget(self._gui_rx_bandwidth_range, self.set_gui_rx_bandwidth, "Bandwidth", "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_bandwidth_win, 1, 2, 1, 2) self._gui_dc_offset_q_range = Range(-1.0, 1.0, (1.0 / 2048.0), dc_offset_q, 200) self._gui_dc_offset_q_win = RangeWidget(self._gui_dc_offset_q_range, self.set_gui_dc_offset_q, "Q DC Offset", "counter_slider", float) self.top_grid_layout.addWidget(self._gui_dc_offset_q_win, 1, 6, 1, 2) self._gui_dc_offset_i_range = Range(-1.0, 1.0, (1.0 / 2048.0), dc_offset_i, 200) self._gui_dc_offset_i_win = RangeWidget(self._gui_dc_offset_i_range, self.set_gui_dc_offset_i, "I DC Offset", "counter_slider", float) self.top_grid_layout.addWidget(self._gui_dc_offset_i_win, 1, 4, 1, 2) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_rx_frequency, #fc gui_rx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 5, 5, 5) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 8192, #size rx_sample_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 7, 0, 3, 10) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_rx_frequency, #fc gui_rx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 5, 5) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + bladerf_args ) self.osmosdr_source_0.set_sample_rate(gui_rx_sample_rate) self.osmosdr_source_0.set_center_freq(gui_rx_frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gui_rx_lna_gain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(gui_rx_vga_gain, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(gui_rx_bandwidth, 0) self._gui_bladerf_args_tool_bar = Qt.QToolBar(self) if None: self._gui_bladerf_args_formatter = None else: self._gui_bladerf_args_formatter = lambda x: x self._gui_bladerf_args_tool_bar.addWidget(Qt.QLabel("bladeRF arguments"+": ")) self._gui_bladerf_args_label = Qt.QLabel(str(self._gui_bladerf_args_formatter(self.gui_bladerf_args))) self._gui_bladerf_args_tool_bar.addWidget(self._gui_bladerf_args_label) self.top_grid_layout.addWidget(self._gui_bladerf_args_tool_bar, 11, 0, 1, 10) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((gui_dc_offset_q, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((gui_dc_offset_i, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, "Tetra Rx Multi") options = self.get_options() self.src = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/myout1.ch", False) ################################################## # Variables ################################################## self.srate_rx = srate_rx = options.sample_rate self.channels = srate_rx / 25000 self.srate_channel = 36000 self.afc_period = 15 self.afc_gain = 0.01 self.afc_channel = options.auto_tune or -1 self.afc_ppm_step = 100 self.debug = options.debug self.last_pwr = -100000 self.sig_det_period = 10 self.sig_det_bw = sig_det_bw = options.sig_detection_bw or srate_rx if self.sig_det_bw <= 1.: self.sig_det_bw *= srate_rx self.sig_det_threshold = options.sig_detection_threshold self.sig_det_channels = [] for ch in range(self.channels): if ch >= self.channels / 2: ch_ = (self.channels - ch - 1) else: ch_ = ch if (float(ch_) / self.channels * 2) <= (self.sig_det_bw / srate_rx): self.sig_det_channels.append(ch) self.channels = 10 ################################################## # RPC server ################################################## self.xmlrpc_server = SimpleXMLRPCServer.SimpleXMLRPCServer( ("localhost", options.listen_port), allow_none=True) self.xmlrpc_server.register_instance(self) threading.Thread(target=self.xmlrpc_server.serve_forever).start() ################################################## # Rx Blocks and connections ################################################## out_type, dst_path = options.output.split("://", 1) if out_type == "udp": dst_ip, dst_port = dst_path.split(':', 1) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_gr_complex*1, 1) self.squelch = [] self.digital_mpsk_receiver_cc = [] self.diff_phasor = [] self.complex_to_arg = [] self.multiply_const = [] self.add_const = [] self.float_to_uchar = [] self.map_bits = [] self.unpack_k_bits = [] self.blocks_sink = [] for ch in range(0, self.channels): mpsk = digital.mpsk_receiver_cc( 4, math.pi/4, math.pi/100.0, -0.5, 0.5, 0.25, 0.001, 2, 0.001, 0.001) diff_phasor = digital.diff_phasor_cc() complex_to_arg = blocks.complex_to_arg(1) multiply_const = blocks.multiply_const_vff((2./math.pi, )) add_const = blocks.add_const_vff((1.5, )) float_to_uchar = blocks.float_to_uchar() map_bits = digital.map_bb(([3, 2, 0, 1, 3])) unpack_k_bits = blocks.unpack_k_bits_bb(2) brmchannels = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71] #brmchannels = [11,4,3,64,45,47,53,8,68,6,56,49,17,54,65,5,71,22,48,7,50] # itds kancl #brmchannels = [23,13,40,69,59,7,42,54,5,14,4,56,45,46,67,55,66,44,71,49,31,57,0,65,70] # doma - dole #brmchannels = [23,13,59,40,69,7,49,60,42,70,4,50,66,67,3,14,57,33,46,22,68,32,39,24,6,12,43,58,48,17,5,56,65,29,54,30,16,52,53,41,47,2,34,44,8] # doma - strecha #brmchannels = [67, 7, 23, 70] # doma - strecha - SDS #brmchannels = [67, 7, 23, 70,9,71,64,63,62,61,55,51,45,38,37,36,35,31,28,27,26,25,21,20,19,18,15,11,10,1,0] # doma - strecha - komplement if out_type == 'udp': sink = blocks.udp_sink(gr.sizeof_gr_char, dst_ip, int(dst_port)+ch, 1472, True) elif out_type == 'file': sink = blocks.file_sink(gr.sizeof_char, dst_path % ch, False) sink.set_unbuffered(True) else: raise ValueError("Invalid output URL '%s'" % options.output) print "connect %i"%ch if ch in brmchannels: self.connect((self.blocks_deinterleave_0, ch), #(squelch, 0), (mpsk, 0), (diff_phasor, 0), (complex_to_arg, 0), (multiply_const, 0), (add_const, 0), (float_to_uchar, 0), (map_bits, 0), (unpack_k_bits, 0), (sink, 0)) self.digital_mpsk_receiver_cc.append(mpsk) self.diff_phasor.append(diff_phasor) self.complex_to_arg.append(complex_to_arg) self.multiply_const.append(multiply_const) self.add_const.append(add_const) self.float_to_uchar.append(float_to_uchar) self.map_bits.append(map_bits) self.unpack_k_bits.append(unpack_k_bits) self.blocks_sink.append(sink) self.connect( (self.src, 0), (self.blocks_deinterleave_0, 0)) ################################################## # signal strenght identification ################################################## ''' self.pwr_probes = [] for ch in range(self.channels): pwr_probe = analog.probe_avg_mag_sqrd_c(0, 1./self.srate_channel) self.pwr_probes.append(pwr_probe) print "connect %i"%ch self.connect((self.blocks_deinterleave_0, ch), (pwr_probe, 0)) def _sig_det_probe(): while True: pwr = [self.pwr_probes[ch].level() for ch in range(self.channels) if ch in self.sig_det_channels] pwr = [10 * math.log10(p) for p in pwr if p > 0.] if not pwr: continue pwr = min(pwr) + self.sig_det_threshold print "power threshold target %f"%pwr if abs(pwr - self.last_pwr) > (self.sig_det_threshold / 2): for s in []: s.set_threshold(pwr) self.last_pwr = pwr time.sleep(self.sig_det_period) if self.sig_det_threshold is not None: self._sig_det_probe_thread = threading.Thread(target=_sig_det_probe) self._sig_det_probe_thread.daemon = True self._sig_det_probe_thread.start() ''' ################################################## # AFC blocks and connections ################################################## self.afc_selector = grc_blks2.selector( item_size=gr.sizeof_gr_complex, num_inputs=self.channels, num_outputs=1, input_index=0, output_index=0, ) self.afc_demod = analog.quadrature_demod_cf(self.srate_channel/(2*math.pi)) samp_afc = self.srate_channel*self.afc_period / 2 self.afc_avg = blocks.moving_average_ff(samp_afc, 1./samp_afc*self.afc_gain) self.afc_probe = blocks.probe_signal_f() def _afc_probe(): rt = 0.0 while True: time.sleep(self.afc_period) if self.afc_channel == -1: continue err = self.afc_probe.level() freq = err * self.afc_gain print "err: %f\tfreq: %f\trt %f" % (err, freq, rt) changed = False if err < -1: rt += 0.1 changed = True elif err > 1: rt -= 0.1 changed = True if changed: os.system("echo \"setrot %f\" | nc localhost 3333"%rt) self.afc_channel = 0 self._afc_err_thread = threading.Thread(target=_afc_probe) self._afc_err_thread.daemon = True self._afc_err_thread.start() for ch in range(self.channels): print "connect %i"%ch self.connect((self.blocks_deinterleave_0, ch), (self.afc_selector, ch)) self.connect( (self.afc_selector, 0), (self.afc_demod, 0), (self.afc_avg, 0), (self.afc_probe, 0)) if self.afc_channel != -1: self.afc_selector.set_input_index(self.afc_channel)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 7.5e6 self.decim = decim = 150 self.xlate_bw = xlate_bw = 25e3 self.usrp_gain = usrp_gain = 33 self.rx_antenna = rx_antenna = "RX2" self.port = port = 47110 self.phase = phase = 0 self.mlen = mlen = 100 self.keep_plot = keep_plot = 16 self.keep = keep = 1 self.ip = ip = "localhost" self.freq_offset = freq_offset = 200e3 self.fire = fire = 0 self.device_args = device_args = "type=x300, master_clock_rate=150e6" self.calib_freq_offset = calib_freq_offset = 2e6 self.cal_freq = cal_freq = 450e6 self.baseband_rate = baseband_rate = int(samp_rate/decim) self.angular_resolution = angular_resolution = 360 self.N_keep = N_keep = 1000 self.N = N = 512 self.M_keep = M_keep = 100 ################################################## # Blocks ################################################## self.tabw = Qt.QTabWidget() self.tabw_widget_0 = Qt.QWidget() self.tabw_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabw_widget_0) self.tabw_grid_layout_0 = Qt.QGridLayout() self.tabw_layout_0.addLayout(self.tabw_grid_layout_0) self.tabw.addTab(self.tabw_widget_0, "Synchronization Setup") self.tabw_widget_1 = Qt.QWidget() self.tabw_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabw_widget_1) self.tabw_grid_layout_1 = Qt.QGridLayout() self.tabw_layout_1.addLayout(self.tabw_grid_layout_1) self.tabw.addTab(self.tabw_widget_1, "DOA") self.top_layout.addWidget(self.tabw) self._xlate_bw_layout = Qt.QVBoxLayout() self._xlate_bw_tool_bar = Qt.QToolBar(self) self._xlate_bw_layout.addWidget(self._xlate_bw_tool_bar) self._xlate_bw_tool_bar.addWidget(Qt.QLabel("Xlate Bandwidth"+": ")) self._xlate_bw_counter = Qwt.QwtCounter() self._xlate_bw_counter.setRange(0, baseband_rate, 1) self._xlate_bw_counter.setNumButtons(2) self._xlate_bw_counter.setValue(self.xlate_bw) self._xlate_bw_tool_bar.addWidget(self._xlate_bw_counter) self._xlate_bw_counter.valueChanged.connect(self.set_xlate_bw) self._xlate_bw_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._xlate_bw_slider.setRange(0, baseband_rate, 1) self._xlate_bw_slider.setValue(self.xlate_bw) self._xlate_bw_slider.setMinimumWidth(200) self._xlate_bw_slider.valueChanged.connect(self.set_xlate_bw) self._xlate_bw_layout.addWidget(self._xlate_bw_slider) self.tabw_grid_layout_0.addLayout(self._xlate_bw_layout, 0,2,1,1) self._phase_layout = Qt.QVBoxLayout() self._phase_tool_bar = Qt.QToolBar(self) self._phase_layout.addWidget(self._phase_tool_bar) self._phase_tool_bar.addWidget(Qt.QLabel("phase"+": ")) self._phase_counter = Qwt.QwtCounter() self._phase_counter.setRange(-3, 3, 0.001) self._phase_counter.setNumButtons(2) self._phase_counter.setValue(self.phase) self._phase_tool_bar.addWidget(self._phase_counter) self._phase_counter.valueChanged.connect(self.set_phase) self._phase_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_slider.setRange(-3, 3, 0.001) self._phase_slider.setValue(self.phase) self._phase_slider.setMinimumWidth(200) self._phase_slider.valueChanged.connect(self.set_phase) self._phase_layout.addWidget(self._phase_slider) self.top_layout.addLayout(self._phase_layout) self._keep_tool_bar = Qt.QToolBar(self) self._keep_tool_bar.addWidget(Qt.QLabel("Keep input vectors"+": ")) self._keep_line_edit = Qt.QLineEdit(str(self.keep)) self._keep_tool_bar.addWidget(self._keep_line_edit) self._keep_line_edit.returnPressed.connect( lambda: self.set_keep(int(self._keep_line_edit.text().toAscii()))) self.tabw_grid_layout_1.addWidget(self._keep_tool_bar, 2,1,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_tool_bar = Qt.QToolBar(self) self._freq_offset_layout.addWidget(self._freq_offset_tool_bar) self._freq_offset_tool_bar.addWidget(Qt.QLabel("Xlate Freq. Offset"+": ")) self._freq_offset_counter = Qwt.QwtCounter() self._freq_offset_counter.setRange(-samp_rate/2, samp_rate/2, 1) self._freq_offset_counter.setNumButtons(2) self._freq_offset_counter.setValue(self.freq_offset) self._freq_offset_tool_bar.addWidget(self._freq_offset_counter) self._freq_offset_counter.valueChanged.connect(self.set_freq_offset) self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-samp_rate/2, samp_rate/2, 1) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.tabw_grid_layout_0.addLayout(self._freq_offset_layout, 0,1,1,1) self.xlate_interleave_0 = xlate_interleave( samp_rate=samp_rate, decim=decim, freq_offset=freq_offset, xlate_bw=xlate_bw, ) self._usrp_gain_tool_bar = Qt.QToolBar(self) self._usrp_gain_tool_bar.addWidget(Qt.QLabel("USRP RF Gain"+": ")) self._usrp_gain_line_edit = Qt.QLineEdit(str(self.usrp_gain)) self._usrp_gain_tool_bar.addWidget(self._usrp_gain_line_edit) self._usrp_gain_line_edit.returnPressed.connect( lambda: self.set_usrp_gain(eng_notation.str_to_num(self._usrp_gain_line_edit.text().toAscii()))) self.tabw_grid_layout_0.addWidget(self._usrp_gain_tool_bar, 0,3,1,1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( angular_resolution, #size 1.0/1000.0, #samp_rate "MUSIC Spectrum", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-3.0, 20.0) self.qtgui_time_sink_x_1.enable_tags(-1, False) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tabw_grid_layout_1.addWidget(self._qtgui_time_sink_x_1_win, 0,0,2,1) self.missile_launcher_0 = misc.async_missile_launcher(azimuth=0.0, elevation=25.0, threshold=0.0, recal_threshold=0.0) self.misc_numbersink_0 = misc.numbersink(float, "Angle", "Degrees", samp_rate, 0, 360, 1.0, 10, 0.0, 15, False, 0, "Angle", False, True) self._misc_numbersink_0_win = self.misc_numbersink_0.get_pyqwidget() self.tabw_grid_layout_1.addWidget(self._misc_numbersink_0_win, 1,1,1,1) self.misc_music_doa_1 = misc.music_doa_helper(m=2, n=1, nsamples=N, angular_resolution=angular_resolution, frequency=cal_freq, array_spacing=0.132, antenna_array=[[0,0],[1,0]], output_spectrum=True) self.misc_compass_0 = misc.compass(False, "nice", "simple", 15) self._misc_compass_0_win = self.misc_compass_0.get_pyqwidget() self.tabw_grid_layout_1.addWidget(self._misc_compass_0_win, 0,1,1,1) self._fire_tool_bar = Qt.QToolBar(self) self._fire_tool_bar.addWidget(Qt.QLabel("FIRE!"+": ")) self._fire_line_edit = Qt.QLineEdit(str(self.fire)) self._fire_tool_bar.addWidget(self._fire_line_edit) self._fire_line_edit.returnPressed.connect( lambda: self.set_fire(int(self._fire_line_edit.text().toAscii()))) self.tabw_grid_layout_1.addWidget(self._fire_tool_bar, 2,0,1,1) self._calib_freq_offset_layout = Qt.QVBoxLayout() self._calib_freq_offset_tool_bar = Qt.QToolBar(self) self._calib_freq_offset_layout.addWidget(self._calib_freq_offset_tool_bar) self._calib_freq_offset_tool_bar.addWidget(Qt.QLabel("Calibration Tone Offset"+": ")) self._calib_freq_offset_counter = Qwt.QwtCounter() self._calib_freq_offset_counter.setRange(-samp_rate/2, samp_rate/2, 1) self._calib_freq_offset_counter.setNumButtons(2) self._calib_freq_offset_counter.setValue(self.calib_freq_offset) self._calib_freq_offset_tool_bar.addWidget(self._calib_freq_offset_counter) self._calib_freq_offset_counter.valueChanged.connect(self.set_calib_freq_offset) self._calib_freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._calib_freq_offset_slider.setRange(-samp_rate/2, samp_rate/2, 1) self._calib_freq_offset_slider.setValue(self.calib_freq_offset) self._calib_freq_offset_slider.setMinimumWidth(200) self._calib_freq_offset_slider.valueChanged.connect(self.set_calib_freq_offset) self._calib_freq_offset_layout.addWidget(self._calib_freq_offset_slider) self.tabw_grid_layout_0.addLayout(self._calib_freq_offset_layout, 0,0,1,1) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_float*1, angular_resolution) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, N) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, angular_resolution, 0) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((math.e**(1.0j*phase), )) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*angular_resolution, keep_plot) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_gr_complex*N, keep) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 200e3, 1, 0) ################################################## # Connections ################################################## self.connect((self.blocks_keep_one_in_n_0, 0), (self.misc_music_doa_1, 0)) self.connect((self.misc_music_doa_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.xlate_interleave_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.xlate_interleave_0, 0)) self.connect((self.xlate_interleave_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.misc_numbersink_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.missile_launcher_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.misc_compass_0, 0)) self.connect((self.misc_music_doa_1, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.misc_music_doa_1, 2), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.qtgui_time_sink_x_1, 0))
def __init__(self, sym_rate=256, samp_per_sym=256, nominal_uplink_freq=2041.95e6*0 + 2041.9479e6 + 1e6*0, lo_off=5e6 * 0, tx_gain=15*0 + 13.5*0, backoff=0.150*0 + (0.6+0.1)*0 + 1e-3, record_path='/media/balint/PATRIOT/ICE/TX/'): grc_wxgui.top_block_gui.__init__(self, title="Uplink") ################################################## # Parameters ################################################## self.sym_rate = sym_rate self.samp_per_sym = samp_per_sym self.nominal_uplink_freq = nominal_uplink_freq self.lo_off = lo_off self.tx_gain = tx_gain self.backoff = backoff self.record_path = record_path ################################################## # Variables ################################################## self.time_format = time_format = "%Y-%d-%m_%H-%M-%S" self.time_now = time_now = time.strftime(time_format) self.samp_rate = samp_rate = 250000 self.pre_resamp_rate = pre_resamp_rate = sym_rate * samp_per_sym self.f1 = f1 = 9000.0 self.f0 = f0 = 7500.0 self.resamp_rate = resamp_rate = float(samp_rate)/float(pre_resamp_rate) self.pm = pm = 1.2*0 + 1.0 self.nominal_uplink_freq_chooser = nominal_uplink_freq_chooser = nominal_uplink_freq self.manual_doppler = manual_doppler = 0 self.file_name = file_name = time_now + ".mcfile" self.doppler = doppler = 0 self.deviation = deviation = (f1 - f0) / 2.0 self.tx_gain_user = tx_gain_user = tx_gain self.subcarrier_freq = subcarrier_freq = f0 + deviation self.source = source = 'external' self.pm_txt = pm_txt = pm self.nominal_uplink_freq_user = nominal_uplink_freq_user = nominal_uplink_freq_chooser self.lo_off_user = lo_off_user = lo_off self.length_mul = length_mul = float(samp_per_sym) * resamp_rate self.invert = invert = 1 self.final_record_path = final_record_path = os.path.join(record_path, file_name) self.final_doppler = final_doppler = doppler + manual_doppler self.backoff_user = backoff_user = backoff ################################################## # Blocks ################################################## _tx_gain_user_sizer = wx.BoxSizer(wx.VERTICAL) self._tx_gain_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._tx_gain_user_slider = forms.slider( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, minimum=0, maximum=32, num_steps=32, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_user_sizer) self._nominal_uplink_freq_user_text_box = forms.text_box( parent=self.GetWin(), value=self.nominal_uplink_freq_user, callback=self.set_nominal_uplink_freq_user, label="Nominal Uplink Freq", converter=forms.float_converter(), ) self.Add(self._nominal_uplink_freq_user_text_box) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Output FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input Phase/Mag") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Mod Clk/Data") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Output Scope") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Input") self.Add(self.nb) self._lo_off_user_text_box = forms.text_box( parent=self.GetWin(), value=self.lo_off_user, callback=self.set_lo_off_user, label="LO Offset", converter=forms.float_converter(), ) self.Add(self._lo_off_user_text_box) self._final_doppler_static_text = forms.static_text( parent=self.GetWin(), value=self.final_doppler, callback=self.set_final_doppler, label="Final Doppler", converter=forms.float_converter(), ) self.Add(self._final_doppler_static_text) self._doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.doppler, callback=self.set_doppler, label="Doppler Shift", converter=forms.float_converter(), ) self.Add(self._doppler_text_box) _backoff_user_sizer = wx.BoxSizer(wx.VERTICAL) self._backoff_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, label="Backoff", converter=forms.float_converter(), proportion=0, ) self._backoff_user_slider = forms.slider( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_backoff_user_sizer) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 52003), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.nb.GetPage(5).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(5).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=256, fft_rate=10, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, fft_in=False, always_run=False, fft_out=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F4A7C3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "", True, ) self.uhd_usrp_sink_0.set_clock_source(source, 0) self.uhd_usrp_sink_0.set_time_source(source, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(nominal_uplink_freq_user,lo_off_user), 0) self.uhd_usrp_sink_0.set_gain(tx_gain*0 + tx_gain_user, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate), decimation=int(pre_resamp_rate), taps=None, fractional_bw=None, ) self._pm_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.pm_txt, callback=self.set_pm_txt, label="Phase Moduation Index", converter=forms.float_converter(), ) self.Add(self._pm_txt_static_text) self._nominal_uplink_freq_chooser_chooser = forms.drop_down( parent=self.GetWin(), value=self.nominal_uplink_freq_chooser, callback=self.set_nominal_uplink_freq_chooser, label="Nomial Uplink Frequency", choices=[2041.9479e6, 2090.66e6], labels=['B: 2041.9479', 'A: 2090.66'], ) self.Add(self._nominal_uplink_freq_chooser_chooser) self._manual_doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.manual_doppler, callback=self.set_manual_doppler, label="Manual Doppler", converter=forms.float_converter(), ) self.Add(self._manual_doppler_text_box) self.mac_burst_tagger_0 = mac.burst_tagger('packet_len', length_mul, 256, 32*0 + 256, True, False) self.clock_and_data = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.clock_and_data.win) self.carrier = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler*0 + final_doppler, 0*backoff + backoff_user, 0) self.blocks_vector_source_x_0 = blocks.vector_source_f(tuple([1] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [1] * (samp_per_sym/4)), True, 1, []) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len", 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((2.0/3, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert, )) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.to_pmt({'ignore': True}), pmt.init_u8vector(1, 1*[0])), 0) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, final_record_path, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1.0/3, )) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, )) self.binary_to_pdu0 = isee3.binary_to_pdu() self.analog_sig_source_x_0 = analog.sig_source_c(pre_resamp_rate, analog.GR_COS_WAVE, subcarrier_freq, 1/1.333, 0) self.analog_phase_modulator_fc_1 = analog.phase_modulator_fc(pm / (2.0*0 + 1)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(float(deviation) / float(pre_resamp_rate) * math.pi*2.0) ################################################## # Connections ################################################## self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.clock_and_data, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.carrier, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_phase_modulator_fc_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.mac_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.mac_burst_tagger_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.analog_phase_modulator_fc_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.mac_burst_tagger_0, 0), (self.blocks_file_meta_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.binary_to_pdu0, "pdu_out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.binary_to_pdu0, "binary_in") self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.uhd_usrp_sink_0, "ctl", self.blocks_message_strobe_0_0, "trigger")
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.data_rate_V2 = data_rate_V2 = 510*2 self.version_chooser = version_chooser = data_rate_V2 self.freq_range = freq_range = 433.995 self.audio_rate = audio_rate = 48000 self.trans = trans = 1.2e3 self.samp_rate = samp_rate = 2400000 self.samp_per_sym = samp_per_sym = audio_rate/version_chooser self.gain = gain = 390 self.freq_offset = freq_offset = 100e3 self.freq = freq = (0*433.886e6+0*433.877e6+0*433.995e6)+freq_range*1e6+100e3 self.data_rate_V1 = data_rate_V1 = 680 self.data_rate = data_rate = version_chooser self.channel_trans = channel_trans = 2000 self.channel_spacing = channel_spacing = 25e3 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "Frequency") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "Signal") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Datarate") self.top_layout.addWidget(self.tab) self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("Decoder_Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 1000, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 1000, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(1000) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.tab_layout_1.addLayout(self._gain_layout) self._version_chooser_options = [data_rate_V1, data_rate_V2] self._version_chooser_labels = ["V1","V2"] self._version_chooser_tool_bar = Qt.QToolBar(self) self._version_chooser_tool_bar.addWidget(Qt.QLabel("Oregon Scientific Version"+": ")) self._version_chooser_combo_box = Qt.QComboBox() self._version_chooser_tool_bar.addWidget(self._version_chooser_combo_box) for label in self._version_chooser_labels: self._version_chooser_combo_box.addItem(label) self._version_chooser_callback = lambda i: Qt.QMetaObject.invokeMethod(self._version_chooser_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._version_chooser_options.index(i))) self._version_chooser_callback(self.version_chooser) self._version_chooser_combo_box.currentIndexChanged.connect( lambda i: self.set_version_chooser(self._version_chooser_options[i])) self.tab_grid_layout_2.addWidget(self._version_chooser_tool_bar, 0,0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,0) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq-freq_offset, #fc samp_rate/50, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(True) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ["", "", "", "", "", "", "", "", "", ""] units = ["", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_1.addWidget(self._qtgui_number_sink_0_win, 0,0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0,0) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("TX/RX", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(50, (firdes.low_pass(1, samp_rate, channel_spacing,channel_trans, firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate) self._freq_range_layout = Qt.QVBoxLayout() self._freq_range_tool_bar = Qt.QToolBar(self) self._freq_range_layout.addWidget(self._freq_range_tool_bar) self._freq_range_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._freq_range_counter = qwt_counter_pyslot() self._freq_range_counter.setRange(433, 434, 0.005) self._freq_range_counter.setNumButtons(2) self._freq_range_counter.setValue(self.freq_range) self._freq_range_tool_bar.addWidget(self._freq_range_counter) self._freq_range_counter.valueChanged.connect(self.set_freq_range) self._freq_range_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_range_slider.setRange(433, 434, 0.005) self._freq_range_slider.setValue(self.freq_range) self._freq_range_slider.setMinimumWidth(1) self._freq_range_slider.valueChanged.connect(self.set_freq_range) self._freq_range_layout.addWidget(self._freq_range_slider) self.tab_grid_layout_0.addLayout(self._freq_range_layout, 1,0) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_1 = digital.binary_slicer_fb() self._data_rate_tool_bar = Qt.QToolBar(self) self._data_rate_tool_bar.addWidget(Qt.QLabel("Datarate"+": ")) self._data_rate_line_edit = Qt.QLineEdit(str(self.data_rate)) self._data_rate_tool_bar.addWidget(self._data_rate_line_edit) self._data_rate_line_edit.returnPressed.connect( lambda: self.set_data_rate(int(self._data_rate_line_edit.text().toAscii()))) self.tab_grid_layout_2.addWidget(self._data_rate_tool_bar, 1,0) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/fifo", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((gain*1e-3, )) self.band_pass_filter_0 = filter.fir_filter_ccc(1, firdes.complex_band_pass( 1, samp_rate/50, -2500, 2500, trans, firdes.WIN_HAMMING, 6.76)) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=samp_rate/50, audio_decim=1, audio_pass=0*500+1*2500, audio_stop=5000, ) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1, 0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.digital_binary_slicer_fb_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_1, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.thresh = thresh = 900*10**-3 self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## _thresh_sizer = wx.BoxSizer(wx.VERTICAL) self._thresh_text_box = forms.text_box( parent=self.GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, label='thresh', converter=forms.float_converter(), proportion=0, ) self._thresh_slider = forms.slider( parent=self.GetWin(), sizer=_thresh_sizer, value=self.thresh, callback=self.set_thresh, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_thresh_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=200*10**-3, v_offset=0, t_scale=100*10**-3, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=1, factor=1.0, decimal_places=6, ref_level=0, sample_rate=samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.digital_glfsr_source_x_0 = digital.glfsr_source_b(6, True, 0, 1) self.blocks_xor_xx_0 = blocks.xor_bb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_threshold_ff_0 = blocks.threshold_ff(thresh, thresh, 0) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0.5, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1280, bits_per_symbol=1, ) self.analog_noise_source_x_0 = analog.noise_source_f(analog.GR_UNIFORM, 0.5, 32) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_xor_xx_0, 1)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_xor_xx_0, 0)) self.connect((self.blocks_xor_xx_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_glfsr_source_x_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, "FM Radio") Qt.QWidget.__init__(self) self.setWindowTitle("FM Radio") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fm_radio") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.valid_gains = valid_gains = [0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6] self.samp_rate = samp_rate = 2.048e6 self.baseband_decimation = baseband_decimation = 10 self.rf_gain = rf_gain = len(valid_gains)-1 self.rds_dec = rds_dec = 10 self.pilot_tone = pilot_tone = 19e3 self.baseband_rate = baseband_rate = samp_rate // baseband_decimation self.stereo_subcarrier = stereo_subcarrier = pilot_tone * 2 self.stereo_button = stereo_button = 0 self.slider_volume = slider_volume = 0 self.sdr_gain = sdr_gain = valid_gains[rf_gain] self.rds_symbols_per_bit = rds_symbols_per_bit = 2 self.rds_subcarrier = rds_subcarrier = pilot_tone * 3 self.rds_samp_rate = rds_samp_rate = baseband_rate / rds_dec self.rds_bitrate = rds_bitrate = 1.1875e3 self.rds_bandwidth = rds_bandwidth = 2.83e3 self.fm_station = fm_station = 102.7 self.fm_broadcast_seperation = fm_broadcast_seperation = 0.2 self.fm_broadcast_low = fm_broadcast_low = 87.1 self.fm_broadcast_high = fm_broadcast_high = 107.9 self.audio_rate = audio_rate = 48e3 ################################################## # Blocks ################################################## self.notebook_top = Qt.QTabWidget() self.notebook_top_widget_0 = Qt.QWidget() self.notebook_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_0) self.notebook_top_grid_layout_0 = Qt.QGridLayout() self.notebook_top_layout_0.addLayout(self.notebook_top_grid_layout_0) self.notebook_top.addTab(self.notebook_top_widget_0, "RF Receive") self.notebook_top_widget_1 = Qt.QWidget() self.notebook_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_1) self.notebook_top_grid_layout_1 = Qt.QGridLayout() self.notebook_top_layout_1.addLayout(self.notebook_top_grid_layout_1) self.notebook_top.addTab(self.notebook_top_widget_1, "Baseband") self.notebook_top_widget_2 = Qt.QWidget() self.notebook_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_2) self.notebook_top_grid_layout_2 = Qt.QGridLayout() self.notebook_top_layout_2.addLayout(self.notebook_top_grid_layout_2) self.notebook_top.addTab(self.notebook_top_widget_2, "Mono Audio") self.notebook_top_widget_3 = Qt.QWidget() self.notebook_top_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_3) self.notebook_top_grid_layout_3 = Qt.QGridLayout() self.notebook_top_layout_3.addLayout(self.notebook_top_grid_layout_3) self.notebook_top.addTab(self.notebook_top_widget_3, "Sub-Carrier Generation") self.notebook_top_widget_4 = Qt.QWidget() self.notebook_top_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_4) self.notebook_top_grid_layout_4 = Qt.QGridLayout() self.notebook_top_layout_4.addLayout(self.notebook_top_grid_layout_4) self.notebook_top.addTab(self.notebook_top_widget_4, "Stereo") self.notebook_top_widget_5 = Qt.QWidget() self.notebook_top_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_top_widget_5) self.notebook_top_grid_layout_5 = Qt.QGridLayout() self.notebook_top_layout_5.addLayout(self.notebook_top_grid_layout_5) self.notebook_top.addTab(self.notebook_top_widget_5, "RDS") self.top_grid_layout.addWidget(self.notebook_top, 3, 0, 1, 8) self._slider_volume_range = Range(0, 11.1, 0.1, 0, 100) self._slider_volume_win = RangeWidget(self._slider_volume_range, self.set_slider_volume, 'Volume', "counter_slider", float) self.top_grid_layout.addWidget(self._slider_volume_win, 1, 1, 1, 1) self.notebook_subcarriers = Qt.QTabWidget() self.notebook_subcarriers_widget_0 = Qt.QWidget() self.notebook_subcarriers_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_subcarriers_widget_0) self.notebook_subcarriers_grid_layout_0 = Qt.QGridLayout() self.notebook_subcarriers_layout_0.addLayout(self.notebook_subcarriers_grid_layout_0) self.notebook_subcarriers.addTab(self.notebook_subcarriers_widget_0, "Pilot Signal") self.notebook_subcarriers_widget_1 = Qt.QWidget() self.notebook_subcarriers_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_subcarriers_widget_1) self.notebook_subcarriers_grid_layout_1 = Qt.QGridLayout() self.notebook_subcarriers_layout_1.addLayout(self.notebook_subcarriers_grid_layout_1) self.notebook_subcarriers.addTab(self.notebook_subcarriers_widget_1, "Spectrum") self.notebook_top_grid_layout_3.addWidget(self.notebook_subcarriers, 0, 0, 1, 1) self.notebook_rds = Qt.QTabWidget() self.notebook_rds_widget_0 = Qt.QWidget() self.notebook_rds_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rds_widget_0) self.notebook_rds_grid_layout_0 = Qt.QGridLayout() self.notebook_rds_layout_0.addLayout(self.notebook_rds_grid_layout_0) self.notebook_rds.addTab(self.notebook_rds_widget_0, "RDS Signal") self.notebook_rds_widget_1 = Qt.QWidget() self.notebook_rds_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.notebook_rds_widget_1) self.notebook_rds_grid_layout_1 = Qt.QGridLayout() self.notebook_rds_layout_1.addLayout(self.notebook_rds_grid_layout_1) self.notebook_rds.addTab(self.notebook_rds_widget_1, "RDS Bitstream") self.notebook_top_grid_layout_5.addWidget(self.notebook_rds, 0, 0, 1, 1) self._fm_station_range = Range(fm_broadcast_low, fm_broadcast_high, fm_broadcast_seperation, 102.7, 200) self._fm_station_win = RangeWidget(self._fm_station_range, self.set_fm_station, "FM Station", "counter_slider", float) self.top_grid_layout.addWidget(self._fm_station_win, 0, 0, 1, 8) self._stereo_button_options = (0, 1, ) self._stereo_button_labels = ("Mono", "Stereo", ) self._stereo_button_tool_bar = Qt.QToolBar(self) self._stereo_button_tool_bar.addWidget(Qt.QLabel("Audio Output"+": ")) self._stereo_button_combo_box = Qt.QComboBox() self._stereo_button_tool_bar.addWidget(self._stereo_button_combo_box) for label in self._stereo_button_labels: self._stereo_button_combo_box.addItem(label) self._stereo_button_callback = lambda i: Qt.QMetaObject.invokeMethod(self._stereo_button_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._stereo_button_options.index(i))) self._stereo_button_callback(self.stereo_button) self._stereo_button_combo_box.currentIndexChanged.connect( lambda i: self.set_stereo_button(self._stereo_button_options[i])) self.top_grid_layout.addWidget(self._stereo_button_tool_bar, 1, 2, 1, 1) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fm_station * 1e6, 0) self.rtlsdr_source_0.set_freq_corr(14, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(sdr_gain, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine( 2, rds_samp_rate, rds_bitrate * rds_symbols_per_bit, 0.275, 16)) self._rf_gain_range = Range(0, len(valid_gains)-1, 1, len(valid_gains)-1, 200) self._rf_gain_win = RangeWidget(self._rf_gain_range, self.set_rf_gain, "RF Gain", "counter_slider", int) self.top_grid_layout.addWidget(self._rf_gain_win, 1, 0, 1, 1) self.rds_qt_panel_0 = self.rds_qt_panel_0 = rds.qt_panel() self.notebook_top_layout_5.addWidget(self.rds_qt_panel_0) self.rational_resampler_xxx_0_0_0_1 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0_0_0 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0_0 = filter.rational_resampler_fff( interpolation=int(audio_rate), decimation=int(baseband_rate), taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "RBDS Bit Stream", #name 2 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1.7, 1.7) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, False) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["Raw Bit Stream", "Differential Decoded", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.notebook_rds_layout_1.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size baseband_rate, #samp_rate "19 KHz Pilot Signal", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "counts") self.qtgui_time_sink_x_0.enable_tags(-1, False) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_subcarriers_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc rds_samp_rate, #bw "RDS Subcarrier Signal (DSB-SSC)", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.notebook_rds_grid_layout_0 .addWidget(self._qtgui_freq_sink_x_1_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_1_0_1_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Stereo Audio Left", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_1_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_1_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_1_0.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_1_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_1_0_1_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_1_0.set_plot_pos_half(not False) labels = ["Stereo Left", "Stereo Right", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_1_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_1_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_4.addWidget(self._qtgui_freq_sink_x_0_1_0_1_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_1_0_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Stereo Audio Right", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_1.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_1_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_1.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_1.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_1_0_1.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_1.set_plot_pos_half(not False) labels = ["Stereo Right", "Stereo Right", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_1_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_1.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_4.addWidget(self._qtgui_freq_sink_x_0_1_0_1_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0_1_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "Pilot & Stereo Carrier", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_1_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_1_0_0.set_y_axis(-80, 0) self.qtgui_freq_sink_x_0_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_1_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_1_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_1_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_1_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_1_0_0.set_plot_pos_half(not False) labels = ["Pilot Tone", "Stereo Carrier", "RDS Carrier", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1_0_0.pyqwidget(), Qt.QWidget) self.notebook_subcarriers_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_1_0_0_win, 0, 0, 1, 1) self.qtgui_freq_sink_x_0_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Mono Audio (L+R)", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0_0.set_fft_average(0.2) self.qtgui_freq_sink_x_0_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_0_0.set_plot_pos_half(not False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_2.addWidget(self._qtgui_freq_sink_x_0_0_0_win, 1, 0, 1, 5) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc baseband_rate, #bw "FM Baseband", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-100, -30) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0_0.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fm_station * 1e6, #fc samp_rate, #bw "RF Frequency", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-90, 0) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_top_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 1, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "RDS BPSK Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-1.6, 1.6) self.qtgui_const_sink_x_0.set_x_axis(-1.6, 1.6) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) if not False: self.qtgui_const_sink_x_0.disable_legend() labels = ["RBDS BPSK", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.notebook_rds_grid_layout_0.addWidget(self._qtgui_const_sink_x_0_win, 0, 1, 1, 1) self.low_pass_filter_4 = filter.fir_filter_fff(1, firdes.low_pass( 1, baseband_rate, 60e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_fff(1, firdes.low_pass( 1, baseband_rate, 16e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 10, baseband_rate, 15e3, 3e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(baseband_decimation, firdes.low_pass( 1, samp_rate, 75e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.gr_rds_parser_0 = rds.parser(False, False, 1) self.gr_rds_decoder_0 = rds.decoder(False, False) self.freq_xlating_fir_filter_xxx_1 = filter.freq_xlating_fir_filter_fcc(rds_dec, (firdes.low_pass(2500,baseband_rate,rds_bandwidth,1e3,firdes.WIN_HAMMING)), rds_subcarrier, baseband_rate) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, (2 * cmath.pi) / 100, -0.00006, 0.00006, 0.5, 0.05, rds_samp_rate / (rds_bitrate * 2), ((rds_samp_rate / (rds_bitrate * 2)) ** 2)/ 4, 0.005) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_uchar_to_float_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_multiply_xx_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_0_1_0_1 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1_0_0 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1_0 = blocks.multiply_const_vff((11, )) self.blocks_multiply_const_vxx_1_0_1 = blocks.multiply_const_vff((slider_volume, )) self.blocks_multiply_const_vxx_1_0_0 = blocks.multiply_const_vff((slider_volume, )) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((slider_volume, )) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 2) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((0.5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1.5, )) self.blks2_selector_0_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=0, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_float*1, num_inputs=2, num_outputs=1, input_index=0, output_index=0, ) self.band_pass_filter_1 = filter.fir_filter_fff(1, firdes.band_pass( 1, baseband_rate, stereo_subcarrier - 0.5e3, stereo_subcarrier + 0.5e3, 0.5e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 1, baseband_rate, 23e3, 53e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fcc(1, firdes.complex_band_pass( 1, baseband_rate, pilot_tone - 0.5e3, pilot_tone+0.5e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=baseband_rate, audio_decimation=1, ) self.analog_pll_refout_cc_0 = analog.pll_refout_cc(1e-3, 2 * cmath.pi * (19000+200) / baseband_rate, 2 * cmath.pi * (19000-200) / baseband_rate) self.analog_fm_deemph_0_0_0_1 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) self.analog_fm_deemph_0_0_0_0 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) self.analog_fm_deemph_0_0_0 = analog.fm_deemph(fs=baseband_rate, tau=75e-6) ################################################## # Connections ################################################## self.msg_connect((self.gr_rds_decoder_0, 'out'), (self.gr_rds_parser_0, 'in')) self.msg_connect((self.gr_rds_parser_0, 'out'), (self.rds_qt_panel_0, 'in')) self.connect((self.analog_fm_deemph_0_0_0, 0), (self.rational_resampler_xxx_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0_0, 0), (self.rational_resampler_xxx_0_0_0_0, 0)) self.connect((self.analog_fm_deemph_0_0_0_1, 0), (self.rational_resampler_xxx_0_0_0_1, 0)) self.connect((self.analog_pll_refout_cc_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.low_pass_filter_4, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_pll_refout_cc_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.band_pass_filter_1, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.band_pass_filter_1, 0), (self.qtgui_freq_sink_x_0_1_0_0, 1)) self.connect((self.blks2_selector_0, 0), (self.audio_sink_0, 0)) self.connect((self.blks2_selector_0_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_fm_deemph_0_0_0_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_freq_sink_x_0_1_0_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blks2_selector_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_freq_sink_x_0_1_0_1, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.blks2_selector_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_0, 0), (self.qtgui_freq_sink_x_0_1_0_1_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.blks2_selector_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.blks2_selector_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1, 0), (self.qtgui_freq_sink_x_0_0_0, 1)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0, 0), (self.qtgui_freq_sink_x_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0_0, 0), (self.qtgui_freq_sink_x_0_1_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_1_0_1_0_1, 0), (self.qtgui_freq_sink_x_0_1_0_1_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.band_pass_filter_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_2, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.analog_fm_deemph_0_0_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_uchar_to_float_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_uchar_to_float_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.gr_rds_decoder_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.freq_xlating_fir_filter_xxx_1, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.analog_fm_deemph_0_0_0_1, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.blocks_add_xx_0, 1)) self.connect((self.low_pass_filter_2, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.low_pass_filter_4, 0), (self.band_pass_filter_0, 0)) self.connect((self.low_pass_filter_4, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_4, 0), (self.freq_xlating_fir_filter_xxx_1, 0)) self.connect((self.low_pass_filter_4, 0), (self.low_pass_filter_1, 0)) self.connect((self.low_pass_filter_4, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_1_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_0_0, 0), (self.blocks_multiply_const_vxx_1_0_1_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0_1, 0), (self.blocks_multiply_const_vxx_1_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0_0_1, 0), (self.blocks_multiply_const_vxx_1_0_1_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.rtlsdr_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self, filenames, dev_addrs, onebit, iq, noise, mix, gain, fs, fc, unint, sync_pps): gr.top_block.__init__(self) if mix: raise NotImplementedError("TODO: Hilbert remix mode not implemented.") uhd_sinks = [ uhd.usrp_sink(",".join( [addr, "send_frame_size=32768,num_send_frames=128"]), uhd.stream_args( cpu_format="fc32", otwformat="sc8", channels=[0])) for addr in dev_addrs] for sink in uhd_sinks: sink.set_clock_rate(fs*2, uhd.ALL_MBOARDS) sink.set_samp_rate(fs) sink.set_center_freq(fc, 0) sink.set_gain(gain, 0) # TODO Use offset tuning? if sync_pps: sink.set_clock_source("external") # 10 MHz sink.set_time_source("external") # PPS if unint: if noise or onebit or not iq: raise NotImplementedError("TODO: RX channel-interleaved mode only " "supported for noiseless 8-bit complex.") BLOCK_N=16*1024*1024 demux = blocks.vector_to_streams(2, len(uhd_sinks)) self.connect(blocks.file_source(2*len(uhd_sinks)*BLOCK_N, filenames[0], False), blocks.vector_to_stream(2*len(uhd_sinks), BLOCK_N), demux) for ix, sink in enumerate(uhd_sinks): self.connect((demux, ix), blocks.vector_to_stream(1, 2), blocks.interleaved_char_to_complex(), # [-128.0, +127.0] blocks.multiply_const_cc(1.0/1024), # [-0.125, 0.125) # blocks.vector_to_stream(8, 16*1024), sink) else: file_srcs = [blocks.file_source(gr.sizeof_char*1, f, False) for f in filenames] for src, sink in zip(file_srcs, uhd_sinks): if iq: node = blocks.multiply_const_cc(1.0/1024) if onebit: self.connect(src, blocks.unpack_k_bits_bb(8), blocks.char_to_short(), # [0, 1] -> [0, 256] blocks.add_const_ss(-128), # [-128, +128], blocks.interleaved_short_to_complex(), # [ -128.0, +128.0] node) # [-0.125, +0.125] else: self.connect(src, # [-128..127] blocks.interleaved_char_to_complex(), # [-128.0, +127.0] node) # [-0.125, +0.125) else: node = blocks.float_to_complex(1) if onebit: self.connect(src, blocks.unpack_k_bits_bb(8), # [0, 1] -> [-0.125, +0.125] blocks.char_to_float(vlen=1, scale=4), blocks.add_const_vff((-0.125, )), node) else: self.connect(src, # [-128..127] -> [-0.125, +0.125) blocks.char_to_float(vlen=1, scale=1024), node) if noise: combiner = blocks.add_vcc(1) self.connect(node, combiner, sink) self.connect(analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise, -222, 8192), (combiner, 1)) else: self.connect(node, sink) print "Setting clocks..." if sync_pps: time.sleep(1.1) # Ensure there's been an edge. TODO: necessary? last_pps_time = uhd_sinks[0].get_time_last_pps() while last_pps_time == uhd_sinks[0].get_time_last_pps(): time.sleep(0.1) print "Got edge" [sink.set_time_next_pps(uhd.time_spec(round(time.time())+1)) for sink in uhd_sinks] time.sleep(1.0) # Wait for edge to set the clocks else: # No external PPS/10 MHz. Just set each clock and accept some skew. t = time.time() [sink.set_time_now(uhd.time_spec(time.time())) for sink in uhd_sinks] if len(uhd_sinks) > 1: print "Uncabled; loosely synced only. Initial skew ~ %.1f ms" % ( (time.time()-t) * 1000) t_start = uhd.time_spec(time.time() + 1.5) [sink.set_start_time(t_start) for sink in uhd_sinks] print "ready"
def __init__(self, rxPort=52002, txPort=52001): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.rxPort = rxPort self.txPort = txPort ################################################## # Variables ################################################## self.localOscillator = localOscillator = 14070000 self.threshold = threshold = -200 self.samp_rate = samp_rate = 48000 self.rxPhase = rxPhase = .84 self.rxMagnitude = rxMagnitude = 0.854 self.freqFine = freqFine = 0 self.freq = freq = localOscillator self.bandwidth = bandwidth = 50 ################################################## # Blocks ################################################## _threshold_sizer = wx.BoxSizer(wx.VERTICAL) self._threshold_text_box = forms.text_box( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, label="threshold", converter=forms.float_converter(), proportion=0, ) self._threshold_slider = forms.slider( parent=self.GetWin(), sizer=_threshold_sizer, value=self.threshold, callback=self.set_threshold, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_threshold_sizer) self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "tuning") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "scope") self.Add(self.notebook_0) _freqFine_sizer = wx.BoxSizer(wx.VERTICAL) self._freqFine_text_box = forms.text_box( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, label="Tuning", converter=forms.float_converter(), proportion=0, ) self._freqFine_slider = forms.slider( parent=self.GetWin(), sizer=_freqFine_sizer, value=self.freqFine, callback=self.set_freqFine, minimum=-500, maximum=500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freqFine_sizer) _freq_sizer = wx.BoxSizer(wx.VERTICAL) self._freq_text_box = forms.text_box( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, label="Frequency", converter=forms.float_converter(), proportion=0, ) self._freq_slider = forms.slider( parent=self.GetWin(), sizer=_freq_sizer, value=self.freq, callback=self.set_freq, minimum=localOscillator-samp_rate, maximum=localOscillator+samp_rate, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_freq_sizer) _bandwidth_sizer = wx.BoxSizer(wx.VERTICAL) self._bandwidth_text_box = forms.text_box( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, label="Signal Bandwidth", converter=forms.float_converter(), proportion=0, ) self._bandwidth_slider = forms.slider( parent=self.GetWin(), sizer=_bandwidth_sizer, value=self.bandwidth, callback=self.set_bandwidth, minimum=30, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_bandwidth_sizer) self.wxgui_waterfallsink2_0_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(1).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(1).Add(self.wxgui_waterfallsink2_0_0_0.win) self.wxgui_waterfallsink2_0_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=125*8, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0_0.win) self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=localOscillator, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.notebook_0.GetPage(0).Add(self.wxgui_waterfallsink2_0.win) self.low_pass_filter_0_1 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, 500, 500, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 30, 30, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(samp_rate/125/8, firdes.low_pass( 1, samp_rate, bandwidth, bandwidth, firdes.WIN_HAMMING, 6.76)) self.digital_mpsk_receiver_cc_0 = digital.mpsk_receiver_cc(2, 0, cmath.pi/100.0, -0.5, 0.5, 0.25, 0.01, 125*8/31.25, 0.001, 0.001) self.blocks_transcendental_1 = blocks.transcendental("sin", "float") self.blocks_transcendental_0 = blocks.transcendental("cos", "float") self.blocks_throttle_0_1 = blocks.throttle(gr.sizeof_float*1, samp_rate) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, 31.25) self.blocks_threshold_ff_0 = blocks.threshold_ff(1e-12, 1e-12, 0) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, int(samp_rate/31.25)) self.blocks_null_source_1 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_null_source_0 = blocks.null_source(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((rxMagnitude, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_float_to_complex_1_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=txPort, server=False, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=rxPort, server=False, ) self.audio_source_0 = audio.source(samp_rate, "", True) self.audio_sink_0 = audio.sink(samp_rate, "", True) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(threshold, 1) self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -freqFine, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq+freqFine-localOscillator, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, -(freq-localOscillator), 1, 0) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, rxPhase*3.14159/180.0) self.analog_agc_xx_0 = analog.agc_cc(1e-4, 1.0, 1.0) self.analog_agc_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_1, 0)) self.connect((self.analog_const_source_x_0, 0), (self.blocks_transcendental_0, 0)) self.connect((self.blocks_transcendental_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_transcendental_1, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_null_source_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.audio_source_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_float_to_complex_1_0, 1)) self.connect((self.audio_source_0, 1), (self.blocks_float_to_complex_1_0, 0)) self.connect((self.blocks_float_to_complex_1_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.blocks_null_source_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.digital_mpsk_receiver_cc_0, 0), (self.blocks_delay_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0_1, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_1, 0)) self.connect((self.low_pass_filter_0_1, 0), (self.wxgui_waterfallsink2_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.digital_mpsk_receiver_cc_0, 0)) self.connect((self.analog_agc_xx_0, 0), (self.wxgui_waterfallsink2_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.audio_sink_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.wxgui_waterfallsink2_0, 0))
def __init__(self, MTU=1500): gr.top_block.__init__(self, "Telemetry Rx Final") Qt.QWidget.__init__(self) self.setWindowTitle("Telemetry Rx Final") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "telemetry_rx_final") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.MTU = MTU ################################################## # Variables ################################################## self.symb_rate = symb_rate = 44643 self.sec_dec = sec_dec = 10 self.samp_per_symb = samp_per_symb = 10 self.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.first_dec = first_dec = 1 self.ss_ted_gain_range = ss_ted_gain_range = 100 self.ss_loopbw_range = ss_loopbw_range = 0.4 self.ss_damping_factor_range = ss_damping_factor_range = 0.5 self.source_option = source_option = False self.pll_loopbw_range = pll_loopbw_range = 0.4 self.doppler = doppler = 10000 self.dec_cc = dec_cc = fec.cc_decoder.make(MTU*8, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False) self.channel_bw = channel_bw = 1200000 self.ad_samp_rate = ad_samp_rate = symb_rate*first_dec*sec_dec*samp_per_symb ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Frequency Plot') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Control Tab') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Time') self.tab_widget_3 = Qt.QWidget() self.tab_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_3) self.tab_grid_layout_3 = Qt.QGridLayout() self.tab_layout_3.addLayout(self.tab_grid_layout_3) self.tab.addTab(self.tab_widget_3, 'Demoded Bits') self.tab_widget_4 = Qt.QWidget() self.tab_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_4) self.tab_grid_layout_4 = Qt.QGridLayout() self.tab_layout_4.addLayout(self.tab_grid_layout_4) self.tab.addTab(self.tab_widget_4, 'Decoded Data') self.tab_widget_5 = Qt.QWidget() self.tab_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_5) self.tab_grid_layout_5 = Qt.QGridLayout() self.tab_layout_5.addLayout(self.tab_grid_layout_5) self.tab.addTab(self.tab_widget_5, 'Decrypted Data') self.top_grid_layout.addWidget(self.tab, 0, 0, 4, 4) for r in range(0, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self._ss_ted_gain_range_range = Range(1, 1000, 1, 100, 10000) self._ss_ted_gain_range_win = RangeWidget(self._ss_ted_gain_range_range, self.set_ss_ted_gain_range, 'Symbol Sync TED gain', "dial", float) self.tab_grid_layout_1.addWidget(self._ss_ted_gain_range_win, 1, 2, 1, 1) for r in range(1, 2): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(2, 3): self.tab_grid_layout_1.setColumnStretch(c, 1) self._ss_loopbw_range_range = Range(0.001, 2, 0.001, 0.4, 10000) self._ss_loopbw_range_win = RangeWidget(self._ss_loopbw_range_range, self.set_ss_loopbw_range, 'Symbol Sync LBW', "dial", float) self.tab_grid_layout_1.addWidget(self._ss_loopbw_range_win, 1, 0, 1, 1) for r in range(1, 2): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._ss_damping_factor_range_range = Range(0.001, 2, 0.001, 0.5, 10000) self._ss_damping_factor_range_win = RangeWidget(self._ss_damping_factor_range_range, self.set_ss_damping_factor_range, 'Symbol Sync DF', "dial", float) self.tab_grid_layout_1.addWidget(self._ss_damping_factor_range_win, 1, 1, 1, 1) for r in range(1, 2): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 2): self.tab_grid_layout_1.setColumnStretch(c, 1) self._source_option_options = (True, False, ) self._source_option_labels = ('AD9361', 'File', ) self._source_option_group_box = Qt.QGroupBox('Source From') self._source_option_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._source_option_button_group = variable_chooser_button_group() self._source_option_group_box.setLayout(self._source_option_box) for i, label in enumerate(self._source_option_labels): radio_button = Qt.QRadioButton(label) self._source_option_box.addWidget(radio_button) self._source_option_button_group.addButton(radio_button, i) self._source_option_callback = lambda i: Qt.QMetaObject.invokeMethod(self._source_option_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._source_option_options.index(i))) self._source_option_callback(self.source_option) self._source_option_button_group.buttonClicked[int].connect( lambda i: self.set_source_option(self._source_option_options[i])) self.tab_grid_layout_1.addWidget(self._source_option_group_box, 2, 0, 1, 1) for r in range(2, 3): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._pll_loopbw_range_range = Range(0.001, 2, 0.001, 0.4, 10000) self._pll_loopbw_range_win = RangeWidget(self._pll_loopbw_range_range, self.set_pll_loopbw_range, 'PLL LBW', "dial", float) self.tab_grid_layout_1.addWidget(self._pll_loopbw_range_win, 0, 0, 1, 1) for r in range(0, 1): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.tab_grid_layout_1.setColumnStretch(c, 1) self._doppler_range = Range(-50000, 50000, 1, 10000, 10000) self._doppler_win = RangeWidget(self._doppler_range, self.set_doppler, 'Doppler', "dial", int) self.tab_grid_layout_1.addWidget(self._doppler_win, 0, 1, 1, 1) for r in range(0, 1): self.tab_grid_layout_1.setRowStretch(r, 1) for c in range(1, 2): self.tab_grid_layout_1.setColumnStretch(c, 1) self.satellites_decode_rs_general_0 = satellites.decode_rs_general(285, 0, 1, 32, False, True) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=first_dec, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc ad_samp_rate/first_dec, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(True) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 0, 2, 4) for r in range(2, 4): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_0.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_1_0_0 = qtgui.time_sink_f( 203, #size 1, #samp_rate "GCM-AES Decryptor Out", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_y_axis(-10, 300) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "frm_len") self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_1_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_1_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_5.addWidget(self._qtgui_time_sink_x_0_0_0_0_1_0_0_win, 0, 0, 2, 4) for r in range(0, 2): self.tab_grid_layout_5.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_5.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_1_0 = qtgui.time_sink_f( 255, #size 1, #samp_rate "Viterbi Decoder Out", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_1_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_1_0.set_y_axis(-10, 300) self.qtgui_time_sink_x_0_0_0_0_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_1_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "pkt_len") self.qtgui_time_sink_x_0_0_0_0_1_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_1_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_1_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_4.addWidget(self._qtgui_time_sink_x_0_0_0_0_1_0_win, 0, 0, 2, 4) for r in range(0, 2): self.tab_grid_layout_4.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_4.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_1 = qtgui.time_sink_f( 223, #size 1, #samp_rate "Reed-Solomon Decoder Out", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_1.set_y_axis(-10, 300) self.qtgui_time_sink_x_0_0_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "pkt_len") self.qtgui_time_sink_x_0_0_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_1.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_1.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_1.pyqwidget(), Qt.QWidget) self.tab_grid_layout_4.addWidget(self._qtgui_time_sink_x_0_0_0_0_1_win, 2, 0, 2, 4) for r in range(2, 4): self.tab_grid_layout_4.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_4.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f( 4144, #size ad_samp_rate/first_dec/sec_dec/samp_per_symb, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1, 2) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "pkt_len") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win, 2, 0, 2, 4) for r in range(2, 4): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size ad_samp_rate/first_dec/sec_dec/samp_per_symb, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(True) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_time_sink_x_0_0_win, 0, 0, 2, 2) for r in range(0, 2): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(0, 2): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size ad_samp_rate/first_dec/sec_dec, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-20, 20) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [2, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0_0.set_update_time(0.10) self.qtgui_number_sink_0_0.set_title("Decrypted Frame Counter") labels = ['Counter', 'Rate', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0.set_min(i, -1) self.qtgui_number_sink_0_0.set_max(i, 1) self.qtgui_number_sink_0_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0.set_label(i, labels[i]) self.qtgui_number_sink_0_0.set_unit(i, units[i]) self.qtgui_number_sink_0_0.set_factor(i, factor[i]) self.qtgui_number_sink_0_0.enable_autoscale(False) self._qtgui_number_sink_0_0_win = sip.wrapinstance(self.qtgui_number_sink_0_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_number_sink_0_0_win, 0, 3, 2, 1) for r in range(0, 2): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(3, 4): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 2 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("Received Frame Counter") labels = ['Counter', 'Rate', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(2): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_3.addWidget(self._qtgui_number_sink_0_win, 0, 2, 2, 1) for r in range(0, 2): self.tab_grid_layout_3.setRowStretch(r, 1) for c in range(2, 3): self.tab_grid_layout_3.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc ad_samp_rate/first_dec, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-160, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_grid_layout_0.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 2, 4) for r in range(0, 2): self.tab_grid_layout_0.setRowStretch(r, 1) for c in range(0, 4): self.tab_grid_layout_0.setColumnStretch(c, 1) self.low_pass_filter_0 = filter.fir_filter_ccf(sec_dec, firdes.low_pass( 1, ad_samp_rate/first_dec, channel_bw, channel_bw/10, firdes.WIN_HAMMING, 6.76)) self.iustsat_zafar_telemetry_frame_extractor_1 = iustsat.zafar_telemetry_frame_extractor("pkt_len") self.iustsat_zafar_telemetry_derand_0 = iustsat.zafar_telemetry_derand("pkt_len") self.iustsat_tag_counter_0 = iustsat.tag_counter('pkt_len') self.iustsat_synch_detect_tag_1_0 = iustsat.synch_detect_tag(60,'pkt_len',259*2*8) self.iustsat_synch_detect_tag_1 = iustsat.synch_detect_tag(60,'pkt_len',259*2*8) self.iustsat_rs_to_decrypt_0_0 = iustsat.rs_to_decrypt('iv', ([0xCA, 0xFE, 0xBA, 0xBE, 0xFA, 0xCE, 0xDB, 0xAD, 0xDE, 0xCA, 0xF8, 0x88]), 'aad', 'auth_tag') self.iustsat_pdu_to_message_0 = iustsat.pdu_to_message('frm_len') self.iustsat_frame_analysis_0 = iustsat.frame_analysis('frm_len') self.iio_fmcomms2_source_0 = iio.fmcomms2_source_f32c('192.168.1.10', 436500000+doppler, ad_samp_rate, channel_bw, True, False, 0x8000, True, True, True, "fast_attack", 64.0, "manual", 64.0, "A_BALANCED", '', True) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, ([1,1,1,-1,1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,1,1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1])) self.fir_filter_xxx_0.declare_sample_delay(0) self.fec_async_decoder_0 = fec.async_decoder(dec_cc, True, False, MTU) self.digital_symbol_sync_xx_0 = digital.symbol_sync_ff(digital.TED_GARDNER, samp_per_symb, ss_loopbw_range, ss_damping_factor_range, ss_ted_gain_range, 1, 1, digital.constellation_bpsk().base(), digital.IR_PFB_NO_MF, 128, ([])) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.dc_blocker_xx_0 = filter.dc_blocker_ff(100000, True) self.crypto_auth_dec_aes_gcm_0_0 = crypto.auth_dec_aes_gcm(([0xFE, 0xFF, 0xE9, 0x92, 0x86, 0x65, 0x73, 0x1C, 0x6D, 0x6A, 0x8F, 0x94, 0x67, 0x30, 0x83, 0x08]), 16, 96) self.blocks_uchar_to_float_1_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, ad_samp_rate,True) self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("") self.blocks_pdu_to_tagged_stream_0_0_0_0 = blocks.pdu_to_tagged_stream(blocks.float_t, 'frm_len') self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(blocks.float_t, 'frm_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pkt_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'pkt_len') self.blocks_multiply_const_vxx_2_0 = blocks.multiply_const_vcc((source_option, )) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc(((not source_option), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0.066666667, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((2, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(samp_per_symb, 10, 4000, 1) self.blocks_message_debug_0_0 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/iust/Documents/zafar_prj/gr-iustsat/examples/Records/REC7_GMSK.bin', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float*1, 63) self.blocks_delay_0 = blocks.delay(gr.sizeof_float*1, 63) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((0, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.analog_pll_freqdet_cf_0 = analog.pll_freqdet_cf(pll_loopbw_range, 700000*6.28/(ad_samp_rate/first_dec/sec_dec), 300000*6.28/(ad_samp_rate/first_dec/sec_dec)) ################################################## # Connections ################################################## self.msg_connect((self.crypto_auth_dec_aes_gcm_0_0, 'pdus'), (self.iustsat_frame_analysis_0, 'in')) self.msg_connect((self.crypto_auth_dec_aes_gcm_0_0, 'pdus'), (self.iustsat_pdu_to_message_0, 'in')) self.msg_connect((self.fec_async_decoder_0, 'out'), (self.iustsat_zafar_telemetry_derand_0, 'in')) self.msg_connect((self.iustsat_frame_analysis_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.iustsat_pdu_to_message_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0_0, 'pdus')) self.msg_connect((self.iustsat_rs_to_decrypt_0_0, 'out'), (self.crypto_auth_dec_aes_gcm_0_0, 'pdus')) self.msg_connect((self.iustsat_zafar_telemetry_derand_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.iustsat_zafar_telemetry_derand_0, 'out'), (self.satellites_decode_rs_general_0, 'in')) self.msg_connect((self.iustsat_zafar_telemetry_frame_extractor_1, 'out'), (self.fec_async_decoder_0, 'in')) self.msg_connect((self.satellites_decode_rs_general_0, 'out'), (self.blocks_message_debug_0_0, 'print_pdu')) self.msg_connect((self.satellites_decode_rs_general_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.satellites_decode_rs_general_0, 'out'), (self.iustsat_rs_to_decrypt_0_0, 'in')) self.connect((self.analog_pll_freqdet_cf_0, 0), (self.dc_blocker_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.iustsat_synch_detect_tag_1, 0)) self.connect((self.blocks_delay_0_0, 0), (self.iustsat_synch_detect_tag_1_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_2_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_uchar_to_float_1_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0), (self.qtgui_number_sink_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0_0_1_0_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.qtgui_time_sink_x_0_0_0_0_1, 0)) self.connect((self.blocks_uchar_to_float_1_0, 0), (self.qtgui_time_sink_x_0_0_0_0_1_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.iustsat_synch_detect_tag_1, 1)) self.connect((self.fir_filter_xxx_0, 0), (self.iustsat_synch_detect_tag_1_0, 1)) self.connect((self.iio_fmcomms2_source_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.iustsat_synch_detect_tag_1, 0), (self.iustsat_tag_counter_0, 0)) self.connect((self.iustsat_synch_detect_tag_1, 0), (self.iustsat_zafar_telemetry_frame_extractor_1, 0)) self.connect((self.iustsat_synch_detect_tag_1_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.iustsat_tag_counter_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.iustsat_tag_counter_0, 1), (self.qtgui_number_sink_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.analog_pll_freqdet_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.initpathprefix = initpathprefix = "/home/user/alarm-fingerprint/AlarmGnuRadioFiles/" self.pathprefix = pathprefix = "/home/user/alarm-fingerprint/AlarmGnuRadioFiles/Captured/" self.finput = finput = initpathprefix + "Capture_init.cap" self.foutput = foutput = pathprefix + finput.rsplit("/", 1)[1] self.symb_rate = symb_rate = 4000 self.samp_rate = samp_rate = 10e6 self.decimation = decimation = 100 self.channel_spacing = channel_spacing = 2000000 + 1000000 self.addconst = addconst = 0 self.symb_rate_slider = symb_rate_slider = 4000 self.samp_per_sym = samp_per_sym = int((samp_rate / decimation) / symb_rate) self.recfile4 = recfile4 = initpathprefix + "/init/_AddConst" + str(addconst) + "_DSC.dat" self.freq_offset = freq_offset = (channel_spacing / 2) + (channel_spacing * 0.1) self.freq = freq = 433.92e6 self.channel_trans = channel_trans = 1.2e6 ################################################## # Blocks ################################################## _channel_trans_sizer = wx.BoxSizer(wx.VERTICAL) self._channel_trans_text_box = forms.text_box( parent=self.GetWin(), sizer=_channel_trans_sizer, value=self.channel_trans, callback=self.set_channel_trans, label="channel_trans", converter=forms.float_converter(), proportion=0, ) self._channel_trans_slider = forms.slider( parent=self.GetWin(), sizer=_channel_trans_sizer, value=self.channel_trans, callback=self.set_channel_trans, minimum=0, maximum=1.8e6, num_steps=10, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_channel_trans_sizer) _symb_rate_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._symb_rate_slider_text_box = forms.text_box( parent=self.GetWin(), sizer=_symb_rate_slider_sizer, value=self.symb_rate_slider, callback=self.set_symb_rate_slider, label="symb_rate_slider", converter=forms.float_converter(), proportion=0, ) self._symb_rate_slider_slider = forms.slider( parent=self.GetWin(), sizer=_symb_rate_slider_sizer, value=self.symb_rate_slider, callback=self.set_symb_rate_slider, minimum=0, maximum=10e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_symb_rate_slider_sizer) self.low_pass_filter_0 = filter.fir_filter_fff( decimation, firdes.low_pass(1, samp_rate, 8e3, 1.8e6, firdes.WIN_BLACKMAN, 6.76) ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1, samp_rate, channel_spacing, channel_trans, firdes.WIN_BLACKMAN, 6.76)), -freq_offset, samp_rate, ) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005 ) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex * 1, finput, False) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char * 1, recfile4, False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((addconst,)) ################################################## # Connections ################################################## self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.blocks_file_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.r = r = 10 self.n = n = 64800 self.mult = mult = 100 self.SNR = SNR = 20 ################################################## # Blocks ################################################## self._SNR_range = Range(-50, 50, 1, 20, 200) self._SNR_win = RangeWidget(self._SNR_range, self.set_SNR, "SNR", "counter_slider", float) self.top_layout.addWidget(self._SNR_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 16200, #size samp_rate, #samp_rate 'LDPC IN', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-mult - 0.1, mult + 0.1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 10800, #size samp_rate, #samp_rate 'LDPC OUT', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-0.1, 1.1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.5, qtgui.NUM_GRAPH_NONE, 1) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10-6', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1e6, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, -1) self.qtgui_number_sink_0.set_max(i, 1) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance( self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_win) self.mapper_prbs_source_b_0 = mapper.prbs_source_b("PRBS7", 108000) self.mapper_prbs_sink_b_0 = mapper.prbs_sink_b("PRBS7", 108000) self.mack_sdr_ldpc_encoder_0 = mack_sdr.ldpc_encoder(n, r) self.ldpc_dec_soft_0 = ldpc_dec_soft( n=n, r=r, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000000, bits_per_symbol=1, ) self.analog_noise_source_x_0 = analog.noise_source_f( analog.GR_GAUSSIAN, math.pow(10.0, -(SNR - 1.25) / 20.0) / math.sqrt(2.0) * mult, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.ldpc_dec_soft_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.ldpc_dec_soft_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.ldpc_dec_soft_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.ldpc_dec_soft_0, 0), (self.mapper_prbs_sink_b_0, 0)) self.connect((self.mack_sdr_ldpc_encoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.mapper_prbs_source_b_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.mapper_prbs_source_b_0, 0), (self.mack_sdr_ldpc_encoder_0, 0))
def __init__(self, buflen=4096, dc_offset_i=0, dc_offset_q=0, instance=0, num_buffers=16, num_xfers=8, rx_bandwidth=1.5e6, rx_frequency=950e6, rx_lna_gain=6, rx_sample_rate=3e6, rx_vga_gain=20, serial="", verbosity="info"): gr.top_block.__init__(self, "Simple bladeRF RX GUI") Qt.QWidget.__init__(self) self.setWindowTitle("Simple bladeRF RX GUI") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "bladeRF_rx") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Parameters ################################################## self.buflen = buflen self.dc_offset_i = dc_offset_i self.dc_offset_q = dc_offset_q self.instance = instance self.num_buffers = num_buffers self.num_xfers = num_xfers self.rx_bandwidth = rx_bandwidth self.rx_frequency = rx_frequency self.rx_lna_gain = rx_lna_gain self.rx_sample_rate = rx_sample_rate self.rx_vga_gain = rx_vga_gain self.serial = serial self.verbosity = verbosity ################################################## # Variables ################################################## self.bladerf_selection = bladerf_selection = str( instance) if serial == "" else serial self.bladerf_args = bladerf_args = "bladerf=" + bladerf_selection + ",buffers=" + str( num_buffers) + ",buflen=" + str(buflen) + ",num_xfers=" + str( num_xfers) + ",verbosity=" + verbosity self.gui_rx_vga_gain = gui_rx_vga_gain = rx_vga_gain self.gui_rx_sample_rate = gui_rx_sample_rate = rx_sample_rate self.gui_rx_lna_gain = gui_rx_lna_gain = rx_lna_gain self.gui_rx_frequency = gui_rx_frequency = rx_frequency self.gui_rx_bandwidth = gui_rx_bandwidth = rx_bandwidth self.gui_dc_offset_q = gui_dc_offset_q = dc_offset_q self.gui_dc_offset_i = gui_dc_offset_i = dc_offset_i self.gui_bladerf_args = gui_bladerf_args = bladerf_args ################################################## # Blocks ################################################## self._gui_rx_vga_gain_range = Range(5, 60, 1, rx_vga_gain, 200) self._gui_rx_vga_gain_win = RangeWidget(self._gui_rx_vga_gain_range, self.set_gui_rx_vga_gain, 'RX VGA1 + VGA2 Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_vga_gain_win, 0, 5, 1, 4) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(5, 9)] self._gui_rx_sample_rate_range = Range(1.5e6, 40e6, 500e3, rx_sample_rate, 200) self._gui_rx_sample_rate_win = RangeWidget( self._gui_rx_sample_rate_range, self.set_gui_rx_sample_rate, 'Sample Rate', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_sample_rate_win, 1, 0, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 2)] self._gui_rx_lna_gain_options = ( 0, 3, 6, ) self._gui_rx_lna_gain_labels = ( '0 dB', '3 dB', '6 dB', ) self._gui_rx_lna_gain_tool_bar = Qt.QToolBar(self) self._gui_rx_lna_gain_tool_bar.addWidget(Qt.QLabel('LNA Gain' + ": ")) self._gui_rx_lna_gain_combo_box = Qt.QComboBox() self._gui_rx_lna_gain_tool_bar.addWidget( self._gui_rx_lna_gain_combo_box) for label in self._gui_rx_lna_gain_labels: self._gui_rx_lna_gain_combo_box.addItem(label) self._gui_rx_lna_gain_callback = lambda i: Qt.QMetaObject.invokeMethod( self._gui_rx_lna_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._gui_rx_lna_gain_options.index(i))) self._gui_rx_lna_gain_callback(self.gui_rx_lna_gain) self._gui_rx_lna_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_gui_rx_lna_gain(self._gui_rx_lna_gain_options[i] )) self.top_grid_layout.addWidget(self._gui_rx_lna_gain_tool_bar, 0, 9, 1, 1) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(9, 10)] self._gui_rx_frequency_range = Range(0, 3.8e9, 1e6, rx_frequency, 200) self._gui_rx_frequency_win = RangeWidget(self._gui_rx_frequency_range, self.set_gui_rx_frequency, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_frequency_win, 0, 0, 1, 5) [self.top_grid_layout.setRowStretch(r, 1) for r in range(0, 1)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 5)] self._gui_rx_bandwidth_range = Range(1.5e6, 28e6, 0.5e6, rx_bandwidth, 200) self._gui_rx_bandwidth_win = RangeWidget(self._gui_rx_bandwidth_range, self.set_gui_rx_bandwidth, 'Bandwidth', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_rx_bandwidth_win, 1, 2, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(2, 4)] self._gui_dc_offset_q_range = Range(-1.0, 1.0, (1.0 / 2048.0), dc_offset_q, 200) self._gui_dc_offset_q_win = RangeWidget(self._gui_dc_offset_q_range, self.set_gui_dc_offset_q, 'Q DC Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_dc_offset_q_win, 1, 6, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(6, 8)] self._gui_dc_offset_i_range = Range(-1.0, 1.0, (1.0 / 2048.0), dc_offset_i, 200) self._gui_dc_offset_i_win = RangeWidget(self._gui_dc_offset_i_range, self.set_gui_dc_offset_i, 'I DC Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._gui_dc_offset_i_win, 1, 4, 1, 2) [self.top_grid_layout.setRowStretch(r, 1) for r in range(1, 2)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(4, 6)] self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_rx_frequency, #fc gui_rx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2, 5, 5, 5) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 7)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(5, 10)] self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 8192, #size rx_sample_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 7, 0, 3, 10) [self.top_grid_layout.setRowStretch(r, 1) for r in range(7, 10)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 10)] self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype gui_rx_frequency, #fc gui_rx_sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 5, 5) [self.top_grid_layout.setRowStretch(r, 1) for r in range(2, 7)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 5)] self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + bladerf_args) self.osmosdr_source_0.set_sample_rate(gui_rx_sample_rate) self.osmosdr_source_0.set_center_freq(gui_rx_frequency, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(gui_rx_lna_gain, 0) self.osmosdr_source_0.set_if_gain(0, 0) self.osmosdr_source_0.set_bb_gain(gui_rx_vga_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(gui_rx_bandwidth, 0) self._gui_bladerf_args_tool_bar = Qt.QToolBar(self) if None: self._gui_bladerf_args_formatter = None else: self._gui_bladerf_args_formatter = lambda x: str(x) self._gui_bladerf_args_tool_bar.addWidget( Qt.QLabel("bladeRF arguments" + ": ")) self._gui_bladerf_args_label = Qt.QLabel( str(self._gui_bladerf_args_formatter(self.gui_bladerf_args))) self._gui_bladerf_args_tool_bar.addWidget(self._gui_bladerf_args_label) self.top_grid_layout.addWidget(self._gui_bladerf_args_tool_bar, 11, 0, 1, 10) [self.top_grid_layout.setRowStretch(r, 1) for r in range(11, 12)] [self.top_grid_layout.setColumnStretch(c, 1) for c in range(0, 10)] self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff( (gui_dc_offset_q, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((gui_dc_offset_i, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_complex_to_float_0, 0))
def __init__( self, samp_per_bit=20, samp_rate=1000, spacing=170, taps=None, ): gr.hier_block2.__init__( self, "AM FSK Modulator", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.samp_per_bit = samp_per_bit self.samp_rate = samp_rate self.spacing = spacing self.taps = taps ################################################## # Blocks ################################################## self._mark_filter = interp_fir_filter_fcc(samp_per_bit, (self._taps())) self._mark_filter.declare_sample_delay(0) self._space_filter = interp_fir_filter_fcc( samp_per_bit, (self._taps()) ) self._space_filter.declare_sample_delay(0) self._space_rotator = blocks.rotator_cc(2*pi*-spacing/samp_rate) self._char_to_float = blocks.char_to_float(1, 1) self._sum_mark_and_space = blocks.add_vcc(1) ################################################## # Connections ################################################## self.connect((self, 0), (self._char_to_float, 0)) # mark self.connect( self._char_to_float, self._mark_filter, self._sum_mark_and_space, ) # space self.connect( self._char_to_float, blocks.multiply_const_vff((-1,)), blocks.add_const_vff((1,)), self._space_filter, self._space_rotator, (self._sum_mark_and_space, 1), ) self.connect( self._sum_mark_and_space, self, )
def _do_connect(self): """Do all reconfiguration operations in the proper order.""" rate_changed = False if self.source is not self._sources[self.source_name]: print 'Switching source' self.__needs_reconnect = True def tune_hook(): reactor.callLater(self.source.get_tune_delay(), tune_hook_actual) def tune_hook_actual(): if self.source is not this_source: return freq = this_source.get_freq() self.input_freq = freq for key, receiver in self._receivers.iteritems(): receiver.set_input_center_freq(freq) self._update_receiver_validity(key) this_source = self._sources[self.source_name] this_source.set_tune_hook(tune_hook) self.source = this_source this_rate = this_source.get_sample_rate() rate_changed = self.input_rate != this_rate self.input_rate = this_rate self.input_freq = this_source.get_freq() if self.__needs_spectrum or rate_changed: print 'Rebuilding spectrum FFT' self.__needs_spectrum = False self.__needs_reconnect = True self.spectrum_queue = gr.msg_queue(limit=10) self.spectrum_sink = blocks.message_sink( self.spectrum_resolution * gr.sizeof_float, self.spectrum_queue, True) # dont_block self.spectrum_fft_block = gnuradio.fft.logpwrfft.logpwrfft_c( sample_rate=self.input_rate, fft_size=self.spectrum_resolution, ref_scale=2, frame_rate=self.spectrum_rate, avg_alpha=1.0, average=False, ) # adjust units so displayed level is independent of resolution (log power per bandwidth rather than per bin) # TODO work out and document exactly what units we're using self.spectrum_rescale_block = blocks.add_const_vff( [10*math.log10(self.spectrum_resolution)] * self.spectrum_resolution) if rate_changed: print 'Changing sample rate' for receiver in self._receivers.itervalues(): receiver.set_input_rate(self.input_rate) if self.__needs_reconnect: print 'Reconnecting' self.__needs_reconnect = False self._recursive_lock() self.disconnect_all() # recreated each time because reusing an add_ff w/ different # input counts fails; TODO: report/fix bug audio_sum_l = blocks.add_ff() audio_sum_r = blocks.add_ff() self.connect( self.source, self.spectrum_fft_block, self.spectrum_rescale_block, self.spectrum_sink) audio_sum_index = 0 for key, receiver in self._receivers.iteritems(): self._receiver_valid[key] = receiver.get_is_valid() if self._receiver_valid[key]: if audio_sum_index >= 6: # Sanity-check to avoid burning arbitrary resources # TODO: less arbitrary constant; communicate this restriction to client print 'Refusing to connect more than 6 receivers' break self.connect(self.source, receiver) self.connect((receiver, 0), (audio_sum_l, audio_sum_index)) self.connect((receiver, 1), (audio_sum_r, audio_sum_index)) audio_sum_index += 1 if audio_sum_index > 0: # connect audio output only if there is at least one input if len(self.audio_queue_sinks) > 0: used_resamplers = set() for (queue_rate, interleaver, sink) in self.audio_queue_sinks.itervalues(): if queue_rate == self.audio_rate: self.connect(audio_sum_l, (interleaver, 0)) self.connect(audio_sum_r, (interleaver, 1)) else: if queue_rate not in self.audio_resampler_cache: # Moderately expensive due to the internals using optfir print 'Constructing resampler for audio rate', queue_rate self.audio_resampler_cache[queue_rate] = ( make_resampler(self.audio_rate, queue_rate), make_resampler(self.audio_rate, queue_rate) ) resamplers = self.audio_resampler_cache[queue_rate] used_resamplers.add(resamplers) self.connect(resamplers[0], (interleaver, 0)) self.connect(resamplers[1], (interleaver, 1)) self.connect(interleaver, sink) for resamplers in used_resamplers: self.connect(audio_sum_l, resamplers[0]) self.connect(audio_sum_r, resamplers[1]) else: # no stream sinks, gnuradio requires a dummy sink self.connect(audio_sum_l, blocks.null_sink(gr.sizeof_float)) self.connect(audio_sum_r, blocks.null_sink(gr.sizeof_float)) self._recursive_unlock() print 'Done reconnecting'
def __init__(self, antenna=satnogs.not_set_antenna, bb_gain=satnogs.not_set_rx_bb_gain, decoded_data_file_path='/home/mocha/.satnogs/data/data', dev_args='rtl=00000002', doppler_correction_per_sec=20, enable_iq_dump=0, file_path='/home/mocha/Desktop/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=137812000, rx_sdr_device='rtlsdr', sync=1): gr.top_block.__init__(self, "APT Generic Demodulation") ################################################## # Parameters ################################################## 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.iq_file_path = iq_file_path self.lo_offset = lo_offset self.ppm = ppm self.rf_gain = rf_gain self.rigctl_port = rigctl_port self.rx_freq = rx_freq self.rx_sdr_device = rx_sdr_device self.sync = sync ################################################## # Variables ################################################## self.samp_rate_rx = samp_rate_rx = satnogs.hw_rx_settings[rx_sdr_device]['samp_rate'] self.xlate_filter_taps = xlate_filter_taps = firdes.low_pass(1, samp_rate_rx, 125000, 25000, firdes.WIN_HAMMING, 6.76) self.taps = taps = firdes.low_pass(12.0, samp_rate_rx, 100e3, 60000, firdes.WIN_HAMMING, 6.76) self.initial_bandwidth = initial_bandwidth = 100e3 self.first_stage_filter_taps = first_stage_filter_taps = firdes.low_pass(1.0, 1.0, 0.2, 0.1, firdes.WIN_HAMMING, 6.76) self.first_stage_decimation = first_stage_decimation = 4 self.filter_rate = filter_rate = 250000 self.deviation = deviation = 17000 self.audio_samp_rate = audio_samp_rate = 48000 self.audio_decimation = audio_decimation = 2 ################################################## # Blocks ################################################## self.satnogs_noaa_apt_sink_0 = satnogs.noaa_apt_sink('/tmp/.satnogs/data/test-2.png', 2080, 1800, bool(sync), bool(flip_images)) self.rational_resampler_xxx_1_0 = filter.rational_resampler_fff( interpolation=int(samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation), decimation=48000, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1, decimation=2, taps=None, fractional_bw=None, ) self.rational_resampler_3 = filter.rational_resampler_fff( interpolation=1, decimation=4, taps=None, fractional_bw=None, ) self.rational_resampler_2 = filter.rational_resampler_fff( interpolation=4*4160, decimation=int((samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation)/2), taps=None, fractional_bw=None, ) self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(int(samp_rate_rx/filter_rate), (xlate_filter_taps), lo_offset, samp_rate_rx) self.fir_filter_xxx_1 = filter.fir_filter_fff(2, ([0.5, 0.5])) self.fir_filter_xxx_1.declare_sample_delay(0) self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate_rx,True) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((0.008, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.008, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, '/home/mocha/Desktop/1912_December/iq_NOAA_18_20191016T101359_137812000Hz_IQ.wav', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_deinterleave_0 = blocks.deinterleave(gr.sizeof_char*1, 1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-127, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((127, )) self.blks2_rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=48, decimation=125, taps=None, fractional_bw=None, ) self.band_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.band_pass( 6, samp_rate_rx/ ( first_stage_decimation * int(samp_rate_rx/ first_stage_decimation / initial_bandwidth)) / audio_decimation, 500, 4.2e3, 200, firdes.WIN_HAMMING, 6.76)) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((2*math.pi*deviation)/96000) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.fir_filter_xxx_1, 0)) self.connect((self.blks2_rational_resampler_xxx_1, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.rational_resampler_3, 0)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_deinterleave_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_throttle_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.fir_filter_xxx_1, 0), (self.rational_resampler_2, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blks2_rational_resampler_xxx_1, 0)) self.connect((self.hilbert_fc_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.rational_resampler_2, 0), (self.hilbert_fc_0, 0)) self.connect((self.rational_resampler_3, 0), (self.satnogs_noaa_apt_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.band_pass_filter_0_0, 0))
def __init__(self, input_file, output_file): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 2048000 ################################################## # Blocks ################################################## self.low_pass_filter_1 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 85000, 2000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, 200000, 1000, firdes.WIN_HAMMING, 6.76)) if input_file != None: self.blocks_wavfile_source_0 = blocks.wavfile_source(input_file, False) else: import osmosdr self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(433463000, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(10, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) if output_file == '-': self.blocks_file_sink_0 = blocks.file_descriptor_sink(4, 1) else: self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, output_file, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0.00, )) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -420000, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.blocks_add_const_vxx_0, 0)) if input_file != None: self.connect((self.blocks_wavfile_source_0, 1), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0, 0)) else: self.connect((self.rtlsdr_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 128, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1.5, 2.5) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.blocks_char_to_float_0_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((-1.5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1.5, )) self.ax25_nrzi_encoder_0 = ax25.nrzi_encoder(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 128)), False) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.ax25_nrzi_encoder_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.ax25_nrzi_encoder_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.ax25_nrzi_encoder_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0, 2)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_char_to_float_0_0_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_char_to_float_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Cr Application") Qt.QWidget.__init__(self) self.setWindowTitle("Cr Application") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "cr_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.usrp_rf_freq = usrp_rf_freq = 2435000000 self.tx_pkt_rate = tx_pkt_rate = 157 self.samp_rate = samp_rate = 200000 self.preamble_qpsk = preamble_qpsk = map(lambda x: x*(1+1j)/pow(2,0.5), preamble) self.payload_size = payload_size = 50 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.digital_gain = digital_gain = 1.0/8 ################################################## # Blocks ################################################## self.crew_db_channel_selector_0 = crew.db_channel_selector('test_crew', 'zigbee', 'max', 0.05) def _usrp_rf_freq_probe(): while True: val = self.crew_db_channel_selector_0.get_freq() try: self.set_usrp_rf_freq(val) except AttributeError: pass time.sleep(1.0 / (10)) _usrp_rf_freq_thread = threading.Thread(target=_usrp_rf_freq_probe) _usrp_rf_freq_thread.daemon = True _usrp_rf_freq_thread.start() self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("addr=192.168.30.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_source_0_0.set_gain(28, 0) self.uhd_usrp_source_0_0.set_antenna("J1", 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("addr=192.168.50.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_sink_0_0.set_gain(26, 0) self.uhd_usrp_sink_0_0.set_antenna("J1", 0) self.sync_blocks_0 = sync_blocks( digital_gain=19, ) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_VERT, 1 ) self.qtgui_number_sink_0.set_update_time(0.2) self.qtgui_number_sink_0.set_title("Packet Reception Rate") labels = [" ", "", "", "", "", "", "", "", "", ""] units = ["%", "", "", "", "", "", "", "", "", ""] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0.set_min(i, 0) self.qtgui_number_sink_0.set_max(i, 100) self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0.set_label(i, labels[i]) self.qtgui_number_sink_0.set_unit(i, units[i]) self.qtgui_number_sink_0.set_factor(i, factor[i]) self.qtgui_number_sink_0.enable_autoscale(False) self._qtgui_number_sink_0_win = sip.wrapinstance(self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0,1,1,1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 20000, #size "Rx Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not False: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 0,0,1,1) self.packet_gen_0 = packet_gen( payload_size=payload_size, ) self.crew_packet_decoder_cb_0 = crew.packet_decoder_cb((preamble_qpsk)) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((1.0/(tx_pkt_rate), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((-1.0/(tx_pkt_rate), )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/root/BasicTxRx/wilabt/file_sent.txt", True) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1.0, )) ################################################## # Connections ################################################## self.connect((self.blocks_add_const_vxx_0, 0), (self.crew_db_channel_selector_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.packet_gen_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 1), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.crew_packet_decoder_cb_0, 1), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.crew_packet_decoder_cb_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.packet_gen_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.sync_blocks_0, 0), (self.crew_packet_decoder_cb_0, 0)) self.connect((self.sync_blocks_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.sync_blocks_0, 0))
def __init__(self, antenna="TX/RX", vor_freq_1=111e6, com_freq_1=135.275e6, vor_freq_2=111e6, rx_gain=30, gain=20): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Parameters ################################################## self.antenna = antenna self.vor_freq_1 = vor_freq_1 self.com_freq_1 = com_freq_1 self.vor_freq_2 = vor_freq_2 self.rx_gain = rx_gain self.gain = gain ################################################## # Variables ################################################## self.obs_decimation = obs_decimation = 25 self.ils_decimation = ils_decimation = 50 self.am_sample_rate = am_sample_rate = 12.5e3 self.vor_samp_rate = vor_samp_rate = 250e3 self.vor_freq_entry_2 = vor_freq_entry_2 = vor_freq_2 self.vor_freq_entry_1 = vor_freq_entry_1 = vor_freq_1 self.vor_center_freq_0 = vor_center_freq_0 = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.vor_center_freq = vor_center_freq = (117.95e6 - 108.00e6) / 2 + 117.95e6 self.squelch_slider = squelch_slider = -110 self.rxgain = rxgain = 15 self.phase_correction = phase_correction = 5 self.obs_sample_rate = obs_sample_rate = am_sample_rate / obs_decimation self.ils_sample_rate = ils_sample_rate = am_sample_rate / ils_decimation self.gain_slider = gain_slider = gain self.com_freq_entry_1 = com_freq_entry_1 = com_freq_1 self.band_center_freq = band_center_freq = (136.975e6 - 108.0e6) / 2 + 108.0e6 self.audio_select = audio_select = 0 self.audio_sample_rate = audio_sample_rate = 48e3 self.am_decimation = am_decimation = 1 ################################################## # Blocks ################################################## self.notebook_0 = self.notebook_0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "RF Analyzer") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Channel FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Demod Audio FFT") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Ref and Phase Scope") self.notebook_0.AddPage(grc_wxgui.Panel(self.notebook_0), "Manipulated Ref and Phase") self.Add(self.notebook_0) self._vor_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_1, callback=self.set_vor_freq_entry_1, label='vor_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_1_text_box) _gain_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, label='gain_slider', converter=forms.float_converter(), proportion=0, ) self._gain_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_gain_slider_sizer, value=self.gain_slider, callback=self.set_gain_slider, minimum=0, maximum=30, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_gain_slider_sizer) self._com_freq_entry_1_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.com_freq_entry_1, callback=self.set_com_freq_entry_1, label='com_freq_entry_1', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._com_freq_entry_1_text_box) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.notebook_0.GetPage(1).GetWin(), title="Scope Plot", sample_rate=10e3, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=2, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.notebook_0.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100, maxval=100, factor=1.0, decimal_places=10, ref_level=0, sample_rate=10, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.notebook_0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=12.5e3, fft_size=1024, fft_rate=5, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.notebook_0.GetPage(0).Add(self.wxgui_fftsink2_0.win) self._vor_freq_entry_2_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), value=self.vor_freq_entry_2, callback=self.set_vor_freq_entry_2, label='vor_freq_entry_2', converter=forms.float_converter(), ) self.notebook_0.GetPage(0).Add(self._vor_freq_entry_2_text_box) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_subdev_spec("A:0 A:0", 0) self.uhd_usrp_source_0.set_samp_rate(vor_samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(com_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain_slider, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(vor_freq_entry_1, rf_freq=band_center_freq, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0.set_gain(gain_slider, 1) self.uhd_usrp_source_0.set_antenna("TX/RX", 1) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(250e3) self.uhd_usrp_sink_0.set_center_freq( uhd.tune_request(com_freq_entry_1, 20e6), 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) _squelch_slider_sizer = wx.BoxSizer(wx.VERTICAL) self._squelch_slider_text_box = forms.text_box( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, label='squelch_slider', converter=forms.float_converter(), proportion=0, ) self._squelch_slider_slider = forms.slider( parent=self.notebook_0.GetPage(0).GetWin(), sizer=_squelch_slider_sizer, value=self.squelch_slider, callback=self.set_squelch_slider, minimum=-110, maximum=0, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.notebook_0.GetPage(0).Add(_squelch_slider_sizer) self.squelch = analog.pwr_squelch_cc(squelch_slider, 0.01, 20, True) self.rational_resampler_xxx_2 = filter.rational_resampler_fff( interpolation=250, decimation=48, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_fff( interpolation=480, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=4, decimation=5, taps=None, fractional_bw=None, ) self.openavionics_joystick_interface_0 = openavionics.joystick_interface( ) self.openavionics_audio_ptt_0 = openavionics.audio_ptt() self.null_sink_0_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.multiply_xx_0_0_0 = blocks.multiply_vcc(1) self.multiply_xx_0_0 = blocks.multiply_vff(1) self.low_pass_filter_3 = filter.fir_filter_ccf( 1, firdes.low_pass(1, 10e3, 1, 2, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2_0 = filter.fir_filter_ccf( 5, firdes.low_pass(1, 40e3, 2e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_2 = filter.fir_filter_ccf( 5, firdes.low_pass(1, vor_samp_rate, 15e3, 5e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_1 = filter.interp_fir_filter_fff( 1, firdes.low_pass(1, 12.5e3, 3e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( int(250e3 / 12.5e3), firdes.low_pass(1, vor_samp_rate, 10e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.goertzel_fc_0_0 = fft.goertzel_fc(10000, 1000, 30) self.goertzel_fc_0 = fft.goertzel_fc(40000, 4000, 30) self.float_to_complex_0_0 = blocks.float_to_complex(1) self.const_source_x_0_0_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.const_source_x_0_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.550) self.const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0.450) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_complex_to_arg_0 = blocks.complex_to_arg(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-87.2665e-3, )) self.band_pass_filter_0_0 = filter.fir_filter_fff( 4, firdes.band_pass(1, 40e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_fff( 1, firdes.band_pass(1, 10e3, 20, 40, 20, firdes.WIN_HAMMING, 6.76)) self.audio_source_0 = audio.source(48000, "", True) self.audio_sink_0 = audio.sink(int(audio_sample_rate), "", True) self._audio_select_chooser = forms.drop_down( parent=self.GetWin(), value=self.audio_select, callback=self.set_audio_select, label='audio_select', choices=[0, 1], labels=['AM Voice', 'VOR Subcarrier'], ) self.Add(self._audio_select_chooser) self.analog_sig_source_x_0 = analog.sig_source_c( 40e3, analog.GR_COS_WAVE, -9.96e3, 1, 0) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1) self.analog_am_demod_cf_0 = analog.am_demod_cf( channel_rate=40e3, audio_decim=4, audio_pass=5000, audio_stop=5500, ) self.analog_agc2_xx_0_1_0 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1_0.set_max_gain(100) self.analog_agc2_xx_0_1 = analog.agc2_ff(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_1.set_max_gain(100) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(100) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(100) self.am_demod_cf_0 = analog.am_demod_cf( channel_rate=am_sample_rate, audio_decim=am_decimation, audio_pass=3e3, audio_stop=4e3, ) self.agc2_xx_0 = analog.agc2_cc(1, 1, 0.75, 1.0) self.agc2_xx_0.set_max_gain(0.0) self.add_xx_0_0 = blocks.add_vff(1) ################################################## # Connections ################################################## self.connect((self.agc2_xx_0, 0), (self.am_demod_cf_0, 0)) self.connect((self.am_demod_cf_0, 0), (self.low_pass_filter_1, 0)) self.connect((self.agc2_xx_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.multiply_xx_0_0, 0), (self.add_xx_0_0, 0)) self.connect((self.const_source_x_0, 0), (self.multiply_xx_0_0, 1)) self.connect((self.const_source_x_0_0, 0), (self.add_xx_0_0, 1)) self.connect((self.multiply_xx_0_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 0)) self.connect((self.add_xx_0_0, 0), (self.float_to_complex_0_0, 1)) self.connect((self.float_to_complex_0_0, 0), (self.multiply_xx_0_0_0, 0)) self.connect((self.const_source_x_0_0_0, 0), (self.multiply_xx_0_0_0, 1)) self.connect((self.uhd_usrp_source_0, 0), (self.null_sink_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_1, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.audio_sink_0, 0)) self.connect((self.analog_agc2_xx_0_1_0, 0), (self.wxgui_scopesink2_0, 1)) self.connect((self.analog_agc2_xx_0_1, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.analog_agc2_xx_0_1, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.analog_agc2_xx_0_1_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.band_pass_filter_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_complex_to_arg_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.low_pass_filter_3, 0), (self.blocks_complex_to_arg_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.low_pass_filter_3, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.analog_agc2_xx_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.analog_am_demod_cf_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.low_pass_filter_2_0_0, 0), (self.analog_am_demod_cf_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_2_0_0, 0)) self.connect((self.low_pass_filter_2_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_2_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.null_sink_0_0, 0)) self.connect((self.low_pass_filter_2, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0)) self.connect((self.openavionics_audio_ptt_0, 0), (self.rational_resampler_xxx_2, 0)) self.connect((self.rational_resampler_xxx_2, 0), (self.multiply_xx_0_0, 0)) self.connect((self.squelch, 0), (self.agc2_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.squelch, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_2, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
def __init__(self, mode='VOR', zero_point=59, **kwargs): self.channel_rate = channel_rate = 40000 internal_audio_rate = 20000 # TODO over spec'd self.zero_point = zero_point transition = 5000 SimpleAudioDemodulator.__init__(self, mode=mode, audio_rate=internal_audio_rate, demod_rate=channel_rate, band_filter=fm_subcarrier * 1.25 + fm_deviation + transition / 2, band_filter_transition=transition, **kwargs) self.dir_rate = dir_rate = 10 if internal_audio_rate % dir_rate != 0: raise ValueError('Audio rate %s is not a multiple of direction-finding rate %s' % (internal_audio_rate, dir_rate)) self.dir_scale = dir_scale = internal_audio_rate // dir_rate self.audio_scale = audio_scale = channel_rate // internal_audio_rate self.zeroer = blocks.add_const_vff((zero_point * (math.pi / 180), )) self.dir_vector_filter = grfilter.fir_filter_ccf(1, firdes.low_pass( 1, dir_rate, 1, 2, firdes.WIN_HAMMING, 6.76)) self.am_channel_filter_block = grfilter.fir_filter_ccf(1, firdes.low_pass( 1, channel_rate, 5000, 5000, firdes.WIN_HAMMING, 6.76)) self.goertzel_fm = fft.goertzel_fc(channel_rate, dir_scale * audio_scale, 30) self.goertzel_am = fft.goertzel_fc(internal_audio_rate, dir_scale, 30) self.fm_channel_filter_block = grfilter.freq_xlating_fir_filter_ccc(1, (firdes.low_pass(1.0, channel_rate, fm_subcarrier / 2, fm_subcarrier / 2, firdes.WIN_HAMMING)), fm_subcarrier, channel_rate) self.multiply_conjugate_block = blocks.multiply_conjugate_cc(1) self.complex_to_arg_block = blocks.complex_to_arg(1) self.am_agc_block = analog.feedforward_agc_cc(1024, 1.0) self.am_demod_block = analog.am_demod_cf( channel_rate=channel_rate, audio_decim=audio_scale, audio_pass=5000, audio_stop=5500, ) self.fm_demod_block = analog.quadrature_demod_cf(1) self.phase_agc_fm = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.phase_agc_am = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.probe = blocks.probe_signal_f() self.audio_filter_block = grfilter.fir_filter_fff(1, design_lofi_audio_filter(internal_audio_rate, False)) ################################################## # Connections ################################################## # Input self.connect( self, self.band_filter_block) # AM chain self.connect( self.band_filter_block, self.am_channel_filter_block, self.am_agc_block, self.am_demod_block) # AM audio self.connect( self.am_demod_block, blocks.multiply_const_ff(1.0 / audio_modulation_index * 0.5), self.audio_filter_block) self.connect_audio_output(self.audio_filter_block) # AM phase self.connect( self.am_demod_block, self.goertzel_am, self.phase_agc_am, (self.multiply_conjugate_block, 0)) # FM phase self.connect( self.band_filter_block, self.fm_channel_filter_block, self.fm_demod_block, self.goertzel_fm, self.phase_agc_fm, (self.multiply_conjugate_block, 1)) # Phase comparison and output self.connect( self.multiply_conjugate_block, self.dir_vector_filter, self.complex_to_arg_block, blocks.multiply_const_ff(-1), # opposite angle conventions self.zeroer, self.probe)
def __init__(self, subdev="A:0", devid="addr=192.168.10.2", frequency=1.4125e9, fftsize=8192): grc_wxgui.top_block_gui.__init__(self, title="Total Power Radiometer - N200") ################################################## # Parameters ################################################## self.subdev = subdev self.devid = devid self.frequency = frequency self.fftsize = fftsize ################################################## # Variables ################################################## self.GUI_samp_rate = GUI_samp_rate = 10e6 self.samp_rate = samp_rate = int(GUI_samp_rate) self.prefix = prefix = "tpr_" self.text_samp_rate = text_samp_rate = GUI_samp_rate self.text_deviceID = text_deviceID = subdev self.text_Device_addr = text_Device_addr = devid self.spec_data_fifo = spec_data_fifo = "spectrum_" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.spavg = spavg = 1 self.scope_rate = scope_rate = 2 self.recfile_tpr = recfile_tpr = prefix + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.recfile_kelvin = recfile_kelvin = prefix+"kelvin" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat" self.rec_button_tpr = rec_button_tpr = 1 self.rec_button_iq = rec_button_iq = 1 self.noise_amplitude = noise_amplitude = .5 self.integ = integ = 2 self.gain = gain = 26 self.freq = freq = frequency self.file_rate = file_rate = 2.0 self.fftrate = fftrate = int(samp_rate/fftsize) self.det_rate = det_rate = int(20.0) self.dc_gain = dc_gain = 1 self.calib_2 = calib_2 = -342.774 self.calib_1 = calib_1 = 4.0755e3 self.add_noise = add_noise = 0 ################################################## # Blocks ################################################## self.Main = self.Main = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.Main.AddPage(grc_wxgui.Panel(self.Main), "N200 Control Panel") self.Main.AddPage(grc_wxgui.Panel(self.Main), "TPR Measurements") self.Add(self.Main) _spavg_sizer = wx.BoxSizer(wx.VERTICAL) self._spavg_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, label="Spectral Averaging (Seconds)", converter=forms.int_converter(), proportion=0, ) self._spavg_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_spavg_sizer, value=self.spavg, callback=self.set_spavg, minimum=1, maximum=20, num_steps=20, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Main.GetPage(0).GridAdd(_spavg_sizer, 1, 1, 1, 1) self._rec_button_tpr_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_tpr, callback=self.set_rec_button_tpr, label="Record TPR Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_tpr_chooser, 4, 1, 1, 1) self._rec_button_iq_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.rec_button_iq, callback=self.set_rec_button_iq, label="Record I/Q Data", choices=[0,1], labels=['Stop','Start'], ) self.Main.GetPage(0).GridAdd(self._rec_button_iq_chooser, 4, 0, 1, 1) _integ_sizer = wx.BoxSizer(wx.VERTICAL) self._integ_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, label="Integration Time (Seconds)", converter=forms.float_converter(), proportion=0, ) self._integ_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_integ_sizer, value=self.integ, callback=self.set_integ, minimum=1, maximum=60, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_integ_sizer, 0, 2, 1, 1) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label="RF Gain (dB)", converter=forms.float_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=50, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_gain_sizer, 0, 1, 1, 1) self._freq_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.freq, callback=self.set_freq, label="Center Frequency (Hz)", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._freq_text_box, 0, 0, 1, 1) self._dc_gain_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.dc_gain, callback=self.set_dc_gain, label="DC Gain", choices=[1, 10, 100, 1000, 10000], labels=[], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._dc_gain_chooser, 1, 0, 1, 1) self._calib_2_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_2, callback=self.set_calib_2, label="Calibration value 2", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_2_text_box, 3, 1, 1, 1) self._calib_1_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), value=self.calib_1, callback=self.set_calib_1, label="Calibration value 1", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._calib_1_text_box, 3, 0, 1, 1) self._GUI_samp_rate_chooser = forms.radio_buttons( parent=self.Main.GetPage(0).GetWin(), value=self.GUI_samp_rate, callback=self.set_GUI_samp_rate, label="Sample Rate (BW)", choices=[1e6,2e6,5e6,10e6,25e6], labels=['1 MHz','2 MHz','5 MHz','10 MHz','25 MHz'], style=wx.RA_HORIZONTAL, ) self.Main.GetPage(0).GridAdd(self._GUI_samp_rate_chooser, 1, 3, 1, 1) self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.Main.GetPage(1).GetWin(), title="Total Power", sample_rate=2, v_scale=.1, v_offset=0, t_scale=100, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label="power level", ) self.Main.GetPage(1).Add(self.wxgui_scopesink2_2.win) self.wxgui_numbersink2_2 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=0, maxval=1, factor=1.0, decimal_places=10, ref_level=0, sample_rate=GUI_samp_rate, number_rate=15, average=False, avg_alpha=None, label="Number Plot", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_2.win) self.wxgui_numbersink2_0_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="", minval=0, maxval=.2, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=True, avg_alpha=.01, label="Raw Power level", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.Main.GetPage(1).GetWin(), unit="Kelvin", minval=0, maxval=400, factor=1, decimal_places=6, ref_level=0, sample_rate=scope_rate, number_rate=15, average=False, avg_alpha=None, label="Calibrated Temperature", peak_hold=False, show_gauge=True, ) self.Main.GetPage(1).Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.Main.GetPage(0).GetWin(), baseband_freq=freq, y_per_div=10, y_divs=10, ref_level=20, ref_scale=2.0, sample_rate=GUI_samp_rate, fft_size=1024, fft_rate=5, average=True, avg_alpha=0.1, title="Spectrum", peak_hold=False, size=(800,400), ) self.Main.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((devid, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(GUI_samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) (self.uhd_usrp_source_0).set_processor_affinity([0]) self._text_samp_rate_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_samp_rate, callback=self.set_text_samp_rate, label="Samp rate", converter=forms.float_converter(), ) self.Main.GetPage(0).GridAdd(self._text_samp_rate_static_text, 2, 0, 1, 1) self._text_deviceID_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_deviceID, callback=self.set_text_deviceID, label="SubDev", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._text_deviceID_static_text, 2, 1, 1, 1) self._text_Device_addr_static_text = forms.static_text( parent=self.Main.GetPage(0).GetWin(), value=self.text_Device_addr, callback=self.set_text_Device_addr, label="Device Address", converter=forms.str_converter(), ) self.Main.GetPage(0).GridAdd(self._text_Device_addr_static_text, 2, 2, 1, 1) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(1.0/((samp_rate*integ)/2.0), 1) (self.single_pole_iir_filter_xx_0).set_processor_affinity([1]) _noise_amplitude_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_amplitude_text_box = forms.text_box( parent=self.Main.GetPage(0).GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, label='noise_amplitude', converter=forms.float_converter(), proportion=0, ) self._noise_amplitude_slider = forms.slider( parent=self.Main.GetPage(0).GetWin(), sizer=_noise_amplitude_sizer, value=self.noise_amplitude, callback=self.set_noise_amplitude, minimum=.01, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Main.GetPage(0).GridAdd(_noise_amplitude_sizer, 3, 2, 1, 1) self.logpwrfft_x_0 = logpwrfft.logpwrfft_c( sample_rate=samp_rate, fft_size=fftsize, ref_scale=2, frame_rate=fftrate, avg_alpha=1.0/float(spavg*fftrate), average=True, ) self.blocks_peak_detector_xb_0 = blocks.peak_detector_fb(0.25, 0.40, 10, 0.001) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((calib_1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((dc_gain, )) self.blocks_keep_one_in_n_4 = blocks.keep_one_in_n(gr.sizeof_float*1, samp_rate/det_rate) self.blocks_keep_one_in_n_3 = blocks.keep_one_in_n(gr.sizeof_float*fftsize, fftrate) self.blocks_keep_one_in_n_1 = blocks.keep_one_in_n(gr.sizeof_float*1, int(det_rate/file_rate)) self.blocks_file_sink_5 = blocks.file_sink(gr.sizeof_float*fftsize, spec_data_fifo, False) self.blocks_file_sink_5.set_unbuffered(True) self.blocks_file_sink_4 = blocks.file_sink(gr.sizeof_float*1, recfile_tpr, False) self.blocks_file_sink_4.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, prefix+"iq_raw" + datetime.now().strftime("%Y.%m.%d.%H.%M.%S") + ".dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_float*1, recfile_kelvin, False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_complex_to_mag_squared_1 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1 = blocks.add_const_vff((calib_2, )) self.blks2_valve_2 = grc_blks2.valve(item_size=gr.sizeof_gr_complex*1, open=bool(rec_button_iq)) self.blks2_valve_1 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(0)) self.blks2_valve_0 = grc_blks2.valve(item_size=gr.sizeof_float*1, open=bool(rec_button_tpr)) self._add_noise_chooser = forms.button( parent=self.Main.GetPage(0).GetWin(), value=self.add_noise, callback=self.set_add_noise, label="Noise Source", choices=[0,1], labels=['Off','On'], ) self.Main.GetPage(0).GridAdd(self._add_noise_chooser, 3, 3, 1, 1) ################################################## # Connections ################################################## self.connect((self.blks2_valve_0, 0), (self.blocks_file_sink_4, 0)) self.connect((self.blks2_valve_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_valve_2, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blks2_valve_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.wxgui_numbersink2_2, 0)) self.connect((self.blocks_complex_to_mag_squared_1, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_peak_detector_xb_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blks2_valve_0, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_keep_one_in_n_1, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_keep_one_in_n_3, 0), (self.blocks_file_sink_5, 0)) self.connect((self.blocks_keep_one_in_n_4, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_keep_one_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_numbersink2_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_peak_detector_xb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.logpwrfft_x_0, 0), (self.blocks_keep_one_in_n_3, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_4, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blks2_valve_2, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 16000 self.repeat = repeat = samp_rate/80 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.blocks_unpacked_to_packed_xx_1 = blocks.unpacked_to_packed_bb(8, gr.GR_MSB_FIRST) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_uchar_to_float_0_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_short_to_char_0 = blocks.short_to_char(1) self.blocks_rms_xx_0_0 = blocks.rms_ff(1) self.blocks_rms_xx_0 = blocks.rms_ff(1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, repeat) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(1, 8, "", False, gr.GR_MSB_FIRST) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_0_2 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_1 = blocks.multiply_vff(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vss((256, )) self.blocks_integrate_xx_1 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0_1 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0_0 = blocks.integrate_ff(repeat) self.blocks_integrate_xx_0 = blocks.integrate_ff(repeat) self.blocks_float_to_uchar_0 = blocks.float_to_uchar() self.blocks_file_source_0 = blocks.file_source(gr.sizeof_short*1, "/home/sidekiq/Documents/Documentation_SDR/sdr.in", True) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/sidekiq/Documents/Documentation_SDR/text_output", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_argmax_xx_0 = blocks.argmax_fs(1) self.blocks_add_xx_0_0 = blocks.add_vff(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((1, )) self.blocks_abs_xx_0_2 = blocks.abs_ff(1) self.blocks_abs_xx_0_1 = blocks.abs_ff(1) self.blocks_abs_xx_0_0 = blocks.abs_ff(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble="11111000", access_code="11111111", pad_for_usrp=False, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.audio_sink_1 = audio.sink(16000, "", True) self.analog_sig_source_x_1 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_1 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 1330, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_f(samp_rate, analog.GR_SIN_WAVE, 2720, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 2720, 1, 0) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(100) ################################################## # Connections ################################################## self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_2, 0)) self.connect((self.analog_sig_source_x_0_1, 0), (self.blocks_multiply_xx_0_1, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_unpacked_to_packed_xx_1, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_abs_xx_0_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.blocks_abs_xx_0_1, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_abs_xx_0_2, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_add_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_rms_xx_0_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.audio_sink_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_1, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_xx_0_2, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_float_to_uchar_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_abs_xx_0_2, 0)) self.connect((self.blocks_integrate_xx_0_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_integrate_xx_0_1, 0), (self.blocks_abs_xx_0_0, 0)) self.connect((self.blocks_integrate_xx_1, 0), (self.blocks_abs_xx_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_short_to_char_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_integrate_xx_1, 0)) self.connect((self.blocks_multiply_xx_0_1, 0), (self.blocks_integrate_xx_0_1, 0)) self.connect((self.blocks_multiply_xx_0_2, 0), (self.blocks_integrate_xx_0_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_uchar_to_float_0_0_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_argmax_xx_0, 1)) self.connect((self.blocks_rms_xx_0_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_short_to_char_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_float_to_uchar_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_uchar_to_float_0_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_1, 0), (self.blocks_file_sink_0_0, 0))