def __init__(self, sample_rate, frequency, freq_correction, rf_gain, if_gain, bb_gain, bandwidth, port): gr.top_block.__init__(self, "Top Block") self.sample_rate = sample_rate self.rf_gain = rf_gain self.port = port self.if_gain = if_gain self.frequency = frequency self.freq_correction = freq_correction self.bb_gain = bb_gain self.bandwidth = bandwidth self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + 'airspy') self.osmosdr_source_0.set_time_unknown_pps(osmosdr.time_spec_t()) self.osmosdr_source_0.set_sample_rate(sample_rate) self.osmosdr_source_0.set_center_freq(frequency, 0) self.osmosdr_source_0.set_freq_corr(freq_correction, 0) self.osmosdr_source_0.set_gain(rf_gain, 0) self.osmosdr_source_0.set_if_gain(if_gain, 0) self.osmosdr_source_0.set_bb_gain(bb_gain, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(bandwidth, 0) self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink( gr.sizeof_gr_complex * 1, '127.0.0.1', port, False) self.connect((self.osmosdr_source_0, 0), (self.blocks_tcp_server_sink_0, 0))
def go(self, host, port): self.tcp_server_sink = blocks.tcp_server_sink(gr.sizeof_gr_complex * 1, host, port, True) print("IQ port connected") # send samples out via a TCP server self.connect(self.signal_sum, self.tcp_server_sink) self.start() print("flowgraph running") self.wait() print("flowgraph complete")
def test_001(self): self.addr = '127.0.0.1' self.port = 65510 self.itemsize = gr.sizeof_short n_data = 16 self.data = tuple([x for x in range(n_data)]) # tcp_server_sink blocks until client does not connect, start client process first p = Process(target=self._tcp_client) p.start() src = blocks.vector_source_s(self.data, False) tcp_snd = blocks.tcp_server_sink(self.itemsize, self.addr, self.port, False) self.tb_snd.connect(src, tcp_snd) self.tb_snd.run() del tcp_snd self.tb_snd = None p.join()
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Vor Receive Realtime Clean") ################################################## # Variables ################################################## self.morse_vol = morse_vol = 10 self.samp_rate = samp_rate = 32000 self.rtl_gain = rtl_gain = 42 self.rtl_freq = rtl_freq = 112500e3 self.morse_gain = morse_gain = pow(10, morse_vol / 10) self.morse_amp_level = morse_amp_level = 0 self.PI = PI = 3.14159 ################################################## # Blocks ################################################## self.wxgui_scopesink2_1_0_0 = scopesink2.scope_sink_f( self.GetWin(), title='Morse', sample_rate=samp_rate / (1600), v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_STRIPCHART, y_axis_label='Amp', ) self.Add(self.wxgui_scopesink2_1_0_0.win) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate * 64) self.rtlsdr_source_0.set_center_freq(rtl_freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(rtl_gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.pfb_decimator_ccf_0 = pfb.decimator_ccf( 64, (firdes.low_pass(1, samp_rate * 64, 16e3, 200e3)), 0, 100, True, True) self.pfb_decimator_ccf_0.declare_sample_delay(0) _morse_vol_sizer = wx.BoxSizer(wx.VERTICAL) self._morse_vol_text_box = forms.text_box( parent=self.GetWin(), sizer=_morse_vol_sizer, value=self.morse_vol, callback=self.set_morse_vol, label='Morse Volume (dB):', converter=forms.float_converter(), proportion=0, ) self._morse_vol_slider = forms.slider( parent=self.GetWin(), sizer=_morse_vol_sizer, value=self.morse_vol, callback=self.set_morse_vol, minimum=-25, maximum=25, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_morse_vol_sizer) def _morse_amp_level_probe(): while True: val = self.morse_amp.level() try: self.set_morse_amp_level(val) except AttributeError: pass time.sleep(1.0 / (25)) _morse_amp_level_thread = threading.Thread( target=_morse_amp_level_probe) _morse_amp_level_thread.daemon = True _morse_amp_level_thread.start() self.hilbert_fc_0 = filter.hilbert_fc(64, firdes.WIN_HAMMING, 6.76) self.goertzel_fc_0_0 = fft.goertzel_fc(samp_rate, 3200, 30) self.goertzel_fc_0 = fft.goertzel_fc(samp_rate, 3200, 30) self.freq_xlating_fft_filter_ccc_0 = filter.freq_xlating_fft_filter_ccc( 1, (firdes.low_pass(1, samp_rate, 480 * 2, 500 * 2)), 9960, samp_rate) self.freq_xlating_fft_filter_ccc_0.set_nthreads(1) self.freq_xlating_fft_filter_ccc_0.declare_sample_delay(0) self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink( gr.sizeof_gr_complex * 1, '0.0.0.0', 20000, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (morse_gain, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_integrate_xx_1 = blocks.integrate_ff(1600, 1) self.blocks_integrate_xx_0 = blocks.integrate_cc(8, 1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.band_pass_filter_0 = filter.fir_filter_fcc( 1, firdes.complex_band_pass(1, samp_rate, 1010, 1030, 100, firdes.WIN_HAMMING, 6.76)) self.audio_sink_0_0 = audio.sink(samp_rate, '', True) self.analog_wfm_rcv_0 = analog.wfm_rcv( quad_rate=samp_rate, audio_decimation=1, ) self.analog_agc3_xx_0 = analog.agc3_cc(1e-3, 1e-4, 1.0, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.analog_wfm_rcv_0, 0), (self.goertzel_fc_0_0, 0)) self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.band_pass_filter_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.goertzel_fc_0, 0)) self.connect((self.blocks_complex_to_mag_0, 0), (self.hilbert_fc_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_integrate_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_tcp_server_sink_0, 0)) self.connect((self.blocks_integrate_xx_1, 0), (self.wxgui_scopesink2_1_0_0, 0)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0_0, 0)) self.connect((self.freq_xlating_fft_filter_ccc_0, 0), (self.analog_wfm_rcv_0, 0)) self.connect((self.goertzel_fc_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.goertzel_fc_0_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.hilbert_fc_0, 0), (self.freq_xlating_fft_filter_ccc_0, 0)) self.connect((self.pfb_decimator_ccf_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.pfb_decimator_ccf_0, 0))
def __init__(self, host='127.0.0.1', iq_port=9094, tx_packet_filename='out_packets.bin'): gr.top_block.__init__(self, "Hurdle 1") ################################################## # Parameters ################################################## self.host = host self.iq_port = iq_port self.tx_packet_filename = tx_packet_filename ################################################## # Variables ################################################## self.symbol_rate = symbol_rate = 1000000 self.samp_rate = samp_rate = 4000000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( 1.0, samp_rate, symbol_rate, 0.35, 11 * 4) self.constellation_1 = constellation_1 = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self.hurdle1_zero_pad_0 = hurdle1.zero_pad(gr.sizeof_gr_complex, 'zero_pad') self.hurdle1_traffic_parser_0 = hurdle1.traffic_parser( 'pkt_len', 'zero_pad') self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constellation_1, differential=False, samples_per_symbol=samp_rate / symbol_rate, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_tcp_server_sink_0 = blocks.tcp_server_sink( gr.sizeof_gr_complex * 1, host, iq_port, False) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char * 1, tx_packet_filename, False) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 74500, 1, 0) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, 0, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_tcp_server_sink_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.hurdle1_traffic_parser_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.hurdle1_zero_pad_0, 0)) self.connect((self.hurdle1_traffic_parser_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.hurdle1_zero_pad_0, 0), (self.blocks_multiply_xx_0, 0))