def __init__(self): gr.hier_block2.__init__(self, "transmit_path", gr.io_signature(0,0,0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) ################################################## # Variables ################################################## self.msgq_limit = msgq_limit = 2 ################################################## # Blocks ################################################## self.pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit) # self.input_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.mod = digital.gfsk_mod( samples_per_symbol=4, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) ################################################## # Connections ################################################## self.connect(self.pkt_input, self.mod, self)
def __init__(self): gr.hier_block2.__init__(self, "transmitter_gfsk", gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.repack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.mod = digital.gfsk_mod(sps, sensitivity=0.1, bt=ebw) self.connect(self, self.repack, self.mod, self)
def __init__(self, ebn0, nbits): gr.hier_block2.__init__(self, 'FSK', gr.io_signature(1, 1, gr.sizeof_char), gr.io_signature(1, 1, gr.sizeof_char)) samp_rate = 48e3 sps = 5 deviation = 5000 bt = 1.0 self.head = blocks.head(gr.sizeof_char, nbits) self.pack = blocks.pack_k_bits_bb(8) self.modulator = digital.gfsk_mod( samples_per_symbol = sps, sensitivity = 2*np.pi*deviation/samp_rate, bt = bt, verbose = False, log = False) spb = sps self.channel = channels.channel_model(np.sqrt(spb)/10**(ebn0/20), 0, 1.0, [1], RAND_SEED, False) self.demod = fsk_demodulator(samp_rate/sps, samp_rate, deviation = deviation, iq = True) self.slice = digital.binary_slicer_fb() self.connect(self, self.head, self.pack, self.modulator, self.channel, self.demod, self.slice, self)
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 = 8 self.fm_sensitivity = fm_sensitivity = 1.0 self.center_freq = center_freq = 2400e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(sps*1000000) self.uhd_usrp_sink_0.set_center_freq(center_freq, 0) self.uhd_usrp_sink_0.set_gain(70, 0) self.uhd_usrp_sink_0.set_bandwidth(1e6, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=fm_sensitivity, bt=0.32, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "sync3", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
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, rf_params, bb_params): gr.hier_block2.__init__( self, "TX Mod Block", gr.io_signature(1, 1, gr.sizeof_char * 1), gr.io_signature(1, 1, gr.sizeof_gr_complex * 1)) ################################################## # Parameters ################################################## # ADD VALIDITY CHECKS TO EACH OF THESE self.samp_rate = rf_params.samp_rate self.fsk_dev = rf_params.fsk_dev self.symbol_time = bb_params.symbol_time ################################################## # Variables ################################################## self.sps = int(self.samp_rate * self.symbol_time) self.sensitivity = 2 * 3.1415 * self.fsk_dev / self.samp_rate ################################################## # Blocks ################################################## # just the modulator self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=self.sps, sensitivity=self.sensitivity, bt=0.35, verbose=False, log=False, ) self.connect((self, 0), (self.digital_gfsk_mod_0, 0)) # send to hier block output self.connect((self.digital_gfsk_mod_0, 0), (self, 0))
def __init__(self, options): gr.top_block.__init__(self) # Setup USRP self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len") if(options.spec): self.u.set_subdev_spec(options.spec, 0) if(options.antenna): self.u.set_antenna(options.antenna, 0) self.u.set_samp_rate(options.rate) # Gain is set in the hopper block if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2.0 print "-- Setting gain to {} dB".format(options.gain) r = self.u.set_center_freq(options.freq) if not r: print '[ERROR] Failed to set base frequency.' raise SystemExit, 1 hopper_block = FrequencyHopperSrc( options.num_bursts, options.num_channels, options.freq_delta, options.freq, options.samp_per_burst, 1.0, options.hop_time / 1000., options.post_tuning, options.gain, options.verbose, ) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## # self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(1, firdes.root_raised_cosine(1, samp_rate, 1, 0.35, 11*samp_rate)) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b((1,1,1,1), True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((.500, )) 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="11111111", pad_for_usrp=True, ), payload_length=0, ) self.connect(self.blocks_vector_source_x_0, self.blks2_packet_encoder_0, self.digital_gfsk_mod_0, self.blocks_multiply_const_vxx_0, hopper_block, self.u)
def gfsk(sps, sensitivity, excess_bw=0.35): return digital.gfsk_mod( samples_per_symbol=sps, sensitivity=sensitivity, bt=excess_bw, verbose=False, log=False, )
def raw_gfsk_mod(self, sps, sensi, bts, isVerbose, make_log): return digital.gfsk_mod( samples_per_symbol=self.sps, sensitivity=sensi, bt=bts, verbose=isVerbose, log=make_log, )
def __init__(self, buffer, baud_rate=38400, samp_rate_tx=4000000, sps=10): gr.top_block.__init__(self, "Top Block") ################################################## # Parameters ################################################## self.baud_rate = baud_rate self.samp_rate_tx = samp_rate_tx self.sps = sps ################################################## # Variables ################################################## self.samp_rate = samp_rate = 384000 self.freq = freq = 867300000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate_tx, decimation=samp_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + '') self.osmosdr_sink_0.set_sample_rate(samp_rate_tx) self.osmosdr_sink_0.set_center_freq(freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(30, 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.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=1, bt=1, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b( buffer, True, 1, []) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (800000000, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_vector_source_x_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.blocks_multiply_const_vxx_0, 0))
def __init__(self, args): gr.top_block.__init__(self, "Nordic Auto-ACK Example") # SDR configuration self.freq = 2400e6 + args.channel * 1e6 self.gain = args.gain self.symbol_rate = args.data_rate self.sample_rate = args.data_rate * args.samples_per_symbol # SDR source (gr-osmosdr source) self.osmosdr_source = osmosdr.source() self.osmosdr_source.set_sample_rate(self.sample_rate) self.osmosdr_source.set_center_freq(self.freq) self.osmosdr_source.set_gain(self.gain) self.osmosdr_source.set_antenna('TX/RX') # SDR sink (gr-osmosdr source) self.osmosdr_sink = osmosdr.sink() self.osmosdr_sink.set_sample_rate(self.sample_rate) self.osmosdr_sink.set_center_freq(self.freq) self.osmosdr_sink.set_gain(self.gain) self.osmosdr_sink.set_antenna('TX/RX') # Transmit chain self.tx = nordic.nordic_tx() self.gfsk_mod = digital.gfsk_mod( samples_per_symbol=args.samples_per_symbol) self.connect(self.tx, self.gfsk_mod) self.connect(self.gfsk_mod, self.osmosdr_sink) # Receive chain dr = 0 if args.data_rate == 1e6: dr = 1 elif args.data_rate == 2e6: dr = 2 self.rx = nordic.nordic_rx(args.channel, args.address_length, args.crc_length, dr) self.gfsk_demod = digital.gfsk_demod( samples_per_symbol=args.samples_per_symbol) self.lpf = filter.fir_filter_ccf( 1, firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 50e3, 50)) self.connect(self.osmosdr_source, self.lpf) self.connect(self.lpf, self.gfsk_demod) self.connect(self.gfsk_demod, self.rx) # Handle incoming packets self.nordictap_ack_handler = nordictap_ack_handler() self.msg_connect(self.rx, "nordictap_out", self.nordictap_ack_handler, "nordictap_in") # Reply with ACKs self.msg_connect(self.nordictap_ack_handler, "nordictap_out", self.tx, "nordictap_in")
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 = 32e3 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(32e3) self.uhd_usrp_sink_0.set_center_freq(2.417e9, 0) self.uhd_usrp_sink_0.set_gain(20, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(3e6, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_crc32_bb_0 = digital.crc32_bb(False, "packet_len") self.blocks_vector_source_x_0 = blocks.vector_source_b((1,0,1,0), True, 1, []) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 8, "packet_len") 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=True, ), payload_length=0, ) self.Spread_ds_spreader_0 = Spread.ds_spreader(2, (1, 1, 0, 1), (1, 1, 1)) ################################################## # Connections ################################################## self.connect((self.Spread_ds_spreader_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_crc32_bb_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_crc32_bb_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Virtualtransmissiontest") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=2, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 4, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 4, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/thomas/Documents/esft/packet', False) self.blocks_file_sink_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/thomas/Documents/esft/transmittedpacket', False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): gr.top_block.__init__(self, 'Top Block') # sample frequency = 44100 Hz # 44100 discrete samples per second to reconstruct the signal when playing it back self.samp_rate = samp_rate = 44100 # data to hide centered at (44100 / 2 - 1000) = 21050 Hz # human ear can't catch sounds below 20 Hz or above 20 kHz (however regular audio players won't reproduce sounds at 21050 Hz) self.freq_xlating_fir_filter_xxx_0 = gnufilter.freq_xlating_fir_filter_ccc(1, (1, ), samp_rate / 2 - 1000, samp_rate) # one encoded bit each (44100 / 100) samples of audio self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol = samp_rate / 100, sensitivity = 0.01, bt = 0.35, verbose = False, log = False, ) # block that defines the source audio file self.blocks_wavfile_source_0 = blocks.wavfile_source(tmp_audio_extracted, False) # block that defines the destination audio file self.blocks_wavfile_sink_0 = blocks.wavfile_sink(tmp_audio_modified, 1, samp_rate, 16) # block that defines the source data file to hide self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, tmp_data_formatted, True) # block that defines sample rate when processing the audio self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float * 1, samp_rate, True) # block that reduces the amplitude of both waves to half, avoiding any possible distorsion coming from wave overlapping self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((.5, )) # block that transforms the complex gmsk signal to a real one so that it can be embedded into a wav file self.blocks_complex_to_real_0 = blocks.complex_to_real(1) # block that adds the original audio wave and the forged one self.blocks_add_xx_0 = blocks.add_vff(1) # connections between blocks self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0))
def __init__(self): gr.top_block.__init__(self, "Gfsk") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.ch = ch = 25 self.rf_gain = rf_gain = 0 self.if_gain = if_gain = 20 self.fsk_deviation_hz = fsk_deviation_hz = 170000 self.fc = fc = 2400000000 + ch * 1000000 self.bw = bw = samp_rate self.bitrate = bitrate = 250000 self.bb_gain = bb_gain = 30 ################################################## # Blocks ################################################## 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(fc, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(rf_gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 0) self.osmosdr_sink_0.set_bb_gain(bb_gain, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(samp_rate, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_rate / bitrate, sensitivity=0.5, bt=0.5, verbose=False, log=False, ) self.blocks_vector_source_x_1 = blocks.vector_source_b([ 0x00, 0xaa, 0xa2, 0x00, 0x09, 0x89, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x95, 0x7f, 0x1e ] + [0x00] * 100, True, 1, []) (self.blocks_vector_source_x_1).set_min_output_buffer(0) (self.blocks_vector_source_x_1).set_max_output_buffer(0) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.osmosdr_sink_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 = 1e6 ################################################## # Blocks ################################################## 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(145.6e6, 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.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=4, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/david/Projects/telemetrum_sim/teledata.dat", 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=32, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Gfsk") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.ch = ch = 25 self.rf_gain = rf_gain = 0 self.if_gain = if_gain = 20 self.fsk_deviation_hz = fsk_deviation_hz = 170000 self.fc = fc = 2400000000+ch*1000000 self.bw = bw = samp_rate self.bitrate = bitrate = 250000 self.bb_gain = bb_gain = 30 ################################################## # Blocks ################################################## 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(fc, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(rf_gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 0) self.osmosdr_sink_0.set_bb_gain(bb_gain, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(samp_rate, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_rate/bitrate, sensitivity=0.5, bt=0.5, verbose=False, log=False, ) self.blocks_vector_source_x_1 = blocks.vector_source_b([0x00, 0xaa, 0xa2, 0x00, 0x09, 0x89, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x95, 0x7f, 0x1e]+ [0x00]*100, True, 1, []) (self.blocks_vector_source_x_1).set_min_output_buffer(0) (self.blocks_vector_source_x_1).set_max_output_buffer(0) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Bt Tx 1") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.sps = sps = 4 self.samp_rate_0 = samp_rate_0 = 1e6 self.mod_index = mod_index = 0.32 self.freq = freq = 2404e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(sps) self.uhd_usrp_sink_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0.set_gain(50, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=1, bt=0.32, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "sync2", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "plutotransmitter") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.freq = freq = 2400000000 ################################################## # Blocks ################################################## self.pluto_sink_0 = iio.pluto_sink('', 2400000000, freq, 500000, 0x8000, False, 10.0, '', True) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=.75, verbose=False, log=False, ) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/esft/datafiles/packet', True) 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=0, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.pluto_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "ax25_tx_test") ################################################## # Variables ################################################## self.tx_samp_rate = tx_samp_rate = 233645 self.baud = baud = 9600 self.tx_samp_per_sym = tx_samp_per_sym = tx_samp_rate/baud self.tx_freq = tx_freq = 450e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(tx_samp_rate) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(10, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=tx_samp_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, )) self.Interfaces_ax25_queue_source_b_0 = Interfaces.ax25_queue_source_b('U', True) ################################################## # Connections ################################################## self.connect((self.Interfaces_ax25_queue_source_b_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "AX.25 Sink Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 256000 self.baud = baud = 9600 self.samp_per_sym = samp_per_sym = samp_rate/baud ################################################## # Blocks ################################################## self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=samp_per_sym, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, "/home/ground/jaidenfe/gr-Interfaces/examples/.ax25_sink_test.dat", True) self.Interfaces_ax25_sink_b_0 = Interfaces.ax25_sink_b("WJ9XLE", "WJ9XLE") ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.Interfaces_ax25_sink_b_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.digital_gfsk_demod_0, 0))
def __init__(self): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10000000 self.bitrate = bitrate = 9910.0 ################################################## # Blocks ################################################## 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(314.98e6, 0) self.osmosdr_sink_0.set_freq_corr(4, 0) self.osmosdr_sink_0.set_gain(14, 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(10, (firdes.low_pass(1, samp_rate, 180000, 20000, firdes.WIN_HAMMING, 6.76)), 0, samp_rate) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_rate / bitrate / 8, sensitivity=0.050, bt=0.9, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b([0], False, 1, []) # self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, 'testgen_314.97m_0.400m_20161115_133333z_hackrf.cfile', False) # self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_0, 0), (self.digital_gfsk_mod_0, 0)) # self.connect((self.digital_gfsk_mod_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.osmosdr_sink_0, 0))
def __init__(self, args): gr.top_block.__init__(self, "Nordic Single-Channel Receiver Example") self.freq = 2414e6 self.gain = args.gain self.symbol_rate = 2e6 self.sample_rate = 4e6 # Channel map channel_count = 3 channel_map = [14, 18, 10] # Data rate index dr = 2 # 2M # SDR sink (gr-osmosdr sink) self.osmosdr_sink = osmosdr.sink() self.osmosdr_sink.set_sample_rate(self.sample_rate * channel_count) self.osmosdr_sink.set_center_freq(self.freq) self.osmosdr_sink.set_gain(self.gain) self.osmosdr_sink.set_antenna('TX/RX') # PFB channelizer taps = firdes.low_pass_2(1, self.sample_rate, self.symbol_rate / 2, 100e3, 30) self.synthesizer = filter.pfb_synthesizer_ccf(channel_count, taps) # Modulators and packet framers self.nordictap_transmitter = nordictap_transmitter(channel_map) self.mods = [] self.tx = nordic.nordic_tx(channel_count) for x in range(channel_count): self.mods.append(digital.gfsk_mod()) self.connect((self.tx, x), self.mods[x]) self.connect(self.mods[x], (self.synthesizer, x)) self.connect(self.synthesizer, self.osmosdr_sink) # Wire up output packet connection self.msg_connect(self.nordictap_transmitter, "nordictap_out", self.tx, "nordictap_in")
def __init__(self): gr.top_block.__init__(self, "Queue Length Deframer Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 256000 self.baud = baud = 9600 self.samp_per_sym = samp_per_sym = samp_rate / baud ################################################## # Blocks ################################################## self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=samp_per_sym, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) # self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/ubnl-sof/COM/SDR_PHY_COM/tests/.sink_test.dat", True) path = str(os.path.dirname(os.path.realpath(__file__))) + "/.sink_test.dat" self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, path, True) self.Interfaces_queue_len_deframer_sink_b_0 = Interfaces.queue_len_deframer_sink_b("\x33", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.Interfaces_queue_len_deframer_sink_b_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.digital_gfsk_demod_0, 0))
def __init__(self): gr.hier_block2.__init__(self, "transmit_path", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_gr_complex)) # VerA # Create Input Vector here # barker13_uni = [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0] # barker13_wpadding_uni = [0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0] # # sync_pattern = barker13_uni # sync_pattern = barker13_wpadding_uni # s = "Hello World\n" # msg = string_to_list.conv_string_to_1_0_list(s) # input_vector = sync_pattern + msg # self.input_vector_source = blocks.vector_source_b(input_vector, True, 1, []) # self.input_unpacked_to_packed = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) # VerB self.msgq_limit = msgq_limit = 2 self.pkt_input = blocks.message_source(gr.sizeof_char, msgq_limit) self.mod = digital.gfsk_mod( samples_per_symbol=4, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) ################################################## # Connections ################################################## # VerA # self.connect(self.input_vector_source, self.input_unpacked_to_packed, self.mod, self) # VerB self.connect(self.pkt_input, self.mod, self)
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Gfsk") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1000000 self.ch = ch = 25 self.rf_gain = rf_gain = 0 self.if_gain = if_gain = 20 self.fsk_deviation_hz = fsk_deviation_hz = 170000 self.fc = fc = 2400000000+ch*1000000 self.bw = bw = samp_rate self.bitrate = bitrate = 250000 self.bb_gain = bb_gain = 30 ################################################## # Blocks ################################################## _rf_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._rf_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, label='rf_gain', converter=forms.int_converter(), proportion=0, ) self._rf_gain_slider = forms.slider( parent=self.GetWin(), sizer=_rf_gain_sizer, value=self.rf_gain, callback=self.set_rf_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_rf_gain_sizer) _if_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._if_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, label='if_gain', converter=forms.int_converter(), proportion=0, ) self._if_gain_slider = forms.slider( parent=self.GetWin(), sizer=_if_gain_sizer, value=self.if_gain, callback=self.set_if_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_if_gain_sizer) _bb_gain_sizer = wx.BoxSizer(wx.VERTICAL) self._bb_gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, label='bb_gain', converter=forms.int_converter(), proportion=0, ) self._bb_gain_slider = forms.slider( parent=self.GetWin(), sizer=_bb_gain_sizer, value=self.bb_gain, callback=self.set_bb_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_bb_gain_sizer) self.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(fc, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(rf_gain, 0) self.osmosdr_sink_0.set_if_gain(if_gain, 0) self.osmosdr_sink_0.set_bb_gain(bb_gain, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(samp_rate, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_rate/bitrate, sensitivity=0.5, bt=0.5, verbose=False, log=False, ) _ch_sizer = wx.BoxSizer(wx.VERTICAL) self._ch_text_box = forms.text_box( parent=self.GetWin(), sizer=_ch_sizer, value=self.ch, callback=self.set_ch, label='ch', converter=forms.int_converter(), proportion=0, ) self._ch_slider = forms.slider( parent=self.GetWin(), sizer=_ch_sizer, value=self.ch, callback=self.set_ch, minimum=0, maximum=128, num_steps=128, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_ch_sizer) self.blocks_vector_source_x_1 = blocks.vector_source_b([0x00, 0xaa, 0xa2, 0x00, 0x09, 0x89, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x95, 0x7f, 0x1e], True, 1, []) (self.blocks_vector_source_x_1).set_min_output_buffer(20) (self.blocks_vector_source_x_1).set_max_output_buffer(20) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.osmosdr_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 __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Gfsk Hackrf Tx") _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 = 2e6 self.IFgain = IFgain = 30 self.CenterFreq = CenterFreq = 2.4e9 self.BBgain = BBgain = 30 ################################################## # Blocks ################################################## _IFgain_sizer = wx.BoxSizer(wx.VERTICAL) self._IFgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_IFgain_sizer, value=self.IFgain, callback=self.set_IFgain, label='IFgain', converter=forms.float_converter(), proportion=0, ) self._IFgain_slider = forms.slider( parent=self.GetWin(), sizer=_IFgain_sizer, value=self.IFgain, callback=self.set_IFgain, minimum=1, maximum=40, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_IFgain_sizer) _CenterFreq_sizer = wx.BoxSizer(wx.VERTICAL) self._CenterFreq_text_box = forms.text_box( parent=self.GetWin(), sizer=_CenterFreq_sizer, value=self.CenterFreq, callback=self.set_CenterFreq, label='CenterFreq', converter=forms.float_converter(), proportion=0, ) self._CenterFreq_slider = forms.slider( parent=self.GetWin(), sizer=_CenterFreq_sizer, value=self.CenterFreq, callback=self.set_CenterFreq, minimum=2.35e9, maximum=2.6e9, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_CenterFreq_sizer) _BBgain_sizer = wx.BoxSizer(wx.VERTICAL) self._BBgain_text_box = forms.text_box( parent=self.GetWin(), sizer=_BBgain_sizer, value=self.BBgain, callback=self.set_BBgain, label='BBgain', converter=forms.float_converter(), proportion=0, ) self._BBgain_slider = forms.slider( parent=self.GetWin(), sizer=_BBgain_sizer, value=self.BBgain, callback=self.set_BBgain, minimum=1, maximum=40, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_BBgain_sizer) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( 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.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + 'hackrf') self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(CenterFreq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(0, 0) self.osmosdr_sink_0.set_if_gain(IFgain, 0) self.osmosdr_sink_0.set_bb_gain(BBgain, 0) self.osmosdr_sink_0.set_antenna('', 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, )) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/xxno/code/hackrf_GFSK_Transmit_Text/xx.txt', True) 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=200, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_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.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): grc_wxgui.top_block_gui.__init__(self, title="FHSS transmit") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.samp_sym = samp_sym = 64 self.tx_freq = tx_freq = 2.414e9 self.samp_rate = samp_rate = 400e3 self.registers = registers = 3 self.init = init = 1, 1, 1, 1 self.generator = generator = 1, 1, 0, 0, 1 self.code_rate = code_rate = int(samp_sym * 500) ################################################## # Blocks ################################################## self._tx_freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.tx_freq, callback=self.set_tx_freq, label="tx_freq", choices=[2414000000, 2432000000, 2450000000, 2468000000], labels=[1,2,3,4], ) self.Add(self._tx_freq_chooser) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), 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(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(20, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(1.125e6, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=64, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b((0, 1, 0, 1), True, 1, []) 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=True, ), payload_length=0, ) self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 9000, samp_rate, (generator), (init)) ################################################## # Connections ################################################## self.connect((self.Spread_synthesizer_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.Spread_synthesizer_0, 0))
def create_blocks(self, modulation, sym, sn, train): self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=1, taps=None, fractional_bw=None, ) if modulation == "2psk": self.digital_mod = digital.psk.psk_mod( constellation_points=2, mod_code="gray", differential=True, samples_per_symbol=sym, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "4psk": self.digital_mod = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=sym, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "8psk": self.digital_mod = digital.psk.psk_mod( constellation_points=8, mod_code="gray", differential=True, samples_per_symbol=sym, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "fsk": self.digital_mod = digital.gfsk_mod( samples_per_symbol=sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) elif modulation == "qam16": self.digital_mod = digital.qam.qam_mod( constellation_points=16, mod_code="gray", differential=True, samples_per_symbol=sym, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "qam64": self.digital_mod = digital.qam.qam_mod( constellation_points=64, mod_code="gray", differential=True, samples_per_symbol=sym, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "gmsk": self.digital_mod = digital.gmsk_mod( samples_per_symbol=sym, bt=0.35, verbose=False, log=False, ) if train: self.blocks_wavfile_source_0 = blocks.wavfile_source( "music.wav", False) else: self.blocks_wavfile_source_0 = blocks.wavfile_source( "music2.wav", False) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=44100, quad_rate=44100 * 5, tau=75e-6, max_dev=75e3, fh=-1.0, ) self.analog_nfm_tx_0 = analog.nbfm_tx( audio_rate=44100, quad_rate=44100 * 2, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=SNRV[sn][1], frequency_offset=100.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=np.random.randint(np.iinfo(np.int32).max), block_tags=False)
def __init__(self, fsk_dev=10000, lpf_cutoff=10e3, lpf_trans=1e3): gr.top_block.__init__(self, "Afsk Test") Qt.QWidget.__init__(self) self.setWindowTitle("Afsk Test") 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", "afsk_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fsk_dev = fsk_dev self.lpf_cutoff = lpf_cutoff self.lpf_trans = lpf_trans ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.baud = baud = 1200 self.samps_per_symb = samps_per_symb = int(samp_rate/baud) self.noise_amp = noise_amp = 0.3 self.mult = mult = (samp_rate)/2/3.141593 self.decim = decim = 2 self.bb_gain = bb_gain = .75 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._noise_amp_range = Range(0, 1, 0.005, 0.3, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_win, 6,0,1,4) self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 5,0,1,4) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(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 "float" == "float" or "float" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #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) self.qtgui_time_sink_x_1.enable_stem_plot(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(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2048, #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(True) self.qtgui_time_sink_x_0.enable_grid(True) 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4,4,3,4) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim, #bw "RX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-80, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_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_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,4,4,4) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,4,4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0; self.top_layout.addWidget(self._pyqt_text_output_0_win) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0; self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 4,0,1,4) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_nrzi_encode_0 = kiss.nrzi_encode() self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samps_per_symb, sensitivity=0.06, bt=1, verbose=False, log=False, ) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0)/decim, 0.25*0.175*0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("packet_len") self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", '0.0.0.0', '52002', 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, )) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1700, 1, 0) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_dev/8.0)) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=samp_rate, quad_rate=samp_rate, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0_2, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.kiss_nrzi_encode_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bench Com Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 195312 self.baud = baud = 9600 self.tx_freq = tx_freq = 430e6 self.samp_per_sym = samp_per_sym = samp_rate/baud self.rx_freq = rx_freq = 430e6 self.gain = gain = 0 self.bandwidth = bandwidth = 10 self.tx_addr = "192.168.10.3" self.rx_addr = "192.168.10.2" ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.3", "addr=192.168.10.2")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(rx_freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("RX2", 0) self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "addr=192.168.10.3")), 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(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(bandwidth, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=samp_per_sym, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.8, )) self.Interfaces_length_framing_source_b_0 = Interfaces.length_framing_source_b("GP", True) self.Interfaces_length_framing_sink_b_0 = Interfaces.length_framing_sink_b("GP", True) ################################################## # Connections ################################################## self.connect((self.Interfaces_length_framing_source_b_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.Interfaces_length_framing_sink_b_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_gfsk_demod_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5e6 self.c_freq = c_freq = 2.426e9 ################################################## # Blocks ################################################## self.uhd_usrp_sink_1 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(c_freq, 0) self.uhd_usrp_sink_1.set_gain(25, 0) self.uhd_usrp_sink_1.set_bandwidth(36e6, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=5, sensitivity=1.0, bt=0.5, verbose=False, log=False, ) #advertisement = 'AA8E89BED643C80844210712140201050909456E73777F7274689BC70A' advertisement = '556B7D9171F283FAA738052E25EE0C2882F96C2951A431D10F7D5F2EC2' advertisement = list(bin(int(advertisement, base=16)).lstrip('0b')) #advertisement = np.asarray(advertisement, dtype=np.uint8) advertisement = string_to_list.conv_string_to_1_0_list(advertisement) advertisement = [0] + advertisement self.blocks_vector_source_x_0 = blocks.vector_source_b( ([1, 1, 1, 1, 1, 1]), True, 1, []) ################################################## # Connections ################################################## self.connect((self.blocks_vector_source_x_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 #self.ac1=ac1 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 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_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(1e6) self.osmosdr_sink_0.set_center_freq(100e6, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(20, 0) self.osmosdr_sink_0.set_if_gain(30, 0) self.osmosdr_sink_0.set_bb_gain(30, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(400000, 0) self.file_source = blocks.file_source( gr.sizeof_float * 1, '/home/firas/Downloads/10.1.1.623.6305.pdf', True) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=2, bt=0.35, verbose=False, log=False, ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) if choice == 1: self.num = 0 self.g = 3 self.p = 5 self.y = 6 if choice == 2: self.num = 0 self.g = 5 self.p = 7 self.y = 9 num = pow(self.g, self.y) % self.p print(num) self.blocks_vector_source_x_0 = blocks.vector_source_f((num, num, num), True, 1, []) self.blocks_vector_source_x_1 = blocks.vector_source_f((1, 2, 3), True, 1, []) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_f( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble="", access_code="100010001000100010001111", pad_for_usrp=True, ), payload_length=1024, ) self.blks2_packet_encoder_1 = grc_blks2.packet_mod_f( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble="", access_code="100010001000100010001000", pad_for_usrp=True, ), payload_length=512, ) self.blks2_packet_encoder_2 = grc_blks2.packet_mod_f( grc_blks2.packet_encoder( samples_per_symbol=2, bits_per_symbol=1, preamble="", access_code="100010001000100010101010", pad_for_usrp=True, ), payload_length=256, ) self.probe_sig_0 = blocks.probe_signal_f() ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.probe_sig_0, 0))
def __init__(self,modulation,snr): self.samp_rate = samp_rate = 32000 gr.top_block.__init__(self) #self.inspector_scf_0 = inspector.scf() if modulation == "2psk": self.digital_mod = digital.psk.psk_mod( constellation_points=2, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) bits = 1 elif modulation == "4psk": self.digital_mod = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) bits = 2 elif modulation == "8psk": self.digital_mod = digital.psk.psk_mod( constellation_points=8, mod_code="gray", differential=True, samples_per_symbol=2, excess_bw=0.35, verbose=False, log=False, ) bits = 3 elif modulation == "fsk": self.digital_mod = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) bits = 1 self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc((snrv[snr][0], )) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, snrv[snr][1], 0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 2*400000)), False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "data/train-rnd3/%s-snr%d.dat" % (modulation,snr), False) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_mod, 0)) #self.connect((self.digital_mod, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_mod, 0), (self.blocks_multiply_const_vxx_3, 0)) # self.connect((self.blocks_throttle_0, 0),(self.blocks_multiply_const_vxx_3, 0)) self.connect((self.blocks_add_xx_1, 0),(self.blocks_file_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Communications Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 195312 self.baud = baud = 9600 self.samp_per_sym = samp_per_sym = samp_rate/baud ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("address0=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(460e6, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("address0=192.168.10.3", "")), 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(460e6, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samp_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=samp_per_sym, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.7, )) self.Interfaces_queue_len_framer_source_b_0 = Interfaces.queue_len_framer_source_b('\x7e', True) self.Interfaces_queue_len_deframer_sink_b_0 = Interfaces.queue_len_deframer_sink_b('\x7e', True) ################################################## # Connections ################################################## self.connect((self.Interfaces_queue_len_framer_source_b_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.Interfaces_queue_len_deframer_sink_b_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.digital_gfsk_demod_0, 0))
def __init__(self, center_freq=440000000, filename="_send.bin"): gr.top_block.__init__(self, "Tx 2400 R2") ################################################## # Parameters ################################################## self.center_freq = center_freq self.filename = filename ################################################## # Variables ################################################## self.sps = sps = 10 self.prefix = prefix = '/usr/share/adafruit/webide/repositories/bladerf/BladeRX/' self.baud_rate = baud_rate = 2490 self.txvga2 = txvga2 = 25 self.txvga1 = txvga1 = -4 self.samp_rate_tx = samp_rate_tx = 400000 self.samp_rate = samp_rate = int(baud_rate * sps) self.freq = freq = center_freq self.filepath = filepath = prefix + filename ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=samp_rate_tx, decimation=samp_rate, taps=None, fractional_bw=None, ) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "bladerf=0") self.osmosdr_sink_0.set_sample_rate(samp_rate_tx) self.osmosdr_sink_0.set_center_freq(freq, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(txvga2, 0) self.osmosdr_sink_0.set_if_gain(0, 0) self.osmosdr_sink_0.set_bb_gain(txvga1, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(1500000, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=sps, sensitivity=1.0, bt=1, verbose=False, log=False, ) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, filepath, True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_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.osmosdr_sink_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") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.down_samprate = down_samprate = 120e3 self.down_bw = down_bw = 20e3 self.up_symbolrate = up_symbolrate = 10e3 self.lpf_taps = lpf_taps = firdes.low_pass(1.0, down_samprate, down_bw / 2, down_bw / 8, firdes.WIN_HAMMING, 6.76) self.vfo = vfo = 30e3 self.up_samprate = up_samprate = down_samprate self.up_mod_index = up_mod_index = 2 self.up_gain = up_gain = 60 self.up_freq = up_freq = 436.5e6 self.up_bw = up_bw = up_symbolrate * 4 self.sc_id = sc_id = 1 self.lpf_ntaps = lpf_ntaps = len(lpf_taps) self.fcorr = fcorr = 0 self.down_symbolrate = down_symbolrate = 20e3 self.down_gain = down_gain = 23 self.down_freq = down_freq = 436.5e6 self.down_decim = down_decim = 3 ################################################## # Blocks ################################################## self._fcorr_range = Range(-15e3, 15e3, 100, 0, 200) self._fcorr_win = RangeWidget(self._fcorr_range, self.set_fcorr, "fcorr", "counter_slider", float) self.top_layout.addWidget(self._fcorr_win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(down_samprate) self.uhd_usrp_source_0.set_center_freq(down_freq - vfo, 0) self.uhd_usrp_source_0.set_gain(down_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(down_samprate / 2, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(up_samprate) self.uhd_usrp_sink_0.set_center_freq(up_freq + fcorr, 0) self.uhd_usrp_sink_0.set_gain(up_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(up_samprate / 2, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype down_freq - vfo, #fc down_samprate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.1) 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, -60) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size down_samprate / 1024, #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) 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_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc down_samprate / down_decim, #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, -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(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [0.3, 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.kcsa_vitfilt27_bb_0_0 = kcsa.vitfilt27_bb() self.kcsa_vitfilt27_bb_0 = kcsa.vitfilt27_bb() self.kcsa_kiss_server_0 = kcsa.kiss_server('127.0.0.1', 2610, 1024, 25, 10) self.kcsa_halfduplex_tc_0 = kcsa.halfduplex_tc(1, 0, True, 128, 4) self.kcsa_fec_decode_b_0_0_0 = kcsa.fec_decode_b( 223, False, False, True, False) self.kcsa_fec_decode_b_0_0 = kcsa.fec_decode_b(223, False, False, True, False) self.gpredict_doppler_0 = gpredict.doppler(self.set_fcorr, "localhost", 4532, True) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( down_decim, (lpf_taps), vfo + fcorr, down_samprate) self.fir_filter_xxx_0 = filter.fir_filter_fff(1024, (np.ones(1024) / 1024)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=int(down_samprate / down_decim / down_symbolrate), gain_mu=0.175, mu=0.5, omega_relative_limit=0.02, freq_error=0.01, verbose=False, log=False, ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=int(up_samprate / up_symbolrate), sensitivity=math.pi * up_mod_index / int(up_samprate / up_symbolrate), bt=0.5, verbose=False, log=False, ) self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_gr_complex * 1, '', "") self.blocks_tag_debug_0.set_display(True) self.blocks_rms_xx_0 = blocks.rms_cf(0.0001) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_delay_0 = blocks.delay(gr.sizeof_char * 1, 1) ################################################## # Connections ################################################## self.msg_connect((self.kcsa_fec_decode_b_0_0, 'out'), (self.kcsa_kiss_server_0, 'in')) self.msg_connect((self.kcsa_fec_decode_b_0_0_0, 'out'), (self.kcsa_kiss_server_0, 'in')) self.msg_connect((self.kcsa_kiss_server_0, 'out'), (self.kcsa_halfduplex_tc_0, 'pdu')) self.connect((self.blocks_delay_0, 0), (self.kcsa_vitfilt27_bb_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.kcsa_vitfilt27_bb_0_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.kcsa_halfduplex_tc_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.kcsa_vitfilt27_bb_0, 0), (self.kcsa_fec_decode_b_0_0, 0)) self.connect((self.kcsa_vitfilt27_bb_0_0, 0), (self.kcsa_fec_decode_b_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self,modulation,snr): self.samp_rate = samp_rate = 32000 gr.top_block.__init__(self) if modulation == "2psk": self.digital_mod = digital.psk.psk_mod( constellation_points=2, mod_code="gray", differential=True, samples_per_symbol=5, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "4psk": self.digital_mod = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=5, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "8psk": self.digital_mod = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=5, excess_bw=0.35, verbose=False, log=False, ) elif modulation == "fsk": self.digital_mod = digital.gfsk_mod( samples_per_symbol=5, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) elif modulation == "qam16": self.digital_mod = digital.qam.qam_mod( constellation_points=16, mod_code="gray", differential=True, samples_per_symbol=5, excess_bw=0.35, verbose=False, log=False, ) self.sink = blocks.vector_sink_f(2*Np) self.sink = blocks.null_sink(gr.sizeof_float * 2 * Np) self.blocks_add_xx_1 = blocks.add_vcc(1) self.specest_cyclo_fam_1 = specest.cyclo_fam(Np, P, L) self.blocks_multiply_const_vxx_3 = blocks.multiply_const_vcc((snrv[snr][0], )) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 1024) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, snrv[snr][1], 0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 2000000)), False) self.msgq_out = blocks_message_sink_0_msgq_out = gr.msg_queue(1) self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_float*2*Np, blocks_message_sink_0_msgq_out, False) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.blocks_multiply_const_vxx_3, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_mod, 0)) self.connect((self.digital_mod, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0),(self.blocks_multiply_const_vxx_3, 0)) self.connect((self.blocks_add_xx_1, 0),(self.specest_cyclo_fam_1, 0)) self.connect((self.specest_cyclo_fam_1,0),(self.sink,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.tx_freq = tx_freq = 2.407e9 self.samp_rate = samp_rate = 32e3 ################################################## # Blocks ################################################## self._tx_freq_chooser = forms.drop_down( parent=self.GetWin(), value=self.tx_freq, callback=self.set_tx_freq, label="tx_freq", choices=[2.407e9, 2.41e9, 2.413e9, 2.416e9, 2.419e9, 2.422e9, 2.425e9, 2.427e9, 2.429e9, 2.431e9, 2.433e9, 2.436e9, 2.439e9, 2.441e9, 2.443e9,2.422e9, 2.446e9, 2.449e9, 2.452e9, 2.455e9, 2.458e9, 2.460e9, 2.463e9, 2.466e9, 2.469e9, 2.472e9, 2.475e9, 2.478e9 ], labels=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28], ) self.Add(self._tx_freq_chooser) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_samp_rate(32e3) self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0) self.uhd_usrp_sink_0.set_gain(20, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0.set_bandwidth(3e6, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b((1,0,1,0), True, 1, []) 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=True, ), payload_length=0, ) self.Spread_ds_spreader_0 = Spread.ds_spreader(2, (1, 1, 0, 1), (1, 1, 1)) ################################################## # Connections ################################################## self.connect((self.Spread_ds_spreader_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_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.sample_rate = sample_rate = 4e6 ################################################## # Blocks ################################################## self.wxgui_waterfallsink2_0 = waterfallsink2.waterfall_sink_c( self.GetWin(), baseband_freq=0, dynamic_range=100, ref_level=0, ref_scale=2.0, sample_rate=sample_rate, fft_size=512, fft_rate=15, average=False, avg_alpha=None, title="Waterfall Plot", ) self.Add(self.wxgui_waterfallsink2_0.win) 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=sample_rate, fft_size=1024, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.osmosdr_sink_0 = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink_0.set_sample_rate(sample_rate) self.osmosdr_sink_0.set_center_freq(2.402e9, 0) self.osmosdr_sink_0.set_freq_corr(0, 0) self.osmosdr_sink_0.set_gain(2000, 0) self.osmosdr_sink_0.set_if_gain(4000, 0) self.osmosdr_sink_0.set_bb_gain(4000, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(0, 0) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=int(sample_rate / 1e6), sensitivity=(3.1415926 / 2) / (sample_rate / 1e6), bt=0.5, verbose=False, log=False, ) self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1, 1e6, True) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, sample_rate, True) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, "ha", True) ################################################## # Connections ################################################## self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_waterfallsink2_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_throttle_0, 0))
def __init__(self, samp_rate=48000, tx_gain=1, rx_gain=1): gr.hier_block2.__init__( self, "XCEIVER", # input signature, # Port 1 = audio in (left) # 2 = audio in (right) # 3 = frame in gr.io_signaturev( 3, 3, [gr.sizeof_float, gr.sizeof_float, gr.sizeof_char]), # output signature # Port 1 = audio out # 2 = frame out # 3 = receive filter output gr.io_signaturev( 3, 3, [gr.sizeof_float, gr.sizeof_char, gr.sizeof_gr_complex])) ####################################################################### # Variables self.tx_gain = tx_gain self.transition = 1000 # samples_per_symbol self.sps = 8 self.sideband_tx = 500 self.sideband_rx = 500 self.samp_rate = samp_rate self.interpolation = 100 # w.r.t. transmitter self.carrier = 8000 # Hz # sensitivity is pi * modulation_index/samples_per_symbol self.sensitivity = (math.pi * 0.6) / self.sps ####################################################################### # Receiver # convert each float number from the audio source to a complex number self.blocks_float_to_complex = blocks.float_to_complex(1) self.freq_xlating_fir_filter_R = \ filter.freq_xlating_fir_filter_ccc( \ 1, \ (firdes.band_pass (0.5,self.samp_rate,self.carrier-self.sideband_rx, \ self.carrier+self.sideband_rx,self.transition)), \ 0, \ self.samp_rate) # see transmitter for the calculation of signal rate, in symbol/second. self.rational_resampler_R = filter.rational_resampler_ccc( interpolation=1, # always one here decimation=1, taps=None, fractional_bw=None, ) # input is the complex modulated signal at baseband. # output is a stream of bits packed 1 bit per byte (the LSB) self.digital_gfsk_demod = digital.gfsk_demod( samples_per_symbol=self.sps * self.interpolation, sensitivity=1, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.null_sink = blocks.null_sink(gr.sizeof_float) # connect audio in (left) self.connect((self, 0), \ (self.blocks_float_to_complex, 0)) # connect audio in (right) self.connect((self, 1), \ (self.null_sink, 0)) # (self.blocks_float_to_complex, 1)) self.connect((self.blocks_float_to_complex, 0), \ (self.freq_xlating_fir_filter_R, 0)) self.connect((self.freq_xlating_fir_filter_R, 0), (self.rational_resampler_R, 0)) self.connect((self.rational_resampler_R, 0), \ (self.digital_gfsk_demod, 0)) # connect resampler (filter) output to frame out port self.connect((self.rational_resampler_R, 0), \ (self, 2)) # connect demodulator output to frame out port self.connect((self.digital_gfsk_demod, 0), \ (self, 1)) ####################################################################### # Transmitter # Gaussian Frequency Shift Key (GFSK) modulator # input is a byte stream (unsigned char) and the # output is the complex modulated signal at baseband. self.digital_gfsk_mod = digital.gfsk_mod( samples_per_symbol=self.sps, sensitivity=self.sensitivity, bt=0.35, # Gaussian filter bandwidth * symbol time verbose=False, log=False, ) self.rational_resampler_T = filter.rational_resampler_ccc( # Calculation of signal rate, in symbol/second: # self.samp_rate samples/sec / # (self.sps samples/symbol*self.interpolation) = N symbols/sec # With samp_rate = 48,000, self.sps = 8 and # self.interpolation = 100, we have 60 = symbols/sec interpolation=self.interpolation, decimation=1, # always one here taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter = \ filter.freq_xlating_fir_filter_ccc( \ 1, \ (firdes.band_pass (0.5,self.samp_rate,self.carrier-self.sideband_tx, \ self.carrier+self.sideband_tx,self.transition)), \ self.carrier, \ self.samp_rate) self.blocks_complex_to_real = blocks.complex_to_real(1) self.blocks_multiply_const = blocks.multiply_const_vff( (self.tx_gain, )) self.blocks_throttle = blocks.throttle(gr.sizeof_gr_complex * 1, self.samp_rate, True) # Connections # frame in port to modulator self.connect((self, 2), \ (self.digital_gfsk_mod, 0)) self.connect((self.digital_gfsk_mod, 0), \ (self.rational_resampler_T, 0)) self.connect((self.rational_resampler_T, 0), (self.freq_xlating_fir_filter, 0)) self.connect((self.freq_xlating_fir_filter, 0), \ (self.blocks_throttle, 0)) self.connect((self.blocks_throttle, 0), \ (self.blocks_complex_to_real, 0)) self.connect((self.blocks_complex_to_real, 0), \ (self.blocks_multiply_const, 0)) # Connect transmitter output to audio out port self.connect((self.blocks_multiply_const, 0), \ (self, 0))
def __init__(self, rate=1e6, access_code_threshold=0, samps_per_sym=2, ampl=1): gr.hier_block2.__init__( self, "GFSK Modem", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.rate = rate self.access_code_threshold = access_code_threshold self.samps_per_sym = samps_per_sym self.ampl = ampl ################################################## # Variables ################################################## self.samp_rate = samp_rate = rate ################################################## # Message Queues ################################################## mac_packet_deframer_0_msgq_out = mac_packet_to_pdu_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## self.pad_source_1 = None;self.message_port_register_hier_out("msg_in") self.pad_sink_0_0 = None;self.message_port_register_hier_in("msg_out") self.mac_packet_to_pdu_0 = mac.packet_to_pdu(msgq=mac_packet_to_pdu_0_msgq_in, dewhiten=True, output_invalid=False) self.mac_packet_framer_0 = mac.packet_framer( access_code="", whitener_offset=0, rotate_whitener_offset=0, whiten=True, preamble=''.join(['\x55']*((256*1)/8/samps_per_sym)), postamble=''.join(['\x00']*(16/8/samps_per_sym)*0), ) self.mac_packet_deframer_0 = mac.packet_deframer(msgq=mac_packet_deframer_0_msgq_out, access_code="", threshold=access_code_threshold) self.mac_burst_tagger_0 = mac.burst_tagger('length', samps_per_sym*8, 32*0+ 0, 16*0 + 16) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samps_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=samps_per_sym, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "length") ################################################## # Connections ################################################## self.connect((self.mac_burst_tagger_0, 0), (self, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.mac_packet_deframer_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.mac_burst_tagger_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.mac_packet_framer_0, "out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.mac_packet_to_pdu_0, "pdu", self, "msg_out") self.msg_connect(self, "msg_in", self.mac_packet_framer_0, "in")
def __init__(self): gr.top_block.__init__(self, "Cr Application") Qt.QWidget.__init__(self) self.setWindowTitle("Cr Application") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "cr_application") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.usrp_rf_freq = usrp_rf_freq = 2405000000 self.usrp_int_freq = usrp_int_freq = 2400000000 self.timing_loop_bw = timing_loop_bw = 6.28/100 self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, -0.3 + 0.2j] self.samp_rate = samp_rate = 390625 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.phase_bw = phase_bw = 6.28/100 self.excess_bw = excess_bw = 0.35 self.eq_gain = eq_gain = 0.01 self.arity = arity = 4 ################################################## # Blocks ################################################## self.crew_db_channel_selector_0 = crew.db_channel_selector('test_may14_r1', 'zigbee', 'max', 0.05) def _usrp_rf_freq_probe(): while True: val = self.crew_db_channel_selector_0.get_freq() try: self.set_usrp_rf_freq(val) except AttributeError, e: pass time.sleep(1.0/(0.2)) _usrp_rf_freq_thread = threading.Thread(target=_usrp_rf_freq_probe) _usrp_rf_freq_thread.daemon = True _usrp_rf_freq_thread.start() self._usrp_int_freq_layout = Qt.QVBoxLayout() self._usrp_int_freq_tool_bar = Qt.QToolBar(self) self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_tool_bar) self._usrp_int_freq_tool_bar.addWidget(Qt.QLabel("usrp_int_freq"+": ")) self._usrp_int_freq_counter = Qwt.QwtCounter() self._usrp_int_freq_counter.setRange(2400000000, 2480000000, 5000000) self._usrp_int_freq_counter.setNumButtons(2) self._usrp_int_freq_counter.setValue(self.usrp_int_freq) self._usrp_int_freq_tool_bar.addWidget(self._usrp_int_freq_counter) self._usrp_int_freq_counter.valueChanged.connect(self.set_usrp_int_freq) self._usrp_int_freq_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._usrp_int_freq_slider.setRange(2400000000, 2480000000, 5000000) self._usrp_int_freq_slider.setValue(self.usrp_int_freq) self._usrp_int_freq_slider.setMinimumWidth(100) self._usrp_int_freq_slider.valueChanged.connect(self.set_usrp_int_freq) self._usrp_int_freq_layout.addWidget(self._usrp_int_freq_slider) self.top_layout.addLayout(self._usrp_int_freq_layout) self.uhd_usrp_source_0_0 = uhd.usrp_source( device_addr="addr=192.168.30.2", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(usrp_rf_freq, 0) self.uhd_usrp_source_0_0.set_gain(10, 0) self.uhd_usrp_sink_1 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", args="addr=192.168.40.2", channels=range(1), ), ) self.uhd_usrp_sink_1.set_samp_rate(samp_rate) self.uhd_usrp_sink_1.set_center_freq(usrp_int_freq, 0) self.uhd_usrp_sink_1.set_gain(40, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="addr=192.168.20.2", stream_args=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(usrp_rf_freq, 0) self.uhd_usrp_sink_0.set_gain(10, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate/2, #samp_rate "BER", #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.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, "BER") 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_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 2) self.digital_map_bb_0 = digital.map_bb(([0,1,2,3])) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc(20, 0.02, 2, qpsk) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(4) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(phase_bw, arity) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(qpsk, timing_loop_bw, 0.0001, 0.0002) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=qpsk, differential=True, samples_per_symbol=4, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b((170,170), True, 1, []) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.analog_random_source_x_1 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 1000)), True) ################################################## # Connections ################################################## self.connect((self.digital_constellation_modulator_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_receiver_cb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.uhd_usrp_sink_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.crew_db_channel_selector_0, 0))
def __init__( self, carrier, sideband, transition, sps, interpolation, looutdev): gr.top_block.__init__(self, "Transmit block") ################################################## # Variables ################################################## self.samp_rate = SAMPLE_RATE self.carrier = carrier self.sideband = sideband self.transition = transition self.sps = sps self.interpolation = interpolation ################################################## # 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,SAMPLE_RATE,carrier-sideband,carrier+sideband,transition)), -carrier, SAMPLE_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_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_LEN, ) self.audio_sink_0 = audio.sink(SAMPLE_RATE, looutdev, True) self.source_queue = gr.msg_queue() self.msg_source = blocks.message_source(gr.sizeof_char, self.source_queue) ################################################## # Connections ################################################## self.connect((self.msg_source, 0), (self.blks2_packet_encoder_0, 0)) 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.blocks_complex_to_real_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.audio_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.fsk_deviation_hz = fsk_deviation_hz = 15e3 self.channel_width = channel_width = fsk_deviation_hz * 1.3 self.t_width = t_width = channel_width / 10 self.samp_rate = samp_rate = 8e6 self.freq2 = freq2 = 433.777e6 self.freq1 = freq1 = 434.138e6 self.freq0 = freq0 = 433.178e6 self.channel_filter_taps = channel_filter_taps = firdes.low_pass( 1, samp_rate, channel_width, t_width) self.center_freq = center_freq = 435e6 self.baseband_samp_rate = baseband_samp_rate = 16e3 ################################################## # Message Queues ################################################## #blocks_message_sink_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(2) self.blocks_message_source_0_msgq_in = gr.msg_queue() ################################################## # Blocks ################################################## self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=int(samp_rate / baseband_samp_rate), sensitivity=(2 * math.pi * (fsk_deviation_hz / 2)) / samp_rate, bt=0.35, verbose=False, log=False, ) self.blocks_vector_to_streams_0 = blocks.vector_to_streams( gr.sizeof_char * 1, 4) self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0, 0, 1), True, 4, []) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_uchar_to_float_1_0_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_1_0 = blocks.uchar_to_float() self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_xx_0_0_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0_0 = 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_message_source_0 = blocks.message_source( gr.sizeof_char * 4, self.blocks_message_source_0_msgq_in) #self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char * 4, blocks_message_sink_0_msgq_out, False) self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, "test.iq", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0_0_0_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq2 - center_freq, 1, 0) self.analog_sig_source_x_0_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq1 - center_freq, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq0 - center_freq, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.analog_sig_source_x_0_0_0, 0), (self.blocks_multiply_xx_0_0_0, 0)) self.connect((self.analog_sig_source_x_0_0_0_1, 0), (self.blocks_multiply_xx_0_0_0_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.blocks_multiply_xx_0_0_0, 1)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.blocks_multiply_xx_0_0_0_1, 1)) self.connect((self.blocks_message_source_0, 0), (self.blocks_vector_to_streams_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_multiply_xx_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blocks_multiply_xx_0_0_0_1, 0), (self.blocks_add_xx_0, 2)) self.connect((self.blocks_throttle_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_uchar_to_float_1_0, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.blocks_uchar_to_float_1_0, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self.blocks_uchar_to_float_1_0_0, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.blocks_uchar_to_float_1_0_0, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_gfsk_mod_0, 0)) #self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_message_sink_0, 0)) self.connect((self.blocks_vector_to_streams_0, 1), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_vector_to_streams_0, 2), (self.blocks_uchar_to_float_1_0, 0)) self.connect((self.blocks_vector_to_streams_0, 3), (self.blocks_uchar_to_float_1_0_0, 0)) self.connect((self.blocks_vector_to_streams_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_xx_0, 1))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.noise_volt = noise_volt = 10e-3 self.mult_const = mult_const = 1 self.cutoff = cutoff = 10.7e3 ################################################## # Blocks ################################################## _noise_volt_sizer = wx.BoxSizer(wx.VERTICAL) self._noise_volt_text_box = forms.text_box( parent=self.GetWin(), sizer=_noise_volt_sizer, value=self.noise_volt, callback=self.set_noise_volt, label="Noise Voltage", converter=forms.float_converter(), proportion=0, ) self._noise_volt_slider = forms.slider( parent=self.GetWin(), sizer=_noise_volt_sizer, value=self.noise_volt, callback=self.set_noise_volt, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_noise_volt_sizer) _mult_const_sizer = wx.BoxSizer(wx.VERTICAL) self._mult_const_text_box = forms.text_box( parent=self.GetWin(), sizer=_mult_const_sizer, value=self.mult_const, callback=self.set_mult_const, label="Amplifier", converter=forms.float_converter(), proportion=0, ) self._mult_const_slider = forms.slider( parent=self.GetWin(), sizer=_mult_const_sizer, value=self.mult_const, callback=self.set_mult_const, minimum=0, maximum=2, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_mult_const_sizer) _cutoff_sizer = wx.BoxSizer(wx.VERTICAL) self._cutoff_text_box = forms.text_box( parent=self.GetWin(), sizer=_cutoff_sizer, value=self.cutoff, callback=self.set_cutoff, label="Cutoff Frequency", converter=forms.float_converter(), proportion=0, ) self._cutoff_slider = forms.slider( parent=self.GetWin(), sizer=_cutoff_sizer, value=self.cutoff, callback=self.set_cutoff, minimum=5e3, maximum=16e3, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_cutoff_sizer) 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="Tx", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0_0.win) 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="Rx", peak_hold=False, ) self.Add(self.wxgui_fftsink2_0.win) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, cutoff, 100, firdes.WIN_HAMMING, 6.76)) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_volt, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=42, block_tags=False ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult_const, )) 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=True, ), payload_length=0, ) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_SIN_WAVE, 10000, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 512)), True) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.wxgui_fftsink2_0_0, 0))
def __init__(self, center_freq, samp_rate, gain, fsk_deviation_hz, baseband_file_name, baseband_samp_rate, freq_hop_list, verbose=False, hardware_transmit_enable=True, hw_sel=0, hw_gain=0, iq_file_out=False): gr.top_block.__init__(self) # display the parameters used for transmit if True: #verbose: print "Baseband File Name: {}".format(baseband_file_name) print "Baseband Sample Rate: {}".format(baseband_samp_rate) print "SDR Center Freq: {}".format(center_freq) print "SDR Sample Rate: {}".format(samp_rate) print "Flowgraph Gain: {}".format(gain) print "GFSK deviation: {}".format(fsk_deviation_hz) print "Freq 0-2: {}".format(freq_hop_list) print "Verbose: {}".format(verbose) print "Hardware TX Enable: {}".format(hardware_transmit_enable) print "IQ to File: {}".format(iq_file_out) ################################################## # Variables ################################################## self.center_freq = center_freq self.samp_rate = samp_rate self.gain = gain self.fsk_deviation_hz = fsk_deviation_hz self.baseband_file_name = baseband_file_name self.baseband_samp_rate = baseband_samp_rate self.freq_hop_list = freq_hop_list self.hw_sel = hw_sel self.hw_gain = hw_gain """ r = gr.enable_realtime_scheduling() if r == gr.RT_OK: print "Note: Realtime scheduling enabled" """ # self.cutoff_freq = channel_width/2 ################################################## # Blocks ################################################## # replace this with a message source #self.blocks_file_source_0 = blocks.file_source( # gr.sizeof_char * 1, # baseband_file_name, # repeat) # message sink is primary method of getting baseband data into # the flowgraph #self.source_queue = gr.msg_queue() #self.blocks_message_source_0 = blocks.message_source( # gr.sizeof_char*1, # self.source_queue) #self.blocks_message_source_0.set_max_output_buffer(1) # TESTING FLOWGRAPH ONLY (DELETE WHEN DONE) #blocks_message_sink_0_msgq_out = blocks_message_source_0_msgq_in = gr.msg_queue(2) #self.blocks_vector_source_x_0 = blocks.vector_source_b((1, 0, 0, 1), True, 4, []) #self.blocks_message_sink_0 = blocks.message_sink(gr.sizeof_char * 4, blocks_message_sink_0_msgq_out, False) #self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_message_sink_0, 0)) self.source_queue_v = gr.msg_queue() #self.source_queue_v = gr.msg_queue(2048) # smaller values cause hang self.blocks_message_source_0 = blocks.message_source( gr.sizeof_char * 4, self.source_queue_v) self.blocks_vector_to_streams = blocks.vector_to_streams( gr.sizeof_char * 1, 4) self.connect((self.blocks_message_source_0, 0), (self.blocks_vector_to_streams, 0)) # blocks and connections for carrier for first hop frequency self.analog_sig_source_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq_hop_list[0] - center_freq, 1, 0) self.repeat_0 = blocks.repeat(gr.sizeof_char * 1, int(samp_rate / baseband_samp_rate)) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_multiply_0 = blocks.multiply_vcc(1) self.connect((self.blocks_vector_to_streams, 1), (self.repeat_0, 0)) self.connect((self.repeat_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_0, 1)) self.connect((self.analog_sig_source_0, 0), (self.blocks_multiply_0, 0)) # blocks and connections for carrier for second hop frequency self.analog_sig_source_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq_hop_list[1] - center_freq, 1, 0) self.repeat_1 = blocks.repeat(gr.sizeof_char * 1, int(samp_rate / baseband_samp_rate)) self.blocks_uchar_to_float_1 = blocks.uchar_to_float() self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_multiply_1 = blocks.multiply_vcc(1) self.connect((self.blocks_vector_to_streams, 2), (self.repeat_1, 0)) self.connect((self.repeat_1, 0), (self.blocks_uchar_to_float_1, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_uchar_to_float_1, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_float_to_complex_1, 0), (self.blocks_multiply_1, 1)) self.connect((self.analog_sig_source_1, 0), (self.blocks_multiply_1, 0)) # blocks and connections for carrier for third hop frequency self.analog_sig_source_2 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, freq_hop_list[2] - center_freq, 1, 0) self.repeat_2 = blocks.repeat(gr.sizeof_char * 1, int(samp_rate / baseband_samp_rate)) self.blocks_uchar_to_float_2 = blocks.uchar_to_float() self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_multiply_2 = blocks.multiply_vcc(1) self.connect((self.blocks_vector_to_streams, 3), (self.repeat_2, 0)) self.connect((self.repeat_2, 0), (self.blocks_uchar_to_float_2, 0)) self.connect((self.blocks_uchar_to_float_2, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.blocks_uchar_to_float_2, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_2, 1)) self.connect((self.analog_sig_source_2, 0), (self.blocks_multiply_2, 0)) # now add the three gated carrier together; the selected # one will pass through self.blocks_add = blocks.add_vcc(1) self.connect((self.blocks_multiply_0, 0), (self.blocks_add, 0)) self.connect((self.blocks_multiply_1, 0), (self.blocks_add, 1)) self.connect((self.blocks_multiply_2, 0), (self.blocks_add, 2)) # all of the baseband data goes to the modulation chain self.blocks_unpacked_to_packed = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.digital_gfsk_mod = digital.gfsk_mod( samples_per_symbol=int(samp_rate / baseband_samp_rate), sensitivity=(2 * math.pi * (fsk_deviation_hz / 2)) / samp_rate, bt=0.35, verbose=False, log=False, ) self.connect((self.blocks_vector_to_streams, 0), (self.blocks_unpacked_to_packed, 0)) self.connect((self.blocks_unpacked_to_packed, 0), (self.digital_gfsk_mod, 0)) # use the passed-through carrier to tune/modulate the gfsk output self.blocks_multiply_tune = blocks.multiply_vcc(1) self.connect((self.digital_gfsk_mod, 0), (self.blocks_multiply_tune, 0)) self.connect((self.blocks_add, 0), (self.blocks_multiply_tune, 1)) # setup osmocom block for HackRF control # NEED: add control switch for USRP models if hardware_transmit_enable: if self.hw_sel == 0: self.osmosdr_sink = osmosdr.sink(args="numchan=" + str(1) + " " + "") self.osmosdr_sink.set_sample_rate(samp_rate) self.osmosdr_sink.set_center_freq(center_freq, 0) self.osmosdr_sink.set_freq_corr(0, 0) self.osmosdr_sink.set_gain(hw_gain, 0) self.osmosdr_sink.set_if_gain(20, 0) self.osmosdr_sink.set_bb_gain(20, 0) self.osmosdr_sink.set_antenna("", 0) self.osmosdr_sink.set_bandwidth(0, 0) self.connect((self.blocks_multiply_tune, 0), (self.osmosdr_sink, 0)) elif self.hw_sel == 1: self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), 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(center_freq, 0) self.uhd_usrp_sink_0.set_gain(hw_gain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.connect((self.blocks_multiply_tune, 0), (self.uhd_usrp_sink_0, 0)) # this file sink provides an IQ capture of the RF # being transmitted by this app; the resulting file # is used for debugging only and should be disabled # under normal use if iq_file_out: self.blocks_file_sink_iq = blocks.file_sink( gr.sizeof_gr_complex * 1, "takeover_output_c435M_s8M.iq", False) self.blocks_file_sink_iq.set_unbuffered(False) self.connect((self.blocks_multiply_tune, 0), (self.blocks_file_sink_iq, 0)) # attempts to decrease latency #self.blocks_message_source_0.set_max_noutput_items(128) #self.blocks_multiply_tune.set_max_noutput_items(512) buffer_size = 1 self.blocks_message_source_0.set_max_output_buffer(buffer_size) self.blocks_vector_to_streams.set_max_output_buffer(buffer_size)
def __init__(self, options): gr.top_block.__init__(self) # Setup USRP self.u = uhd.usrp_sink(options.args, uhd.stream_args('fc32'), "packet_len") if(options.spec): self.u.set_subdev_spec(options.spec, 0) if(options.antenna): self.u.set_antenna(options.antenna, 0) self.u.set_samp_rate(options.rate) # Gain is set in the hopper block if options.gain is None: g = self.u.get_gain_range() options.gain = float(g.start()+g.stop())/2.0 print "-- Setting gain to {} dB".format(options.gain) r = self.u.set_center_freq(options.freq) if not r: print '[ERROR] Failed to set base frequency.' raise SystemExit, 1 hopper_block = FrequencyHopperSrc( options.num_bursts, options.num_channels, options.freq_delta, options.freq, options.samp_per_burst, 1.0, options.hop_time / 1000., options.post_tuning, options.gain, options.verbose, ) ################################################## # Variables ################################################## self.samp_sym = samp_sym = 64 self.samp_rate = samp_rate = 400e3 self.registers = registers = 3 self.init = init = 1, 1, 1, 1 self.generator = generator = 1, 1, 0, 0, 1 self.code_rate = code_rate = int(samp_sym * 500) ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=64, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_0 = blocks.vector_source_b((0, 1, 0, 1), True, 1, []) 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=True, ), payload_length=0, ) self.Spread_synthesizer_0 = Spread.synthesizer(code_rate, 9000, samp_rate, (generator), (init)) self.connect(self.blocks_vector_source_x_0, self.blks2_packet_encoder_0, self.digital_gfsk_mod_0, self.Spread_synthesizer_0, hopper_block, self.u)
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.pam4_constellation = pam4_constellation = digital.constellation_calcdist( ([0, 1, 3, 2]), ([0, 1, 3, 2]), 4, 1).base() self.noiseamp = noiseamp = (10**(-0.9) + 10) / 2 self.noise_enable = noise_enable = 0 self.mod_select = mod_select = 1 self.ebw_range = ebw_range = 0.35 self.a_src_freq = a_src_freq = 200e3 ################################################## # Blocks ################################################## self._noiseamp_range = Range(10**(-0.9), 10, 0.001, (10**(-0.9) + 10) / 2, 200) self._noiseamp_win = RangeWidget(self._noiseamp_range, self.set_noiseamp, "Noise Amplitude", "counter_slider", float) self.top_grid_layout.addWidget(self._noiseamp_win, 0, 2) _noise_enable_check_box = Qt.QCheckBox("Noise Enable") self._noise_enable_choices = {True: 1, False: 0} self._noise_enable_choices_inv = dict( (v, k) for k, v in self._noise_enable_choices.iteritems()) self._noise_enable_callback = lambda i: Qt.QMetaObject.invokeMethod( _noise_enable_check_box, "setChecked", Qt.Q_ARG("bool", self._noise_enable_choices_inv[i])) self._noise_enable_callback(self.noise_enable) _noise_enable_check_box.stateChanged.connect( lambda i: self.set_noise_enable(self._noise_enable_choices[bool(i)] )) self.top_grid_layout.addWidget(_noise_enable_check_box, 0, 1) self._mod_select_options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] self._mod_select_labels = [ "BPSK", "QPSK", "8PSK", "QAM16", "QAM64", "PAM4", "GFSK", "CPFSK", "WBFM", "AM-DSB", "AM-SSB" ] self._mod_select_tool_bar = Qt.QToolBar(self) self._mod_select_tool_bar.addWidget(Qt.QLabel("mod_select" + ": ")) self._mod_select_combo_box = Qt.QComboBox() self._mod_select_tool_bar.addWidget(self._mod_select_combo_box) for label in self._mod_select_labels: self._mod_select_combo_box.addItem(label) self._mod_select_callback = lambda i: Qt.QMetaObject.invokeMethod( self._mod_select_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._mod_select_options.index(i))) self._mod_select_callback(self.mod_select) self._mod_select_combo_box.currentIndexChanged.connect( lambda i: self.set_mod_select(self._mod_select_options[i])) self.top_grid_layout.addWidget(self._mod_select_tool_bar, 0, 0) self._a_src_freq_range = Range(44100, 200e3, 10, 200e3, 200) self._a_src_freq_win = RangeWidget(self._a_src_freq_range, self.set_a_src_freq, "Analog Source Frequency", "counter_slider", float) self.top_layout.addWidget(self._a_src_freq_win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), 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(0, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.sig_source_0 = analog.sig_source_f(samp_rate, analog.GR_TRI_WAVE, 44100, 1, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 2048, #size samp_rate, #samp_rate "Times Series", #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(True) self.qtgui_time_sink_x_0.enable_grid(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(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 1, 2) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Frequency Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(True) self.qtgui_freq_sink_x_0.enable_grid(True) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2, 0, 1, 3) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 2048, #size "Constellation", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-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(True) self.qtgui_const_sink_x_0.enable_grid(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, 1, 0, 1, 2) self.hilbert_fc_0 = filter.hilbert_fc(401, firdes.WIN_HAMMING, 6.76) self.fractional_interpolator_xx_0 = filter.fractional_interpolator_ff( 0, 44100 / a_src_freq) self.digital_qam_mod_0_1 = digital.qam.qam_mod( constellation_points=64, mod_code="gray", differential=True, samples_per_symbol=8, excess_bw=ebw_range, verbose=False, log=False, ) self.digital_qam_mod_0_0 = digital.qam.qam_mod( constellation_points=16, mod_code="gray", differential=True, samples_per_symbol=8, excess_bw=ebw_range, verbose=False, log=False, ) self.digital_psk_mod_1 = digital.psk.psk_mod( constellation_points=8, mod_code="gray", differential=True, samples_per_symbol=8, excess_bw=ebw_range, verbose=False, log=False, ) self.digital_psk_mod_0_0 = digital.psk.psk_mod( constellation_points=2, mod_code="gray", differential=True, samples_per_symbol=8, excess_bw=ebw_range, verbose=False, log=False, ) self.digital_psk_mod_0 = digital.psk.psk_mod( constellation_points=4, mod_code="gray", differential=True, samples_per_symbol=8, excess_bw=ebw_range, verbose=False, log=False, ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=8, sensitivity=0.1, bt=ebw_range, verbose=False, log=False, ) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=pam4_constellation, differential=True, samples_per_symbol=8, pre_diff_code=True, excess_bw=ebw_range, verbose=False, log=False, ) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_1 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0_0 = blocks.multiply_vff(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((0.1, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc( (1 + 1j, )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blocks_add_const_vxx_0_0 = blocks.add_const_vff((1, )) self.blocks_add_const_vxx_0 = blocks.add_const_vcc((1, )) self.blks2_selector_1 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=2, num_outputs=1, input_index=noise_enable, output_index=0, ) self.blks2_selector_0 = grc_blks2.selector( item_size=gr.sizeof_gr_complex * 1, num_inputs=11, num_outputs=1, input_index=mod_select, output_index=0, ) self.analog_wfm_tx_0 = analog.wfm_tx( audio_rate=44100, quad_rate=220500, tau=75e-6, max_dev=75e3, ) self.analog_sig_source_x_0_0 = analog.sig_source_f( samp_rate, analog.GR_COS_WAVE, a_src_freq, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, a_src_freq, 1, 0) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 64, 8192)), True) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noiseamp, 31415) self.analog_cpfsk_bc_0 = analog.cpfsk_bc(0.5, 1.0, 8) self.analog_const_source_x_1 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, 0) self.analog_const_source_x_0 = analog.sig_source_c( 0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0, 0), (self.blks2_selector_1, 0)) self.connect((self.analog_const_source_x_1, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_cpfsk_bc_0, 0), (self.blks2_selector_0, 7)) self.connect((self.analog_noise_source_x_0, 0), (self.blks2_selector_1, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_packed_to_unpacked_xx_1, 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.analog_wfm_tx_0, 0), (self.blks2_selector_0, 8)) self.connect((self.blks2_selector_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.blks2_selector_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blks2_selector_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_0_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blks2_selector_0, 9)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.analog_cpfsk_bc_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_psk_mod_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_psk_mod_0_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_psk_mod_1, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_qam_mod_0_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_qam_mod_0_1, 0)) self.connect((self.blocks_packed_to_unpacked_xx_1, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blks2_selector_0, 5)) self.connect((self.digital_gfsk_mod_0, 0), (self.blks2_selector_0, 6)) self.connect((self.digital_psk_mod_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_psk_mod_0_0, 0), (self.blks2_selector_0, 0)) self.connect((self.digital_psk_mod_1, 0), (self.blks2_selector_0, 2)) self.connect((self.digital_qam_mod_0_0, 0), (self.blks2_selector_0, 3)) self.connect((self.digital_qam_mod_0_1, 0), (self.blks2_selector_0, 4)) self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.fractional_interpolator_xx_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.hilbert_fc_0, 0), (self.blks2_selector_0, 10)) self.connect((self.sig_source_0, 0), (self.analog_wfm_tx_0, 0)) self.connect((self.sig_source_0, 0), (self.fractional_interpolator_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Fsk Sender") ################################################## # Variables ################################################## self.transistion = transistion = 100 self.sps = sps = 8 self.sideband_rx = sideband_rx = 1000 self.sideband = sideband = 1000 self.samp_rate = samp_rate = 48000 self.interpolation = interpolation = 18000 self.decimation = decimation = 1 self.carrier = carrier = 10000 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0_1 = filter.rational_resampler_ccc( interpolation=interpolation, decimation=decimation, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.band_pass(0.5, samp_rate, 10000 - sideband, 10000 + 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_wavfile_sink_1 = blocks.wavfile_sink( "FSK_output.wav", 1, 48000, 16) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((0.1, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, "TestData2", False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1, "inputBinary", False) self.blocks_file_sink_0_0.set_unbuffered(False) self.blocks_complex_to_real_0_0 = blocks.complex_to_real(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_real_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_wavfile_sink_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.rational_resampler_xxx_0_1, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0_0, 0)) self.connect((self.rational_resampler_xxx_0_1, 0), (self.freq_xlating_fir_filter_xxx_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.freq = freq = 2375e6 self.udp_len = udp_len = 1472*16 self.time_preamble = time_preamble = [0.125000+0.000000j, 0.522104-0.148216j, -0.495528+0.114832j, -0.267916+0.091700j, 0.236544-0.138456j, -0.098500+0.473800j, 0.476480-0.225344j, -0.187516+0.035372j, 0.051776-0.353552j, -0.104936+0.059916j, 0.228684+0.117504j, -0.530912+0.560756j, 0.359128+0.015872j, -0.132852+0.632840j, -0.105164-0.368872j, 0.368272-0.032412j, 0.125000+0.750000j, 0.463968+0.457792j, 0.151476-0.430948j, 0.685052+0.238524j, 0.494428+0.119428j, -0.557540-0.050056j, 0.416348+0.017368j, 0.104256-0.568836j, -0.301776-0.353552j, 0.079812+0.451516j, 0.439152+0.528072j, 0.642060+0.178484j, -0.090096+0.465096j, -0.446492+0.305776j, -0.111440-0.093688j, -0.538848-0.320228j, 0.125000+0.000000j, -0.538848+0.320228j, -0.111440+0.093688j, -0.446492-0.305776j, -0.090096-0.465096j, 0.642060-0.178484j, 0.439152-0.528072j, 0.079812-0.451516j, -0.301776+0.353552j, 0.104256+0.568836j, 0.416348-0.017368j, -0.557540+0.050056j, 0.494428-0.119428j, 0.685052-0.238524j, 0.151476+0.430948j, 0.463968-0.457792j, 0.125000-0.750000j, 0.368272+0.032412j, -0.105164+0.368872j, -0.132852-0.632840j, 0.359128-0.015872j, -0.530912-0.560756j, 0.228684-0.117504j, -0.104936-0.059916j, 0.051776+0.353552j, -0.187516-0.035372j, 0.476480+0.225344j, -0.098500-0.473800j, 0.236544+0.138456j, -0.267916-0.091700j, -0.495528-0.114832j, 0.522104+0.148216j] self.samp_rate = samp_rate = 1200000 self.preamble_len = preamble_len = 128 self.padding = padding = 12 self.packet_len = packet_len = 1024*4 self.number_len = number_len = 6*4*8 self.new_time_preamble = new_time_preamble = [52.000000 +0.000000j, -5.919279 -8.536566j, -4.260753 -12.607212j,8.939880 -6.125765j,0.884604 -4.096587j,-6.474256 -3.434596j,-4.174710 -0.578714j,3.791506 +1.235053j,0.279833 -0.109122j,5.530533-0.567199j,-1.929208 -7.317350j,-1.378117 +3.190803j,2.805871 -7.702256j,-5.711313 -1.701914j,-2.966432 +1.741682j,-0.247675 +4.490168j,-3.292893 -1.707107j,2.883898 +2.676192j,5.619135 +0.751750j,-4.115069 +2.814674j,-2.589373 -7.294397j,4.612185 +5.259877j,1.197091 +3.742967j,-0.979906 -3.882719j,-1.890878 +1.962808j,4.160219 -3.353154j,-0.540289 +6.005091j,-2.112620 -3.003023j,-3.042150 +2.611726j,1.802848 +4.135673j,5.298560 +4.620461j,0.703246 +3.450126j,5.000000 -1.000000j,5.157142 -0.379740j,3.726040 -3.647292j,-2.997688 +3.323755j,4.889909 -1.616118j,4.836721 +0.468047j,0.992839 -6.866692j,2.704855 -0.610792j,-6.351763 -2.279833j,-1.939613 +0.731610j,7.529818 +3.181252j,-4.310881 -0.784855j,3.354740 -3.048814j,-3.174640 +4.788060j,1.959678 +1.522812j,7.693754 -1.672790j,-4.707107 +0.292893j,5.049252 +3.458181j,1.552404 -4.513244j,3.323670 -1.959693j,-3.571238 +2.200182j,3.211846 +2.977140j,2.428551 -5.636953j,4.723748 +2.769317j,-0.037192 -4.351763j,-4.334488 -2.957252j,2.495908 +3.419032j,3.958268 +0.210689j,-2.732363 -2.667578j,4.275458 -3.511993j,-2.928632 +2.726462j,-1.663484 -3.392583j,2.000000 +0.000000j,-1.663484 +3.392583j,-2.928632 -2.726462j,4.275458 +3.511993j,-2.732363 +2.667578j,3.958268 -0.210689j,2.495908 -3.419032j,-4.334488 +2.957252j,-0.037192 +4.351763j,4.723748 -2.769317j,2.428551 +5.636953j,3.211846 -2.977140j,-3.571238 -2.200182j,3.323670 +1.959693j,1.552404 +4.513244j,5.049252 -3.458181j,-4.707107 -0.292893j,7.693754 +1.672790j,1.959678 -1.522812j,-3.174640 -4.788060j,3.354740 +3.048814j,-4.310881 +0.784855j,7.529818 -3.181252j,-1.939613 -0.731610j,-6.351763 +2.279833j,2.704855 +0.610792j,0.992839 +6.866692j,4.836721 -0.468047j,4.889909 +1.616118j,-2.997688 -3.323755j,3.726040 +3.647292j,5.157142 +0.379740j,5.000000 +1.000000j,0.703246 -3.450126j,5.298560 -4.620461j,1.802848-4.135673j,-3.042150 -2.611726j,-2.112620 +3.003023j,-0.540289 -6.005091j,4.160219 +3.353154j,-1.890878 -1.962808j,-0.979906 +3.882719j,1.197091 -3.742967j,4.612185 -5.259877j,-2.589373 +7.294397j,-4.115069 -2.814674j,5.619135 -0.751750j,2.883898 -2.676192j,-3.292893 +1.707107j,-0.247675 -4.490168j,-2.966432 -1.741682j,-5.711313 +1.701914j,2.805871 +7.702256j,-1.378117 -3.190803j,-1.929208 +7.317350j,5.530533 +0.567199j,0.279833 +0.109122j,3.791506 -1.235053j,-4.174710 +0.578714j,-6.474256 +3.434596j,0.884604 +4.096587j,8.939880 +6.125765j,-4.260753 +12.607212j,-5.919279 +8.536566j] self.length = length = 96 self.gain2 = gain2 = 0.6 self.gain = gain = 0.7 self.freq2 = freq2 = freq+5e6 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join(("", "serial= 30C6272")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_subdev_spec("A:B", 0) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(freq, 0) self.uhd_usrp_sink_0_0.set_normalized_gain(gain, 0) self.uhd_usrp_sink_0_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "serial=30C628B")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq2, 0) self.uhd_usrp_sink_0.set_normalized_gain(gain2, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.qtgui_freq_sink_x_0_1 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_1.set_update_time(0.10) self.qtgui_freq_sink_x_0_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_1.enable_autoscale(False) self.qtgui_freq_sink_x_0_1.enable_grid(False) self.qtgui_freq_sink_x_0_1.set_fft_average(1.0) self.qtgui_freq_sink_x_0_1.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_0_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_1_win, 0, 0, 1, 2) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0_0.enable_autoscale(False) self.qtgui_freq_sink_x_0_0.enable_grid(False) self.qtgui_freq_sink_x_0_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 1, 1, 1, 1) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #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_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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1, 1) self.mysvl_svl_1 = mysvl.svl(gr.sizeof_gr_complex*1, 1, "./inputs/spectrum_maps/one_many_tx.txt", "./inputs/parameters/one_many_tx.txt") self.mysvl_stream_demux_0_0 = mysvl.stream_demux(gr.sizeof_gr_complex*1, (1,packet_len-2,1), False) self.mysvl_stream_demux_0 = mysvl.stream_demux(gr.sizeof_gr_complex*1, (1,packet_len-2,1), False) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=16, packet_length_tag_key="length", bps_header=1, bps_payload=1, rolloff=0, debug_log=False, scramble_bits=False ) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=2, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.blocks_vector_source_x_1_0 = blocks.vector_source_b(range(1,65), True, 1, []) self.blocks_vector_source_x_0_0 = blocks.vector_source_c(new_time_preamble, True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_c(new_time_preamble, True, 1, []) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_char*1, "127.0.0.1", 3000, 1472, True) self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, length, "length") self.blocks_stream_mux_1_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (padding+1, packet_len-2,padding+1)) self.blocks_stream_mux_1 = blocks.stream_mux(gr.sizeof_gr_complex*1, (padding+1, packet_len-2,padding+1)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, number_len, packet_len+2*padding)) self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, (preamble_len, number_len,packet_len+2*padding)) self.blocks_repeat_0_1 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0_0_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex*1, padding+1) self.blocks_multiply_const_vxx_0_0_0_0 = blocks.multiply_const_vcc((0.25, )) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vcc((0.25, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) 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, ) ################################################## # Connections ################################################## self.connect((self.blks2_packet_encoder_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.mysvl_svl_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.blocks_stream_mux_0, 1)) self.connect((self.blocks_multiply_const_vxx_0_0_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_stream_mux_1, 2)) self.connect((self.blocks_repeat_0_0, 0), (self.blocks_stream_mux_1, 0)) self.connect((self.blocks_repeat_0_0_0, 0), (self.blocks_stream_mux_1_0, 0)) self.connect((self.blocks_repeat_0_1, 0), (self.blocks_stream_mux_1_0, 2)) self.connect((self.blocks_stream_mux_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_stream_mux_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_stream_mux_1, 0), (self.blocks_stream_mux_0, 2)) self.connect((self.blocks_stream_mux_1_0, 0), (self.blocks_stream_mux_0_0, 2)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.blocks_vector_source_x_1_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_multiply_const_vxx_0_0_0_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.qtgui_freq_sink_x_0_1, 0)) self.connect((self.mysvl_stream_demux_0, 2), (self.blocks_repeat_0, 0)) self.connect((self.mysvl_stream_demux_0, 0), (self.blocks_repeat_0_0, 0)) self.connect((self.mysvl_stream_demux_0, 1), (self.blocks_stream_mux_1, 1)) self.connect((self.mysvl_stream_demux_0_0, 0), (self.blocks_repeat_0_0_0, 0)) self.connect((self.mysvl_stream_demux_0_0, 2), (self.blocks_repeat_0_1, 0)) self.connect((self.mysvl_stream_demux_0_0, 1), (self.blocks_stream_mux_1_0, 1)) self.connect((self.mysvl_svl_1, 0), (self.mysvl_stream_demux_0, 0)) self.connect((self.mysvl_svl_1, 1), (self.mysvl_stream_demux_0_0, 0))