def __init__(self): gr.top_block.__init__(self, "Acoust Out") ################################################## # Variables ################################################## self.transistion = transistion = 100 self.sps = sps = 2 self.sideband_rx = sideband_rx = 1000 self.sideband = sideband = 1000 self.samp_rate = samp_rate = 48000 self.payload = payload = 20 self.interpolation = interpolation = 200 self.fd = fd = 0 self.carrier = carrier = 13000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interpolation, decimation=1, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=9000, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=sps, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=False, ), payload_length=payload, ) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_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.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/john/sdrportal//sdrportal/log.out", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=34770, server=True, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_file_sink_0, 0))
def __init__(self, rx_packet_filename='rx_packets.bin', host='127.0.0.1', packet_port=9095): gr.top_block.__init__(self, "Hurdle 1 Rx") ################################################## # Parameters ################################################## self.rx_packet_filename = rx_packet_filename self.host = host self.packet_port = packet_port ################################################## # Blocks ################################################## self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, rx_packet_filename, False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr=host, port=packet_port, server=True, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_file_sink_0_0, 0))
def __init__(self, samp_rate): gr.hier_block2.__init__(self, "throttled_source", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate) self.source = grc_blks2.tcp_source(itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=8888, server=False,) #OK self.connect(self.source, self.throttle, self)
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: atsc-hackrf.py port [output_file]\n") sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 rf_gain = 14 if_gain = 40 tb = gr.top_block() src = grc_blks2.tcp_source(gr.sizeof_char * 1, "127.0.0.1", port, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc( ([symbol + 1.25 for symbol in [-7, -5, -3, -1, 1, 3, 5, 7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc = filter.fft_filter_ccc( 1, firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate / 2, 0.1152, 100)) out = osmosdr.sink(args="hackrf=0") out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bandwidth(6000000, 0) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: atsc-blade.py port [output_file]\n"); sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 tx_gain = 83 # max 89.5 tb = gr.top_block() out = uhd.usrp_sink( device_addr="recv_frame_size=65536,num_recv_frames=128,send_frame_size=65536,num_send_frames=128,master_clock_rate=" + str(symbol_rate*4), stream_args=uhd.stream_args( cpu_format="fc32", otw_format="sc16", channels=range(1), ), ) out.set_samp_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_gain(tx_gain, 0) #src = blocks.udp_source(gr.sizeof_char*1, "127.0.0.1", port, 18800, True) src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc(([symbol + 1.25 for symbol in [-7,-5,-3,-1,1,3,5,7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc = filter.fft_filter_ccc(1, firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate/2, 0.1152, 100)) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
def __init__(self): gr.top_block.__init__(self, "Qam64 B200") ################################################## # Variables ################################################## self.interpolation = interpolation = 2 self.samp_rate = samp_rate = 5056941 * interpolation self.rrc_taps = rrc_taps = 50 self.gain = gain = 83 self.center_freq = center_freq = 441000000 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="recv_frame_size=65536,num_recv_frames=128,send_frame_size=65536,num_send_frames=128,master_clock_rate=" + str(samp_rate*4), stream_args=uhd.stream_args( cpu_format="fc32", otw_format="sc16", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.qam_trellis_enc_bb_0 = qam.trellis_enc_bb() self.qam_transport_framing_enc_bb_0 = qam.transport_framing_enc_bb() self.qam_reed_solomon_enc_bb_0 = qam.reed_solomon_enc_bb() self.qam_randomizer_bb_0 = qam.randomizer_bb() self.qam_interleaver_bb_0 = qam.interleaver_bb(128,4) self.qam_frame_sync_enc_bb_0 = qam.frame_sync_enc_bb(6) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(interpolation, (firdes.root_raised_cosine(0.14, samp_rate, samp_rate/interpolation, 0.18, rrc_taps))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([complex(1,1), complex(1,-1), complex(1,-3), complex(-3,-1), complex(-3,1), complex(1,3), complex(-3,-3), complex(-3,3), complex(-1,1), complex(-1,-1), complex(3,1), complex(-1,3), complex(-1,-3), complex(3,-1), complex(3,-3), complex(3,3), complex(5,1), complex(1,-5), complex(1,-7), complex(-7,-1), complex(-3,5), complex(5,3), complex(-7,-3), complex(-3,7), complex(-1,5), complex(-5,-1), complex(7,1), complex(-1,7), complex(-5,-3), complex(3,-5), complex(3,-7), complex(7,3), complex(1,5), complex(5,-1), complex(5,-3), complex(-3,-5), complex(-7,1), complex(1,7), complex(-3,-7), complex(-7,3), complex(-5,1), complex(-1,-5), complex(3,5), complex(-5,3), complex(-1,-7), complex(7,-1), complex(7,-3), complex(3,7), complex(5,5), complex(5,-5), complex(5,-7), complex(-7,-5), complex(-7,5), complex(5,7), complex(-7,-7), complex(-7,7), complex(-5,5), complex(-5,-5), complex(7,5), complex(-5,7), complex(-5,-7), complex(7,-5), complex(7,-7), complex(7,7)]), 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(7, gr.GR_MSB_FIRST) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=5555, server=True, ) ################################################## # Connections ################################################## self.connect((self.interp_fir_filter_xxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.qam_interleaver_bb_0, 0), (self.qam_randomizer_bb_0, 0)) self.connect((self.qam_randomizer_bb_0, 0), (self.qam_frame_sync_enc_bb_0, 0)) self.connect((self.qam_frame_sync_enc_bb_0, 0), (self.qam_trellis_enc_bb_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.qam_transport_framing_enc_bb_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.qam_reed_solomon_enc_bb_0, 0)) self.connect((self.qam_transport_framing_enc_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.qam_trellis_enc_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.qam_reed_solomon_enc_bb_0, 0), (self.qam_interleaver_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "Qam64 HackRF") ################################################## # Variables ################################################## self.interpolation = interpolation = 2 self.samp_rate = samp_rate = 5056941 * interpolation self.rrc_taps = rrc_taps = 50 self.gain = gain = 40 self.center_freq = center_freq = 441000000 ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink( args="hackrf=0" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(14, 0) self.osmosdr_sink_0.set_if_gain(gain, 0) self.osmosdr_sink_0.set_bb_gain(-4, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.qam_trellis_enc_bb_0 = qam.trellis_enc_bb() self.qam_transport_framing_enc_bb_0 = qam.transport_framing_enc_bb() self.qam_reed_solomon_enc_bb_0 = qam.reed_solomon_enc_bb() self.qam_randomizer_bb_0 = qam.randomizer_bb() self.qam_interleaver_bb_0 = qam.interleaver_bb(128,4) self.qam_frame_sync_enc_bb_0 = qam.frame_sync_enc_bb(6) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(interpolation, (firdes.root_raised_cosine(0.14, samp_rate, samp_rate/interpolation, 0.18, rrc_taps))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([complex(1,1), complex(1,-1), complex(1,-3), complex(-3,-1), complex(-3,1), complex(1,3), complex(-3,-3), complex(-3,3), complex(-1,1), complex(-1,-1), complex(3,1), complex(-1,3), complex(-1,-3), complex(3,-1), complex(3,-3), complex(3,3), complex(5,1), complex(1,-5), complex(1,-7), complex(-7,-1), complex(-3,5), complex(5,3), complex(-7,-3), complex(-3,7), complex(-1,5), complex(-5,-1), complex(7,1), complex(-1,7), complex(-5,-3), complex(3,-5), complex(3,-7), complex(7,3), complex(1,5), complex(5,-1), complex(5,-3), complex(-3,-5), complex(-7,1), complex(1,7), complex(-3,-7), complex(-7,3), complex(-5,1), complex(-1,-5), complex(3,5), complex(-5,3), complex(-1,-7), complex(7,-1), complex(7,-3), complex(3,7), complex(5,5), complex(5,-5), complex(5,-7), complex(-7,-5), complex(-7,5), complex(5,7), complex(-7,-7), complex(-7,7), complex(-5,5), complex(-5,-5), complex(7,5), complex(-5,7), complex(-5,-7), complex(7,-5), complex(7,-7), complex(7,7)]), 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(7, gr.GR_MSB_FIRST) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=5555, server=True, ) ################################################## # Connections ################################################## self.connect((self.interp_fir_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.qam_interleaver_bb_0, 0), (self.qam_randomizer_bb_0, 0)) self.connect((self.qam_randomizer_bb_0, 0), (self.qam_frame_sync_enc_bb_0, 0)) self.connect((self.qam_frame_sync_enc_bb_0, 0), (self.qam_trellis_enc_bb_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.qam_transport_framing_enc_bb_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.qam_reed_solomon_enc_bb_0, 0)) self.connect((self.qam_transport_framing_enc_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.qam_trellis_enc_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.qam_reed_solomon_enc_bb_0, 0), (self.qam_interleaver_bb_0, 0))
def __init__(self, host='127.0.0.1', iq_port=9094, packet_port=9095, sample_filename='sample_filename.dat'): gr.top_block.__init__(self, "Hurdle 1 Solution Stub") ################################################## # Parameters ################################################## self.host = host self.iq_port = iq_port self.packet_port = packet_port self.sample_filename = sample_filename ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4e6 self.num_garbage = num_garbage = int(1e6 / 8) ################################################## # Blocks ################################################## self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1, samp_rate / 8.0, True) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, num_garbage) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, sample_filename, False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr=host, port=iq_port, server=False, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr=host, port=packet_port, server=False, ) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_head_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.blocks_head_0, 0))
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: atsc-hackrf.py port [output_file]\n"); sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 rf_gain = 14 if_gain = 40 tb = gr.top_block() src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc(([symbol + 1.25 for symbol in [-7,-5,-3,-1,1,3,5,7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc = filter.fft_filter_ccc(1, firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate/2, 0.1152, 100)) out = osmosdr.sink(args="hackrf=0") out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bandwidth(6000000, 0) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
def __init__(self, samp_rate): gr.hier_block2.__init__(self, "throttled_source", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.throttle = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate) self.source = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr="127.0.0.1", port=8888, server=False, ) #OK self.connect(self.source, self.throttle, self)
def __init__(self, radio, device_address, samp_rate, center_freq, gain, antenna, port_number): """ :param radio: Which radio to use: Currently supports "USRP" or "AR2300" or "TCP" :type radio: string :param device_address: Device address for USRP or TCP. :type device_address: string :param samp_rate: the sampling rate :type samp_rate: int :param center_freq: the center frequency :type center_freq: double :param gain: Receiver gain :type gain: int :param antenna: The antenna to use :type antenna: string :param port_number: Port number for TCP :type port_number: int """ gr.hier_block2.__init__( self, "radio_source", gr.io_signature(0, 0, 0), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature # Define blocks and connect them if radio == "AR2300": self.radio_block = starcoder_swig.ar2300_source() elif radio == "USRP": self.radio_block = uhd.usrp_source( device_address, uhd.stream_args( cpu_format="fc32", channels=range(1), )) self.radio_block.set_samp_rate(samp_rate) self.radio_block.set_center_freq(center_freq, 0) self.radio_block.set_gain(gain, 0) self.radio_block.set_antenna(antenna, 0) elif radio == "TCP": self.radio_block = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr=device_address, port=port_number, server= False, # TODO: We usually use as client although might be better to make this configurable. ) else: raise NotImplementedError self.connect(self.radio_block, self)
def __init__(self, win, filename_raw, sample_rate): gr.hier_block2.__init__(self, "Receiver Stage 1", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.sample_rate = sample_rate self.fname = filename_raw self.decim = 8 self.wxgui_fftsink = fftsink2.fft_sink_c( win, baseband_freq=0, y_per_div=5, y_divs=10, ref_level=-35, ref_scale=2.0, sample_rate=self.sample_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot (input)", peak_hold=True, ) self.tcp_source = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=7890, server=False, ) self.throttle = blocks.throttle(gr.sizeof_gr_complex*1, sample_rate) if filename_raw is not None: self.file_sink_raw = blocks.file_sink(gr.sizeof_gr_complex*1, str(filename_raw)) self.file_sink_raw.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.tcp_source, 0), (self.throttle, 0)) self.connect((self.throttle, 0), (self.wxgui_fftsink, 0)) if filename_raw is not None: self.connect((self.throttle, 0), (self.file_sink_raw, 0)) self.connect((self.throttle, 0), self)
def __init__(self, hurdle2_IQ_port=9091, hurdle2_result_port=9090, hurdle2_scoring_host='127.0.0.1', num_bins=30, sample_filename='sample_filename.dat'): gr.top_block.__init__(self, "Hurdle2 Solution Stub Autogenerated") ################################################## # Parameters ################################################## self.hurdle2_IQ_port = hurdle2_IQ_port self.hurdle2_result_port = hurdle2_result_port self.hurdle2_scoring_host = hurdle2_scoring_host self.num_bins = num_bins self.sample_filename = sample_filename ################################################## # Variables ################################################## self.samp_rate = samp_rate = 3e6 # ADDED BY HAND ################################################## # Blocks ################################################## self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, sample_filename, False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr=hurdle2_scoring_host, port=hurdle2_IQ_port, server=False, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0))
def __init__(self, samp_rate, freq, gain, bw, port): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.gain = gain self.freq = freq self.bw = bw ################################################## # Blocks ################################################## #self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, "/tmp/send_test.complex", False) #self.blocks_file_sink_0.set_unbuffered(True) # self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate, True) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "bladerf") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(gain, 0) # self.osmosdr_sink_0.set_if_gain(gain, 0) # self.osmosdr_sink_0.set_bb_gain(gain, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(bw, 0) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr="", # Vorher: 127.0.0.1 port=port, server=False, ) ################################################## # Connections ################################################## #self.connect((self.blks2_tcp_source_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Tcp Server") _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 = 32000 ################################################## # Blocks ################################################## 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=False, ) self.Add(self.wxgui_fftsink2_0.win) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr='0.0.0.0', port=12345, server=True, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.wxgui_fftsink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Tcp Server") _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 = 32000 ################################################## # 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.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_float * 1, addr='0.0.0.0', port=12345, server=True, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Tcp Server") _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 = 32000 ################################################## # 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.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_float*1, addr='0.0.0.0', port=12345, server=True, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self, samp_rate, freq, gain, bw, ip, port): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate self.gain = gain self.freq = freq self.bw = bw ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=" + ip, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_bandwidth(bw, 0) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr="", # Vorher 127.0.0.1 port=port, server=False, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Simple TX/RX Path") ################################################## # Blocks ################################################## self.blks2_gmsk_demod_0 = blks2.gmsk_demod( samples_per_symbol=2, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blks2_gmsk_mod_0 = blks2.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) 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.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, access_code="", pad_for_usrp=True, ), payload_length=0, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=9001, server=True, ) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=9000, server=True, ) self.gr_channel_model_0 = gr.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=42, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blks2_gmsk_mod_0, 0)) self.connect((self.blks2_gmsk_mod_0, 0), (self.gr_channel_model_0, 0)) self.connect((self.gr_channel_model_0, 0), (self.blks2_gmsk_demod_0, 0)) self.connect((self.blks2_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0))
def __init__(self, type, sat_name, mode_name, audio_fname, frequency, line1, line2, lat, lon, alt, when, port = 0, pipe_fname = None, sample_rate=2048000, frequency_offset = 0, filename_raw = 'pants_raw_ssb.dat', audio = True): grc_wxgui.top_block_gui.__init__(self, title = str(type)+" Channel "+sat_name) _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) print 'Trying to connect source to port', port, 'in SSB_RX_Chan' self.tcp_source = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=port, server=False, ) self.gr_throttle = blocks.throttle(gr.sizeof_gr_complex*1, sample_rate) freq_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_offset = 0.0 self.freq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=freq_sizer, value=self.freq_offset, callback=self.set_freq, label="Fine Frequency Offset", converter=forms.float_converter(), proportion=0) self.freq_slider = forms.slider( parent=self.GetWin(), sizer=freq_sizer, value=self.freq_offset, callback=self.set_freq, minimum=-5000, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1) self.GridAdd(freq_sizer, 0, 0, 1, 3) #self.Add(self.freq_slider) row = 1 if audio: self.volume = 0.3 vol_sizer = wx.BoxSizer(wx.HORIZONTAL) self.vol_text_box = forms.text_box( parent=self.GetWin(), sizer=vol_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0) self.vol_slider = forms.slider( parent=self.GetWin(), sizer=vol_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=5, num_steps=500, style=wx.SL_HORIZONTAL, cast=float, proportion=1) #self.Add(self.vol_slider) self.GridAdd(vol_sizer, row, 0, 1, 3) row += 1 self.chandown = ChannelDownsample(self.GetWin(), sat_name, mode_name, sample_rate, frequency_offset, filename_raw, frequency, line1, line2, lat, lon, alt, when) self.GridAdd(self.chandown.wxgui_fftsink0.win, row, 0, 1, 3) row += 1 if type == 'SSB': self.demod = ChannelDemodSSB(self.GetWin(), sat_name, mode_name) else: self.demod = ChannelDemodFM(self.GetWin(), sat_name, mode_name) self.GridAdd(self.demod.fftsink_audio.win, row, 0, 1, 3) if audio: self.audio = ChannelAudio(self.GetWin(), sat_name, audio_fname, pipe_fname) else: self.audio = blocks.null_sink(gr.sizeof_gr_complex*1) self.connect(self.tcp_source, self.gr_throttle) self.connect(self.gr_throttle, self.chandown) self.connect(self.chandown, self.demod) self.connect(self.demod, self.audio)
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: atsc-blade.py port [output_file]\n") sys.exit(1) symbol_rate = 4500000.0 / 286 * 684 pilot_freq = 309441 center_freq = 441000000 tx_gain = 83 # max 89.5 tb = gr.top_block() out = uhd.usrp_sink( device_addr= "recv_frame_size=65536,num_recv_frames=128,send_frame_size=65536,num_send_frames=128,master_clock_rate=" + str(symbol_rate * 4), stream_args=uhd.stream_args( cpu_format="fc32", otw_format="sc16", channels=range(1), ), ) out.set_samp_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_gain(tx_gain, 0) #src = blocks.udp_source(gr.sizeof_char*1, "127.0.0.1", port, 18800, True) src = grc_blks2.tcp_source(gr.sizeof_char * 1, "127.0.0.1", port, True) pad = atsc.pad() rand = atsc.randomizer() rs_enc = atsc.rs_encoder() inter = atsc.interleaver() trell = atsc.trellis_encoder() fsm = atsc.field_sync_mux() v2s = blocks.vector_to_stream(gr.sizeof_char, 1024) minn = blocks.keep_m_in_n(gr.sizeof_char, 832, 1024, 4) c2sym = digital.chunks_to_symbols_bc( ([symbol + 1.25 for symbol in [-7, -5, -3, -1, 1, 3, 5, 7]]), 1) offset = analog.sig_source_c(symbol_rate, analog.GR_COS_WAVE, -3000000 + pilot_freq, 0.9, 0) mix = blocks.multiply_vcc(1) rrc = filter.fft_filter_ccc( 1, firdes.root_raised_cosine(0.1, symbol_rate, symbol_rate / 2, 0.1152, 100)) tb.connect(src, pad, rand, rs_enc, inter, trell, fsm, v2s, minn, c2sym) tb.connect((c2sym, 0), (mix, 0)) tb.connect((offset, 0), (mix, 1)) tb.connect(mix, rrc, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(rrc, dst) tb.run()
def __init__(self): gr.top_block.__init__(self, "Realtime Waterfall") Qt.QWidget.__init__(self) self.setWindowTitle("Realtime Waterfall") 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", "realtime_waterfall") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 128e3 ################################################## # Blocks ################################################## self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 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(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) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr='127.0.0.1', port=1234, server=False, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, ip='127.0.0.1', iq_file='./rocksat_125kbd_500ksps_date_comment.dat', meta_rate=.1, port='52001', record_iq=0, record_rfo=0, record_snr=0, rfo_file='./rocksat_rfo_date_comment.meta', snr_file='./rocksat_snr_date_comment.meta'): gr.top_block.__init__(self, "VTGS Rocksat Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("VTGS Rocksat Receiver") 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", "vtgs_rx_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.ip = ip self.iq_file = iq_file self.meta_rate = meta_rate self.port = port self.record_iq = record_iq self.record_rfo = record_rfo self.record_snr = record_snr self.rfo_file = rfo_file self.snr_file = snr_file ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.baud = baud = 125e3 / 2 self.samps_per_symb = samps_per_symb = int(samp_rate / baud) self.rx_freq = rx_freq = 2395e6 self.alpha = alpha = 0.5 self.tuned_center = tuned_center = 'baud_0' self.rx_offset = rx_offset = 250e3 self.rx_gain = rx_gain = 10 self.rrc_filter_taps = rrc_filter_taps = firdes.root_raised_cosine( 32, 1.0, 1.0 / (samps_per_symb * 32), alpha, samps_per_symb * 32) self.noise = noise = 0 self.mult = mult = (samp_rate) / 2 / 3.141593 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, samp_rate, samp_rate / 2, 1000, firdes.WIN_HAMMING, 6.76) self.lo = lo = 1833e6 self.khz_offset = khz_offset = 0 self.center_freq_lbl = center_freq_lbl = rx_freq / 1e6 ################################################## # Blocks ################################################## self._noise_range = Range(0, 1, 0.00001, 0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, "noise", "counter_slider", float) self.top_layout.addWidget(self._noise_win) self._khz_offset_range = Range(-150, 150, 1, 0, 200) self._khz_offset_win = RangeWidget(self._khz_offset_range, self.set_khz_offset, 'Offset [kHz]', "counter_slider", float) self.top_grid_layout.addWidget(self._khz_offset_win, 7, 8, 1, 4) self.vtgs_mult_descrambler_0 = vtgs.mult_descrambler(17, 0x3FFFF) self.vtgs_ao40_decoder_0_0 = vtgs.ao40_decoder() self._tuned_center_tool_bar = Qt.QToolBar(self) if None: self._tuned_center_formatter = None else: self._tuned_center_formatter = lambda x: x self._tuned_center_tool_bar.addWidget( Qt.QLabel(' Tuned Center [MHz]' + ": ")) self._tuned_center_label = Qt.QLabel( str(self._tuned_center_formatter(self.tuned_center))) self._tuned_center_tool_bar.addWidget(self._tuned_center_label) self.top_grid_layout.addWidget(self._tuned_center_tool_bar, 1, 8, 1, 2) self._rx_gain_range = Range(0, 86, 1, 10, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 6, 8, 1, 4) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #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(0.010) 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 = ['pre-d', 'post', '', '', '', '', '', '', '', ''] colors = [0, 1, 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(-130, -20) 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, 8, 0, 8, 8) self.qtgui_number_sink_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.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_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance( self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024 * 4, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.0010) self.qtgui_freq_sink_x_0.set_y_axis(-120, -20) 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(True) self.qtgui_freq_sink_x_0.set_fft_average(0.2) 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 = ['pre-d', 'post', '', '', '', '', '', '', '', ''] 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.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, 0, 0, 8, 8) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #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, 1) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) 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) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_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.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.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 8, 8, 8, 4) self.mapper_demapper_soft_0 = mapper.demapper_soft( mapper.BPSK, ([0, 1])) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, (baud * (1 + alpha)) / 2, 1000, firdes.WIN_HAMMING, 6.76)) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (lpf_taps), khz_offset * 1000, samp_rate) self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf( samps_per_symb, math.pi * 2 / 100, (rrc_filter_taps), 32, 16, 1.5, 1) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( math.pi * 2 / 100, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self._center_freq_lbl_tool_bar = Qt.QToolBar(self) if None: self._center_freq_lbl_formatter = None else: self._center_freq_lbl_formatter = lambda x: x self._center_freq_lbl_tool_bar.addWidget( Qt.QLabel('Center Frequency [MHz]' + ": ")) self._center_freq_lbl_label = Qt.QLabel( str(self._center_freq_lbl_formatter(self.center_freq_lbl))) self._center_freq_lbl_tool_bar.addWidget(self._center_freq_lbl_label) self.top_grid_layout.addWidget(self._center_freq_lbl_tool_bar, 0, 8, 1, 2) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", ip, port, 1024, False) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((mult, )) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr='127.0.0.1', port=5000, server=True, ) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noise, 0) self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-3, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.vtgs_ao40_decoder_0_0, 'valid_frames'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.analog_agc2_xx_0_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blks2_tcp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.analog_agc2_xx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mapper_demapper_soft_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 1), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.vtgs_mult_descrambler_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_pfb_clock_sync_xxx_0_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.mapper_demapper_soft_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.vtgs_mult_descrambler_0, 0), (self.vtgs_ao40_decoder_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") 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)) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 150000 self.filter_width = filter_width = 5000 self.carrier = carrier = 40000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=10, taps=None, fractional_bw=None, ) self.qtgui_time_sink_x_0_0_1 = qtgui.time_sink_c( 2048, #size samp_rate / 10, #samp_rate "Decimated PSK Mod", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_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 = [-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_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c( 4096, #size samp_rate, #samp_rate "PSK Mod", #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(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(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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_c( 4096, #size samp_rate, #samp_rate "carrier x psk mod", #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_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 2 #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(1.0) 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(2): 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_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #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(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) 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(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_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.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.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=2, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.1, verbose=False, log=False, ) self.digital_psk_demod_0 = digital.psk.psk_demod( constellation_points=2, differential=True, samples_per_symbol=2, excess_bw=0.1, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=1234, server=True, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=9989, server=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble='', access_code='', 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.band_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.band_pass(1, samp_rate, carrier - (filter_width / 2), carrier + (filter_width / 2), 100, firdes.WIN_HAMMING, 6.76)) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, carrier, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 1)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.digital_psk_demod_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.digital_psk_demod_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_psk_mod_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_time_sink_x_0_0_1, 0))
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: dvbt-hackrf.py port [output_file]\n") sys.exit(1) channel_mhz = 6 mode = dtv.T2k code_rate = dtv.C1_2 constellation = dtv.MOD_QPSK guard_interval = dtv.GI_1_32 symbol_rate = channel_mhz * 8000000.0 / 7 center_freq = 441000000 rf_gain = 14 if_gain = 40 if mode == dtv.T2k: factor = 1 carriers = 2048 elif mode == dtv.T8k: factor = 4 carriers = 8192 if guard_interval == dtv.GI_1_32: gi = carriers / 32 elif guard_interval == dtv.GI_1_16: gi = carriers / 16 elif guard_interval == dtv.GI_1_8: gi = carriers / 8 elif guard_interval == dtv.GI_1_4: gi = carriers / 4 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 tb = gr.top_block() src = grc_blks2.tcp_source(gr.sizeof_char * 1, "127.0.0.1", port, True) dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor) dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver( (136 * factor), 12, 17) dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation, dtv.NH, code_rate) dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver( (1512 * factor), constellation, dtv.NH, mode) dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver( (1512 * factor), mode, 1) dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1) dvbt_reference_signals = dtv.dvbt_reference_signals( gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH, code_rate, code_rate, dtv.GI_1_32, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer( carriers, carriers + (gi), 0, "") blocks_multiply_const_vxx = blocks.multiply_const_vcc( (0.0022097087 * 2.5, )) out = osmosdr.sink() out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbt_energy_dispersal) tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc) tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver) tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder) tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver) tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver) tb.connect(dvbt_symbol_inner_interleaver, dvbt_map) tb.connect(dvbt_map, dvbt_reference_signals) tb.connect(dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) tb.run()
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 = 2600000 ################################################## # Blocks ################################################## self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 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(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_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #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(-30, 40) 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 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_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + 'hackrf=81320f') self.osmosdr_sink_0.set_clock_source('external', 0) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(1575420000, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(17, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna('RX/TX', 0) self.osmosdr_sink_0.set_bandwidth(2600000, 0) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex * 1, addr='127.0.0.1', port=1234, server=True, ) (self.blks2_tcp_source_0).set_max_output_buffer(10000) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Qam64 HackRF") ################################################## # Variables ################################################## self.interpolation = interpolation = 2 self.samp_rate = samp_rate = 5056941 * interpolation self.rrc_taps = rrc_taps = 50 self.gain = gain = 40 self.center_freq = center_freq = 441000000 ################################################## # Blocks ################################################## self.osmosdr_sink_0 = osmosdr.sink(args="hackrf=0") self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(14, 0) self.osmosdr_sink_0.set_if_gain(gain, 0) self.osmosdr_sink_0.set_bb_gain(-4, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(6000000, 0) self.qam_trellis_enc_bb_0 = qam.trellis_enc_bb() self.qam_transport_framing_enc_bb_0 = qam.transport_framing_enc_bb() self.qam_reed_solomon_enc_bb_0 = qam.reed_solomon_enc_bb() self.qam_randomizer_bb_0 = qam.randomizer_bb() self.qam_interleaver_bb_0 = qam.interleaver_bb(128, 4) self.qam_frame_sync_enc_bb_0 = qam.frame_sync_enc_bb(6) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc( interpolation, (firdes.root_raised_cosine( 0.14, samp_rate, samp_rate / interpolation, 0.18, rrc_taps))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(([ complex(1, 1), complex(1, -1), complex(1, -3), complex(-3, -1), complex(-3, 1), complex(1, 3), complex(-3, -3), complex(-3, 3), complex(-1, 1), complex(-1, -1), complex(3, 1), complex(-1, 3), complex(-1, -3), complex(3, -1), complex(3, -3), complex(3, 3), complex(5, 1), complex(1, -5), complex(1, -7), complex(-7, -1), complex(-3, 5), complex(5, 3), complex(-7, -3), complex(-3, 7), complex(-1, 5), complex(-5, -1), complex(7, 1), complex(-1, 7), complex(-5, -3), complex(3, -5), complex(3, -7), complex(7, 3), complex(1, 5), complex(5, -1), complex(5, -3), complex(-3, -5), complex(-7, 1), complex(1, 7), complex(-3, -7), complex(-7, 3), complex(-5, 1), complex(-1, -5), complex(3, 5), complex(-5, 3), complex(-1, -7), complex(7, -1), complex(7, -3), complex(3, 7), complex(5, 5), complex(5, -5), complex(5, -7), complex(-7, -5), complex(-7, 5), complex(5, 7), complex(-7, -7), complex(-7, 7), complex(-5, 5), complex(-5, -5), complex(7, 5), complex(-5, 7), complex(-5, -7), complex(7, -5), complex(7, -7), complex(7, 7) ]), 1) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 7, gr.GR_MSB_FIRST) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr="127.0.0.1", port=5555, server=True, ) ################################################## # Connections ################################################## self.connect((self.interp_fir_filter_xxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.qam_interleaver_bb_0, 0), (self.qam_randomizer_bb_0, 0)) self.connect((self.qam_randomizer_bb_0, 0), (self.qam_frame_sync_enc_bb_0, 0)) self.connect((self.qam_frame_sync_enc_bb_0, 0), (self.qam_trellis_enc_bb_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.qam_transport_framing_enc_bb_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.qam_reed_solomon_enc_bb_0, 0)) self.connect((self.qam_transport_framing_enc_bb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.qam_trellis_enc_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.qam_reed_solomon_enc_bb_0, 0), (self.qam_interleaver_bb_0, 0))
def __init__(self, options): grc_wxgui.top_block_gui.__init__(self, title="DSSDR") self.initialized = False self.stopped = False self.options = copy.copy(options) self._constellation = digital.constellation_bpsk() self._excess_bw = options.excess_bw self._phase_bw = options.phase_bw self._freq_bw = options.freq_bw self._timing_bw = options.timing_bw self._if_freq = options.if_freq self._timing_max_dev= 1.5 self._demod_class = digital.bpsk_demod # the demodulator_class we're using self._chbw_factor = options.chbw_factor # channel filter bandwidth factor self._samples_per_second = 2e6 self._nav_samples_per_second = 16e6 self._down_decim = 1 self._down_samples_per_second = self._scope_sample_rate = self._samples_per_second/self._down_decim self._up_samples_per_second = 1e6 self._asm_threshold = 0 self._access_code = None self._tm_packet_id = 4 self._timestamp_id = 5 self._down_bitrate = options.bitrate self._up_bitrate = options.up_bitrate self._up_samples_per_symbol = self._up_samples_per_second/self._up_bitrate self._samples_per_symbol = self._samples_per_second/self._down_decim/self._down_bitrate self._down_sub_freq = options.down_sub_freq self._up_sub_freq = 25e3 self._tm_len = 8920 self._up_tm_len = 8920 self._coding_method = options.coding_method self._up_coding_method = 'None' self._up_subcarrier = 'Square' self._rs_i = 1 self._ccsds_channel = 38 self._uhd_carrier_offset = 10e3 self._turn_div = 749 self._turn_mult = 880 self._modulation_index = 'pi/3' self._up_modulation_index = 1.047 self._max_carrier_offset = 0.1 self._dssdr_mixer_freq = options.rf_freq self._up_coding_rate = '1' self._down_coding_rate = '1' self._down_conv_en = "False" self._down_randomizer_en = options.down_randomizer_en self._down_manchester_en = options.down_manchester_en self._up_conv_en = "False" self._up_idle_sequence = "\\x55" self._down_default_gain = 64 self._up_default_gain = 44 self._up_en = True if self._access_code is None: self._access_code = packet_utils.default_access_code #Construct the lookup table for parameter-setting functions self.param_setters = { "DSSDR_CHANNEL": self.setChannel, "DSSDR_LO_FREQ": self.setLOFreq, "DSSDR_REF_FREQ": self.setRefFreq, "DSSDR_TURN_MULT": self.setTurnMult, "DSSDR_TURN_DIV": self.setTurnDiv, "DSSDR_UP_GAIN": self.setUpGain, "DSSDR_DOWN_GAIN": self.setDownGain, "DSSDR_UP_BITRATE": self.setUpBitrate, "DSSDR_DOWN_BITRATE": self.setDownBitrate, "DSSDR_DOWN_SAMPLE_RATE": self.setSampRate, "DSSDR_UP_SUB_FREQ": self.setUpSubFreq, "DSSDR_DOWN_SUB_FREQ": self.setDownSubFreq, "DSSDR_DOPPLER_REPORT": self.dopplerReport, "DSSDR_PN_RANGE": self.rangePN, "DSSDR_SEQUENTIAL_RANGE": self.rangeSequential, "DSSDR_DOWN_CODING_METHOD": self.setDownCodingMethod, "DSSDR_UP_CODING_METHOD": self.setUpCodingMethod, "DSSDR_DOWN_TM_LEN": self.setTMLen, "DSSDR_UP_TM_LEN": self.setUpTMLen, "DSSDR_DOWN_MOD_IDX": self.setDownModulationIndex, "DSSDR_UP_MOD_IDX": self.setUpModulationIndex, "DSSDR_DOWN_CONV_EN": self.setDownConvEn, "DSSDR_UP_CONV_EN": self.setUpConvEn, "DSSDR_ASM_TOL": self.setASMThreshold, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_UP_IDLE": self.setUpIdleSequence, "DSSDR_UP_EN": self.setUpEn, "DSSDR_SYNC_TIME": self.syncSDRTime, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_DOWN_ACQUIRE": self.acquireCarrier, "DSSDR_INPUT_SELECT": self.setPanelSelect, "DSSDR_REF_SELECT": self.setRefSelect, "DSSDR_PPS_SELECT": self.setPPSSelect } #TODO:Add status fields for things like DSSDR_REF_LOCK self._dssdr_channels = { 3: [7149597994, 8400061729], 4: [7150753857, 8401419752], 5: [7151909723, 8402777779], 6: [7153065586, 8404135802], 7: [7154221449, 8405493825], 8: [7155377316, 8406851853], 9: [7156533179, 8408209877], 10: [7157689045, 8409567903], 11: [7158844908, 8410925927], 12: [7160000771, 8412283950], 13: [7161156637, 8413641977], 14: [7162312500, 8415000000], 15: [7163468363, 8416358023], 16: [7164624229, 8417716050], 17: [7165780092, 8419074073], 18: [7166935955, 8420432097], 19: [7168091821, 8421790123], 20: [7169247684, 8423148147], 21: [7170403551, 8424506175], 22: [7171559414, 8425864198], 23: [7172715277, 8427222221], 24: [7173871143, 8428580248], 25: [7175027006, 8429938271], 26: [7176182869, 8431296295], 27: [7177338735, 8432654321], 28: [7178494598, 8434012345], 29: [7179650464, 8435370372], 30: [7180806327, 8436728395], 31: [7181962190, 8438086418], 32: [7183118057, 8439444446], 33: [7184273920, 8440802469], 34: [7185429783, 8442160493], 35: [7186585649, 8443518520], 36: [7187741512, 8444876543], 37: [7188897378, 8446234570], 38: [7190000000, 8450000000], } #FLOWGRAPH STUFF if options.test == True: self.u = blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="", port=12905, server=True ) elif options.fromfile == True: self.u2 = blocks.file_meta_source("iq_in.dat") self.u = blocks.throttle(gr.sizeof_gr_complex*1, self._samples_per_second) elif options.frombitlog == True: self.u3 = blocks.file_source(gr.sizeof_char, "bitstream_recording.in", True) self.u2 = blocks.uchar_to_float() self.u1 = blocks.throttle(gr.sizeof_float*1, self._down_bitrate) self.u = blocks.add_const_ff(-0.5) else: self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u.set_clock_source("external") self.u.set_time_source("external") self.u.set_samp_rate(self._samples_per_second) self.u.set_antenna("RX2") self.u.set_gain(self._down_default_gain) self.frontend = dfi.dssdrFrontendInterface(self.u) if options.debug_pps == True: self.debug_pps = blocks.tag_debug(gr.sizeof_gr_complex, "debug-pps", "rx_time") if options.tofile == True: self.u_tx = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_out.dat", self._up_samples_per_second) elif options.tonull == True: self.u_tx = blocks.null_sink(gr.sizeof_gr_complex) else: self.u_tx = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u_tx.set_clock_source("external") self.u_tx.set_time_source("external") self.u_tx.set_samp_rate(self._up_samples_per_second) self.u_tx.set_antenna("TX/RX") self.u_tx.set_gain(self._up_default_gain) #GUI STUFF if options.graphics == True: self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "TX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Nav") self.Add(self.nb0) self.constellation_scope = scopesink2.scope_sink_c( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.constellation_scope.win) #self.constellation_scope.win.set_marker('plus') self._scope_is_fft = False self.time_scope = scopesink2.scope_sink_f( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=.005, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.time_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.time_scope.win) self.fft_scope = fftsink2.fft_sink_c( self.nb0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=self._scope_sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb0.GetPage(0).Add(self.fft_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.fft_scope.win) self.row1_sizer = wx.BoxSizer(wx.HORIZONTAL) self.recording_onoff_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Off', callback=self.setRecording, label="IQ Recording", choices=['Off','On'], labels=[], style=wx.RA_HORIZONTAL, ) self.front_panel_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='RF', callback=self.setPanelSelect, label="Input Select", choices=['RF','IF'], labels=[], style=wx.RA_HORIZONTAL, ) self.ref_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setRefSelect, label="Ref Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.pps_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setPPSSelect, label="PPS Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.sync_button = forms.button( parent=self.nb0.GetPage(0).GetWin(), value='Sync to PPS', callback=self.syncSDRTime, choices=['Sync to PPS'], style=wx.RA_HORIZONTAL, ) self.ref_locked_text = forms.static_text( parent=self.nb0.GetPage(0).GetWin(), value="", callback=self.setRefLocked, label="", converter=forms.str_converter(), ) self.row1_sizer.Add(self.recording_onoff_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.front_panel_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.pps_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.sync_button, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_locked_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(0).Add(self.row1_sizer) self.complex_scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Constellation', callback=self.setComplexScopeStyle, label="Complex Scope", choices=['Constellation','FFT'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.complex_scope_chooser) self.scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='USRP', callback=self.setScopePoint, label="Scope Probe Point", choices=['USRP','Carrier Tracking','Sub-Carrier Costas','Sub-Carrier Sync','Data Sync'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.scope_chooser) self._bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_bitrate, callback=self.setDownBitrate, label="Symbol Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._bitrate_text_box) self._samprate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._samples_per_second, callback=self.setSampRate, label="Sampling Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._samprate_text_box) self._subcfreq_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_sub_freq, callback=self.setDownSubFreq, label="Downlink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._subcfreq_text_box) self._mod_index_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._modulation_index, callback=self.setDownModulationIndex, label="Modulation Index", choices=['pi/2', 'pi/3'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._mod_index_chooser) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._tm_len, callback=self.setTMLen, label="Downlink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._coding_method, callback=self.setDownCodingMethod, label="Coding", choices=['None', 'RS', 'Turbo 1/2', 'Turbo 1/3', 'Turbo 1/4', 'Turbo 1/6'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._down_conv_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_conv_en, callback=self.setDownConvEn, label="Convolutional Decode", true="True", false="False", ) self.nb0.GetPage(0).Add(self._down_conv_check_box) self._down_randomizer_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_randomizer_en, callback=self.setDownRandomizerEn, label="De-randomizer", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_randomizer_check_box) self._down_manchester_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_manchester_en, callback=self.setDownManchesterEn, label="Manchester Decode", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_manchester_check_box) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._asm_threshold, callback=self.setASMThreshold, label="ASM Error Tolerance (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._rs_i, callback=self.setRSI, label="Reed-Solomon Interleaving Depth", choices=[1,5], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._ccsds_chan_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._ccsds_channel, callback=self.setChannel, label="CCSDS Channel", converter=forms.int_converter(), ) self.nb0.GetPage(0).Add(self._ccsds_chan_text_box) self.setChannel(self._ccsds_channel) if options.test == True or options.fromfile == True or options.frombitlog == True: glow = 0.0 ghigh = 1.0 cur_g = 0.5 else: g = self.u.get_gain_range() cur_g = self._down_default_gain # some configurations don't have gain control if g.stop() <= g.start(): glow = 0.0 ghigh = 1.0 else: glow = g.start() ghigh = g.stop() self._uhd_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(0).GetWin(), sizer=self._uhd_gain_slider, label="USRP RX Gain", weight=3, min=int(glow), max=int(ghigh), value=cur_g, callback=self.setDownGain ) self.nb0.GetPage(0).Add(self._uhd_gain_slider) #TX chain GUI components if options.test == True or options.tofile == True or options.tonull == True: gtxlow = 0.0 gtxhigh = 1.0 cur_gtx = 0.5 else: gtx = self.u_tx.get_gain_range() cur_gtx = self._up_default_gain # some configurations don't have gain control if gtx.stop() <= gtx.start(): gtxlow = 0.0 gtxhigh = 1.0 else: gtxlow = gtx.start() gtxhigh = gtx.stop() self._up_en_chooser = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value='True', callback=self.setUpEn, label="TX Enable", true='True', false='False', ) self.nb0.GetPage(1).Add(self._up_en_chooser) self._uhd_tx_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(1).GetWin(), sizer=self._uhd_tx_gain_slider, label="USRP TX Gain", weight=3, min=int(gtxlow), max=int(gtxhigh), value=cur_gtx, callback=self.setUpGain ) self.nb0.GetPage(1).Add(self._uhd_tx_gain_slider) self._subcfreq_up_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_sub_freq, callback=self.setUpSubFreq, label="Uplink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._subcfreq_up_text_box) self._up_bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_bitrate, callback=self.setUpBitrate, label="Uplink Bitrate", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_bitrate_text_box) self._up_data_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="1234ABCD", callback=self.txData, label="TX Data", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._up_data_text_box) self._up_mod_index_chooser = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_modulation_index, callback=self.setUpModulationIndex, label="Uplink Modulation Index", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_mod_index_chooser) self._up_coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_coding_method, callback=self.setUpCodingMethod, label="Coding", choices=['None', 'RS'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._up_coding_chooser) self._subcarrier_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_subcarrier, callback=self.setUpSubcarrier, label="Subcarrier Type", choices=['Square','Sine'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._subcarrier_chooser) self._up_conv_check_box = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_conv_en, callback=self.setUpConvEn, label="Convolutional Encode", true="True", false="False", ) self.nb0.GetPage(1).Add(self._up_conv_check_box) self._up_pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_tm_len, callback=self.setUpTMLen, label="Uplink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_pktlen_text_box) self._uhd_offset_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._uhd_carrier_offset, callback=self.setUHDCarrierOffset, label="USRP Offset Frequency (Hz)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._uhd_offset_text_box) self._sweep_gen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="rf2_1", callback=self.freqSweep, label="Frequency Sweep Profile", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._sweep_gen_text_box) self._idle_sequence_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_idle_sequence, callback=self.setUpIdleSequence, label="Uplink Idle Sequence", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._idle_sequence_text_box) self._pn_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangePN, label="Queue PN Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._pn_ranging_text_box) self._sequential_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangeSequential, label="Queue Sequential Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._sequential_ranging_text_box) self.row2_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_acq_button = forms.button( parent=self.nb0.GetPage(2).GetWin(), value='Acquire Carrier Offset', callback=self.acquireCarrier, choices=['Acquire Carrier Offset'], style=wx.RA_HORIZONTAL, ) self.carrier_offset_text = forms.static_text( parent=self.nb0.GetPage(2).GetWin(), value="", label="", converter=forms.str_converter(), ) self.row2_sizer.Add(self.freq_acq_button, flag=wx.ALIGN_CENTER) self.row2_sizer.Add(self.carrier_offset_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(2).Add(self.row2_sizer) self.file_sink = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_recording.dat", self._samples_per_second) self.file_sink.close() self.iq_recording_ctr = 0 # Selection logic to switch between recording and normal flowgraph routes # NOTE: u_valve logic is implemented backwards in GNURadio.... #self.u_valve = blks2.valve( # item_size=gr.sizeof_gr_complex, # open=False #) # Temporary code used to verify coherent turnaround self.turnaround_mixer = blocks.multiply_cc() self.turnaround_mixer_source = analog.sig_source_c(self._down_samples_per_second, analog.GR_SIN_WAVE, -25e3, 1.0) self.turnaround_iir = filter.single_pole_iir_filter_cc(0.0001) self.turnaround_null = blocks.null_sink(gr.sizeof_float) # PLL and associated carrier for tracking carrier frequency if residual carrier is used self.carrier_tracking = sdrp.pll_freq_acq_cc(math.pi/2000, math.pi, -math.pi, int(options.acq_samples)) self.imag_to_float = blocks.complex_to_imag() #Suppressed carrier requires costas after subcarrier mixer self.subcarrier_costas = digital.costas_loop_cc(0.001, 2) self.real_to_float = blocks.complex_to_real() #Square wave subcarrier sync self.subcarrier_sync = sdrp.square_sub_tracker_ff(0.001, 2*self._down_sub_freq/self._down_samples_per_second*1.0001, 2*self._down_sub_freq/self._down_samples_per_second*0.9999) #Data sync self.data_sync = sdrp.square_data_tracker_ff(0.001, self._down_bitrate/self._down_samples_per_second*1.001, self._down_bitrate/self._down_samples_per_second*0.999) #Data framing self.soft_correlator = sdrp.correlate_soft_access_tag_ff(conv_packed_binary_string_to_1_0_string('\x1A\xCF\xFC\x1D'), self._asm_threshold, "asm_corr") self.conv_decoder = sdrp.ccsds_tm_conv_decoder("asm_corr") self.de_randomizer = sdrp.ccsds_tm_derandomizer("asm_corr") self.tm_framer = sdrp.ccsds_tm_framer(self._tm_packet_id, self._timestamp_id, "asm_corr", "rx_time", self._down_bitrate) self.tm_framer.setFrameLength(self._tm_len) self._current_scope_block = None self._current_scoped_block = self.u self._current_scoped_block_port = 0 self._recording = 'Off' #TX path in flowgraph self.pkt_gen_msgq = gr.msg_queue(10) self.pkt_gen = sdrp.ccsds_tm_tx(self._tm_packet_id, self._timestamp_id, 1.0, 16, self.pkt_gen_msgq) self.conj = blocks.conjugate_cc() #Sweep generator for transponder lock self.sweep_gen = sdrp.sweep_generator_cc(self._up_samples_per_second) # DSSDR subcarrier mixer (either 25 kHz or 0 kHz depending on baud rate) self.up_subcarrier_mixer = blocks.multiply_ff() self.subcarrier_mixer_source_tx = analog.sig_source_f(self._up_samples_per_second, analog.GR_SQR_WAVE, 25e3, 2.0, -1.0) self.phase_mod_tx = analog.phase_modulator_fc(self._up_modulation_index) self.tx_attenuator = blocks.multiply_const_cc((0.1+0.0j)) #Add in bit recorder if needed if self.options.bitlog: self.bit_slicer = digital.binary_slicer_fb() self.bit_recorder = blocks.file_sink(1, "bitstream_recording.out") self.setDownCodingMethod(self._coding_method) self.setUpCodingMethod("None") self.setUpSubcarrier(self._up_subcarrier) self.setDownBitrate(self._down_bitrate) self.setUpBitrate(self._up_bitrate) self.setDownModulationIndex(self._modulation_index) self.setUpModulationIndex(self._up_modulation_index) self.setDownConvEn(self._down_conv_en) self.setUpConvEn(self._up_conv_en) self.setUpIdleSequence(self._up_idle_sequence) self.setDownRandomizerEn(self._down_randomizer_en) self.setDownManchesterEn(self._down_manchester_en) #Connection to outside world self.socket_pdu = blocks.socket_pdu("TCP_SERVER", "127.0.0.1", "12902", 10000) self.sdrp_interpreter = sdrp.sdrp_packet_interpreter() self.msg_connect(self.tm_framer, "tm_frame_out", self.sdrp_interpreter, "sdrp_pdu_in") self.msg_connect(self.sdrp_interpreter, "socket_pdu_out", self.socket_pdu, "pdus") self.msg_connect(self.socket_pdu, "pdus", self.sdrp_interpreter, "socket_pdu_in") self.msg_connect(self.sdrp_interpreter,"sdrp_pdu_out", self.pkt_gen, "ccsds_tx_msg_in") if options.test == False and options.fromfile == False and options.frombitlog == False: _threading.Thread(target=self.watchRef).start() self.initialized = True print "DS-SDR Initialized"
def __init__(self): gr.top_block.__init__ (self) parser=OptionParser(option_class=eng_option) parser.add_option("-H", "--hostname", type="string", default="localhost", help="set hostname of generic sdr") parser.add_option("-P", "--portnum", type="int", default=None, help="set portnum of generic sdr") parser.add_option("-r", "--sdr_rate", type="eng_float", default=250e3, help="set sample rate of generic sdr") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option("-O", "--audio-output", type="string", default="plughw:0,0", help="pcm device name (default is plughw:0,0)") # print help when called with wrong arguments (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.vol = options.volume if self.vol is None: self.vol = 0.1 # connect to generic SDR sdr_rate = options.sdr_rate audio_decim = 8 audio_rate = int(sdr_rate/audio_decim) print "audio_rate = ", audio_rate self.interleaved_short_to_complex = gr.interleaved_short_to_complex() self.char_to_short = gr.char_to_short(1) self.sdr_source = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr=options.hostname, port=options.portnum, server=False ) # self.sdr_source = gr.file_source(1, 'sdrs_baseband.dat') # self.throttle = gr.throttle(1, 500e3) # self.connect(self.sdr_source, self.file_sink) self.logger = gr.file_sink(1, 'log.out') self.connect(self.sdr_source, self.logger) # channel filter chan_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 80e3, # passband cutoff 35e3, # transition width gr.firdes.WIN_HAMMING) self.chan_filter = gr.fir_filter_ccf(1, chan_filter_coeffs) # print "# channel filter:", len(chan_filter_coeffs), "taps" # PLL-based WFM demod fm_alpha = 0.25 * 250e3 * math.pi / sdr_rate # 0.767 fm_beta = fm_alpha * fm_alpha / 4.0 # 0.147 fm_max_freq = 2.0 * math.pi * 90e3 / sdr_rate # 2.209 self.fm_demod = gr.pll_freqdet_cf( 1.0, # Loop BW fm_max_freq, # in radians/sample -fm_max_freq) self.fm_demod.set_alpha(fm_alpha) self.fm_demod.set_beta(fm_beta) self.connect(self.sdr_source, self.char_to_short) self.connect(self.char_to_short, self.interleaved_short_to_complex) self.connect(self.interleaved_short_to_complex, self.chan_filter, self.fm_demod) # L+R, pilot, L-R, RDS filters lpr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lpr_filter = gr.fir_filter_fff(audio_decim, lpr_filter_coeffs) pilot_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 19e3-500, # low cutoff 19e3+500, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.pilot_filter = gr.fir_filter_fff(1, pilot_filter_coeffs) dsbsc_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 38e3-15e3/2, # low cutoff 38e3+15e3/2, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.dsbsc_filter = gr.fir_filter_fff(1, dsbsc_filter_coeffs) rds_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 57e3-3e3, # low cutoff 57e3+3e3, # high cutoff 3e3, # transition width gr.firdes.WIN_HAMMING) self.rds_filter = gr.fir_filter_fff(1, rds_filter_coeffs) # print "# lpr filter:", len(lpr_filter_coeffs), "taps" # print "# pilot filter:", len(pilot_filter_coeffs), "taps" # print "# dsbsc filter:", len(dsbsc_filter_coeffs), "taps" # print "# rds filter:", len(rds_filter_coeffs), "taps" self.connect(self.fm_demod, self.lpr_filter) self.connect(self.fm_demod, self.pilot_filter) self.connect(self.fm_demod, self.dsbsc_filter) self.connect(self.fm_demod, self.rds_filter) # down-convert L-R, RDS self.stereo_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.stereo_baseband, 0)) self.connect(self.pilot_filter, (self.stereo_baseband, 1)) self.connect(self.dsbsc_filter, (self.stereo_baseband, 2)) self.rds_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.rds_baseband, 0)) self.connect(self.pilot_filter, (self.rds_baseband, 1)) self.connect(self.pilot_filter, (self.rds_baseband, 2)) self.connect(self.rds_filter, (self.rds_baseband, 3)) # low-pass and downsample L-R lmr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lmr_filter = gr.fir_filter_fff(audio_decim, lmr_filter_coeffs) self.connect(self.stereo_baseband, self.lmr_filter) # create L, R from L-R, L+R self.left = gr.add_ff() self.right = gr.sub_ff() self.connect(self.lpr_filter, (self.left, 0)) self.connect(self.lmr_filter, (self.left, 1)) self.connect(self.lpr_filter, (self.right, 0)) self.connect(self.lmr_filter, (self.right, 1)) # volume control, complex2flot, audio sink self.volume_control_l = gr.multiply_const_ff(self.vol) self.volume_control_r = gr.multiply_const_ff(self.vol) output_audio_rate = 48000 self.resamp_L = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.resamp_R = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.connect(self.left, self.volume_control_l, self.resamp_L) self.connect(self.right, self.volume_control_r, self.resamp_R) # self.audio_sink = audio.sink(int(output_audio_rate), # options.audio_output, False) # self.connect(self.resamp_L, (self.audio_sink, 0)) # self.connect(self.resamp_R, (self.audio_sink, 1)) self.file_sink1 = gr.file_sink(gr.sizeof_float, 'audioL.dat') self.file_sink2 = gr.file_sink(gr.sizeof_float, 'audioR.dat') self.file_sink3 = gr.file_sink(gr.sizeof_float, 'fmDemod.dat') self.connect(self.resamp_L, self.file_sink1) self.connect(self.resamp_R, self.file_sink2) self.connect(self.fm_demod, self.file_sink3) # low-pass the baseband RDS signal at 1.5kHz rds_bb_filter_coeffs = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.5e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HAMMING) self.rds_bb_filter = gr.fir_filter_fff(audio_decim, rds_bb_filter_coeffs) # print "# rds bb filter:", len(rds_bb_filter_coeffs), "taps" self.connect(self.rds_baseband, self.rds_bb_filter) # 1187.5bps = 19kHz/16 self.clock_divider = rds.freq_divider(16) rds_clock_taps = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.2e3, # passband cutoff 1.5e3, # transition width gr.firdes.WIN_HAMMING) self.rds_clock = gr.fir_filter_fff(audio_decim, rds_clock_taps) # print "# rds clock filter:", len(rds_clock_taps), "taps" self.connect(self.pilot_filter, self.clock_divider, self.rds_clock) # bpsk_demod, diff_decoder, rds_decoder self.bpsk_demod = rds.bpsk_demod(audio_rate) self.differential_decoder = gr.diff_decoder_bb(2) self.msgq = gr.msg_queue() self.rds_decoder = rds.data_decoder(self.msgq) self.connect(self.rds_bb_filter, (self.bpsk_demod, 0)) self.connect(self.rds_clock, (self.bpsk_demod, 1)) self.connect(self.bpsk_demod, self.differential_decoder) self.connect(self.differential_decoder, self.rds_decoder)
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.variable_1 = variable_1 = 0 self.variable_0 = variable_0 = 0 self.sideband_rx = sideband_rx = 1000 self.samp_rate = samp_rate = 48000 ################################################## # Blocks ################################################## 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=4800, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=500, decimation=1, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(100e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(10, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(20, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate, sideband_rx,100)), -2300, 4800) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=3009, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_c(grc_blks2.packet_encoder( samples_per_symbol=9, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=True, ), payload_length=8, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) 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.osmosdr_sink_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
def __init__(self, baudrate=9600, default_attenuation=10, default_dev=4950 / 2, default_input=0, default_ip='127.0.0.1', default_port=5000, freq=435750000, samp_rate_tx=1920000, sdr_dev='uhd=0'): gr.top_block.__init__(self, "GFSK TX") Qt.QWidget.__init__(self) self.setWindowTitle("GFSK TX") 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", "gfsk_tx_1U") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.baudrate = baudrate self.default_attenuation = default_attenuation self.default_dev = default_dev self.default_input = default_input self.default_ip = default_ip self.default_port = default_port self.freq = freq self.samp_rate_tx = samp_rate_tx self.sdr_dev = sdr_dev ################################################## # Variables ################################################## self.interp_tx = interp_tx = samp_rate_tx / baudrate self.sensitivity = sensitivity = 2 * math.pi * default_dev / samp_rate_tx self.rrc_taps = rrc_taps = firdes.root_raised_cosine( 1, samp_rate_tx, interp_tx, 0.3, 88) self.freq_offset = freq_offset = 0 self.bt = bt = 0.5 self.attenuation = attenuation = default_attenuation ################################################## # Blocks ################################################## self._freq_offset_range = Range(-20000, 20000, 100, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Signal Frequency Offset', "counter_slider", int) self.top_grid_layout.addWidget(self._freq_offset_win, 0, 2, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 4): self.top_grid_layout.setColumnStretch(c, 1) self._bt_range = Range(0, 1, 0.05, 0.5, 200) self._bt_win = RangeWidget(self._bt_range, self.set_bt, 'Gaussian BT', "counter_slider", float) self.top_grid_layout.addWidget(self._bt_win, 0, 4, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._attenuation_range = Range(0, 100, 1, default_attenuation, 200) self._attenuation_win = RangeWidget(self._attenuation_range, self.set_attenuation, 'Signal Attenuation', "counter_slider", int) self.top_grid_layout.addWidget(self._attenuation_win, 0, 0, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate_tx, #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, 3, 0, 2, 6) for r in range(3, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 6): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 500, #size samp_rate_tx, #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(-2, 2) 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, 1, 0, 1, 3) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate_tx, #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(1.0) 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 = [2, 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, 1, 3, 1, 3) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 6): self.top_grid_layout.setColumnStretch(c, 1) self.iio_fmcomms2_sink_0 = iio.fmcomms2_sink_f32c( 'ip:pluto.local', freq + freq_offset, samp_rate_tx, 20000000, True, False, 0x8000, False, "A", attenuation, 10.0, '', True) self.digital_scrambler_bb_1 = digital.scrambler_bb(0x21, 0x7F, 16) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=interp_tx, sensitivity=sensitivity, bt=bt, verbose=False, log=False, ) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blks2_tcp_source = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr=default_ip, port=default_port, server=True, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_scrambler_bb_1, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.iio_fmcomms2_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.digital_scrambler_bb_1, 0), (self.blocks_pack_k_bits_bb_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.sps = sps = 45 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'fc', "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance( self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_1_win) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1.1E3, .6E3, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 8, .01, 1, BPSK) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.05, 2, False) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.25, verbose=False, log=False, ) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=4321, server=True, ) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=1234, server=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code='', 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_source_0 = audio.source(44100, '', True) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1) ################################################## # Connections ################################################## self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_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.audio_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_feedforward_agc_cc_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Acpmeter") _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 = 96000 ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.GetWin(), title="Scope Plot", sample_rate=9600, 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="Power [Watts]", ) self.Add(self.wxgui_scopesink2_0.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="Units", minval=-100, maxval=1000, factor=1.0, decimal_places=10, 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.fir_filter_xxx_0 = filter.fir_filter_fff(10, (firdes.low_pass(1, samp_rate, 100, 100, firdes.WIN_BLACKMAN_HARRIS))) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_rms_xx_0 = blocks.rms_ff(0.1) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((1, )) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=3701, server=False, ) ################################################## # Connections ################################################## self.connect((self.blks2_tcp_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.wxgui_scopesink2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") 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)) ################################################## # Variables ################################################## self.sps = sps = 45 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'fc', "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #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.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 True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "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_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.25, verbose=False, log=False, ) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr='127.0.0.1', port=1235, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.digital_constellation_modulator_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.sps_slider = sps_slider = 45 self.sps = sps = sps_slider self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.fc_slider = fc_slider = 2200 self.amp_slider = amp_slider = 1 self.BPSK = BPSK = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'fc', "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self._amp_slider_range = Range(0, 20, 1, 1, 150) self._amp_slider_win = RangeWidget(self._amp_slider_range, self.set_amp_slider, 'amp', "counter_slider", float) self.top_layout.addWidget(self._amp_slider_win) self._sps_slider_range = Range(0, 200, 10, 45, 150) self._sps_slider_win = RangeWidget(self._sps_slider_range, self.set_sps_slider, 'sps', "counter_slider", float) self.top_layout.addWidget(self._sps_slider_win) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Tempo nao codificado', #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.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_2.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance( self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate 'Tempo codificado', #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(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) 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(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_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 = [-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_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) 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.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'Tempo modulado', #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) 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_freq_sink_x_1_1 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Frequ\xc3\xaancia modulada ', #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_1.set_update_time(0.10) self.qtgui_freq_sink_x_1_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_1.enable_autoscale(False) self.qtgui_freq_sink_x_1_1.enable_grid(False) self.qtgui_freq_sink_x_1_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_1_1.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_1_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(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_1_1_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw 'Frequ\xc3\xaancia codificada', #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(1.0) 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_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size 'Constela\xc3\xa7\xc3\xa3o antes multi', #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(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: 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_layout.addWidget(self._qtgui_const_sink_x_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size 'Constela\xc3\xa7\xc3\xa3o depois multi', #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(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) 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(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_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.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.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.25, verbose=False, log=False, ) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=3656, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fc_slider, amp_slider, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_freq_sink_x_1_1, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.qtgui_time_sink_x_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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", "top_block") 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)) ################################################## # Variables ################################################## self.sps = sps = 45 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_qpsk().base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'fc', "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_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(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.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.25, verbose=False, log=False, ) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr='127.0.0.1', port=1233, server=False, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b( grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self, type, sat_name, mode_name, audio_fname, frequency, line1, line2, lat, lon, alt, when, port = 0, pipe_fname = None, sample_rate=2048000, frequency_offset = 0, filename_raw = 'pants_raw_ssb.dat', audio = True): grc_wxgui.top_block_gui.__init__(self, title = str(type)+" Channel "+sat_name) _icon_path = "/usr/local/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) print 'Trying to connect source to port', port, 'in SSB_RX_Chan' self.tcp_source = grc_blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="127.0.0.1", port=port, server=False, ) self.gr_throttle = blocks.throttle(gr.sizeof_gr_complex*1, sample_rate) freq_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_offset = 0.0 self.freq_offset_text_box = forms.text_box( parent=self.GetWin(), sizer=freq_sizer, value=self.freq_offset, callback=self.set_freq, label="Fine Frequency Offset", converter=forms.float_converter(), proportion=0) self.freq_slider = forms.slider( parent=self.GetWin(), sizer=freq_sizer, value=self.freq_offset, callback=self.set_freq, minimum=-5000, maximum=5000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1) self.GridAdd(freq_sizer, 0, 0, 1, 3) #self.Add(self.freq_slider) row = 1 if audio: self.volume = 0.3 vol_sizer = wx.BoxSizer(wx.HORIZONTAL) self.vol_text_box = forms.text_box( parent=self.GetWin(), sizer=vol_sizer, value=self.volume, callback=self.set_volume, label="Volume", converter=forms.float_converter(), proportion=0) self.vol_slider = forms.slider( parent=self.GetWin(), sizer=vol_sizer, value=self.volume, callback=self.set_volume, minimum=0, maximum=5, num_steps=500, style=wx.SL_HORIZONTAL, cast=float, proportion=1) #self.Add(self.vol_slider) self.GridAdd(vol_sizer, row, 0, 1, 3) row += 1 self.chandown = ChannelDownsample(self.GetWin(), sat_name, mode_name, sample_rate, frequency_offset, filename_raw, frequency, line1, line2, lat, lon, alt, when) self.GridAdd(self.chandown.wxgui_fftsink0.win, row, 0, 1, 3) row += 1 if type == 'SSB': self.demod = ChannelDemodSSB(self.GetWin(), sat_name, mode_name) else: self.demod = ChannelDemodFM(self.GetWin(), sat_name, mode_name) self.GridAdd(self.demod.fftsink_audio.win, row, 0, 1, 3) if audio: self.audio = ChannelAudio(self.GetWin(), sat_name, audio_fname, pipe_fname) else: self.audio = blocks.null_sink(gr.sizeof_gr_complex*1) self.connect(self.tcp_source, self.gr_throttle) self.connect(self.gr_throttle, self.chandown) self.connect(self.chandown, self.demod) self.connect(self.demod, self.audio)
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, callsign='WJ2XMS', client_port='8000', gs_id='WFF', post_bytes=64, pre_bytes=64, sc_id='VCC-A', server_ip='0.0.0.0', ssid=0, verbose=0, wallops_dn_port='56101', wallops_up_port='56100'): gr.top_block.__init__(self, "Wff Nogui V4 Stream") ################################################## # Parameters ################################################## self.callsign = callsign self.client_port = client_port self.gs_id = gs_id self.post_bytes = post_bytes self.pre_bytes = pre_bytes self.sc_id = sc_id self.server_ip = server_ip self.ssid = ssid self.verbose = verbose self.wallops_dn_port = wallops_dn_port self.wallops_up_port = wallops_up_port ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S") self.fn_up = fn_up = "{:s}_{:s}_{:s}".format(gs_id, sc_id, ts_str) self.fn_dn = fn_dn = "{:s}_{:s}_{:s}".format(sc_id, gs_id, ts_str) self.fp_up = fp_up = "/gnuradio/captures/{:s}".format(fn_up) self.fp_dn = fp_dn = "/gnuradio/captures/{:s}".format(fn_dn) ################################################## # Blocks ################################################## self.vcc_insert_time_tag_bb_0 = vcc.insert_time_tag_bb( 'core:datetime', 'packet_len') self.vcc_insert_src_callsign_pdu_0 = vcc.insert_src_callsign_pdu( callsign=callsign, ssid=ssid, verbose=bool(verbose)) self.vcc_burst_scramble_bb_0 = vcc.burst_scramble_bb(0x21, 0x0, 16) self.sigmf_sink_1 = gr_sigmf.sink("ri8", fp_dn, gr_sigmf.sigmf_time_mode_absolute, False) self.sigmf_sink_1.set_global_meta("core:sample_rate", 0) self.sigmf_sink_1.set_global_meta( "core:description", 'Wallops Flight Facility Interface, Downlink') self.sigmf_sink_1.set_global_meta("core:author", 'Zach Leffke, [email protected]') self.sigmf_sink_1.set_global_meta("core:license", 'MIT') self.sigmf_sink_1.set_global_meta("core:hw", 'WFF UHF Ground Station') self.sigmf_sink_1.set_global_meta('vcc:spacecraft', 'VCC-A') self.sigmf_sink_1.set_global_meta('vcc:ground_station', 'WFF') self.sigmf_sink_1.set_global_meta('vcc:callsign', 'WJ2XMS-0') self.sigmf_sink_1.set_global_meta( 'vcc:tap_point', 'Packed Bytes, NRZ-I decoded, before descrambling') self.sigmf_sink_0 = gr_sigmf.sink("ri8", fp_up, gr_sigmf.sigmf_time_mode_absolute, False) self.sigmf_sink_0.set_global_meta("core:sample_rate", 0) self.sigmf_sink_0.set_global_meta( "core:description", 'Wallops Flight Facility Interface, Uplink') self.sigmf_sink_0.set_global_meta("core:author", 'Zach Leffke, [email protected]') self.sigmf_sink_0.set_global_meta("core:license", 'MIT') self.sigmf_sink_0.set_global_meta("core:hw", 'WFF UHF Ground Station') self.sigmf_sink_0.set_global_meta('vcc:spacecraft', 'VCC-A') self.sigmf_sink_0.set_global_meta('vcc:ground_station', 'WFF') self.sigmf_sink_0.set_global_meta('vcc:uplink_callsign', 'WJ2XMS-0') self.sigmf_sink_0.set_global_meta('vcc:tap_point', 'KISS input') self.pdu_utils_pack_unpack_0 = pdu_utils.pack_unpack( pdu_utils.MODE_PACK_BYTE, pdu_utils.BIT_ORDER_MSB_FIRST) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=pre_bytes, postamble_bytes=post_bytes) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.blocks_socket_pdu_1 = blocks.socket_pdu("TCP_SERVER", server_ip, wallops_up_port, 1500, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", server_ip, client_port, 1024, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char * 1, addr=server_ip, port=int(wallops_dn_port), server=True, ) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.vcc_burst_scramble_bb_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.vcc_insert_src_callsign_pdu_0, 'in')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.pdu_utils_pack_unpack_0, 'pdu_out'), (self.blocks_socket_pdu_1, 'pdus')) self.msg_connect((self.vcc_burst_scramble_bb_0, 'out'), (self.pdu_utils_pack_unpack_0, 'pdu_in')) self.msg_connect((self.vcc_insert_src_callsign_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.blks2_tcp_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.sigmf_sink_1, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.vcc_insert_time_tag_bb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.vcc_insert_time_tag_bb_0, 0), (self.kiss_kiss_to_pdu_0, 0)) self.connect((self.vcc_insert_time_tag_bb_0, 0), (self.sigmf_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Ud T") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.transistion = transistion = 100 self.sps = sps = 9 self.sideband_rx = sideband_rx = 1000 self.sideband = sideband = 1000 self.samp_rate = samp_rate = 48000 self.payload = payload = 5 self.interpolation = interpolation = 500 self.carrier = carrier = 23000 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_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=False, ) self.Add(self.wxgui_fftsink2_0_0.win) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=500, decimation=1, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.50,samp_rate,carrier-sideband,carrier+sideband,transistion)), -carrier, samp_rate) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr="127.0.0.1", port=10004, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=sps, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=False, ), payload_length=payload, ) self.audio_sink_0 = audio.sink(48000, "", True) ################################################## # Connections ################################################## self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: dvbt-blade.py port [output_file]\n"); sys.exit(1) channel_mhz = 6 mode = dvbt.T2k code_rate = dvbt.C1_2 constellation = dvbt.QPSK guard_interval = dvbt.G1_32 symbol_rate = channel_mhz * 8000000.0 / 7 center_freq = 441000000 tx_gain = 83 # max 89.5 if mode == dvbt.T2k: factor = 1 carriers = 2048 elif mode == dvbt.T8k: factor = 4 carriers = 8192 if guard_interval == dvbt.G1_32: gi = carriers / 32 elif guard_interval == dvbt.G1_16: gi = carriers / 16 elif guard_interval == dvbt.G1_8: gi = carriers / 8 elif guard_interval == dvbt.G1_4: gi = carriers / 4 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 tb = gr.top_block() out = uhd.usrp_sink( device_addr="recv_frame_size=65536,num_recv_frames=128,send_frame_size=65536,num_send_frames=128,master_clock_rate=" + str(symbol_rate*4), stream_args=uhd.stream_args( cpu_format="fc32", otw_format="sc16", channels=range(1), ), ) out.set_samp_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_gain(tx_gain, 0) #src = blocks.udp_source(gr.sizeof_char*1, "127.0.0.1", port, 18800, True) src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True) dvbt_energy_dispersal = dvbt.energy_dispersal(1 * factor) dvbt_reed_solomon_enc = dvbt.reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dvbt_convolutional_interleaver = dvbt.convolutional_interleaver((136 * factor), 12, 17) dvbt_inner_coder = dvbt.inner_coder(1, (1512 * factor), constellation, dvbt.NH, code_rate) dvbt_bit_inner_interleaver = dvbt.bit_inner_interleaver((1512 * factor), constellation, dvbt.NH, mode) dvbt_symbol_inner_interleaver = dvbt.symbol_inner_interleaver((1512 * factor), mode, 1) dvbt_dvbt_map = dvbt.dvbt_map((1512 * factor), constellation, dvbt.NH, mode, 1) dvbt_reference_signals = dvbt.reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dvbt.NH, code_rate, code_rate, dvbt.G1_32, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(gi), 0, "") blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087 * 2.5, )) tb.connect(src, dvbt_energy_dispersal) tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc) tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver) tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder) tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver) tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver) tb.connect(dvbt_symbol_inner_interleaver, dvbt_dvbt_map) tb.connect(dvbt_dvbt_map, dvbt_reference_signals) tb.connect(dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) tb.run()
def main(args): nargs = len(args) if nargs == 1: port = int(args[0]) outfile = None elif nargs == 2: port = int(args[0]) outfile = args[1] else: sys.stderr.write("Usage: dvbt-hackrf.py port [output_file]\n"); sys.exit(1) channel_mhz = 6 mode = dtv.T2k code_rate = dtv.C1_2 constellation = dtv.MOD_QPSK guard_interval = dtv.GI_1_32 symbol_rate = channel_mhz * 8000000.0 / 7 center_freq = 441000000 rf_gain = 14 if_gain = 40 if mode == dtv.T2k: factor = 1 carriers = 2048 elif mode == dtv.T8k: factor = 4 carriers = 8192 if guard_interval == dtv.GI_1_32: gi = carriers / 32 elif guard_interval == dtv.GI_1_16: gi = carriers / 16 elif guard_interval == dtv.GI_1_8: gi = carriers / 8 elif guard_interval == dtv.GI_1_4: gi = carriers / 4 if channel_mhz == 8: bandwidth = 8750000 elif channel_mhz == 7: bandwidth = 7000000 elif channel_mhz == 6: bandwidth = 6000000 elif channel_mhz == 5: bandwidth = 5000000 else: bandwidth = 8750000 tb = gr.top_block() src = grc_blks2.tcp_source(gr.sizeof_char*1, "127.0.0.1", port, True) dvbt_energy_dispersal = dtv.dvbt_energy_dispersal(1 * factor) dvbt_reed_solomon_enc = dtv.dvbt_reed_solomon_enc(2, 8, 0x11d, 255, 239, 8, 51, (8 * factor)) dvbt_convolutional_interleaver = dtv.dvbt_convolutional_interleaver((136 * factor), 12, 17) dvbt_inner_coder = dtv.dvbt_inner_coder(1, (1512 * factor), constellation, dtv.NH, code_rate) dvbt_bit_inner_interleaver = dtv.dvbt_bit_inner_interleaver((1512 * factor), constellation, dtv.NH, mode) dvbt_symbol_inner_interleaver = dtv.dvbt_symbol_inner_interleaver((1512 * factor), mode, 1) dvbt_map = dtv.dvbt_map((1512 * factor), constellation, dtv.NH, mode, 1) dvbt_reference_signals = dtv.dvbt_reference_signals(gr.sizeof_gr_complex, (1512 * factor), carriers, constellation, dtv.NH, code_rate, code_rate, dtv.GI_1_32, mode, 0, 0) fft_vxx = fft.fft_vcc(carriers, False, (window.rectangular(carriers)), True, 10) digital_ofdm_cyclic_prefixer = digital.ofdm_cyclic_prefixer(carriers, carriers+(gi), 0, "") blocks_multiply_const_vxx = blocks.multiply_const_vcc((0.0022097087 * 2.5, )) out = osmosdr.sink() out.set_sample_rate(symbol_rate) out.set_center_freq(center_freq, 0) out.set_freq_corr(0, 0) out.set_gain(rf_gain, 0) out.set_if_gain(if_gain, 0) out.set_bandwidth(bandwidth, 0) tb.connect(src, dvbt_energy_dispersal) tb.connect(dvbt_energy_dispersal, dvbt_reed_solomon_enc) tb.connect(dvbt_reed_solomon_enc, dvbt_convolutional_interleaver) tb.connect(dvbt_convolutional_interleaver, dvbt_inner_coder) tb.connect(dvbt_inner_coder, dvbt_bit_inner_interleaver) tb.connect(dvbt_bit_inner_interleaver, dvbt_symbol_inner_interleaver) tb.connect(dvbt_symbol_inner_interleaver, dvbt_map) tb.connect(dvbt_map, dvbt_reference_signals) tb.connect(dvbt_reference_signals, fft_vxx) tb.connect(fft_vxx, digital_ofdm_cyclic_prefixer) tb.connect(digital_ofdm_cyclic_prefixer, blocks_multiply_const_vxx) tb.connect(blocks_multiply_const_vxx, out) if outfile: dst = blocks.file_sink(gr.sizeof_gr_complex, outfile) tb.connect(blocks_multiply_const_vxx, dst) tb.run()
def __init__(self): gr.top_block.__init__ (self) parser=OptionParser(option_class=eng_option) parser.add_option("-H", "--hostname", type="string", default="localhost", help="set hostname of generic sdr") parser.add_option("-P", "--portnum", type="int", default=None, help="set portnum of generic sdr") parser.add_option("-W", "--wsportnum", type="int", default=None, help="set portnum of audio websocket server") parser.add_option("-r", "--sdr_rate", type="eng_float", default=250e3, help="set sample rate of generic sdr") parser.add_option("-V", "--volume", type="eng_float", default=None, help="set volume (default is midpoint)") parser.add_option("-O", "--audio-output", type="string", default="plughw:0,0", help="pcm device name (default is plughw:0,0)") # print help when called with wrong arguments (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() sys.exit(1) self.vol = options.volume if self.vol is None: self.vol = 0.1 # connect to generic SDR sdr_rate = options.sdr_rate audio_decim = 8 audio_rate = int(sdr_rate/audio_decim) print "audio_rate = ", audio_rate self.interleaved_short_to_complex = gr.interleaved_short_to_complex() self.char_to_short = gr.char_to_short(1) self.sdr_source = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr=options.hostname, port=options.portnum, server=False ) # self.sdr_source = gr.file_source(1, 'sdrs_baseband.dat') # self.throttle = gr.throttle(1, 500e3) # self.connect(self.sdr_source, self.file_sink) self.logger = gr.file_sink(1, 'log.out') self.connect(self.sdr_source, self.logger) # channel filter chan_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 80e3, # passband cutoff 35e3, # transition width gr.firdes.WIN_HAMMING) self.chan_filter = gr.fir_filter_ccf(1, chan_filter_coeffs) # print "# channel filter:", len(chan_filter_coeffs), "taps" # PLL-based WFM demod fm_alpha = 0.25 * 250e3 * math.pi / sdr_rate # 0.767 fm_beta = fm_alpha * fm_alpha / 4.0 # 0.147 fm_max_freq = 2.0 * math.pi * 90e3 / sdr_rate # 2.209 self.fm_demod = gr.pll_freqdet_cf( 1.0, # Loop BW fm_max_freq, # in radians/sample -fm_max_freq) self.fm_demod.set_alpha(fm_alpha) self.fm_demod.set_beta(fm_beta) self.connect(self.sdr_source, self.char_to_short) self.connect(self.char_to_short, self.interleaved_short_to_complex) self.connect(self.interleaved_short_to_complex, self.chan_filter, self.fm_demod) # L+R, pilot, L-R, RDS filters lpr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lpr_filter = gr.fir_filter_fff(audio_decim, lpr_filter_coeffs) pilot_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 19e3-500, # low cutoff 19e3+500, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.pilot_filter = gr.fir_filter_fff(1, pilot_filter_coeffs) dsbsc_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 38e3-15e3/2, # low cutoff 38e3+15e3/2, # high cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.dsbsc_filter = gr.fir_filter_fff(1, dsbsc_filter_coeffs) rds_filter_coeffs = gr.firdes.band_pass( 1.0, # gain sdr_rate, # sampling rate 57e3-3e3, # low cutoff 57e3+3e3, # high cutoff 3e3, # transition width gr.firdes.WIN_HAMMING) self.rds_filter = gr.fir_filter_fff(1, rds_filter_coeffs) # print "# lpr filter:", len(lpr_filter_coeffs), "taps" # print "# pilot filter:", len(pilot_filter_coeffs), "taps" # print "# dsbsc filter:", len(dsbsc_filter_coeffs), "taps" # print "# rds filter:", len(rds_filter_coeffs), "taps" self.connect(self.fm_demod, self.lpr_filter) self.connect(self.fm_demod, self.pilot_filter) self.connect(self.fm_demod, self.dsbsc_filter) self.connect(self.fm_demod, self.rds_filter) # down-convert L-R, RDS self.stereo_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.stereo_baseband, 0)) self.connect(self.pilot_filter, (self.stereo_baseband, 1)) self.connect(self.dsbsc_filter, (self.stereo_baseband, 2)) self.rds_baseband = gr.multiply_ff() self.connect(self.pilot_filter, (self.rds_baseband, 0)) self.connect(self.pilot_filter, (self.rds_baseband, 1)) self.connect(self.pilot_filter, (self.rds_baseband, 2)) self.connect(self.rds_filter, (self.rds_baseband, 3)) # low-pass and downsample L-R lmr_filter_coeffs = gr.firdes.low_pass( 1.0, # gain sdr_rate, # sampling rate 15e3, # passband cutoff 1e3, # transition width gr.firdes.WIN_HAMMING) self.lmr_filter = gr.fir_filter_fff(audio_decim, lmr_filter_coeffs) self.connect(self.stereo_baseband, self.lmr_filter) # create L, R from L-R, L+R self.left = gr.add_ff() self.right = gr.sub_ff() self.connect(self.lpr_filter, (self.left, 0)) self.connect(self.lmr_filter, (self.left, 1)) self.connect(self.lpr_filter, (self.right, 0)) self.connect(self.lmr_filter, (self.right, 1)) # volume control, complex2flot, audio sink self.volume_control_l = gr.multiply_const_ff(self.vol) self.volume_control_r = gr.multiply_const_ff(self.vol) output_audio_rate = 48000 self.resamp_L = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.resamp_R = blks2.rational_resampler_fff(interpolation=output_audio_rate,decimation=audio_rate,taps=None,fractional_bw=None,) self.connect(self.left, self.volume_control_l, self.resamp_L) self.connect(self.right, self.volume_control_r, self.resamp_R) # self.audio_sink = audio.sink(int(output_audio_rate), # options.audio_output, False) # self.connect(self.resamp_L, (self.audio_sink, 0)) # self.connect(self.resamp_R, (self.audio_sink, 1)) # self.file_sink1 = gr.file_sink(gr.sizeof_float, 'audioL.dat') # self.file_sink2 = gr.file_sink(gr.sizeof_float, 'audioR.dat') # self.file_sink3 = gr.file_sink(gr.sizeof_float, 'fmDemod.dat') # self.connect(self.resamp_L, self.file_sink1) # self.connect(self.resamp_R, self.file_sink2) # self.connect(self.fm_demod, self.file_sink3) # Interleave both channels so that we can push over one websocket connection self.audio_interleaver = gr.float_to_complex(1) self.connect(self.resamp_L, (self.audio_interleaver, 0)) self.connect(self.resamp_R, (self.audio_interleaver, 1)) self.ws_audio_server = sdrportal.ws_sink_c(True, options.wsportnum, "FLOAT") self.connect(self.audio_interleaver, self.ws_audio_server) # low-pass the baseband RDS signal at 1.5kHz rds_bb_filter_coeffs = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.5e3, # passband cutoff 2e3, # transition width gr.firdes.WIN_HAMMING) self.rds_bb_filter = gr.fir_filter_fff(audio_decim, rds_bb_filter_coeffs) # print "# rds bb filter:", len(rds_bb_filter_coeffs), "taps" self.connect(self.rds_baseband, self.rds_bb_filter) # 1187.5bps = 19kHz/16 self.clock_divider = rds.freq_divider(16) rds_clock_taps = gr.firdes.low_pass( 1, # gain sdr_rate, # sampling rate 1.2e3, # passband cutoff 1.5e3, # transition width gr.firdes.WIN_HAMMING) self.rds_clock = gr.fir_filter_fff(audio_decim, rds_clock_taps) # print "# rds clock filter:", len(rds_clock_taps), "taps" self.connect(self.pilot_filter, self.clock_divider, self.rds_clock) # bpsk_demod, diff_decoder, rds_decoder self.bpsk_demod = rds.bpsk_demod(audio_rate) self.differential_decoder = gr.diff_decoder_bb(2) self.msgq = gr.msg_queue() self.rds_decoder = rds.data_decoder(self.msgq) self.connect(self.rds_bb_filter, (self.bpsk_demod, 0)) self.connect(self.rds_clock, (self.bpsk_demod, 1)) self.connect(self.bpsk_demod, self.differential_decoder) self.connect(self.differential_decoder, self.rds_decoder)