def __init__(self): gr.top_block.__init__(self, "Receive_airprobe_bladerf") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # Blocks ################################################## self.zeromq_sub_msg_source_0 = zeromq.sub_msg_source( "tcp://192.168.42.2:4729", 1) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, "packet_len") self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, "/home/abhishek/tmp/Untitled Folder/data_bladeRF1/test", samp_rate, 1, blocks.GR_FILE_FLOAT, True, 48000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_sub_msg_source_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_file_meta_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "File Metadata Vector Sink") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200000 ################################################## # Blocks ################################################## self.blocks_vector_source_x_0 = blocks.vector_source_c( 10 * [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], True, 10, []) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 10, 10010000) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 10, 'C:\\Users\\Zyglabs\\Dropbox\\2017_05_Summer_Research\\EARS\\Refs\\GnuRadio\\Trials\\Trial4_file_metadata_vector_sink.out', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_head_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_head_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.plot_sink_0_0 = gnuradio.input.plot_sink.plot_sink_f( self.GetWin(), title="Scope Plot", vlen=1, decim=1, gsz=500, zoom=0, ) self.Add(self.plot_sink_0_0.win) self.plot_sink_0 = gnuradio.input.plot_sink.plot_sink_f( self.GetWin(), title="Scope Plot", vlen=1, decim=1, gsz=500, zoom=0, ) self.Add(self.plot_sink_0.win) self.const_source_x_0_3_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 1) self.const_source_x_0_3 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.const_source_x_0_2 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 3) self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 36) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 36) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "test.grc", samp_rate, 1, blocks.GR_FILE_FLOAT, False, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.Transfer_function_Response_0 = gnuradio.input.Response.Response(2,12,0,500,1) self.Transfer_function_Numerator_0 = gnuradio.input.Numerator.Numerator(2) self.Transfer_function_Denominator_0 = gnuradio.input.Denominator.Denominator(2) self.Comparator_0 = gnuradio.input.Comparator.Comparator(36, 5, -5) ################################################## # Connections ################################################## self.connect((self.Transfer_function_Denominator_0, 0), (self.Transfer_function_Response_0, 1)) self.connect((self.Transfer_function_Numerator_0, 0), (self.Transfer_function_Response_0, 0)) self.connect((self.const_source_x_0_3_0, 0), (self.Transfer_function_Denominator_0, 0)) self.connect((self.const_source_x_0_0, 0), (self.Transfer_function_Denominator_0, 2)) self.connect((self.const_source_x_0_1, 0), (self.Transfer_function_Denominator_0, 1)) self.connect((self.const_source_x_0_3, 0), (self.Transfer_function_Numerator_0, 2)) self.connect((self.const_source_x_0_2, 0), (self.Transfer_function_Numerator_0, 1)) self.connect((self.const_source_x_0, 0), (self.Transfer_function_Numerator_0, 0)) self.connect((self.Transfer_function_Response_0, 0), (self.Comparator_0, 0)) self.connect((self.Comparator_0, 0), (self.plot_sink_0, 0)) self.connect((self.Transfer_function_Response_0, 0), (self.plot_sink_0_0, 0)) self.connect((self.Transfer_function_Response_0, 0), (self.blocks_file_meta_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "File Metadata Sink") Qt.QWidget.__init__(self) self.setWindowTitle("File Metadata Sink") 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", "file_metadata_sink") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 200000 self.qt_samp_rate = qt_samp_rate = samp_rate ################################################## # Blocks ################################################## self._qt_samp_rate_range = Range(200000, 5000000, 200000, samp_rate, 200) self._qt_samp_rate_win = RangeWidget(self._qt_samp_rate_range, self.set_qt_samp_rate, "qt_samp_rate", "counter_slider", float) self.top_layout.addWidget(self._qt_samp_rate_win) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, 20000000) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, 'C:\\Users\\Zyglabs\\Dropbox\\2017_05_Summer_Research\\EARS\\Refs\\GnuRadio\\Trials\\Trail2_file_metadata_sink.out', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.analog_sig_source_x_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 1000, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_file_meta_sink_0, 0))
def __init__(self, radioNum): gr.top_block.__init__(self, "Spectrum Analyzer") ################################################## # Variables ################################################## self.samp_rate = samp_rate = int(300e3) self.center_freq = center_freq = 900e6 self.radio_num = radioNum # Create custom PMT metadata containing the assigned radio number key0 = pmt.intern("radio_num") val0 = pmt.from_long(self.radio_num) extra_meta = pmt.make_dict() extra_meta = pmt.dict_add(extra_meta, key0, val0) ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='peak=0.003906', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0.set_center_freq(center_freq, 0) self.uhd_usrp_source_0.set_gain(28, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(samp_rate, 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) # No synchronization enforced. self.fft_vxx_0 = fft.fft_vcc(1024, True, window.blackmanharris(1024), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 1024) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, f'./sample{self.radio_num}.dat', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 300000, extra_meta, False) self.blocks_file_meta_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self, filename, filesize=100e6): gr.hier_block2.__init__( self, "Ramdisk File Sink", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev(4, 4, [ gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1, gr.sizeof_float * 1 ]), ) ################################################## # Variables ################################################## mem = psutil.virtual_memory() self.filesize = int(min(mem.free - 500e6, filesize)) print "Actual file size: " + str(filesize) print "Set file size: " + str(self.filesize) self.filename = filename # Create RAMDISK subprocess.call(shlex.split("sudo mkdir /tmp/ramdisk")) subprocess.call( shlex.split("sudo mount -t tmpfs -o size=" + str(int(self.filesize)) + " none /tmp/ramdisk")) username = getpass.getuser() subprocess.call( shlex.split("sudo chown -R " + username + ":" + username + " /tmp/ramdisk")) ################################################## # Blocks ################################################## self.decim = blocks.keep_one_in_n(gr.sizeof_gr_complex * 1, int(self.filesize / 8 / 100)) self.file_meta_sink = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, "/tmp/ramdisk/capture.dat", 1, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.file_meta_sink.set_unbuffered(False) self.ctrl_progress = ctrl_progress(filename=filename, filesize=self.filesize, filesink=self.file_meta_sink) ################################################## # Connections ################################################## self.connect((self, 0), (self.file_meta_sink, 0)) self.connect((self, 0), (self.decim, 0)) self.connect((self.decim, 0), (self.ctrl_progress, 0)) self.connect((self.ctrl_progress, 0), (self, 0)) self.connect((self.ctrl_progress, 1), (self, 1)) self.connect((self.ctrl_progress, 2), (self, 2)) self.connect((self.ctrl_progress, 3), (self, 3))
def create_sinks(self): timestamp = datetime.utcnow().isoformat() source_dict = pmt.dict_add(pmt.make_dict(), pmt.intern('source'), pmt.intern(self.src_name)) extra_dict = pmt.dict_add(source_dict, pmt.intern('lo_freq'), pmt.from_double(self.lo_freq)) self.power_filesinks = [ blocks.file_meta_sink( gr.sizeof_float * self.nfft, f'{self.directory}/{self.src_name}_{timestamp}_power_{chan}', self.samp_rate, 1.0 / (10 * self.decim * self.nfft), blocks.GR_FILE_FLOAT, False, int(self.samp_rate / (self.decim * self.nfft)), extra_dict, True) for chan in range(self.nchans) ] self.crossprods_filesinks = [ blocks.file_meta_sink( gr.sizeof_gr_complex * self.nfft, f'{self.directory}/{self.src_name}_{timestamp}_cross_{pair}', self.samp_rate, 1.0 / (10 * self.decim * self.nfft), blocks.GR_FILE_FLOAT, True, int(self.samp_rate / (self.decim * self.nfft)), extra_dict, True) for pair in range(self.npairs) ]
def __init__(self): gr.top_block.__init__(self, "Gsm Meta Capture") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # Blocks ################################################## 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(samp_rate) self.uhd_usrp_source_0.set_center_freq(906.2e6, 0) self.uhd_usrp_source_0.set_gain(10, 0) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff( .0001, 1) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_float * 1, 13300) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_float * 1, "meta_signal.bin", samp_rate, 1, blocks.GR_FILE_FLOAT, False, 10, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.band_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.band_pass(1, samp_rate, 100e3, 300e3, 200, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.band_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Spectrum Analyzer") ################################################## # Variables ################################################## self.samp_rate = samp_rate = int(300e3) self.mqp_get = mqp_get = 900e6 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", args='peak=0.003906', channels=list(range(0, 1)), ), ) self.uhd_usrp_source_0.set_center_freq(mqp_get, 0) self.uhd_usrp_source_0.set_gain(28, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(samp_rate, 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) # No synchronization enforced. self.fft_vxx_0 = fft.fft_vcc(1024, True, window.blackmanharris(1024), True, 1) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, 1024) self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 1024) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, './sample.dat', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, pmt.make_dict(), False) self.blocks_file_meta_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_stream_to_vector_0, 0))
def __init__(self, options, filename): gr.top_block.__init__(self, "Multi Chirp") self.u = uhd.usrp_source(device_addr="addr=192.168.10.2", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self.s = uhd.usrp_sink(device_addr="addr=192.168.11.2", io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) self.delay = 0.0001 self.fixed_delay = 0.001 self.fk = open('starttime.log', 'w') # Initialization code for controlling the DAC output self.chan = 0 self.unit = uhd.dboard_iface.UNIT_TX self.dac = uhd.dboard_iface.AUX_DAC_A self.iface = self.u.get_dboard_iface(self.chan) # Set up the transmitter. Filename hardcoded for now. self.s.set_samp_rate(options.samp) self.s.set_gain(options.tgain, 0) self.s.set_antenna("TX/RX", 0) #self.s.set_center_freq(2412e6, 0) # Connect the blocks. Source from a file. if len(filename) >= 1: self.fs = blocks.file_source(gr.sizeof_gr_complex * 1, filename[0], True) self.connect((self.fs, 0), (self.s, 0)) # Set up the receiver self.u.set_samp_rate(options.samp) self.u.set_gain(options.rgain, 0) self.u.set_antenna("RX2", 0) #self.u.set_center_freq(2425e6, 0) # Connect the blocks. Write to a file. if len(filename) == 2: self.f = blocks.file_meta_sink(gr.sizeof_gr_complex * 1, filename[1], options.samp, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.f.set_unbuffered(False) self.connect((self.u, 0), (self.f, 0))
def __init__(self): gr.top_block.__init__(self, "Gsm Meta Capture") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # Blocks ################################################## 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(samp_rate) self.uhd_usrp_source_0.set_center_freq(906.2e6, 0) self.uhd_usrp_source_0.set_gain(10, 0) self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(.0001, 1) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_float*1, 13300) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "meta_signal.bin", samp_rate, 1, blocks.GR_FILE_FLOAT, False, 10, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.band_pass_filter_0 = filter.fir_filter_ccf(1, firdes.band_pass( 1, samp_rate, 100e3, 300e3, 200, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.single_pole_iir_filter_xx_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.band_pass_filter_0, 0))
self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7225, 1472, True) self.blocks_udp_sink_0_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7226, 1472, True) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7201, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7200, 1472, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, './Data/meta.raw', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 50e3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 75e3, 1, 0) ################################################## # Connections ################################################## 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.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_udp_sink_0_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_udp_sink_0_1, 0))
def __init__(self): gr.top_block.__init__(self, "NOAA APT Satellite Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA APT Satellite Receiver") 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", "apt_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.satellite_select = satellite_select = 137.62 self.valid_gains = valid_gains = [0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6] self.satellite_frequency = satellite_frequency = satellite_select * 1e6 self.rf_samp_rate = rf_samp_rate = 2.048e6 self.max_doppler = max_doppler = 3000 self.fsk_deviation_hz = fsk_deviation_hz = 17000 self.am_carrier = am_carrier = 2400 self.tuner_frequency = tuner_frequency = satellite_frequency - (rf_samp_rate / 4) self.rf_gain = rf_gain = valid_gains[-1] self.rail_level = rail_level = 0.5 self.processing_rate = processing_rate = 256000 self.fm_bandwidth = fm_bandwidth = (2 * (fsk_deviation_hz + am_carrier)) + max_doppler self.baud_rate = baud_rate = 4160 ################################################## # Blocks ################################################## self.tabs_top = Qt.QTabWidget() self.tabs_top_widget_0 = Qt.QWidget() self.tabs_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_0) self.tabs_top_grid_layout_0 = Qt.QGridLayout() self.tabs_top_layout_0.addLayout(self.tabs_top_grid_layout_0) self.tabs_top.addTab(self.tabs_top_widget_0, "RF Recieve") self.tabs_top_widget_1 = Qt.QWidget() self.tabs_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_1) self.tabs_top_grid_layout_1 = Qt.QGridLayout() self.tabs_top_layout_1.addLayout(self.tabs_top_grid_layout_1) self.tabs_top.addTab(self.tabs_top_widget_1, "APT Signal") self.tabs_top_widget_2 = Qt.QWidget() self.tabs_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_2) self.tabs_top_grid_layout_2 = Qt.QGridLayout() self.tabs_top_layout_2.addLayout(self.tabs_top_grid_layout_2) self.tabs_top.addTab(self.tabs_top_widget_2, "APT Baseband") self.top_grid_layout.addWidget(self.tabs_top, 2, 0, 1, 4) self.tabs_rf = Qt.QTabWidget() self.tabs_rf_widget_0 = Qt.QWidget() self.tabs_rf_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_0) self.tabs_rf_grid_layout_0 = Qt.QGridLayout() self.tabs_rf_layout_0.addLayout(self.tabs_rf_grid_layout_0) self.tabs_rf.addTab(self.tabs_rf_widget_0, "Spectrum") self.tabs_rf_widget_1 = Qt.QWidget() self.tabs_rf_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_1) self.tabs_rf_grid_layout_1 = Qt.QGridLayout() self.tabs_rf_layout_1.addLayout(self.tabs_rf_grid_layout_1) self.tabs_rf.addTab(self.tabs_rf_widget_1, "Waterfall") self.tabs_rf_widget_2 = Qt.QWidget() self.tabs_rf_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_2) self.tabs_rf_grid_layout_2 = Qt.QGridLayout() self.tabs_rf_layout_2.addLayout(self.tabs_rf_grid_layout_2) self.tabs_rf.addTab(self.tabs_rf_widget_2, "Scope") self.tabs_top_layout_0.addWidget(self.tabs_rf) self.tabs_apt_data = Qt.QTabWidget() self.tabs_apt_data_widget_0 = Qt.QWidget() self.tabs_apt_data_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_0) self.tabs_apt_data_grid_layout_0 = Qt.QGridLayout() self.tabs_apt_data_layout_0.addLayout(self.tabs_apt_data_grid_layout_0) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_0, "Scope") self.tabs_apt_data_widget_1 = Qt.QWidget() self.tabs_apt_data_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_1) self.tabs_apt_data_grid_layout_1 = Qt.QGridLayout() self.tabs_apt_data_layout_1.addLayout(self.tabs_apt_data_grid_layout_1) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_1, "Raster") self.tabs_top_layout_1.addWidget(self.tabs_apt_data) self._satellite_select_options = [137.62, 137.9125, 137.1] self._satellite_select_labels = ['NOAA 15 (137.62 MHz)', 'NOAA 18 (137.9125 MHz)', 'NOAA 19 (137.1 MHz)'] self._satellite_select_tool_bar = Qt.QToolBar(self) self._satellite_select_tool_bar.addWidget(Qt.QLabel("Satellite Select"+": ")) self._satellite_select_combo_box = Qt.QComboBox() self._satellite_select_tool_bar.addWidget(self._satellite_select_combo_box) for label in self._satellite_select_labels: self._satellite_select_combo_box.addItem(label) self._satellite_select_callback = lambda i: Qt.QMetaObject.invokeMethod(self._satellite_select_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._satellite_select_options.index(i))) self._satellite_select_callback(self.satellite_select) self._satellite_select_combo_box.currentIndexChanged.connect( lambda i: self.set_satellite_select(self._satellite_select_options[i])) self.top_grid_layout.addWidget(self._satellite_select_tool_bar, 0, 0, 1, 1) self._rf_gain_options = valid_gains self._rf_gain_labels = map(str, self._rf_gain_options) self._rf_gain_tool_bar = Qt.QToolBar(self) self._rf_gain_tool_bar.addWidget(Qt.QLabel("RF Gain"+": ")) self._rf_gain_combo_box = Qt.QComboBox() self._rf_gain_tool_bar.addWidget(self._rf_gain_combo_box) for label in self._rf_gain_labels: self._rf_gain_combo_box.addItem(label) self._rf_gain_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rf_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rf_gain_options.index(i))) self._rf_gain_callback(self.rf_gain) self._rf_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_rf_gain(self._rf_gain_options[i])) self.top_grid_layout.addWidget(self._rf_gain_tool_bar, 0, 1 , 1, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.50) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-40, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( baud_rate / 2, #size baud_rate, #samp_rate 'APT Full Line', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.5) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0.01, 0, 'SyncA') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size processing_rate // 2, #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.tabs_rf_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f( baud_rate, 120*3, baud_rate // 2, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-0.5, 1.5) self.qtgui_time_raster_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [1, 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_time_raster_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_1.addWidget(self._qtgui_time_raster_sink_x_0_win) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 16.64e3, #bw "", #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(-40, 0) 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(False) self.qtgui_freq_sink_x_1_0.set_fft_average(0.2) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: 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 = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] 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.tabs_top_layout_2.addWidget(self._qtgui_freq_sink_x_1_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: 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 = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_0.addWidget(self._qtgui_freq_sink_x_1_win) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, processing_rate // 2, fm_bandwidth + 1e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(2, firdes.low_pass( 1, processing_rate, 60e3, 15e3, firdes.WIN_HAMMING, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, processing_rate,True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/Users/bjmclaug/Downloads/noaa-12_256k.dat", False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "/Users/bjmclaug/source/stem_station/noaa12_sample.dat", baud_rate, 1, blocks.GR_FILE_FLOAT, False, baud_rate * (60 * 20), "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.apt_am_demod_0 = apt_am_demod( parameter_apt_gain=1, parameter_samp_rate=processing_rate / 2, ) self.analog_rail_ff_0_0 = analog.rail_ff(-rail_level, rail_level) self.analog_rail_ff_0 = analog.rail_ff(-rail_level, rail_level) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((processing_rate // 2)/(2*math.pi*fsk_deviation_hz/8.0)) self.analog_agc3_xx_0 = analog.agc3_cc(0.25, 0.5, 0.9, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.apt_am_demod_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_rail_ff_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.apt_am_demod_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.analog_rail_ff_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Frontend DSLWP RX UHD") Qt.QWidget.__init__(self) self.setWindowTitle("Frontend DSLWP RX UHD") 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", "frontend_dslwp_rx_uhd") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.waterfall_ch_min = waterfall_ch_min = -100 self.waterfall_ch_max = waterfall_ch_max = -50 self.samp_rate_2 = samp_rate_2 = 40000 self.samp_rate = samp_rate = 2000000 self.rx_gain = rx_gain = 50 self.fc = fc = 436e6 self.f_offset = f_offset = 0 self.audio_rate = audio_rate = 48000 ################################################## # Blocks ################################################## self.tab3 = Qt.QTabWidget() self.tab3_widget_0 = Qt.QWidget() self.tab3_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab3_widget_0) self.tab3_grid_layout_0 = Qt.QGridLayout() self.tab3_layout_0.addLayout(self.tab3_grid_layout_0) self.tab3.addTab(self.tab3_widget_0, 'Waterfall') self.tab3_widget_1 = Qt.QWidget() self.tab3_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab3_widget_1) self.tab3_grid_layout_1 = Qt.QGridLayout() self.tab3_layout_1.addLayout(self.tab3_grid_layout_1) self.tab3.addTab(self.tab3_widget_1, 'Spectrum') self.top_grid_layout.addWidget(self.tab3, 5, 0, 1, 2) self.tab2 = Qt.QTabWidget() self.tab2_widget_0 = Qt.QWidget() self.tab2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab2_widget_0) self.tab2_grid_layout_0 = Qt.QGridLayout() self.tab2_layout_0.addLayout(self.tab2_grid_layout_0) self.tab2.addTab(self.tab2_widget_0, 'BJ1SN') self.top_grid_layout.addWidget(self.tab2, 4, 0, 1, 2) self._rx_gain_range = Range(0, 73, 1, 50, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0, 0, 1, 1) self._f_offset_tool_bar = Qt.QToolBar(self) self._f_offset_tool_bar.addWidget(Qt.QLabel('Frequency Offset' + ": ")) self._f_offset_line_edit = Qt.QLineEdit(str(self.f_offset)) self._f_offset_tool_bar.addWidget(self._f_offset_line_edit) self._f_offset_line_edit.returnPressed.connect( lambda: self.set_f_offset( eng_notation.str_to_num( str(self._f_offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._f_offset_tool_bar, 0, 1, 1, 1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_subdev_spec('A:B', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) # GPSDO-USRP Sync ################################################## INFO = "[\033[32mINFO\033[0m]" ERROR = "[\033[31mERROR\033[0m]" SUCCESS = "[\033[32mSUEECSS\033[0m]" WARNING = "[\033[33mWARNING\033[0m]" GPS_debug = False print print "##################################################" print "# GPSDO Time Sync #" print "##################################################" #Set the sources self.uhd_usrp_source_0.set_clock_source('gpsdo', 0) self.uhd_usrp_source_0.set_time_source('gpsdo', 0) print INFO, "the default 10 MHz Reference and 1 PPS signals are now from the GPSDO." #Wait for Reference locked time.sleep(1) #Check Reference status if (self.uhd_usrp_source_0.get_mboard_sensor("ref_locked", 0).value == "true"): print INFO, "Reference Locked." else: print ERROR, "Reference Unlocked." exit() #Check GPS status if (self.uhd_usrp_source_0.get_mboard_sensor("gps_locked", 0).value == "true"): print INFO, "GPS Locked." else: print ERROR, "GPS Unlocked." if not GPS_debug: exit() #Print GPS info print INFO, "GPS INFO" print " Time:", self.uhd_usrp_source_0.get_mboard_sensor( "gps_time", 0).value print " GPGGA:", self.uhd_usrp_source_0.get_mboard_sensor( "gps_gpgga", 0).value print " GPRMC:", self.uhd_usrp_source_0.get_mboard_sensor( "gps_gprmc", 0).value #GPSDO-USRP Sync gps_time = int(self.uhd_usrp_source_0.get_mboard_sensor("gps_time", 0)) self.uhd_usrp_source_0.set_time_next_pps(uhd.time_spec(gps_time + 1)) #Wait for it to apply #The wait is 2 seconds because USRP has a issue where #the time at the last PPS does not properly update at the PPS edge #when the time is actually set. print INFO, "Synchronizing the time" time.sleep(2) #Check the time gps_time = uhd.time_spec( int(self.uhd_usrp_source_0.get_mboard_sensor("gps_time", 0))) usrp_time = self.uhd_usrp_source_0.get_time_last_pps() print INFO, "Time INFO" print " GPS time: ", "%.09f" % gps_time.get_real_secs() print " USRP time: ", "%.09f" % usrp_time.get_real_secs() print " Computer time:", "%.09f" % time.time() if (gps_time.get_real_secs() == usrp_time.get_real_secs()): print SUCCESS, "USRP time synchronized to GPS time." else: print ERROR, "Failed to synchronize USRP time to GPS time." ################################################## self.uhd_usrp_source_0.set_center_freq(fc, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.rational_resampler_xxx_0_0_2 = filter.rational_resampler_ccc( interpolation=1, decimation=50, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=1, decimation=50, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0_0_0_0_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 436.4e6, #fc 40e3, #bw "B1", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0_0_0_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0_0_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0_0_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [2, 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_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0_0_0_0.set_line_label( i, labels[i]) self.qtgui_waterfall_sink_x_0_0_0_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0_0_0_0.set_intensity_range( waterfall_ch_min, waterfall_ch_max) self._qtgui_waterfall_sink_x_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.tab2_grid_layout_0.addWidget( self._qtgui_waterfall_sink_x_0_0_0_0_0_win, 0, 1) self.qtgui_waterfall_sink_x_0_0_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 435.4e6, #fc 40e3, #bw "B0", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0_0_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0_0_0.enable_grid(False) self.qtgui_waterfall_sink_x_0_0_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [2, 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_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0_0_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0_0_0.set_intensity_range( waterfall_ch_min, waterfall_ch_max) self._qtgui_waterfall_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab2_grid_layout_0.addWidget( self._qtgui_waterfall_sink_x_0_0_0_win, 0, 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc, #fc samp_rate, #bw "Waterfall", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab3_grid_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 8192, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc, #fc samp_rate, #bw "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_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab3_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0) self.blocks_udp_sink_0_1_1 = blocks.udp_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', 7177, 1472, True) self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_gr_complex * 1, '127.0.0.1', 7161, 1472, True) self.blocks_multiply_xx_0_0_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_file_meta_sink_0_1_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, './Meta/meta_B_436.raw', samp_rate_2, 0.02, blocks.GR_FILE_FLOAT, True, samp_rate_2, "", False) self.blocks_file_meta_sink_0_1_0.set_unbuffered(False) self.blocks_file_meta_sink_0_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, './Meta/meta_B_435.raw', samp_rate_2, 0.02, blocks.GR_FILE_FLOAT, True, samp_rate_2, "", False) self.blocks_file_meta_sink_0_0.set_unbuffered(False) self.analog_sig_source_x_0_0_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, -400e3 + f_offset, 1, 0) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, 600e3 + f_offset, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.analog_sig_source_x_0_0_1, 0), (self.blocks_multiply_xx_0_0_1, 1)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0_1, 0), (self.rational_resampler_xxx_0_0_2, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_file_meta_sink_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_udp_sink_0_1, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.qtgui_waterfall_sink_x_0_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0_2, 0), (self.blocks_file_meta_sink_0_1_0, 0)) self.connect((self.rational_resampler_xxx_0_0_2, 0), (self.blocks_udp_sink_0_1_1, 0)) self.connect((self.rational_resampler_xxx_0_0_2, 0), (self.qtgui_waterfall_sink_x_0_0_0_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0_0_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, args1, args2): gr.top_block.__init__(self) ############################## # TRANSMIT CHAIN ############################## print "\nTRANSMIT CHAIN" ##USRP transmits repeating file generated in MATLAB #self.tx_src = blocks.file_source(gr.sizeof_gr_complex, "iq_in.dat", True) #USRP transmits a repeating vector generated here... tx_list = [ 0.2363 + 0.0741j, 0.0733 - 0.2865j, -0.1035 - 0.2663j, -0.0853 + 0.1909j, -0.0736 + 0.2699j, 0.0773 + 0.1481j, -0.0336 + 0.2079j, -0.0644 - 0.2244j, 0.0396 + 0.2822j, -0.0595 - 0.2416j, 0.1379 + 0.2658j, -0.0449 - 0.2539j, 0.0593 + 0.2946j, 0.0221 - 0.0113j, -0.1303 + 0.2762j, -0.1351 - 0.2598j, -0.0275 - 0.2617j, 0.2157 + 0.1021j, 0.0332 - 0.0383j, -0.1369 - 0.2680j ] self.vec_tx_src = blocks.vector_source_c(tuple(tx_list), True, SIGNAL_LEN, []) self.tx_src = blocks.vector_to_stream(gr.sizeof_gr_complex, SIGNAL_LEN) #Find USRP with device characteristics specified by args1 d1 = uhd.find_devices(uhd.device_addr(args1)) uhd_type1 = d1[0].get('type') print "\nFound '%s' at args '%s'" % \ (uhd_type1, args1) stream_args = uhd.stream_args('fc32') self.u_tx = uhd.usrp_sink(device_addr=args1, stream_args=stream_args) self.u_tx.set_samp_rate(SAMPLE_RATE) self.u_tx.set_clock_source("external") self.center_freq = END_FREQ - STEP_FREQ self.tr = uhd.tune_request(self.center_freq) self.tr.args = uhd.device_addr_t("mode_n=integer") self.u_tx.set_center_freq(self.tr) self.u_tx.set_bandwidth(SAMPLE_RATE * 1.5) # Get dboard gain range and select maximum tx_gain_range = self.u_tx.get_gain_range() tx_gain = tx_gain_range.stop() self.u_tx.set_gain(tx_gain - 9) self.connect(self.vec_tx_src, self.tx_src, self.u_tx) ############################## # RECEIVE CHAIN ############################## print "\nRECEIVE CHAIN" #USRP logs IQ data to file #This PMT dictionary stuff is stupid, however it's required otherwise the header will become corrupted... key = pmt.intern("rx_freq") val = pmt.from_double(0) extras = pmt.make_dict() extras = pmt.dict_add(extras, key, val) extras = pmt.serialize_str(extras) self.tag_debug = None self.u_rxs = [] for usrp_addr in args2.split(","): kv = usrp_addr.split("=") rx_dst = blocks.file_meta_sink( gr.sizeof_gr_complex * SIGNAL_LEN, "iq_out_{}.dat".format(kv[1]), SAMPLE_RATE, extra_dict=extras) #, detached_header=True) #rx_dst = blocks.file_sink(gr.sizeof_gr_complex*SIGNAL_LEN, "iq_out.dat") # Accumulate repeating sequences using custom block rx_accum = slocalization.accumulator_vcvc(SIGNAL_LEN, int(1e3)) #Find USRP with device characteristics specified by args1 d2 = uhd.find_devices(uhd.device_addr(usrp_addr)) uhd_type2 = d2[0].get('type') print "\nFound '%s' at args '%s'" % \ (uhd_type2, usrp_addr) u_rx = uhd.usrp_source(device_addr=usrp_addr, io_type=uhd.io_type.COMPLEX_FLOAT32, num_channels=1) u_rx.set_samp_rate(SAMPLE_RATE) u_rx.set_bandwidth(SAMPLE_RATE * 1.5) u_rx.set_clock_source("external") u_rx.set_center_freq(self.tr) self.u_rxs.append(u_rx) # Get dboard gain range and select maximum rx_gain_range = u_rx.get_gain_range() rx_gain = rx_gain_range.stop() u_rx.set_gain(rx_gain, 0) # Convert stream to vector s_to_v = blocks.stream_to_vector(gr.sizeof_gr_complex, SIGNAL_LEN) self.connect(u_rx, s_to_v, rx_accum, rx_dst) #self.connect (u_rx, s_to_v, rx_dst) if not self.tag_debug: # DEBUG: Monitor incoming tags... self.tag_debug = blocks.tag_debug( gr.sizeof_gr_complex * SIGNAL_LEN, "tag_debugger", "") self.connect(rx_accum, self.tag_debug) # Synchronize both USRPs' timebases u_rx.set_time_now(uhd.time_spec(0.0)) # Synchronize both USRPs' timebases self.u_tx.set_time_now(uhd.time_spec(0.0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry( self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sample_rate = sample_rate = 1000000 self.baud_rate_hz = baud_rate_hz = 9600 self.squelch = squelch = -40 self.samp_per_sym = samp_per_sym = sample_rate / baud_rate_hz self.lpf_tw = lpf_tw = 20000 self.lpf_co = lpf_co = 20000 self.gain = gain = 0.5 self.fsk_deviation_hz = fsk_deviation_hz = 19200 self.freq = freq = 434000000 ################################################## # Blocks ################################################## self.tabs = Qt.QTabWidget() self.tabs_widget_0 = Qt.QWidget() self.tabs_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_0) self.tabs_grid_layout_0 = Qt.QGridLayout() self.tabs_layout_0.addLayout(self.tabs_grid_layout_0) self.tabs.addTab(self.tabs_widget_0, 'Spectrum') self.tabs_widget_1 = Qt.QWidget() self.tabs_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_1) self.tabs_grid_layout_1 = Qt.QGridLayout() self.tabs_layout_1.addLayout(self.tabs_grid_layout_1) self.tabs.addTab(self.tabs_widget_1, 'LPF') self.tabs_widget_2 = Qt.QWidget() self.tabs_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_2) self.tabs_grid_layout_2 = Qt.QGridLayout() self.tabs_layout_2.addLayout(self.tabs_grid_layout_2) self.tabs.addTab(self.tabs_widget_2, 'Processing') self.top_layout.addWidget(self.tabs) self._squelch_range = Range(-100, 100, 1, -40, 200) self._squelch_win = RangeWidget(self._squelch_range, self.set_squelch, 'Squech', "counter_slider", float) self.tabs_layout_1.addWidget(self._squelch_win) self._sample_rate_range = Range(1000000, 10000000, 500000, 1000000, 200) self._sample_rate_win = RangeWidget(self._sample_rate_range, self.set_sample_rate, 'Sample Rate', "counter_slider", float) self.top_layout.addWidget(self._sample_rate_win) self._lpf_tw_range = Range(10000, 100000, 1, 20000, 200) self._lpf_tw_win = RangeWidget(self._lpf_tw_range, self.set_lpf_tw, "lpf_tw", "counter_slider", float) self.tabs_layout_1.addWidget(self._lpf_tw_win) self._lpf_co_range = Range(10000, 100000, 1, 20000, 200) self._lpf_co_win = RangeWidget(self._lpf_co_range, self.set_lpf_co, "lpf_co", "counter_slider", float) self.tabs_layout_1.addWidget(self._lpf_co_win) self._gain_range = Range(0, 1, 0.01, 0.5, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain', "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._freq_range = Range(400000000, 470000000, 1000000, 434000000, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Freq', "counter_slider", float) self.top_layout.addWidget(self._freq_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(sample_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_normalized_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.01) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size sample_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(True) 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.tabs_layout_2.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.01) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_y_label('Relative Gain', 'dB') 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_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(True) if not False: 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 = [ "cyan", "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.tabs_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 4096, #size firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #fc sample_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.01) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(True) 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 = [ "cyan", "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.tabs_layout_0.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, sample_rate, lpf_co, lpf_tw, firdes.WIN_BLACKMAN, 6.76)) self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb( '10101010101010101010101010101010', 0, 'preamble') self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samp_per_sym, 0.01, 0, 0.1, 0.01) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_char * 1, '', "") self.blocks_tag_debug_0.set_display(True) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_char * 1, '/tmp/file_sink', sample_rate, 1, blocks.GR_FILE_BYTE, False, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.analog_simple_squelch_cc_0 = analog.simple_squelch_cc(squelch, 1) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(10) ################################################## # Connections ################################################## self.connect((self.analog_quadrature_demod_cf_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_simple_squelch_cc_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.blocks_tag_debug_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_simple_squelch_cc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "uhd_to_power_spectrum") Qt.QWidget.__init__(self) self.setWindowTitle("uhd_to_power_spectrum") 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 = 100e3 self.fft_size = fft_size = 8192 self.vector_cut_offset = vector_cut_offset = 4096 self.vector_cut_length = vector_cut_length = 8192/16 self.v_gain = v_gain = 42 self.output_vector_sample_rate = output_vector_sample_rate = samp_rate/fft_size self.f_c = f_c = 1296960000 ################################################## # Blocks ################################################## self._v_gain_range = Range(0, 80, 1, 42, 200) self._v_gain_win = RangeWidget(self._v_gain_range, self.set_v_gain, 'Gain', "counter_slider", float) self.top_layout.addWidget(self._v_gain_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_clock_source('external', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(f_c, 0) self.uhd_usrp_source_0.set_gain(v_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.fft_vxx_0_0 = fft.fft_vcc(fft_size, True, (window.blackmanharris(fft_size)), True, 1) self.blocks_vector_to_stream_0_0 = blocks.vector_to_stream(gr.sizeof_float*1, fft_size) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_float*1, vector_cut_length) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, fft_size) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, fft_size, 0) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_float, vector_cut_length, fft_size, vector_cut_offset) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*vector_cut_length, 'power_spectrum.dat', samp_rate, output_vector_sample_rate/samp_rate, blocks.GR_FILE_FLOAT, False, 1000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(fft_size) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.blocks_stream_to_vector_0_0_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_vector_to_stream_0_0, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.fft_vxx_0_0, 0)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.blocks_vector_to_stream_0_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.fft_vxx_0_0, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_stream_to_vector_0_0, 0))
def __init__(self, options, filename): gr.top_block.__init__(self, "Top Block") ################################################## # Blocks ################################################## self.usrp_source = uhd.usrp_source( ",".join((options.dev_args, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) if options.mode != 2: self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join((options.dev_args, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) # Initialization code for controlling the DAC output self.chan = 0 self.unit = uhd.dboard_iface.UNIT_TX self.dac = uhd.dboard_iface.AUX_DAC_A self.iface = self.usrp_source.get_dboard_iface(self.chan) #self.iface.write_aux_dac_config(32) self.iface.write_aux_dac(self.unit, self.dac, 0.2) # Configure frequency band registers (depending on daughter board) # Channel 1 on MIMO cable is the sweeper USRP usrp_info = self.usrp_source.get_usrp_info(0) db_name = usrp_info["rx_subdev_name"] user_reg_1 = 0 user_reg_2 = 0 print("NAME: " + db_name) if (db_name.find("SBX") != -1): # The following two registers can be configured for frequency band # 2.4 GHz comes in 16 and 24 # for all 37 bands, put 4294967295 in reg 1 and 31 in reg 2 stderr.write("Detected SBX DB...\n") user_reg_1 = 48 # frequncy bit array for first 32 bands #32-band6#64-band7 user_reg_2 = 0 # frequency bit array for next 5 bands elif (db_name.find("CBX") != -1): # 2.4 GHz stderr.write("Detected CBX DB...\n") user_reg_1 = options.band1 # frequncy bit array for first 32 bands user_reg_2 = options.band2 # frequency bit array for next 32 bands else: stderr.write("Error: Unknown daughterboard: %s\n" % db_name) exit(1) # Set chirp enable: self.usrp_source.set_user_register(3, 1, 0) # Set bands of interest self.usrp_source.set_user_register(1, user_reg_1, 0) self.usrp_source.set_user_register(2, user_reg_2, 0) #Address 5 -Clk divider self.usrp_source.set_user_register(5, 4, 0) #self.usrp_source.set_user_register(6,1,0) # RF divider to give 400-4.4GHz range. Valid values are 1,2,4,8 and 16. # The following are the new registers that need to be set # for the updated hardware code. # register 4 = jump value - 12 bit number self.usrp_source.set_user_register(4, options.step, 0) # register 7 = start_ramp - 12 bit number self.usrp_source.set_user_register(7, 621, 0) # register 8 = end_ramp - 12 bit number self.usrp_source.set_user_register(8, 3103, 0) # RF Divider parameters self.usrp_source.set_user_register(6, options.rf_div, 0) # Set source parameters self.usrp_source.set_antenna("RX2") self.usrp_source.set_samp_rate(options.samp) self.usrp_source.set_bandwidth(options.samp, 0) self.usrp_source.set_gain(options.rgain, 0) if options.mode != 2: # Set sink parameters self.uhd_usrp_sink_0.set_samp_rate(10e6) self.uhd_usrp_sink_0.set_center_freq(options.txfreq, 0) self.uhd_usrp_sink_0.set_gain(options.tgain, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0.set_bandwidth(25e6, 0) # signal gen blocker self.blocks_head_0 = blocks.head( gr.sizeof_gr_complex * 1, options.inN * options.maxsamp + options.skip) # Signal Source self.analog_sig_source_x_0 = analog.sig_source_c( options.samp, analog.GR_CONST_WAVE, 0, 0, 1) self.usrp_source.set_clock_source('internal', 0) self.usrp_source.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) # Skip Heads self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex * 1, options.skip) # Block Heads self.blocks_head_1 = blocks.head(gr.sizeof_gr_complex * 1, options.maxsamp) # File meta sink pmt_a = pmt.make_dict() self.blocks_file_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, filename[0], options.samp, 1, blocks.GR_FILE_FLOAT, True, options.sweep_time, pmt_a, True) self.blocks_file_sink_0.set_unbuffered(False) # Keep M in N self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n( gr.sizeof_gr_complex, options.sweep_time * options.num_bands, options.sweep_time * options.num_bands * options.inN, 0) ################################################## # Connections ################################################## # Sweeper RX Flow self.connect((self.usrp_source, 0), (self.blocks_skiphead_0)) self.connect((self.blocks_skiphead_0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_keep_m_in_n_0), (self.blocks_head_1, 0)) #self.connect((self.blocks_skiphead_0),(self.blocks_head_1, 0)) self.connect((self.blocks_head_1, 0), (self.blocks_file_sink_0, 0)) if options.mode != 2: # Tone TX Flow self.connect((self.analog_sig_source_x_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_head_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.range_tx_gain = range_tx_gain = 15 self.range_rx_gain = range_rx_gain = 18 self.range_mu = range_mu = 0.4 self.range_freq = range_freq = 3.5e9 self.variable_qtgui_label_0 = variable_qtgui_label_0 = "{:2.1f} GHz".format(float((77e9-range_freq))/1e9) self.tx_gain = tx_gain = range_tx_gain self.threshold = threshold = 40 self.samp_rate = samp_rate = 4e6 self.rx_gain = rx_gain = range_rx_gain self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps) self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base() self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0] self.mu = mu = range_mu self.freq = freq = range_freq self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0] self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128] self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "TX") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "RX") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Demod") self.top_layout.addWidget(self.tab) self._variable_qtgui_label_0_tool_bar = Qt.QToolBar(self) if None: self._variable_qtgui_label_0_formatter = None else: self._variable_qtgui_label_0_formatter = lambda x: x self._variable_qtgui_label_0_tool_bar.addWidget(Qt.QLabel("RF Frequency"+": ")) self._variable_qtgui_label_0_label = Qt.QLabel(str(self._variable_qtgui_label_0_formatter(self.variable_qtgui_label_0))) self._variable_qtgui_label_0_tool_bar.addWidget(self._variable_qtgui_label_0_label) self.top_grid_layout.addWidget(self._variable_qtgui_label_0_tool_bar, 0,1,1,1) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(freq+100e6, 0) self.uhd_usrp_sink_0.set_gain(tx_gain, 0) self._range_tx_gain_range = Range(0, 15, 1, 15, 200) self._range_tx_gain_win = RangeWidget(self._range_tx_gain_range, self.set_range_tx_gain, "Tx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_tx_gain_win, 1,1,1,1) self._range_rx_gain_range = Range(0, 60, 1, 18, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1) self._range_mu_range = Range(0, 1, 0.01, 0.4, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1) self._range_freq_range = Range(2.5e9, 4e9, 100e6, 3.5e9, 200) self._range_freq_win = RangeWidget(self._range_freq_range, self.set_range_freq, "IF Frequency", "counter_slider", float) self.top_grid_layout.addWidget(self._range_freq_win, 0,0,1,1) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 200000, #size 1e6, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(0, 60) self.qtgui_time_sink_x_0_0_0.set_y_label("Corr", "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 20, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 20000, #size samp_rate / 4, #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(0, 80) self.qtgui_time_sink_x_0.set_y_label("Magnitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 1, 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 False: self.qtgui_time_sink_x_0.disable_legend() labels = ["Correlation", "", "", "", "", "", "", "", "", ""] 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.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 128, #size "Payload", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, "fd") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win) self.inets_rrrm_0 = inets.rrrm(0, [0,65]) self.inets_radio_0 = inets_radio( constellation=qpsk_mod, matched_filter_coeff=rrc, mu=mu, preamble=diff_preamble_128, samp_rate=samp_rate, sps=sps, threshold=threshold, ) self.inets_per_logger_0 = inets.per_logger() self.fir_filter_xxx_0 = filter.fir_filter_fff(64, (gnuradio.filter.firdes.low_pass(1,4e6,4e6/64.0,100e3))) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_socket_pdu_1 = blocks.socket_pdu("UDP_SERVER", "localhost", "52002", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "rrrm_test_rx_data.dat", samp_rate, 1.0/64.0, blocks.GR_FILE_FLOAT, False, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_0_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_rrrm_0, 'payload_in')) self.msg_connect((self.blocks_socket_pdu_1, 'pdus'), (self.inets_rrrm_0, 'radar_in')) self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in')) self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in')) self.msg_connect((self.inets_radio_0, 'out'), (self.inets_rrrm_0, 'rrrm_in')) self.msg_connect((self.inets_rrrm_0, 'payload_out'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.inets_rrrm_0, 'rrrm_out'), (self.inets_radio_0, 'in')) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_0_0_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_mag_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.inets_radio_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0)) self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.inets_radio_0, 5), (self.blocks_null_sink_0, 0)) self.connect((self.inets_radio_0, 6), (self.blocks_null_sink_0_0, 0)) self.connect((self.inets_radio_0, 4), (self.blocks_null_sink_0_1, 0)) self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def test_001(self): N = 1000 outfile = "test_out.dat" detached = False samp_rate = 200000 key = pmt.intern("samp_rate") val = pmt.from_double(samp_rate) extras = pmt.make_dict() extras = pmt.dict_add(extras, key, val) extras_str = pmt.serialize_str(extras) data = sig_source_c(samp_rate, 1000, 1, N) src = blocks.vector_source_c(data) fsnk = blocks.file_meta_sink(gr.sizeof_gr_complex, outfile, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, extras_str, detached) fsnk.set_unbuffered(True) self.tb.connect(src, fsnk) self.tb.run() fsnk.close() handle = open(outfile, "rb") header_str = handle.read(parse_file_metadata.HEADER_LENGTH) if(len(header_str) == 0): self.assertFalse() try: header = pmt.deserialize_str(header_str) except RuntimeError: self.assertFalse() info = parse_file_metadata.parse_header(header, False) extra_str = handle.read(info["extra_len"]) self.assertEqual(len(extra_str) > 0, True) handle.close() try: extra = pmt.deserialize_str(extra_str) except RuntimeError: self.assertFalse() extra_info = parse_file_metadata.parse_extra_dict(extra, info, False) self.assertEqual(info['rx_rate'], samp_rate) self.assertEqual(pmt.to_double(extra_info['samp_rate']), samp_rate) # Test file metadata source src.rewind() fsrc = blocks.file_meta_source(outfile, False) vsnk = blocks.vector_sink_c() tsnk = blocks.tag_debug(gr.sizeof_gr_complex, "QA") ssnk = blocks.vector_sink_c() self.tb.disconnect(src, fsnk) self.tb.connect(fsrc, vsnk) self.tb.connect(fsrc, tsnk) self.tb.connect(src, ssnk) self.tb.run() fsrc.close() # Test to make sure tags with 'samp_rate' and 'rx_rate' keys # were generated and received correctly. tags = tsnk.current_tags() for t in tags: if(pmt.eq(t.key, pmt.intern("samp_rate"))): self.assertEqual(pmt.to_double(t.value), samp_rate) elif(pmt.eq(t.key, pmt.intern("rx_rate"))): self.assertEqual(pmt.to_double(t.value), samp_rate) # Test that the data portion was extracted and received correctly. self.assertComplexTuplesAlmostEqual(vsnk.data(), ssnk.data(), 5) os.remove(outfile)
def __init__(self): gr.top_block.__init__(self, "RRRM Test Client") Qt.QWidget.__init__(self) self.setWindowTitle("RRRM Test Client") 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", "rrrm_test_client") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.range_rx_gain = range_rx_gain = 10 self.range_mu = range_mu = 0.6 self.threshold = threshold = 40 self.samp_rate = samp_rate = 4e6 self.rx_gain = rx_gain = range_rx_gain self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps) self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base() self.mu = mu = range_mu self.diff_preamble_128 = diff_preamble_128 = [ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0 ][0:128] self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, "TX") self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, "RX") self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, "Demod") self.top_layout.addWidget(self.tab) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(2e9, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("addr=192.168.10.2", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(1.6e9, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self._range_rx_gain_range = Range(0, 60, 1, 10, 200) self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, "Rx Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1) self._range_mu_range = Range(0, 1, 0.01, 0.6, 200) self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, "BB Derotation Gain", "counter_slider", float) self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 20000, #size samp_rate / 4, #samp_rate "RX Signal", #name 2 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(0, 80) self.qtgui_time_sink_x_0.set_y_label("Magnitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 20, 0, 1, "") 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 False: self.qtgui_time_sink_x_0.disable_legend() labels = ["RX Signal", "Correlation", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "Payload", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_const_sink_x_0_0_win) self.inets_stop_and_wait_arq_0 = inets.stop_and_wait_arq( 0.2, 500, False, 100000) self.inets_rrrm_0 = inets.rrrm(1, [-166, -229, -63]) self.inets_radio_0 = inets_radio( constellation=qpsk_mod, matched_filter_coeff=rrc, mu=mu, preamble=diff_preamble_128, samp_rate=samp_rate, sps=sps, threshold=threshold, ) self.inets_per_logger_0 = inets.per_logger() self.fir_filter_xxx_0 = filter.fir_filter_fff( 64, (gnuradio.filter.firdes.low_pass(1, 4e6, 4e6 / 64.0, 100e3))) self.fir_filter_xxx_0.declare_sample_delay(0) self.blocks_socket_pdu_1 = blocks.socket_pdu("UDP_SERVER", "localhost", "52002", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_char * 1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((1, )) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_float * 1, "/home/inets/Documents/Log/rrrm_test_client_rx_data.dat", samp_rate, 1.0 / 64.0, blocks.GR_FILE_FLOAT, False, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_mag_0_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_stop_and_wait_arq_0, 'from_app')) self.msg_connect((self.blocks_socket_pdu_1, 'pdus'), (self.inets_rrrm_0, 'radar_in')) self.msg_connect((self.inets_radio_0, 'out'), (self.inets_per_logger_0, 'payload_in')) self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_per_logger_0, 'snr_in')) self.msg_connect((self.inets_radio_0, 'out'), (self.inets_rrrm_0, 'rrrm_in')) self.msg_connect((self.inets_radio_0, 'snr'), (self.inets_stop_and_wait_arq_0, 'snr')) self.msg_connect((self.inets_rrrm_0, 'rrrm_out'), (self.inets_radio_0, 'in')) self.msg_connect((self.inets_rrrm_0, 'payload_out'), (self.inets_stop_and_wait_arq_0, 'from_phy')) self.msg_connect((self.inets_stop_and_wait_arq_0, 'to_app'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.inets_stop_and_wait_arq_0, 'to_phy'), (self.inets_rrrm_0, 'payload_in')) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_complex_to_mag_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_mag_0_0_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_complex_to_mag_0_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.inets_radio_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.inets_radio_0, 2), (self.blocks_complex_to_mag_0, 0)) self.connect((self.inets_radio_0, 1), (self.blocks_complex_to_mag_0_0, 0)) self.connect((self.inets_radio_0, 5), (self.blocks_null_sink_0, 0)) self.connect((self.inets_radio_0, 6), (self.blocks_null_sink_0_0, 0)) self.connect((self.inets_radio_0, 4), (self.blocks_null_sink_0_1, 0)) self.connect((self.inets_radio_0, 3), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.inets_radio_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_const_vxx_0, 0))
def __init__(self, samp_rate=256e3, gain=28, freq=89.7e6, samples=1e6, out=None, verbose=True): """ s=single_recorder(samp_rate=256e3, gain=28, freq=89.7e6, samples=1e6, out=None, verbose=True) """ gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate self.gain = gain self.freq = freq self.out = out self.verbose = verbose if samples is not None: self.samples = samples else: self.samples = 1e6 if self.verbose: print('Will record %d samples at %.2f MHz, sampling at %.1f kHz' % (self.samples, self.freq / 1e6, self.samp_rate / 1e3)) ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("master_clock_rate=30.72e6", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(self.samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(self.freq, 0) self.uhd_usrp_source_0.set_gain(self.gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.filenamebase = datetime.datetime.now().strftime('%Y%m%dT%H%M%S') if self.out is not None: self.filenamebase = os.path.join(self.out, self.filenamebase) self.filename_1 = '%s.dat' % self.filenamebase if self.verbose: print('Will write output to %s' % (self.filename_1)) self.blocks_file_meta_sink_1 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, self.filename_1, self.samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_1.set_unbuffered(False) ################################################## # Connections ################################################## self._head1 = blocks.head(gr.sizeof_gr_complex, int(self.samples)) self.connect((self.uhd_usrp_source_0, 0), self._head1, (self.blocks_file_meta_sink_1, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 20e6 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) 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.blocks_wavfile_source_0 = blocks.wavfile_source( '/home/dawson/Documents/space_grant/rocketsat12/parse_time_domain/10_duty_cycle_1_freq.wav', False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_float * 1, '/home/dawson/Documents/space_grant/rocketsat12/parse_time_domain/10_duty_cycle_1_freq.txt', samp_rate, 1, blocks.GR_FILE_FLOAT, False, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.qtgui_time_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Frontend RX UHD") Qt.QWidget.__init__(self) self.setWindowTitle("Frontend RX UHD") 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", "frontend_rx_uhd_VLBI_Ver") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250000 self.rx_gain = rx_gain = 35 ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Waterfall') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Spectrum') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Scope') self.top_grid_layout.addWidget(self.tab, 3,0) self._rx_gain_range = Range(0, 73, 1, 35, 200) self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain, 'RX Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._rx_gain_win, 0,0) 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(samp_rate) # GPSDO-USRP Sync ################################################## INFO = "[\033[32mINFO\033[0m]" ERROR = "[\033[31mERROR\033[0m]" SUCCESS = "[\033[32mSUEECSS\033[0m]" WARNING = "[\033[33mWARNING\033[0m]" GPS_debug = False print print "##################################################" print "# GPSDO Time Sync #" print "##################################################" #Set the sources self.uhd_usrp_source_0.set_clock_source('gpsdo', 0) self.uhd_usrp_source_0.set_time_source('gpsdo', 0) print INFO,"the default 10 MHz Reference and 1 PPS signals are now from the GPSDO." #Wait for Reference locked time.sleep(1) #Check Reference status if (self.uhd_usrp_source_0.get_mboard_sensor("ref_locked",0).value == "true"): print INFO,"Reference Locked." else: print ERROR,"Reference Unlocked." exit() #Check GPS status if (self.uhd_usrp_source_0.get_mboard_sensor("gps_locked",0).value == "true"): print INFO,"GPS Locked." else: print ERROR,"GPS Unlocked." if not GPS_debug : exit() #Print GPS info print INFO,"GPS INFO" print " Time:",self.uhd_usrp_source_0.get_mboard_sensor("gps_time",0).value print " GPGGA:",self.uhd_usrp_source_0.get_mboard_sensor("gps_gpgga",0).value print " GPRMC:",self.uhd_usrp_source_0.get_mboard_sensor("gps_gprmc",0).value #GPSDO-USRP Sync gps_time = int(self.uhd_usrp_source_0.get_mboard_sensor("gps_time",0)) self.uhd_usrp_source_0.set_time_next_pps(uhd.time_spec(gps_time + 1)) #Wait for it to apply #The wait is 2 seconds because USRP has a issue where #the time at the last PPS does not properly update at the PPS edge #when the time is actually set. print INFO,"Synchronizing the time" time.sleep (2) #Check the time gps_time = uhd.time_spec(int(self.uhd_usrp_source_0.get_mboard_sensor("gps_time",0))) usrp_time = self.uhd_usrp_source_0.get_time_last_pps() print INFO,"Time INFO" print " GPS time: ","%.09f"%gps_time.get_real_secs() print " USRP time: ","%.09f"%usrp_time.get_real_secs() print " Computer time:","%.09f"%time.time() if (gps_time.get_real_secs() == usrp_time.get_real_secs()): print SUCCESS,"USRP time synchronized to GPS time." else: print ERROR,"Failed to synchronize USRP time to GPS time." ################################################## self.uhd_usrp_source_0.set_center_freq(437.275e6, 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=24, decimation=125, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=24, decimation=125, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 437.275e6, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [5, 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(-120, -20) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_0.addWidget(self._qtgui_waterfall_sink_x_0_win) 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(True) 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(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 437.275e6, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7225, 1472, True) self.blocks_udp_sink_0_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7226, 1472, True) self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7201, 1472, True) self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_gr_complex*1, '127.0.0.1', 7200, 1472, True) self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, './Data/meta.raw', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.analog_sig_source_x_0_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 50e3, 1, 0) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 75e3, 1, 0) ################################################## # Connections ################################################## 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.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_udp_sink_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_udp_sink_0_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_udp_sink_0_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Trial5 Record Fm Radio") Qt.QWidget.__init__(self) self.setWindowTitle("Trial5 Record Fm Radio") 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", "Trial5_record_fm_radio") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250e3 self.gain = gain = 40 self.freq = freq = 92.7e6 self.deviation = deviation = 30e3*0 + 5e3 self.audio_rate = audio_rate = int(48e3) ################################################## # Blocks ################################################## self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel('Sample Rate'+": ")) self._samp_rate_line_edit = Qt.QLineEdit(str(self.samp_rate)) self._samp_rate_tool_bar.addWidget(self._samp_rate_line_edit) self._samp_rate_line_edit.returnPressed.connect( lambda: self.set_samp_rate(eng_notation.str_to_num(str(self._samp_rate_line_edit.text().toAscii())))) self.top_layout.addWidget(self._samp_rate_tool_bar) self._gain_range = Range(0, 90, 1, 40, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, 'Gain', "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._freq_range = Range(90e6, 110e6, 50, 92.7e6, 200) self._freq_win = RangeWidget(self._freq_range, self.set_freq, 'Frequency', "counter_slider", float) self.top_layout.addWidget(self._freq_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(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=audio_rate, decimation=int(samp_rate), taps=None, fractional_bw=None, ) 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_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(2): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, audio_rate, 3.5e3, 0.5e3, firdes.WIN_HAMMING, 6.76)) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) # Zyg epochTimeStr = str(int(time.time())) outFileName = 'Trial5_record_fm_radio_Mod_'+epochTimeStr+'.out' outFilePath = os.path.join(curFileDir, outFileName) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, outFilePath, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.audio_sink_0 = audio.sink(audio_rate, '', True) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((audio_rate/(2*math.pi*deviation))* 0 + ((2*math.pi*deviation)/audio_rate)) self.analog_pwr_squelch_xx_0 = analog.pwr_squelch_cc(-90, 1e-3, 0, False) ################################################## # Connections ################################################## self.connect((self.analog_pwr_squelch_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.analog_pwr_squelch_xx_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.audio_sink_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_pwr_squelch_xx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wifi Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx") 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", "wifi_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 10e6 self.lo_offset = lo_offset = 0 self.gain = gain = 0.42 self.freq = freq = 5890000000 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._samp_rate_options = [1e6, 5e6, 10e6, 20e6] self._samp_rate_labels = ["1 MHz", "5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod( self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self._lo_offset_options = ( 0, 6e6, 11e6, ) self._lo_offset_labels = ( str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod( self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_layout.addWidget(self._lo_offset_tool_bar) self._gain_range = Range(0, 1, 0.01, 0.42, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._freq_options = [ 2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0 ] self._freq_labels = [ ' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p' ] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod( self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self._chan_est_options = [ ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB ] self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) 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(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq, rf_freq=freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("J1", 0) self.rftap_rftap_encap_0 = rftap.rftap_encap(0, -1, "") self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_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_const_sink_x_0 = qtgui.const_sink_c( 48 * 10, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.ieee802_11_sync_short_0 = ieee802_11.sync_short( 0.56, 2, False, False) self.ieee802_11_sync_long_0 = ieee802_11.sync_long( sync_length, True, False) self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(True, True) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff( window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc( window_size) self.ieee802_11_frame_equalizer_0 = ieee802_11.frame_equalizer( chan_est, freq, samp_rate, False, False) self.ieee802_11_decode_mac_0 = ieee802_11.decode_mac(True, False) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.correctiq_correctiq_0 = correctiq.correctiq() self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, 64) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "52001", 10000, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.complex_t, "packet_len") self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, "packet_len") self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, "/tmp/wifi.pcap", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, "/home/project/prefix/gr-ieee802-11/build/metadata", samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex * 1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.ieee802_11_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_decode_mac_0, 'out'), (self.rftap_rftap_encap_0, 'in')) self.msg_connect((self.ieee802_11_frame_equalizer_0, 'symbols'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.rftap_rftap_encap_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.correctiq_correctiq_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_frame_equalizer_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_11_frame_equalizer_0, 0), (self.ieee802_11_decode_mac_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_sync_short_0, 0), (self.ieee802_11_sync_long_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.correctiq_correctiq_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Top Block") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.plot_sink_0_0 = gnuradio.input.plot_sink.plot_sink_f( self.GetWin(), title="Scope Plot", vlen=1, decim=1, gsz=500, zoom=0, ) self.Add(self.plot_sink_0_0.win) self.plot_sink_0 = gnuradio.input.plot_sink.plot_sink_f( self.GetWin(), title="Scope Plot", vlen=1, decim=1, gsz=500, zoom=0, ) self.Add(self.plot_sink_0.win) self.const_source_x_0_3_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 1) self.const_source_x_0_3 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.const_source_x_0_2 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 0) self.const_source_x_0_1 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 3) self.const_source_x_0_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 36) self.const_source_x_0 = gr.sig_source_f(0, gr.GR_CONST_WAVE, 0, 0, 36) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_float * 1, "test.grc", samp_rate, 1, blocks.GR_FILE_FLOAT, False, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.Transfer_function_Response_0 = gnuradio.input.Response.Response( 2, 12, 0, 500, 1) self.Transfer_function_Numerator_0 = gnuradio.input.Numerator.Numerator( 2) self.Transfer_function_Denominator_0 = gnuradio.input.Denominator.Denominator( 2) self.Comparator_0 = gnuradio.input.Comparator.Comparator(36, 5, -5) ################################################## # Connections ################################################## self.connect((self.Transfer_function_Denominator_0, 0), (self.Transfer_function_Response_0, 1)) self.connect((self.Transfer_function_Numerator_0, 0), (self.Transfer_function_Response_0, 0)) self.connect((self.const_source_x_0_3_0, 0), (self.Transfer_function_Denominator_0, 0)) self.connect((self.const_source_x_0_0, 0), (self.Transfer_function_Denominator_0, 2)) self.connect((self.const_source_x_0_1, 0), (self.Transfer_function_Denominator_0, 1)) self.connect((self.const_source_x_0_3, 0), (self.Transfer_function_Numerator_0, 2)) self.connect((self.const_source_x_0_2, 0), (self.Transfer_function_Numerator_0, 1)) self.connect((self.const_source_x_0, 0), (self.Transfer_function_Numerator_0, 0)) self.connect((self.Transfer_function_Response_0, 0), (self.Comparator_0, 0)) self.connect((self.Comparator_0, 0), (self.plot_sink_0, 0)) self.connect((self.Transfer_function_Response_0, 0), (self.plot_sink_0_0, 0)) self.connect((self.Transfer_function_Response_0, 0), (self.blocks_file_meta_sink_0, 0))
def __init__(self, sym_rate=256, samp_per_sym=256, nominal_uplink_freq=2041.95e6*0 + 2041.9479e6 + 1e6*0, lo_off=5e6 * 0, tx_gain=15*0 + 13.5*0, backoff=0.150*0 + (0.6+0.1)*0 + 1e-3, record_path='/media/balint/PATRIOT/ICE/TX/'): grc_wxgui.top_block_gui.__init__(self, title="Uplink") ################################################## # Parameters ################################################## self.sym_rate = sym_rate self.samp_per_sym = samp_per_sym self.nominal_uplink_freq = nominal_uplink_freq self.lo_off = lo_off self.tx_gain = tx_gain self.backoff = backoff self.record_path = record_path ################################################## # Variables ################################################## self.time_format = time_format = "%Y-%d-%m_%H-%M-%S" self.time_now = time_now = time.strftime(time_format) self.samp_rate = samp_rate = 250000 self.pre_resamp_rate = pre_resamp_rate = sym_rate * samp_per_sym self.f1 = f1 = 9000.0 self.f0 = f0 = 7500.0 self.resamp_rate = resamp_rate = float(samp_rate)/float(pre_resamp_rate) self.pm = pm = 1.2*0 + 1.0 self.nominal_uplink_freq_chooser = nominal_uplink_freq_chooser = nominal_uplink_freq self.manual_doppler = manual_doppler = 0 self.file_name = file_name = time_now + ".mcfile" self.doppler = doppler = 0 self.deviation = deviation = (f1 - f0) / 2.0 self.tx_gain_user = tx_gain_user = tx_gain self.subcarrier_freq = subcarrier_freq = f0 + deviation self.source = source = 'external' self.pm_txt = pm_txt = pm self.nominal_uplink_freq_user = nominal_uplink_freq_user = nominal_uplink_freq_chooser self.lo_off_user = lo_off_user = lo_off self.length_mul = length_mul = float(samp_per_sym) * resamp_rate self.invert = invert = 1 self.final_record_path = final_record_path = os.path.join(record_path, file_name) self.final_doppler = final_doppler = doppler + manual_doppler self.backoff_user = backoff_user = backoff ################################################## # Blocks ################################################## _tx_gain_user_sizer = wx.BoxSizer(wx.VERTICAL) self._tx_gain_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._tx_gain_user_slider = forms.slider( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, minimum=0, maximum=32, num_steps=32, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_user_sizer) self._nominal_uplink_freq_user_text_box = forms.text_box( parent=self.GetWin(), value=self.nominal_uplink_freq_user, callback=self.set_nominal_uplink_freq_user, label="Nominal Uplink Freq", converter=forms.float_converter(), ) self.Add(self._nominal_uplink_freq_user_text_box) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Output FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input Phase/Mag") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Mod Clk/Data") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Output Scope") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Input") self.Add(self.nb) self._lo_off_user_text_box = forms.text_box( parent=self.GetWin(), value=self.lo_off_user, callback=self.set_lo_off_user, label="LO Offset", converter=forms.float_converter(), ) self.Add(self._lo_off_user_text_box) self._final_doppler_static_text = forms.static_text( parent=self.GetWin(), value=self.final_doppler, callback=self.set_final_doppler, label="Final Doppler", converter=forms.float_converter(), ) self.Add(self._final_doppler_static_text) self._doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.doppler, callback=self.set_doppler, label="Doppler Shift", converter=forms.float_converter(), ) self.Add(self._doppler_text_box) _backoff_user_sizer = wx.BoxSizer(wx.VERTICAL) self._backoff_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, label="Backoff", converter=forms.float_converter(), proportion=0, ) self._backoff_user_slider = forms.slider( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_backoff_user_sizer) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 52003), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.nb.GetPage(5).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(5).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=256, fft_rate=10, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, fft_in=False, always_run=False, fft_out=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F4A7C3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "", True, ) self.uhd_usrp_sink_0.set_clock_source(source, 0) self.uhd_usrp_sink_0.set_time_source(source, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(nominal_uplink_freq_user,lo_off_user), 0) self.uhd_usrp_sink_0.set_gain(tx_gain*0 + tx_gain_user, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate), decimation=int(pre_resamp_rate), taps=None, fractional_bw=None, ) self._pm_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.pm_txt, callback=self.set_pm_txt, label="Phase Moduation Index", converter=forms.float_converter(), ) self.Add(self._pm_txt_static_text) self._nominal_uplink_freq_chooser_chooser = forms.drop_down( parent=self.GetWin(), value=self.nominal_uplink_freq_chooser, callback=self.set_nominal_uplink_freq_chooser, label="Nomial Uplink Frequency", choices=[2041.9479e6, 2090.66e6], labels=['B: 2041.9479', 'A: 2090.66'], ) self.Add(self._nominal_uplink_freq_chooser_chooser) self._manual_doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.manual_doppler, callback=self.set_manual_doppler, label="Manual Doppler", converter=forms.float_converter(), ) self.Add(self._manual_doppler_text_box) self.mac_burst_tagger_0 = mac.burst_tagger('packet_len', length_mul, 256, 32*0 + 256, True, False) self.clock_and_data = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.clock_and_data.win) self.carrier = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler*0 + final_doppler, 0*backoff + backoff_user, 0) self.blocks_vector_source_x_0 = blocks.vector_source_f(tuple([1] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [1] * (samp_per_sym/4)), True, 1, []) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len", 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((2.0/3, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert, )) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.to_pmt({'ignore': True}), pmt.init_u8vector(1, 1*[0])), 0) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, final_record_path, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1.0/3, )) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, )) self.binary_to_pdu0 = isee3.binary_to_pdu() self.analog_sig_source_x_0 = analog.sig_source_c(pre_resamp_rate, analog.GR_COS_WAVE, subcarrier_freq, 1/1.333, 0) self.analog_phase_modulator_fc_1 = analog.phase_modulator_fc(pm / (2.0*0 + 1)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(float(deviation) / float(pre_resamp_rate) * math.pi*2.0) ################################################## # Connections ################################################## self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.clock_and_data, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.carrier, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_phase_modulator_fc_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.mac_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.mac_burst_tagger_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.analog_phase_modulator_fc_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.mac_burst_tagger_0, 0), (self.blocks_file_meta_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.binary_to_pdu0, "pdu_out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.binary_to_pdu0, "binary_in") self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.uhd_usrp_sink_0, "ctl", self.blocks_message_strobe_0_0, "trigger")
def __init__(self): gr.top_block.__init__(self, "NOAA APT Satellite Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("NOAA APT Satellite Receiver") 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", "apt_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) self._lock = threading.RLock() ################################################## # Variables ################################################## self.satellite_select = satellite_select = 137.62 self.valid_gains = valid_gains = [ 0.0, 0.9, 1.4, 2.7, 3.7, 7.7, 8.7, 12.5, 14.4, 15.7, 16.6, 19.7, 20.7, 22.9, 25.4, 28.0, 29.7, 32.8, 33.8, 36.4, 37.2, 38.6, 40.2, 42.1, 43.4, 43.9, 44.5, 48.0, 49.6 ] self.satellite_frequency = satellite_frequency = satellite_select * 1e6 self.rf_samp_rate = rf_samp_rate = 2.048e6 self.max_doppler = max_doppler = 3000 self.fsk_deviation_hz = fsk_deviation_hz = 17000 self.am_carrier = am_carrier = 2400 self.tuner_frequency = tuner_frequency = satellite_frequency - ( rf_samp_rate / 4) self.rf_gain = rf_gain = valid_gains[-1] self.rail_level = rail_level = 0.5 self.processing_rate = processing_rate = 256000 self.fm_bandwidth = fm_bandwidth = ( 2 * (fsk_deviation_hz + am_carrier)) + max_doppler self.baud_rate = baud_rate = 4160 ################################################## # Blocks ################################################## self.tabs_top = Qt.QTabWidget() self.tabs_top_widget_0 = Qt.QWidget() self.tabs_top_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_0) self.tabs_top_grid_layout_0 = Qt.QGridLayout() self.tabs_top_layout_0.addLayout(self.tabs_top_grid_layout_0) self.tabs_top.addTab(self.tabs_top_widget_0, "RF Recieve") self.tabs_top_widget_1 = Qt.QWidget() self.tabs_top_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_1) self.tabs_top_grid_layout_1 = Qt.QGridLayout() self.tabs_top_layout_1.addLayout(self.tabs_top_grid_layout_1) self.tabs_top.addTab(self.tabs_top_widget_1, "APT Signal") self.tabs_top_widget_2 = Qt.QWidget() self.tabs_top_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_top_widget_2) self.tabs_top_grid_layout_2 = Qt.QGridLayout() self.tabs_top_layout_2.addLayout(self.tabs_top_grid_layout_2) self.tabs_top.addTab(self.tabs_top_widget_2, "APT Baseband") self.top_grid_layout.addWidget(self.tabs_top, 2, 0, 1, 4) self.tabs_rf = Qt.QTabWidget() self.tabs_rf_widget_0 = Qt.QWidget() self.tabs_rf_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_0) self.tabs_rf_grid_layout_0 = Qt.QGridLayout() self.tabs_rf_layout_0.addLayout(self.tabs_rf_grid_layout_0) self.tabs_rf.addTab(self.tabs_rf_widget_0, "Spectrum") self.tabs_rf_widget_1 = Qt.QWidget() self.tabs_rf_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_1) self.tabs_rf_grid_layout_1 = Qt.QGridLayout() self.tabs_rf_layout_1.addLayout(self.tabs_rf_grid_layout_1) self.tabs_rf.addTab(self.tabs_rf_widget_1, "Waterfall") self.tabs_rf_widget_2 = Qt.QWidget() self.tabs_rf_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_rf_widget_2) self.tabs_rf_grid_layout_2 = Qt.QGridLayout() self.tabs_rf_layout_2.addLayout(self.tabs_rf_grid_layout_2) self.tabs_rf.addTab(self.tabs_rf_widget_2, "Scope") self.tabs_top_layout_0.addWidget(self.tabs_rf) self.tabs_apt_data = Qt.QTabWidget() self.tabs_apt_data_widget_0 = Qt.QWidget() self.tabs_apt_data_layout_0 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_0) self.tabs_apt_data_grid_layout_0 = Qt.QGridLayout() self.tabs_apt_data_layout_0.addLayout(self.tabs_apt_data_grid_layout_0) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_0, "Scope") self.tabs_apt_data_widget_1 = Qt.QWidget() self.tabs_apt_data_layout_1 = Qt.QBoxLayout( Qt.QBoxLayout.TopToBottom, self.tabs_apt_data_widget_1) self.tabs_apt_data_grid_layout_1 = Qt.QGridLayout() self.tabs_apt_data_layout_1.addLayout(self.tabs_apt_data_grid_layout_1) self.tabs_apt_data.addTab(self.tabs_apt_data_widget_1, "Raster") self.tabs_top_layout_1.addWidget(self.tabs_apt_data) self._satellite_select_options = [137.62, 137.9125, 137.1] self._satellite_select_labels = [ 'NOAA 15 (137.62 MHz)', 'NOAA 18 (137.9125 MHz)', 'NOAA 19 (137.1 MHz)' ] self._satellite_select_tool_bar = Qt.QToolBar(self) self._satellite_select_tool_bar.addWidget( Qt.QLabel("Satellite Select" + ": ")) self._satellite_select_combo_box = Qt.QComboBox() self._satellite_select_tool_bar.addWidget( self._satellite_select_combo_box) for label in self._satellite_select_labels: self._satellite_select_combo_box.addItem(label) self._satellite_select_callback = lambda i: Qt.QMetaObject.invokeMethod( self._satellite_select_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._satellite_select_options.index(i))) self._satellite_select_callback(self.satellite_select) self._satellite_select_combo_box.currentIndexChanged.connect( lambda i: self.set_satellite_select(self._satellite_select_options[ i])) self.top_grid_layout.addWidget(self._satellite_select_tool_bar, 0, 0, 1, 1) self._rf_gain_options = valid_gains self._rf_gain_labels = map(str, self._rf_gain_options) self._rf_gain_tool_bar = Qt.QToolBar(self) self._rf_gain_tool_bar.addWidget(Qt.QLabel("RF Gain" + ": ")) self._rf_gain_combo_box = Qt.QComboBox() self._rf_gain_tool_bar.addWidget(self._rf_gain_combo_box) for label in self._rf_gain_labels: self._rf_gain_combo_box.addItem(label) self._rf_gain_callback = lambda i: Qt.QMetaObject.invokeMethod( self._rf_gain_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._rf_gain_options.index(i))) self._rf_gain_callback(self.rf_gain) self._rf_gain_combo_box.currentIndexChanged.connect( lambda i: self.set_rf_gain(self._rf_gain_options[i])) self.top_grid_layout.addWidget(self._rf_gain_tool_bar, 0, 1, 1, 1) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.50) self.qtgui_waterfall_sink_x_0.enable_grid(False) if not False: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-40, 0) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_1.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( baud_rate / 2, #size baud_rate, #samp_rate 'APT Full Line', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-0.5, 1.5) self.qtgui_time_sink_x_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0.01, 0, 'SyncA') self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_0.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size processing_rate // 2, #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.tabs_rf_layout_2.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f( baud_rate, 120 * 3, baud_rate // 2, ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0.set_intensity_range(-0.5, 1.5) self.qtgui_time_raster_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [1, 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_time_raster_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance( self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_apt_data_layout_1.addWidget( self._qtgui_time_raster_sink_x_0_win) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 16.64e3, #bw "", #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(-40, 0) 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(False) self.qtgui_freq_sink_x_1_0.set_fft_average(0.2) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not True: 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 = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] 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.tabs_top_layout_2.addWidget(self._qtgui_freq_sink_x_1_0_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype satellite_frequency, #fc processing_rate // 2, #bw "", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-100, 0) self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(0.2) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not True: 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 = ["Raw", "AGC Output", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance( self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_rf_layout_0.addWidget(self._qtgui_freq_sink_x_1_win) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, processing_rate // 2, fm_bandwidth + 1e3, 1e3, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 2, firdes.low_pass(1, processing_rate, 60e3, 15e3, firdes.WIN_HAMMING, 6.76)) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, processing_rate, True) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/Users/bjmclaug/Downloads/noaa-12_256k.dat", False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_float * 1, "/Users/bjmclaug/source/stem_station/noaa12_sample.dat", baud_rate, 1, blocks.GR_FILE_FLOAT, False, baud_rate * (60 * 20), "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.apt_am_demod_0 = apt_am_demod( parameter_apt_gain=1, parameter_samp_rate=processing_rate / 2, ) self.analog_rail_ff_0_0 = analog.rail_ff(-rail_level, rail_level) self.analog_rail_ff_0 = analog.rail_ff(-rail_level, rail_level) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( (processing_rate // 2) / (2 * math.pi * fsk_deviation_hz / 8.0)) self.analog_agc3_xx_0 = analog.agc3_cc(0.25, 0.5, 0.9, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(1) ################################################## # Connections ################################################## self.connect((self.analog_agc3_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.apt_am_demod_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_rail_ff_0_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.apt_am_demod_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.analog_rail_ff_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_waterfall_sink_x_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.factor_of_baud = factor_of_baud = 8 self.baud_rate = baud_rate = 4160 self.signal_gain = signal_gain = 5 self.samp_rate = samp_rate = 11025 self.demod_rate = demod_rate = baud_rate * factor_of_baud ################################################## # Blocks ################################################## self._signal_gain_range = Range(0, 800, 1, 5, 200) self._signal_gain_win = RangeWidget(self._signal_gain_range, self.set_signal_gain, "Signal Gain", "counter_slider", float) self.top_layout.addWidget(self._signal_gain_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( baud_rate / 2, #size baud_rate, #samp_rate 'APT Full Line', #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-0.5, 0.5) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0.01, 0, 'SyncA') self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0 = qtgui.time_raster_sink_f( baud_rate, 128, int(baud_rate / 2), ([]), ([]), "", 1, ) self.qtgui_time_raster_sink_x_0.set_update_time(0.5) self.qtgui_time_raster_sink_x_0.set_intensity_range(-0.5, 0.75) self.qtgui_time_raster_sink_x_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [1, 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_time_raster_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_raster_sink_x_0_win) self.fm_demodulated_source = blocks.wavfile_source("/home/brian/stem_station/sample_files/N18_4827.wav", False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_float*1, "/home/brian/stem_station/raw_meta1.dat", baud_rate, 1, blocks.GR_FILE_FLOAT, False, baud_rate * (60 * 20), "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.apt_am_demod_0 = apt_am_demod( parameter_apt_gain=signal_gain, parameter_samp_rate=samp_rate, ) ################################################## # Connections ################################################## self.connect((self.apt_am_demod_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_raster_sink_x_0, 0)) self.connect((self.apt_am_demod_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.apt_am_demod_0, 0)) self.connect((self.fm_demodulated_source, 0), (self.blocks_throttle_0, 0))
def __init__(self, options): grc_wxgui.top_block_gui.__init__(self, title="DSSDR") self.initialized = False self.stopped = False self.options = copy.copy(options) self._constellation = digital.constellation_bpsk() self._excess_bw = options.excess_bw self._phase_bw = options.phase_bw self._freq_bw = options.freq_bw self._timing_bw = options.timing_bw self._if_freq = options.if_freq self._timing_max_dev= 1.5 self._demod_class = digital.bpsk_demod # the demodulator_class we're using self._chbw_factor = options.chbw_factor # channel filter bandwidth factor self._samples_per_second = 2e6 self._nav_samples_per_second = 16e6 self._down_decim = 1 self._down_samples_per_second = self._scope_sample_rate = self._samples_per_second/self._down_decim self._up_samples_per_second = 1e6 self._asm_threshold = 0 self._access_code = None self._tm_packet_id = 4 self._timestamp_id = 5 self._down_bitrate = options.bitrate self._up_bitrate = options.up_bitrate self._up_samples_per_symbol = self._up_samples_per_second/self._up_bitrate self._samples_per_symbol = self._samples_per_second/self._down_decim/self._down_bitrate self._down_sub_freq = options.down_sub_freq self._up_sub_freq = 25e3 self._tm_len = 8920 self._up_tm_len = 8920 self._coding_method = options.coding_method self._up_coding_method = 'None' self._up_subcarrier = 'Square' self._rs_i = 1 self._ccsds_channel = 38 self._uhd_carrier_offset = 10e3 self._turn_div = 749 self._turn_mult = 880 self._modulation_index = 'pi/3' self._up_modulation_index = 1.047 self._max_carrier_offset = 0.1 self._dssdr_mixer_freq = options.rf_freq self._up_coding_rate = '1' self._down_coding_rate = '1' self._down_conv_en = "False" self._down_randomizer_en = options.down_randomizer_en self._down_manchester_en = options.down_manchester_en self._up_conv_en = "False" self._up_idle_sequence = "\\x55" self._down_default_gain = 64 self._up_default_gain = 44 self._up_en = True if self._access_code is None: self._access_code = packet_utils.default_access_code #Construct the lookup table for parameter-setting functions self.param_setters = { "DSSDR_CHANNEL": self.setChannel, "DSSDR_LO_FREQ": self.setLOFreq, "DSSDR_REF_FREQ": self.setRefFreq, "DSSDR_TURN_MULT": self.setTurnMult, "DSSDR_TURN_DIV": self.setTurnDiv, "DSSDR_UP_GAIN": self.setUpGain, "DSSDR_DOWN_GAIN": self.setDownGain, "DSSDR_UP_BITRATE": self.setUpBitrate, "DSSDR_DOWN_BITRATE": self.setDownBitrate, "DSSDR_DOWN_SAMPLE_RATE": self.setSampRate, "DSSDR_UP_SUB_FREQ": self.setUpSubFreq, "DSSDR_DOWN_SUB_FREQ": self.setDownSubFreq, "DSSDR_DOPPLER_REPORT": self.dopplerReport, "DSSDR_PN_RANGE": self.rangePN, "DSSDR_SEQUENTIAL_RANGE": self.rangeSequential, "DSSDR_DOWN_CODING_METHOD": self.setDownCodingMethod, "DSSDR_UP_CODING_METHOD": self.setUpCodingMethod, "DSSDR_DOWN_TM_LEN": self.setTMLen, "DSSDR_UP_TM_LEN": self.setUpTMLen, "DSSDR_DOWN_MOD_IDX": self.setDownModulationIndex, "DSSDR_UP_MOD_IDX": self.setUpModulationIndex, "DSSDR_DOWN_CONV_EN": self.setDownConvEn, "DSSDR_UP_CONV_EN": self.setUpConvEn, "DSSDR_ASM_TOL": self.setASMThreshold, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_UP_IDLE": self.setUpIdleSequence, "DSSDR_UP_EN": self.setUpEn, "DSSDR_SYNC_TIME": self.syncSDRTime, "DSSDR_UP_SWEEP": self.freqSweep, "DSSDR_DOWN_ACQUIRE": self.acquireCarrier, "DSSDR_INPUT_SELECT": self.setPanelSelect, "DSSDR_REF_SELECT": self.setRefSelect, "DSSDR_PPS_SELECT": self.setPPSSelect } #TODO:Add status fields for things like DSSDR_REF_LOCK self._dssdr_channels = { 3: [7149597994, 8400061729], 4: [7150753857, 8401419752], 5: [7151909723, 8402777779], 6: [7153065586, 8404135802], 7: [7154221449, 8405493825], 8: [7155377316, 8406851853], 9: [7156533179, 8408209877], 10: [7157689045, 8409567903], 11: [7158844908, 8410925927], 12: [7160000771, 8412283950], 13: [7161156637, 8413641977], 14: [7162312500, 8415000000], 15: [7163468363, 8416358023], 16: [7164624229, 8417716050], 17: [7165780092, 8419074073], 18: [7166935955, 8420432097], 19: [7168091821, 8421790123], 20: [7169247684, 8423148147], 21: [7170403551, 8424506175], 22: [7171559414, 8425864198], 23: [7172715277, 8427222221], 24: [7173871143, 8428580248], 25: [7175027006, 8429938271], 26: [7176182869, 8431296295], 27: [7177338735, 8432654321], 28: [7178494598, 8434012345], 29: [7179650464, 8435370372], 30: [7180806327, 8436728395], 31: [7181962190, 8438086418], 32: [7183118057, 8439444446], 33: [7184273920, 8440802469], 34: [7185429783, 8442160493], 35: [7186585649, 8443518520], 36: [7187741512, 8444876543], 37: [7188897378, 8446234570], 38: [7190000000, 8450000000], } #FLOWGRAPH STUFF if options.test == True: self.u = blks2.tcp_source( itemsize=gr.sizeof_gr_complex*1, addr="", port=12905, server=True ) elif options.fromfile == True: self.u2 = blocks.file_meta_source("iq_in.dat") self.u = blocks.throttle(gr.sizeof_gr_complex*1, self._samples_per_second) elif options.frombitlog == True: self.u3 = blocks.file_source(gr.sizeof_char, "bitstream_recording.in", True) self.u2 = blocks.uchar_to_float() self.u1 = blocks.throttle(gr.sizeof_float*1, self._down_bitrate) self.u = blocks.add_const_ff(-0.5) else: self.u = uhd.usrp_source(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u.set_clock_source("external") self.u.set_time_source("external") self.u.set_samp_rate(self._samples_per_second) self.u.set_antenna("RX2") self.u.set_gain(self._down_default_gain) self.frontend = dfi.dssdrFrontendInterface(self.u) if options.debug_pps == True: self.debug_pps = blocks.tag_debug(gr.sizeof_gr_complex, "debug-pps", "rx_time") if options.tofile == True: self.u_tx = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_out.dat", self._up_samples_per_second) elif options.tonull == True: self.u_tx = blocks.null_sink(gr.sizeof_gr_complex) else: self.u_tx = uhd.usrp_sink(device_addr=options.args, stream_args=uhd.stream_args('fc32')) self.u_tx.set_clock_source("external") self.u_tx.set_time_source("external") self.u_tx.set_samp_rate(self._up_samples_per_second) self.u_tx.set_antenna("TX/RX") self.u_tx.set_gain(self._up_default_gain) #GUI STUFF if options.graphics == True: self.nb0 = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "RX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "TX") self.nb0.AddPage(grc_wxgui.Panel(self.nb0), "Nav") self.Add(self.nb0) self.constellation_scope = scopesink2.scope_sink_c( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.constellation_scope.win) #self.constellation_scope.win.set_marker('plus') self._scope_is_fft = False self.time_scope = scopesink2.scope_sink_f( self.nb0.GetPage(0).GetWin(), title="Scope Plot", sample_rate=self._scope_sample_rate, v_scale=0, v_offset=0, t_scale=.005, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb0.GetPage(0).Add(self.time_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.time_scope.win) self.fft_scope = fftsink2.fft_sink_c( self.nb0.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=self._scope_sample_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb0.GetPage(0).Add(self.fft_scope.win) self.nb0.GetPage(0).GetWin()._box.Hide(self.fft_scope.win) self.row1_sizer = wx.BoxSizer(wx.HORIZONTAL) self.recording_onoff_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Off', callback=self.setRecording, label="IQ Recording", choices=['Off','On'], labels=[], style=wx.RA_HORIZONTAL, ) self.front_panel_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='RF', callback=self.setPanelSelect, label="Input Select", choices=['RF','IF'], labels=[], style=wx.RA_HORIZONTAL, ) self.ref_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setRefSelect, label="Ref Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.pps_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Internal', callback=self.setPPSSelect, label="PPS Select", choices=['Internal','External'], labels=[], style=wx.RA_HORIZONTAL, ) self.sync_button = forms.button( parent=self.nb0.GetPage(0).GetWin(), value='Sync to PPS', callback=self.syncSDRTime, choices=['Sync to PPS'], style=wx.RA_HORIZONTAL, ) self.ref_locked_text = forms.static_text( parent=self.nb0.GetPage(0).GetWin(), value="", callback=self.setRefLocked, label="", converter=forms.str_converter(), ) self.row1_sizer.Add(self.recording_onoff_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.front_panel_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.pps_chooser, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.sync_button, flag=wx.ALIGN_CENTER) self.row1_sizer.Add(self.ref_locked_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(0).Add(self.row1_sizer) self.complex_scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='Constellation', callback=self.setComplexScopeStyle, label="Complex Scope", choices=['Constellation','FFT'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.complex_scope_chooser) self.scope_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value='USRP', callback=self.setScopePoint, label="Scope Probe Point", choices=['USRP','Carrier Tracking','Sub-Carrier Costas','Sub-Carrier Sync','Data Sync'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self.scope_chooser) self._bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_bitrate, callback=self.setDownBitrate, label="Symbol Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._bitrate_text_box) self._samprate_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._samples_per_second, callback=self.setSampRate, label="Sampling Rate", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._samprate_text_box) self._subcfreq_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_sub_freq, callback=self.setDownSubFreq, label="Downlink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._subcfreq_text_box) self._mod_index_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._modulation_index, callback=self.setDownModulationIndex, label="Modulation Index", choices=['pi/2', 'pi/3'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._mod_index_chooser) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._tm_len, callback=self.setTMLen, label="Downlink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._coding_method, callback=self.setDownCodingMethod, label="Coding", choices=['None', 'RS', 'Turbo 1/2', 'Turbo 1/3', 'Turbo 1/4', 'Turbo 1/6'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._down_conv_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_conv_en, callback=self.setDownConvEn, label="Convolutional Decode", true="True", false="False", ) self.nb0.GetPage(0).Add(self._down_conv_check_box) self._down_randomizer_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_randomizer_en, callback=self.setDownRandomizerEn, label="De-randomizer", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_randomizer_check_box) self._down_manchester_check_box = forms.check_box( parent=self.nb0.GetPage(0).GetWin(), value=self._down_manchester_en, callback=self.setDownManchesterEn, label="Manchester Decode", true=True, false=False, ) self.nb0.GetPage(0).Add(self._down_manchester_check_box) self._pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._asm_threshold, callback=self.setASMThreshold, label="ASM Error Tolerance (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(0).Add(self._pktlen_text_box) self._coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(0).GetWin(), value=self._rs_i, callback=self.setRSI, label="Reed-Solomon Interleaving Depth", choices=[1,5], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(0).Add(self._coding_chooser) self._ccsds_chan_text_box = forms.text_box( parent=self.nb0.GetPage(0).GetWin(), value=self._ccsds_channel, callback=self.setChannel, label="CCSDS Channel", converter=forms.int_converter(), ) self.nb0.GetPage(0).Add(self._ccsds_chan_text_box) self.setChannel(self._ccsds_channel) if options.test == True or options.fromfile == True or options.frombitlog == True: glow = 0.0 ghigh = 1.0 cur_g = 0.5 else: g = self.u.get_gain_range() cur_g = self._down_default_gain # some configurations don't have gain control if g.stop() <= g.start(): glow = 0.0 ghigh = 1.0 else: glow = g.start() ghigh = g.stop() self._uhd_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(0).GetWin(), sizer=self._uhd_gain_slider, label="USRP RX Gain", weight=3, min=int(glow), max=int(ghigh), value=cur_g, callback=self.setDownGain ) self.nb0.GetPage(0).Add(self._uhd_gain_slider) #TX chain GUI components if options.test == True or options.tofile == True or options.tonull == True: gtxlow = 0.0 gtxhigh = 1.0 cur_gtx = 0.5 else: gtx = self.u_tx.get_gain_range() cur_gtx = self._up_default_gain # some configurations don't have gain control if gtx.stop() <= gtx.start(): gtxlow = 0.0 gtxhigh = 1.0 else: gtxlow = gtx.start() gtxhigh = gtx.stop() self._up_en_chooser = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value='True', callback=self.setUpEn, label="TX Enable", true='True', false='False', ) self.nb0.GetPage(1).Add(self._up_en_chooser) self._uhd_tx_gain_slider = wx.BoxSizer(wx.HORIZONTAL) form.slider_field( parent=self.nb0.GetPage(1).GetWin(), sizer=self._uhd_tx_gain_slider, label="USRP TX Gain", weight=3, min=int(gtxlow), max=int(gtxhigh), value=cur_gtx, callback=self.setUpGain ) self.nb0.GetPage(1).Add(self._uhd_tx_gain_slider) self._subcfreq_up_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_sub_freq, callback=self.setUpSubFreq, label="Uplink Subcarrier Frequency", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._subcfreq_up_text_box) self._up_bitrate_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_bitrate, callback=self.setUpBitrate, label="Uplink Bitrate", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_bitrate_text_box) self._up_data_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="1234ABCD", callback=self.txData, label="TX Data", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._up_data_text_box) self._up_mod_index_chooser = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_modulation_index, callback=self.setUpModulationIndex, label="Uplink Modulation Index", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_mod_index_chooser) self._up_coding_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_coding_method, callback=self.setUpCodingMethod, label="Coding", choices=['None', 'RS'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._up_coding_chooser) self._subcarrier_chooser = forms.radio_buttons( parent=self.nb0.GetPage(1).GetWin(), value=self._up_subcarrier, callback=self.setUpSubcarrier, label="Subcarrier Type", choices=['Square','Sine'], labels=[], style=wx.RA_HORIZONTAL, ) self.nb0.GetPage(1).Add(self._subcarrier_chooser) self._up_conv_check_box = forms.check_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_conv_en, callback=self.setUpConvEn, label="Convolutional Encode", true="True", false="False", ) self.nb0.GetPage(1).Add(self._up_conv_check_box) self._up_pktlen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_tm_len, callback=self.setUpTMLen, label="Uplink Packet Length (bits)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._up_pktlen_text_box) self._uhd_offset_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._uhd_carrier_offset, callback=self.setUHDCarrierOffset, label="USRP Offset Frequency (Hz)", converter=forms.float_converter(), ) self.nb0.GetPage(1).Add(self._uhd_offset_text_box) self._sweep_gen_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value="rf2_1", callback=self.freqSweep, label="Frequency Sweep Profile", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._sweep_gen_text_box) self._idle_sequence_text_box = forms.text_box( parent=self.nb0.GetPage(1).GetWin(), value=self._up_idle_sequence, callback=self.setUpIdleSequence, label="Uplink Idle Sequence", converter=forms.str_converter(), ) self.nb0.GetPage(1).Add(self._idle_sequence_text_box) self._pn_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangePN, label="Queue PN Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._pn_ranging_text_box) self._sequential_ranging_text_box = forms.text_box( parent=self.nb0.GetPage(2).GetWin(), value="", callback=self.rangeSequential, label="Queue Sequential Ranging", converter=forms.str_converter(), ) self.nb0.GetPage(2).Add(self._sequential_ranging_text_box) self.row2_sizer = wx.BoxSizer(wx.HORIZONTAL) self.freq_acq_button = forms.button( parent=self.nb0.GetPage(2).GetWin(), value='Acquire Carrier Offset', callback=self.acquireCarrier, choices=['Acquire Carrier Offset'], style=wx.RA_HORIZONTAL, ) self.carrier_offset_text = forms.static_text( parent=self.nb0.GetPage(2).GetWin(), value="", label="", converter=forms.str_converter(), ) self.row2_sizer.Add(self.freq_acq_button, flag=wx.ALIGN_CENTER) self.row2_sizer.Add(self.carrier_offset_text, flag=wx.ALIGN_CENTER) self.nb0.GetPage(2).Add(self.row2_sizer) self.file_sink = blocks.file_meta_sink(gr.sizeof_gr_complex, "iq_recording.dat", self._samples_per_second) self.file_sink.close() self.iq_recording_ctr = 0 # Selection logic to switch between recording and normal flowgraph routes # NOTE: u_valve logic is implemented backwards in GNURadio.... #self.u_valve = blks2.valve( # item_size=gr.sizeof_gr_complex, # open=False #) # Temporary code used to verify coherent turnaround self.turnaround_mixer = blocks.multiply_cc() self.turnaround_mixer_source = analog.sig_source_c(self._down_samples_per_second, analog.GR_SIN_WAVE, -25e3, 1.0) self.turnaround_iir = filter.single_pole_iir_filter_cc(0.0001) self.turnaround_null = blocks.null_sink(gr.sizeof_float) # PLL and associated carrier for tracking carrier frequency if residual carrier is used self.carrier_tracking = sdrp.pll_freq_acq_cc(math.pi/2000, math.pi, -math.pi, int(options.acq_samples)) self.imag_to_float = blocks.complex_to_imag() #Suppressed carrier requires costas after subcarrier mixer self.subcarrier_costas = digital.costas_loop_cc(0.001, 2) self.real_to_float = blocks.complex_to_real() #Square wave subcarrier sync self.subcarrier_sync = sdrp.square_sub_tracker_ff(0.001, 2*self._down_sub_freq/self._down_samples_per_second*1.0001, 2*self._down_sub_freq/self._down_samples_per_second*0.9999) #Data sync self.data_sync = sdrp.square_data_tracker_ff(0.001, self._down_bitrate/self._down_samples_per_second*1.001, self._down_bitrate/self._down_samples_per_second*0.999) #Data framing self.soft_correlator = sdrp.correlate_soft_access_tag_ff(conv_packed_binary_string_to_1_0_string('\x1A\xCF\xFC\x1D'), self._asm_threshold, "asm_corr") self.conv_decoder = sdrp.ccsds_tm_conv_decoder("asm_corr") self.de_randomizer = sdrp.ccsds_tm_derandomizer("asm_corr") self.tm_framer = sdrp.ccsds_tm_framer(self._tm_packet_id, self._timestamp_id, "asm_corr", "rx_time", self._down_bitrate) self.tm_framer.setFrameLength(self._tm_len) self._current_scope_block = None self._current_scoped_block = self.u self._current_scoped_block_port = 0 self._recording = 'Off' #TX path in flowgraph self.pkt_gen_msgq = gr.msg_queue(10) self.pkt_gen = sdrp.ccsds_tm_tx(self._tm_packet_id, self._timestamp_id, 1.0, 16, self.pkt_gen_msgq) self.conj = blocks.conjugate_cc() #Sweep generator for transponder lock self.sweep_gen = sdrp.sweep_generator_cc(self._up_samples_per_second) # DSSDR subcarrier mixer (either 25 kHz or 0 kHz depending on baud rate) self.up_subcarrier_mixer = blocks.multiply_ff() self.subcarrier_mixer_source_tx = analog.sig_source_f(self._up_samples_per_second, analog.GR_SQR_WAVE, 25e3, 2.0, -1.0) self.phase_mod_tx = analog.phase_modulator_fc(self._up_modulation_index) self.tx_attenuator = blocks.multiply_const_cc((0.1+0.0j)) #Add in bit recorder if needed if self.options.bitlog: self.bit_slicer = digital.binary_slicer_fb() self.bit_recorder = blocks.file_sink(1, "bitstream_recording.out") self.setDownCodingMethod(self._coding_method) self.setUpCodingMethod("None") self.setUpSubcarrier(self._up_subcarrier) self.setDownBitrate(self._down_bitrate) self.setUpBitrate(self._up_bitrate) self.setDownModulationIndex(self._modulation_index) self.setUpModulationIndex(self._up_modulation_index) self.setDownConvEn(self._down_conv_en) self.setUpConvEn(self._up_conv_en) self.setUpIdleSequence(self._up_idle_sequence) self.setDownRandomizerEn(self._down_randomizer_en) self.setDownManchesterEn(self._down_manchester_en) #Connection to outside world self.socket_pdu = blocks.socket_pdu("TCP_SERVER", "127.0.0.1", "12902", 10000) self.sdrp_interpreter = sdrp.sdrp_packet_interpreter() self.msg_connect(self.tm_framer, "tm_frame_out", self.sdrp_interpreter, "sdrp_pdu_in") self.msg_connect(self.sdrp_interpreter, "socket_pdu_out", self.socket_pdu, "pdus") self.msg_connect(self.socket_pdu, "pdus", self.sdrp_interpreter, "socket_pdu_in") self.msg_connect(self.sdrp_interpreter,"sdrp_pdu_out", self.pkt_gen, "ccsds_tx_msg_in") if options.test == False and options.fromfile == False and options.frombitlog == False: _threading.Thread(target=self.watchRef).start() self.initialized = True print "DS-SDR Initialized"
def test_001(self): N = 1000 outfile = "test_out.dat" detached = False samp_rate = 200000 key = pmt.intern("samp_rate") val = pmt.from_double(samp_rate) extras = pmt.make_dict() extras = pmt.dict_add(extras, key, val) data = sig_source_c(samp_rate, 1000, 1, N) src = blocks.vector_source_c(data) fsnk = blocks.file_meta_sink(gr.sizeof_gr_complex, outfile, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, extras, detached) fsnk.set_unbuffered(True) self.tb.connect(src, fsnk) self.tb.run() fsnk.close() handle = open(outfile, "rb") header_str = handle.read(blocks.parse_file_metadata.HEADER_LENGTH) if(len(header_str) == 0): self.assertFalse() try: header = pmt.deserialize_str(header_str) except RuntimeError: self.assertFalse() info = blocks.parse_header(header, False) extra_str = handle.read(info["extra_len"]) self.assertEqual(len(extra_str) > 0, True) handle.close() try: extra = pmt.deserialize_str(extra_str) except RuntimeError: self.assertFalse() extra_info = blocks.parse_extra_dict(extra, info, False) self.assertEqual(info['rx_rate'], samp_rate) self.assertEqual(pmt.to_double(extra_info['samp_rate']), samp_rate) # Test file metadata source src.rewind() fsrc = blocks.file_meta_source(outfile, False) vsnk = blocks.vector_sink_c() tsnk = blocks.tag_debug(gr.sizeof_gr_complex, "QA") ssnk = blocks.vector_sink_c() self.tb.disconnect(src, fsnk) self.tb.connect(fsrc, vsnk) self.tb.connect(fsrc, tsnk) self.tb.connect(src, ssnk) self.tb.run() fsrc.close() # Test to make sure tags with 'samp_rate' and 'rx_rate' keys # were generated and received correctly. tags = tsnk.current_tags() for t in tags: if(pmt.eq(t.key, pmt.intern("samp_rate"))): self.assertEqual(pmt.to_double(t.value), samp_rate) elif(pmt.eq(t.key, pmt.intern("rx_rate"))): self.assertEqual(pmt.to_double(t.value), samp_rate) # Test that the data portion was extracted and received correctly. self.assertComplexTuplesAlmostEqual(vsnk.data(), ssnk.data(), 5) os.remove(outfile)
def __init__(self, decim=50, decim_df=.2, decim_f=.4, device_address="type=b200", device_arguments="master_clock_rate=30.72e6", df_ref=0, df_test=10e3, f_sample=960e3*4, f_sig=6e9, g_ref=0, g_sig=0, g_test=49, n_samples=1<<24, name="test", pass_tags=False, port_base=6880, f_dsp=0): gr.top_block.__init__(self, "Ampm Cli") ################################################## # Parameters ################################################## self.decim = decim self.decim_df = decim_df self.decim_f = decim_f self.device_address = device_address self.device_arguments = device_arguments self.df_ref = df_ref self.df_test = df_test self.f_sample = f_sample self.f_sig = f_sig self.g_ref = g_ref self.g_sig = g_sig self.g_test = g_test self.n_samples = n_samples self.name = name self.pass_tags = pass_tags self.port_base = port_base self.f_dsp = f_dsp ################################################## # Variables ################################################## self.info = info = {"name":name, "f_sig":f_sig, "df_ref":df_ref, "f_sample":f_sample, "decim":decim} self.filename = filename = "{:s}_f0{:.5g}_df{:.5g}_fs{:.5g}_d{:.5g}".format(name, f_sig/1e6, df_ref, f_sample/1e6, decim) ################################################## # Blocks ################################################## self.zeromq_sub_source_0_2_0 = zeromq.sub_source(gr.sizeof_float, decim**0, "tcp://localhost:{}".format(port_base + 9), 100, pass_tags) self.zeromq_sub_source_0_2 = zeromq.sub_source(gr.sizeof_gr_complex, decim**0, "tcp://localhost:{}".format(port_base + 0), 100, pass_tags) self.zeromq_sub_source_0_1 = zeromq.sub_source(gr.sizeof_gr_complex, decim**1, "tcp://localhost:6881", 100, pass_tags) self.zeromq_sub_source_0_0 = zeromq.sub_source(gr.sizeof_gr_complex, decim**3, "tcp://localhost:6883", 100, pass_tags) self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, decim**2, "tcp://localhost:6882", 100, pass_tags) self.zeromq_pub_sink_0_1_2 = zeromq.pub_sink(gr.sizeof_float, decim**0, "tcp://*:{}".format(port_base + 9), 100, pass_tags) self.zeromq_pub_sink_0_1_1 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**1, "tcp://*:{}".format(port_base + 1), 100, pass_tags) self.zeromq_pub_sink_0_1_0_0 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**3, "tcp://*:{}".format(port_base + 3), 100, pass_tags) self.zeromq_pub_sink_0_1_0 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**2, "tcp://*:{}".format(port_base + 2), 100, pass_tags) self.zeromq_pub_sink_0_1 = zeromq.pub_sink(gr.sizeof_gr_complex, decim**0, "tcp://*:{}".format(port_base + 0), 100, pass_tags) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join((device_address, device_arguments)), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0_0.set_subdev_spec("A:A A:B", 0) self.uhd_usrp_source_0_0.set_time_unknown_pps(uhd.time_spec()) self.uhd_usrp_source_0_0.set_samp_rate(f_sample) self.uhd_usrp_source_0_0.set_center_freq(uhd.tune_request(target_freq=f_sig , dsp_freq=f_dsp, rf_freq_policy=uhd.tune_request.POLICY_AUTO, dsp_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0_0.set_gain(g_sig, 0) self.uhd_usrp_source_0_0.set_bandwidth(30.72e6, 0) self.uhd_usrp_source_0_0.set_center_freq(uhd.tune_request(target_freq=f_sig + df_ref, dsp_freq=f_dsp, rf_freq_policy=uhd.tune_request.POLICY_AUTO, dsp_freq_policy=uhd.tune_request.POLICY_MANUAL), 1) self.uhd_usrp_source_0_0.set_gain(g_ref, 1) self.uhd_usrp_source_0_0.set_bandwidth(30.72e6, 1) self.blocks_stream_to_vector_0_1_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**3) self.blocks_stream_to_vector_0_1 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**2) self.blocks_stream_to_vector_0_0_0 = blocks.stream_to_vector(gr.sizeof_float*1, decim**0) self.blocks_stream_to_vector_0_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**0) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, decim**1) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*decim**3, n_samples/decim**3) self.blocks_head_0_1 = blocks.head(gr.sizeof_gr_complex*decim**1, n_samples/decim**1) self.blocks_head_0_0 = blocks.head(gr.sizeof_gr_complex*decim**3, n_samples/decim**3) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*decim**2, n_samples/decim**2) self.blocks_file_meta_sink_0_3_0 = blocks.file_meta_sink(gr.sizeof_float*decim**0, "{}_w.bin".format(filename), f_sample, decim**3, blocks.GR_FILE_FLOAT, False, 1<<20, "", True) self.blocks_file_meta_sink_0_3_0.set_unbuffered(False) self.blocks_file_meta_sink_0_3 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**0, "{}_0.bin".format(filename), f_sample, decim**3, blocks.GR_FILE_FLOAT, True, 1<<20, "", True) self.blocks_file_meta_sink_0_3.set_unbuffered(False) self.blocks_file_meta_sink_0_1 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**1, "{}_1.bin".format(filename), f_sample, decim**2, blocks.GR_FILE_FLOAT, True, 1<<20, "", True) self.blocks_file_meta_sink_0_1.set_unbuffered(False) self.blocks_file_meta_sink_0_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**3, "{}_3.bin".format(filename), f_sample, decim**0, blocks.GR_FILE_FLOAT, True, 1<<20, "", True) self.blocks_file_meta_sink_0_0.set_unbuffered(False) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*decim**2, "{}_2.bin".format(filename), f_sample, decim**1, blocks.GR_FILE_FLOAT, True, 1<<20, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_ctrlport_probe2_c_0_1 = blocks.ctrlport_probe2_c("d0", "diff0", 1024, gr.DISPTIME) self.blocks_ctrlport_probe2_c_0_0 = blocks.ctrlport_probe2_c("b", "input b", 1024, gr.DISPTIME) self.blocks_ctrlport_probe2_c_0 = blocks.ctrlport_probe2_c("a", "input a", 1024, gr.DISPTIME) self.blocks_ctrlport_monitor_0 = not True or monitor() self.Ampm_0 = Ampm( decim=decim, decim_df=decim_df, decim_f=decim_f, ) ################################################## # Connections ################################################## self.connect((self.Ampm_0, 0), (self.blocks_ctrlport_probe2_c_0_1, 0)) self.connect((self.Ampm_0, 2), (self.blocks_stream_to_vector_0, 0)) self.connect((self.Ampm_0, 3), (self.blocks_stream_to_vector_0_0, 0)) self.connect((self.Ampm_0, 4), (self.blocks_stream_to_vector_0_0_0, 0)) self.connect((self.Ampm_0, 1), (self.blocks_stream_to_vector_0_1, 0)) self.connect((self.Ampm_0, 0), (self.blocks_stream_to_vector_0_1_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.blocks_head_0_0, 0), (self.blocks_file_meta_sink_0_0, 0)) self.connect((self.blocks_head_0_1, 0), (self.blocks_file_meta_sink_0_1, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_head_0_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.zeromq_pub_sink_0_1_1, 0)) self.connect((self.blocks_stream_to_vector_0_0, 0), (self.zeromq_pub_sink_0_1, 0)) self.connect((self.blocks_stream_to_vector_0_0_0, 0), (self.zeromq_pub_sink_0_1_2, 0)) self.connect((self.blocks_stream_to_vector_0_1, 0), (self.zeromq_pub_sink_0_1_0, 0)) self.connect((self.blocks_stream_to_vector_0_1_0, 0), (self.zeromq_pub_sink_0_1_0_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.Ampm_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.Ampm_0, 1)) self.connect((self.uhd_usrp_source_0_0, 0), (self.blocks_ctrlport_probe2_c_0, 0)) self.connect((self.uhd_usrp_source_0_0, 1), (self.blocks_ctrlport_probe2_c_0_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.blocks_head_0, 0)) self.connect((self.zeromq_sub_source_0_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.zeromq_sub_source_0_1, 0), (self.blocks_head_0_1, 0)) self.connect((self.zeromq_sub_source_0_2, 0), (self.blocks_file_meta_sink_0_3, 0)) self.connect((self.zeromq_sub_source_0_2_0, 0), (self.blocks_file_meta_sink_0_3_0, 0))
def __init__(self): gr.top_block.__init__(self, "uhd_to_iq") Qt.QWidget.__init__(self) self.setWindowTitle("uhd_to_iq") 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.v_gain = v_gain = 42 self.samp_rate = samp_rate = 100e3 self.f_c = f_c = 1296960000 ################################################## # Blocks ################################################## self._v_gain_range = Range(0, 80, 1, 42, 200) self._v_gain_win = RangeWidget(self._v_gain_range, self.set_v_gain, 'Gain', "counter_slider", float) self.top_layout.addWidget(self._v_gain_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_clock_source('external', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(f_c, 0) self.uhd_usrp_source_0.set_gain(v_gain, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.blocks_file_meta_sink_0_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, 'samples_iq.dat', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000, "", True) self.blocks_file_meta_sink_0_0.set_unbuffered(False) ################################################## # Connections ################################################## self.connect((self.uhd_usrp_source_0, 0), (self.blocks_file_meta_sink_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Sdr") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 5e6 self.freq = freq = 130e6 self.bandwidth = bandwidth = 1e6 self.Items_skiphead = Items_skiphead = 256 self.Items_head = Items_head = 8448 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(2), ), ) self.uhd_usrp_source_0.set_clock_rate(10e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(freq, 0) self.uhd_usrp_source_0.set_gain(0, 0) self.uhd_usrp_source_0.set_antenna('RX2', 0) self.uhd_usrp_source_0.set_bandwidth(bandwidth, 0) self.uhd_usrp_source_0.set_center_freq(freq, 1) self.uhd_usrp_source_0.set_gain(0, 1) self.uhd_usrp_source_0.set_antenna('RX2', 1) self.uhd_usrp_source_0.set_bandwidth(bandwidth, 1) self.blocks_skiphead_0_1 = blocks.skiphead(gr.sizeof_gr_complex*1, Items_skiphead) self.blocks_skiphead_0_0 = blocks.skiphead(gr.sizeof_gr_complex*1, Items_skiphead) self.blocks_interleave_1 = blocks.interleave(gr.sizeof_float*1, 1) self.blocks_head_0_0 = blocks.head(gr.sizeof_gr_complex*1, Items_head) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, Items_head) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, 'D:\\Workspace\\SDR', samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", False) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.band_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.band_pass( 1, samp_rate, 128e6, 132e6, 1e6, firdes.WIN_HAMMING, 6.76)) self.band_pass_filter_0 = filter.fir_filter_ccf(1, firdes.band_pass( 1, samp_rate, 128e6, 132e6, 1e6, firdes.WIN_HAMMING, 6.76)) ################################################## # Connections ################################################## self.connect((self.band_pass_filter_0, 0), (self.blocks_head_0, 0)) self.connect((self.band_pass_filter_0_0, 0), (self.blocks_head_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_interleave_1, 1)) self.connect((self.blocks_complex_to_float_0, 0), (self.blocks_interleave_1, 0)) self.connect((self.blocks_complex_to_float_0_0, 1), (self.blocks_interleave_1, 3)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.blocks_interleave_1, 2)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_file_meta_sink_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_skiphead_0_0, 0)) self.connect((self.blocks_head_0_0, 0), (self.blocks_skiphead_0_1, 0)) self.connect((self.blocks_interleave_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_skiphead_0_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.blocks_skiphead_0_1, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.uhd_usrp_source_0, 1), (self.band_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.band_pass_filter_0_0, 0))