def test_scrambler_descrambler_003(self): src_data = np.random.randint(0, 2, 1000, dtype=np.int8) src = blocks.vector_source_b(src_data, False) # this is the product of the other two scrambler = digital.scrambler_bb(*lfsr_args(1, 12, 10, 3, 2, 0)) descrambler1 = digital.descrambler_bb(*lfsr_args(1, 5, 3, 0)) descrambler2 = digital.descrambler_bb(*lfsr_args(1, 7, 2, 0)) dst = blocks.vector_sink_b() self.tb.connect(src, scrambler, descrambler1, descrambler2, dst) self.tb.run() # skip garbage during synchronization self.assertTrue(np.all(src_data[:-12] == dst.data()[12:]))
def __init__(self, mode, syncword_threshold=None, options=None): gr.hier_block2.__init__(self, "ax100_deframer", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) options_block.__init__(self, options) self.message_port_register_hier_out('out') if syncword_threshold is None: syncword_threshold = self.options.syncword_threshold if mode not in ['RS', 'ASM']: raise Exception("Unsupported AX100 mode. Use 'RS' or 'ASM'") self.slicer = digital.binary_slicer_fb() if mode == 'RS': self.descrambler = digital.descrambler_bb(0x21, 0, 16) self.deframer = sync_to_pdu_packed(packlen = 256 if mode == 'RS' else 255,\ sync = _syncword,\ threshold = syncword_threshold) self.fec = ax100_decode(self.options.verbose_fec) if mode == 'RS'\ else u482c_decode(self.options.verbose_fec, 0, 1, 1) self._blocks = [self, self.slicer] if mode == 'RS': self._blocks.append(self.descrambler) self._blocks += [self.deframer] self.connect(*self._blocks) self.msg_connect((self.deframer, 'out'), (self.fec, 'in')) self.msg_connect((self.fec, 'out'), (self, 'out'))
def __init__(self, bitrate, constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log): gr.hier_block2.__init__( self, "bert_receive", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._bitrate = bitrate self._demod = digital.generic_demod(constellation, differential, samples_per_symbol, gray_coded, excess_bw, freq_bw, timing_bw, phase_bw, verbose, log) self._symbol_rate = self._bitrate / self._demod.bits_per_symbol() self._sample_rate = self._symbol_rate * samples_per_symbol # Add an SNR probe on the demodulated constellation self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, 1000, alpha=10.0 / self._symbol_rate) self.connect(self._demod.time_recov, self._snr_probe) # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = digital.descrambler_bb( 0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = digital.probe_density_b(1.0 / self._symbol_rate) self.connect(self, self._demod, self._descrambler, self._ber)
def __init__(self, bitrate, constellation, samples_per_symbol, differential, excess_bw, gray_coded, freq_bw, timing_bw, phase_bw, verbose, log): gr.hier_block2.__init__(self, "bert_receive", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(0, 0, 0)) # Output signature self._bitrate = bitrate self._demod = digital.generic_demod(constellation, differential, samples_per_symbol, gray_coded, excess_bw, freq_bw, timing_bw, phase_bw, verbose, log) self._symbol_rate = self._bitrate / self._demod.bits_per_symbol() self._sample_rate = self._symbol_rate * samples_per_symbol # Add an SNR probe on the demodulated constellation self._snr_probe = digital.probe_mpsk_snr_est_c(digital.SNR_EST_M2M4, 1000, alpha=10.0/self._symbol_rate) self.connect(self._demod.time_recov, self._snr_probe) # Descramble BERT sequence. A channel error will create 3 incorrect bits self._descrambler = digital.descrambler_bb(0x8A, 0x7F, 7) # CCSDS 7-bit descrambler # Measure BER by the density of 0s in the stream self._ber = digital.probe_density_b(1.0/self._symbol_rate) self.connect(self, self._demod, self._descrambler, self._ber)
def __init__(self): gr.top_block.__init__(self, "Quetzal-1 Receiver") ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.samp_rate = samp_rate = 48000 self.samp_per_sym = samp_per_sym = int(samp_rate/symb_rate) self.log = log = 0 self.homedir = homedir = "" self.hhmmss = hhmmss = "" self.gain_mu = gain_mu = 0.175*3 self.filename_raw_beacon = filename_raw_beacon = "" self.filename_parsed_beacon = filename_parsed_beacon = "" self.filename_image_metadata = filename_image_metadata = "" self.filename_image = filename_image = "" self.do_once = do_once = 0 self.data_rate = data_rate = 4800 self.count = count = 0 self.center_freq = center_freq = 437.2e6 ################################################## # Blocks ################################################## self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, 'tcp://127.0.0.1:1502', 100, False, -1) self.satellites_strip_ax25_header_0 = satellites.strip_ax25_header() self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_deframer_0 = satellites.hdlc_deframer(check_fcs=True, max_length=10000) self.quetzal1_parse = quetzal1_parse.quetzal1_parse(filename_parsed_beacon='', filename_raw_beacon='') self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, 48000, 2400, 2000, firdes.WIN_HAMMING, 6.76)) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(10, 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/dan/Documents/repos/gr-quetzal1/recordings/example_beacon_quetzal1.wav', False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) ################################################## # Connections ################################################## self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self.satellites_strip_ax25_header_0, 'in')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.quetzal1_parse, 'in')) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.satellites_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_descrambler_bb_0, 0))
def test_scrambler_descrambler(self): src_data = (1,)*1000 src = blocks.vector_source_b(src_data, False) scrambler = digital.scrambler_bb(0x8a, 0x7F, 7) # CCSDS 7-bit scrambler descrambler = digital.descrambler_bb(0x8a, 0x7F, 7) dst = blocks.vector_sink_b() self.tb.connect(src, scrambler, descrambler, dst) self.tb.run() self.assertEqual(tuple(src_data[:-8]), dst.data()[8:]) # skip garbage during synchronization
def __init__(self, callsign='', invert=1, ip='::', latitude=0, longitude=0, port=7355, recstart=''): gr.top_block.__init__(self, "TW-1B decoder") ################################################## # Parameters ################################################## self.callsign = callsign self.invert = invert self.ip = ip self.latitude = latitude self.longitude = longitude self.port = port self.recstart = recstart ################################################## # Variables ################################################## self.threshold = threshold = 6 self.gain_mu = gain_mu = 0.175*3 self.access_code = access_code = "10010011000010110101000111011110" ################################################## # Blocks ################################################## self.sync_to_pdu_packed_0 = sync_to_pdu_packed( packlen=256, sync=access_code, threshold=threshold, ) self.sids_submit_0 = sids.submit('http://tlm.pe0sat.nl/tlmdb/frame_db.php', 40927, callsign, longitude, latitude, recstart) self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S') self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, 48000, 2400, 2000, firdes.WIN_HAMMING, 6.76)) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(10, 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short*1, ip, port, 1472, False) self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767.0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert*10, )) self.blocks_message_debug_0 = blocks.message_debug() self.ax100_gomx3_rs_decode_0 = ax100.gomx3_rs_decode(False) ################################################## # Connections ################################################## self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.sids_print_timestamp_0, 'in')) self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.sids_submit_0, 'in')) self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.sync_to_pdu_packed_0, 'out'), (self.ax100_gomx3_rs_decode_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.sync_to_pdu_packed_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
def __init__(self, options=None): gr.hier_block2.__init__(self, "ax25_deframer", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) self.message_port_register_hier_out('out') self.slicer = digital.binary_slicer_fb() self.nrzi0 = nrzi_decode() self.nrzi1 = nrzi_decode() self.descrambler = digital.descrambler_bb(0x21, 0, 16) self.deframer = hdlc_deframer(True, 10000) self.connect(self, self.slicer, self.nrzi0, self.nrzi1, self.descrambler, self.deframer) self.msg_connect((self.deframer, 'out'), (self, 'out'))
def test_scrambler_descrambler_001(self): src_data = np.random.randint(0, 2, 500, dtype=np.int8) src = blocks.vector_source_b(src_data, False) scrambler = digital.scrambler_bb(*lfsr_args(0b1, 7, 2, 0)) # p(x) = x^7 + x^2 + 1 # we can use any seed here, it is descrambling. descrambler = digital.descrambler_bb(*lfsr_args(0b111, 7, 2, 0)) m_tap = blocks.vector_sink_b() dst = blocks.vector_sink_b() self.tb.connect(src, scrambler, descrambler, dst) self.tb.connect(scrambler, m_tap) self.tb.run() # skip garbage during synchronization self.assertEqual(src_data[:-7].tolist(), dst.data()[7:]) self.assertEqual( tuple(np.convolve(m_tap.data(), [1, 0, 0, 0, 0, 1, 0, 1]) % 2)[7:-10], tuple(src_data[:-10])) # manual descrambling test
def test_scrambler_descrambler_002(self): _a = lfsr_args(0b1, 51, 6, 0) # p(x) = x^51+x^6+1 src_data = np.random.randint(0, 2, 1000, dtype=np.int8) src = blocks.vector_source_b(src_data, False) scrambler = digital.scrambler_bb(*_a) m_tap = blocks.vector_sink_b() descrambler = digital.descrambler_bb(*_a) dst = blocks.vector_sink_b() self.tb.connect(src, scrambler, descrambler, dst) self.tb.connect(scrambler, m_tap) self.tb.run() # skip garbage during synchronization self.assertTrue(np.all(src_data[:-51] == dst.data()[51:])) reg = np.zeros(52, np.int8) reg[::-1][(51, 6, 0), ] = 1 self.assertTrue( np.all( np.convolve(m_tap.data(), reg)[51:-60] % 2 == src_data[:-60])) # manual descrambling test
def __init__(self): gr.top_block.__init__(self, "TW-1 test decoder") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.samp_per_sym = samp_per_sym = 10 self.gain_mu = gain_mu = 0.175*3 ################################################## # Blocks ################################################## self.synctags_fixedlen_tagger_0 = synctags.fixedlen_tagger("syncword", "packet_len", 256*8, numpy.byte) self.low_pass_filter_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, samp_rate, 2400, 2000, firdes.WIN_HAMMING, 6.76)) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16) self.digital_correlate_access_code_tag_bb_0 = digital.correlate_access_code_tag_bb("10010011000010110101000111011110", 4, "syncword") self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source("/tmp/tw-1c.wav", False) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_char*1, "packet_len", 1/8.0) self.blocks_message_debug_1 = blocks.message_debug() self.ax100_gomx3_rs_decode_0 = ax100.gomx3_rs_decode(True) ################################################## # Connections ################################################## self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.blocks_message_debug_1, 'print_pdu')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.ax100_gomx3_rs_decode_0, 'in')) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_correlate_access_code_tag_bb_0, 0), (self.synctags_fixedlen_tagger_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.digital_correlate_access_code_tag_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.synctags_fixedlen_tagger_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
def __init__(self, g3ruh_scrambler, options=None): gr.hier_block2.__init__( self, 'ax25_deframer', gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) self.message_port_register_hier_out('out') self.slicer = digital.binary_slicer_fb() self.nrzi = nrzi_decode() if g3ruh_scrambler: self.descrambler = digital.descrambler_bb(0x21, 0, 16) self.deframer = hdlc_deframer(True, 10000) self._blocks = [self, self.slicer, self.nrzi] if g3ruh_scrambler: self._blocks.append(self.descrambler) self._blocks += [self.deframer] self.connect(*self._blocks) self.msg_connect((self.deframer, 'out'), (self, 'out'))
def __init__(self, options=None): gr.hier_block2.__init__(self, "ops_sat_deframer", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) options_block.__init__(self, options) self.message_port_register_hier_out('out') self.slicer = digital.binary_slicer_fb() self.nrzi = nrzi_decode() self.descrambler = digital.descrambler_bb(0x21, 0, 16) self.deframer = hdlc_deframer(False, 10000) # we skip CRC-16 check self.strip = pdu_head_tail(3, 16) # CCSDS descrambler self.pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.scramble = digital.additive_scrambler_bb( 0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key="packet_len") self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') # prevents passing codewords of incorrect size to the RS decoder self.length_filter = pdu_length_filter(33, 255) self.fec = decode_rs(False, 1) self.connect(self, self.slicer, self.nrzi, self.descrambler, self.deframer) self.msg_connect((self.deframer, 'out'), (self.strip, 'in')) self.msg_connect((self.strip, 'out'), (self.pdu2tag, 'pdus')) self.connect(self.pdu2tag, self.unpack, self.scramble, self.pack, self.tag2pdu) self.msg_connect((self.tag2pdu, 'pdus'), (self.length_filter, 'in')) self.msg_connect((self.length_filter, 'out'), (self.fec, 'in')) self.msg_connect((self.fec, 'out'), (self, 'out'))
def __init__(self, address='serial=30AD34D'): gr.top_block.__init__(self, "MPSK TX RX") Qt.QWidget.__init__(self) self.setWindowTitle("MPSK TX 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", "MPSK_TX_RX") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.address = address ################################################## # Variables ################################################## self.const_type = const_type = 2 self.bits_per_symbol = bits_per_symbol = int(const_type + 1) self.samples_per_symbol = samples_per_symbol = int(2 * (bits_per_symbol)) self.probe_SNR = probe_SNR = 0 self.nfilts = nfilts = 32 self.bitrate = bitrate = 64e3 self.variable_qtgui_label_0 = variable_qtgui_label_0 = { 0: 'BPSK', 1: 'QPSK', 2: '8-PSK' }[const_type] + " - Change const_type for different constellation types!" self.tun_gain_tx = tun_gain_tx = 40 self.tun_freq_tx = tun_freq_tx = 2.39e9 self.timing_bw = timing_bw = 2 * math.pi / 100.0 self.samp_rate = samp_rate = samples_per_symbol * bitrate self.phase_bw = phase_bw = 2 * math.pi / 100.0 self.ntaps = ntaps = 11 * int(samples_per_symbol * nfilts) self.lo_offset = lo_offset = 6e6 self.gain_rx = gain_rx = 0.75 self.freq_rx = freq_rx = 2390e6 self.freq_bw = freq_bw = 2 * math.pi / 100.0 self.fll_ntaps = fll_ntaps = 55 self.excess_bw = excess_bw = 0.35 self.constellation = constellation = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.arrity = arrity = pow(2, bits_per_symbol) self.ampl = ampl = 0.7 self.SNR = SNR = probe_SNR ################################################## # Blocks ################################################## self._tun_gain_tx_range = Range(0, 80, 1, 40, 200) self._tun_gain_tx_win = RangeWidget(self._tun_gain_tx_range, self.set_tun_gain_tx, 'UHD Tx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._tun_gain_tx_win, 1, 0, 1, 1) self._tun_freq_tx_range = Range(2.3e9, 2.5e9, 1, 2.39e9, 200) self._tun_freq_tx_win = RangeWidget(self._tun_freq_tx_range, self.set_tun_freq_tx, 'UHD Tx Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._tun_freq_tx_win, 0, 0, 1, 1) 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_grid_layout.addWidget(self._lo_offset_tool_bar, 2, 1, 1, 1) self._gain_rx_range = Range(0, 1, 0.01, 0.75, 200) self._gain_rx_win = RangeWidget(self._gain_rx_range, self.set_gain_rx, 'UHD Rx Gain', "counter_slider", float) self.top_grid_layout.addWidget(self._gain_rx_win, 1, 1, 1, 1) self._freq_rx_range = Range(2350e6, 2500e6, 10e6, 2390e6, 200) self._freq_rx_win = RangeWidget(self._freq_rx_range, self.set_freq_rx, 'UHD Rx Freq (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_rx_win, 0, 1, 1, 1) self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c( 2, 1000, 10 / bitrate) self._const_type_options = ( 0, 1, 2, ) self._const_type_labels = ( 'DBPSK', 'DQPSK', 'D8PSK', ) self._const_type_tool_bar = Qt.QToolBar(self) self._const_type_tool_bar.addWidget(Qt.QLabel("const_type" + ": ")) self._const_type_combo_box = Qt.QComboBox() self._const_type_tool_bar.addWidget(self._const_type_combo_box) for label in self._const_type_labels: self._const_type_combo_box.addItem(label) self._const_type_callback = lambda i: Qt.QMetaObject.invokeMethod( self._const_type_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._const_type_options.index(i))) self._const_type_callback(self.const_type) self._const_type_combo_box.currentIndexChanged.connect( lambda i: self.set_const_type(self._const_type_options[i])) self.top_layout.addWidget(self._const_type_tool_bar) self._ampl_range = Range(0, 1, 0.01, 0.7, 200) self._ampl_win = RangeWidget(self._ampl_range, self.set_ampl, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._ampl_win, 2, 0, 1, 1) 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('Constellation Type' + ": ")) 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_layout.addWidget(self._variable_qtgui_label_0_tool_bar) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_subdev_spec('A:A', 0) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq( uhd.tune_request(freq_rx, rf_freq=freq_rx - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain_rx, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.uhd_usrp_sink_0_0 = uhd.usrp_sink( ",".join((address, "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0_0.set_subdev_spec('A:B', 0) self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0_0.set_center_freq(tun_freq_tx, 0) self.uhd_usrp_sink_0_0.set_gain(tun_gain_tx, 0) self.uhd_usrp_sink_0_0.set_antenna('TX/RX', 0) self.qtgui_number_sink_0_1 = qtgui.number_sink(gr.sizeof_float, 0, qtgui.NUM_GRAPH_HORIZ, 1) self.qtgui_number_sink_0_1.set_update_time(0.10) self.qtgui_number_sink_0_1.set_title("BER") labels = ['BER', '', '', '', '', '', '', '', '', ''] units = ['x10^-6', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1e6, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_1.set_min(i, 0) self.qtgui_number_sink_0_1.set_max(i, 1) self.qtgui_number_sink_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_1.enable_autoscale(True) self._qtgui_number_sink_0_1_win = sip.wrapinstance( self.qtgui_number_sink_0_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_number_sink_0_1_win) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_0_win, 3, 0, 1, 1) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 3, 1, 1, 1) def _probe_SNR_probe(): while True: val = self.digital_probe_mpsk_snr_est_c_0.snr() try: self.set_probe_SNR(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_SNR_thread = threading.Thread(target=_probe_SNR_probe) _probe_SNR_thread.daemon = True _probe_SNR_thread.start() self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samples_per_symbol, taps=(firdes.root_raised_cosine(nfilts, nfilts, 1.0, 0.35, ntaps)), flt_size=nfilts) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( samples_per_symbol, timing_bw, (firdes.root_raised_cosine( nfilts, nfilts * samples_per_symbol, 1.0, 0.35, ntaps)), nfilts, nfilts // 2, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( samples_per_symbol, excess_bw, fll_ntaps, freq_bw) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(arrity) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(arrity) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( timing_bw, pow(2, bits_per_symbol), False) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb( constellation[const_type].base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (constellation[const_type].points()), 1) self.blocks_vector_source_x_0_0 = blocks.vector_source_b([ 1, ], True, 1, []) self.blocks_vector_source_x_0 = blocks.vector_source_b([ 1, ], True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb( bits_per_symbol) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(bits_per_symbol) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((ampl, )) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000, bits_per_symbol=1, ) self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) self._SNR_tool_bar = Qt.QToolBar(self) if None: self._SNR_formatter = None else: self._SNR_formatter = lambda x: x self._SNR_tool_bar.addWidget(Qt.QLabel("SNR" + ": ")) self._SNR_label = Qt.QLabel(str(self._SNR_formatter(self.SNR))) self._SNR_tool_bar.addWidget(self._SNR_label) self.top_layout.addWidget(self._SNR_tool_bar) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_number_sink_0_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.uhd_usrp_sink_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0))
def __init__(self, rx_freq=401.5e6, rx_offset=250e3): gr.top_block.__init__(self, "VCC Simple Downlink Receiver") Qt.QWidget.__init__(self) self.setWindowTitle("VCC Simple Downlink Receiver") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "fsk_rx_uhd") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.rx_freq = rx_freq self.rx_offset = rx_offset ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250000 self.interp = interp = 24 self.decim = decim = 25 * 5 self.baud = baud = 9600 self.samps_per_symb = samps_per_symb = (samp_rate / decim * interp) / baud self.rx_gain = rx_gain = 0 self.rx_correct = rx_correct = -300 self.lpf_trans = lpf_trans = 1e3 self.lpf_cutoff = lpf_cutoff = 12.5e3 self.fsk_dev = fsk_dev = 10000 ################################################## # Blocks ################################################## self._rx_gain_range = Range(0, 86, 1, 0, 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, 4, 0, 1, 4) self._rx_correct_range = Range(-10000, 10000, 1, -300, 200) self._rx_correct_win = RangeWidget(self._rx_correct_range, self.set_rx_correct, "rx_correct", "counter_slider", float) self.top_grid_layout.addWidget(self._rx_correct_win, 5, 0, 1, 4) 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(rx_freq + rx_correct, rx_offset), 0) self.uhd_usrp_source_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim * interp, #bw "RX Spectrum", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.010) self.qtgui_freq_sink_x_1_0.set_y_axis(-150, 0) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0, 4, 4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0 self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6, 0, 2, 4) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self.kiss_nrzi_decode_0 = kiss.nrzi_decode() self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_socket_pdu_0_2_0 = blocks.socket_pdu( "TCP_SERVER", '0.0.0.0', '8001', 1024, False) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf( (samp_rate / decim * interp) / (2 * math.pi * fsk_dev / 8.0)) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_socket_pdu_0_2_0, 'pdus')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_nrzi_decode_0, 0)) self.connect((self.kiss_nrzi_decode_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self, fsk_dev=10000, lpf_cutoff=12.5e3, lpf_trans=1e3): gr.top_block.__init__(self, "Fsk Rx Udp") Qt.QWidget.__init__(self) self.setWindowTitle("Fsk Rx Udp") 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", "fsk_rx_udp") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fsk_dev = fsk_dev self.lpf_cutoff = lpf_cutoff self.lpf_trans = lpf_trans ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48e3 self.baud = baud = 9600 self.thresh = thresh = -4 self.smooth_len = smooth_len = 25 self.samps_per_symb = samps_per_symb = int(samp_rate/baud) self.offset = offset = 0 self.num_items = num_items = 1024 self.mult = mult = (samp_rate)/2/3.141593 self.decay = decay = 100e-6 self.bw_factor = bw_factor = 1000 self.attack = attack = 0.001 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._thresh_tool_bar = Qt.QToolBar(self) self._thresh_tool_bar.addWidget(Qt.QLabel('Threshold'+": ")) self._thresh_line_edit = Qt.QLineEdit(str(self.thresh)) self._thresh_tool_bar.addWidget(self._thresh_line_edit) self._thresh_line_edit.returnPressed.connect( lambda: self.set_thresh(eng_notation.str_to_num(str(self._thresh_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._thresh_tool_bar, 0,4,1,2) self._offset_range = Range(-10000, 10000, 1, 0, 200) self._offset_win = RangeWidget(self._offset_range, self.set_offset, "offset", "counter_slider", float) self.top_grid_layout.addWidget(self._offset_win, 3,4,1,4) self._decay_tool_bar = Qt.QToolBar(self) self._decay_tool_bar.addWidget(Qt.QLabel("decay"+": ")) self._decay_line_edit = Qt.QLineEdit(str(self.decay)) self._decay_tool_bar.addWidget(self._decay_line_edit) self._decay_line_edit.returnPressed.connect( lambda: self.set_decay(eng_notation.str_to_num(str(self._decay_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._decay_tool_bar, 1,6,1,2) self._bw_factor_tool_bar = Qt.QToolBar(self) self._bw_factor_tool_bar.addWidget(Qt.QLabel("bw_factor"+": ")) self._bw_factor_line_edit = Qt.QLineEdit(str(self.bw_factor)) self._bw_factor_tool_bar.addWidget(self._bw_factor_line_edit) self._bw_factor_line_edit.returnPressed.connect( lambda: self.set_bw_factor(eng_notation.str_to_num(str(self._bw_factor_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._bw_factor_tool_bar, 2,6,1,2) self._attack_tool_bar = Qt.QToolBar(self) self._attack_tool_bar.addWidget(Qt.QLabel("attack"+": ")) self._attack_line_edit = Qt.QLineEdit(str(self.attack)) self._attack_tool_bar.addWidget(self._attack_line_edit) self._attack_line_edit.returnPressed.connect( lambda: self.set_attack(eng_notation.str_to_num(str(self._attack_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._attack_tool_bar, 1,4,1,2) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 50, #size samp_rate, #samp_rate "trigger", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) self.qtgui_time_sink_x_2.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_2_win, 8,0,2,4) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "Freq Error", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.010) 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(True) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 4,0,2,4) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 2048, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.010) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "packet_len") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) if not 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win, 4,4,2,4) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.010) 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, "packet_len") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 8,4,2,4) self.qtgui_number_sink_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_1.set_update_time(0.10) self.qtgui_number_sink_1.set_title("Doppler") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_1.set_min(i, -1) self.qtgui_number_sink_1.set_max(i, 1) self.qtgui_number_sink_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_1.set_label(i, labels[i]) self.qtgui_number_sink_1.set_unit(i, units[i]) self.qtgui_number_sink_1.set_factor(i, factor[i]) self.qtgui_number_sink_1.enable_autoscale(False) self._qtgui_number_sink_1_win = sip.wrapinstance(self.qtgui_number_sink_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_1_win, 2,4,1,2) self.qtgui_number_sink_0_0_1 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0_0_1.set_update_time(0.010) self.qtgui_number_sink_0_0_1.set_title("SNR") labels = ['', '', '', '', '', '', '', '', '', ''] units = ['', '', '', '', '', '', '', '', '', ''] colors = [("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black"), ("black", "black")] factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] for i in xrange(1): self.qtgui_number_sink_0_0_1.set_min(i, 0) self.qtgui_number_sink_0_0_1.set_max(i, 100) self.qtgui_number_sink_0_0_1.set_color(i, colors[i][0], colors[i][1]) if len(labels[i]) == 0: self.qtgui_number_sink_0_0_1.set_label(i, "Data {0}".format(i)) else: self.qtgui_number_sink_0_0_1.set_label(i, labels[i]) self.qtgui_number_sink_0_0_1.set_unit(i, units[i]) self.qtgui_number_sink_0_0_1.set_factor(i, factor[i]) self.qtgui_number_sink_0_0_1.enable_autoscale(False) self._qtgui_number_sink_0_0_1_win = sip.wrapinstance(self.qtgui_number_sink_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_number_sink_0_0_1_win, 2,5,1,1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "RX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.010) self.qtgui_freq_sink_x_1_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,0,4,4) self.pyqt_time_plot_0 = pyqt.time_plot('') self._pyqt_time_plot_0_win = self.pyqt_time_plot_0; self.top_grid_layout.addWidget(self._pyqt_time_plot_0_win, 6,0,2,4) self.pyqt_time_plot_0.line_off() self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0; self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 6,4,2,4) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.es_trigger_edge_f_0 = es.trigger_edge_f(thresh,3500,500,gr.sizeof_float,100) self.es_sink_0 = es.sink(1*[gr.sizeof_float],8,64,0,2,0) self.es_handler_pdu_0 = es.es_make_handler_pdu(es.es_handler_print.TYPE_F32) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samps_per_symb, .5, 512, math.pi/bw_factor) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0), 0.25*0.175*0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex*1, '0.0.0.0', 9001, 1472, True) self.blocks_threshold_ff_0 = blocks.threshold_ff(-100, -100, 0) self.blocks_sub_xx_1_0 = blocks.sub_ff(1) self.blocks_sub_xx_1 = blocks.sub_ff(1) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_float*1, num_items) self.blocks_skiphead_1 = blocks.skiphead(gr.sizeof_gr_complex*1, 500) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float*1, 1) self.blocks_short_to_float_0 = blocks.short_to_float(1, 1) self.blocks_pdu_to_tagged_stream_2 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'packet_len') self.blocks_pdu_remove_0_0 = blocks.pdu_remove(pmt.intern("es::event_buffer")) self.blocks_pdu_remove_0 = blocks.pdu_remove(pmt.intern("es::event_buffer")) self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_short*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_nlog10_ff_0_0_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_nlog10_ff_0_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vff((mult, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((mult*-1, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_moving_average_xx_2 = blocks.moving_average_ff(num_items, 1.0/num_items, 4000, 1) self.blocks_moving_average_xx_0_1_0_0 = blocks.moving_average_ff(500, 1.0/500, 4000, 1) self.blocks_moving_average_xx_0_1_0 = blocks.moving_average_ff(2000, 1.0/2000, 4000, 1) self.blocks_moving_average_xx_0_0 = blocks.moving_average_ff(smooth_len, 1.0/smooth_len, 4000, 1) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(smooth_len, 1.0/smooth_len, 4000, 1) self.blocks_keep_m_in_n_1 = blocks.keep_m_in_n(gr.sizeof_float, 1, num_items, 0) self.blocks_keep_m_in_n_0_1 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 2000, 3500, 10) self.blocks_keep_m_in_n_0_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, 500, 3500, 10) self.blocks_complex_to_mag_squared_0_0_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_argmax_xx_0 = blocks.argmax_fs(num_items) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 1000, 1, offset) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate)/(2*math.pi*fsk_dev/8.0)) self.analog_agc3_xx_0 = analog.agc3_cc(attack, decay, 1.0, 1.0, 1) self.analog_agc3_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.blocks_pdu_remove_0_0, 'pdus')) self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.pyqt_time_plot_0, 'pdus')) self.msg_connect((self.blocks_pdu_remove_0_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_2, 'pdus')) self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.blocks_pdu_remove_0, 'pdus')) self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'), (self.es_handler_pdu_0, 'handle_event')) self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'), (self.es_sink_0, 'schedule_event')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.connect((self.analog_agc3_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_argmax_xx_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.blocks_argmax_xx_0, 1), (self.blocks_short_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0, 0), (self.blocks_moving_average_xx_0_1_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_0_0, 0), (self.blocks_moving_average_xx_0_1_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_0, 0), (self.blocks_complex_to_mag_squared_0_0_0, 0)) self.connect((self.blocks_keep_m_in_n_0_1, 0), (self.blocks_complex_to_mag_squared_0_0, 0)) self.connect((self.blocks_keep_m_in_n_1, 0), (self.blocks_sub_xx_1, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_moving_average_xx_0_0, 0), (self.qtgui_number_sink_1, 0)) self.connect((self.blocks_moving_average_xx_0_1_0, 0), (self.blocks_nlog10_ff_0_0, 0)) self.connect((self.blocks_moving_average_xx_0_1_0_0, 0), (self.blocks_nlog10_ff_0_0_0, 0)) self.connect((self.blocks_moving_average_xx_2, 0), (self.blocks_keep_m_in_n_1, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.es_trigger_edge_f_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_moving_average_xx_0_0, 0)) self.connect((self.blocks_multiply_const_vxx_2, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc3_xx_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_moving_average_xx_2, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.blocks_nlog10_ff_0_0, 0), (self.blocks_sub_xx_1_0, 1)) self.connect((self.blocks_nlog10_ff_0_0_0, 0), (self.blocks_sub_xx_1_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_2, 0), (self.blocks_keep_m_in_n_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_2, 0), (self.blocks_skiphead_1, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_sub_xx_1, 1)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_skiphead_1, 0), (self.blocks_keep_m_in_n_0_1, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.blocks_argmax_xx_0, 0)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_sub_xx_1, 0), (self.blocks_threshold_ff_0, 0)) self.connect((self.blocks_sub_xx_1_0, 0), (self.qtgui_number_sink_0_0_1, 0)) self.connect((self.blocks_threshold_ff_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.es_trigger_edge_f_0, 1)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.digital_fll_band_edge_cc_0, 1), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_fll_band_edge_cc_0, 3), (self.blocks_multiply_const_vxx_2, 0)) self.connect((self.digital_fll_band_edge_cc_0, 2), (self.blocks_null_sink_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.es_trigger_edge_f_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0))
def __init__(self, EbN0, viterbi=False): gr.top_block.__init__(self) self.sps = 5 alpha = 0.35 const = digital.constellation_bpsk().base() modulator = digital.generic_mod( constellation=const, differential=False, samples_per_symbol=self.sps, pre_diff_code=True, excess_bw=alpha, verbose=False, log=False, ) channel = channels.channel_model( noise_voltage=self.EbN0_to_noise_voltage(EbN0, viterbi), frequency_offset=0, epsilon=1.0, taps=(0, 0, (1+1j)/numpy.sqrt(2), ), noise_seed=RAND_SEED, block_tags=False ) self.sink = blocks.vector_sink_f() biterrors = BitErrors() dut = lilacsat1_ber_viterbi() if viterbi else lilacsat1_ber_bpsk() pack = blocks.pack_k_bits_bb(8) descrambler = digital.descrambler_bb(0x21, 0x00, 16) self.connect(blocks.vector_source_b([1], repeat=True), blocks.head(gr.sizeof_char, int(N_BITS)), digital.scrambler_bb(0x21, 0x00, 16), digital.diff_encoder_bb(2), pack) self.connect(modulator, channel, blocks.multiply_const_cc(0.1), # we set some amplitude to test the agc # signal amplitude 1 seems very important dut, digital.diff_decoder_bb(2), descrambler) self.connect(biterrors, self.sink) if viterbi: deinterleave_viterbi = blocks.deinterleave(gr.sizeof_char) interleave_viterbi = blocks.interleave(gr.sizeof_char) self.connect(pack, fec.encode_ccsds_27_bb(), deinterleave_viterbi) self.connect((deinterleave_viterbi, 0), (interleave_viterbi, 1)) self.connect((deinterleave_viterbi, 1), blocks.not_bb(), blocks.and_const_bb(1), (interleave_viterbi, 0)) self.connect(interleave_viterbi, blocks.pack_k_bits_bb(8), modulator) descrambler2 = digital.descrambler_bb(0x21, 0x00, 16) self.connect((dut, 1), digital.diff_decoder_bb(2), descrambler2) or2 = blocks.or_bb() self.connect(descrambler, or2) self.connect(descrambler2, (or2, 1)) self.connect(or2, biterrors) #self.sinkviterbi1 = blocks.vector_sink_b() #self.sinkviterbi2 = blocks.vector_sink_b() #self.connect(descrambler, self.sinkviterbi1) #self.connect(descrambler2, self.sinkviterbi2) else: self.connect(pack, modulator) self.connect(descrambler, biterrors)
def __init__(self, freq=0, gain=0, loopbw=100, fllbw=0.002): gr.top_block.__init__(self, "Rx") ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j] self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j]) self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate) self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1) self.const_order = const_order = pow(2,constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate/even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))
def __init__(self, callsign='WJ2XMS', client_port='8000', gs_id='WFF', post_bytes=64, pre_bytes=64, sc_id='VCC-A', server_ip='0.0.0.0', ssid=0, verbose=0, wallops_dn_port='56101', wallops_up_port='56100'): gr.top_block.__init__(self, "Wff Nogui V3 Verbose") ################################################## # Parameters ################################################## self.callsign = callsign self.client_port = client_port self.gs_id = gs_id self.post_bytes = post_bytes self.pre_bytes = pre_bytes self.sc_id = sc_id self.server_ip = server_ip self.ssid = ssid self.verbose = verbose self.wallops_dn_port = wallops_dn_port self.wallops_up_port = wallops_up_port ################################################## # Variables ################################################## self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S") self.fn_up = fn_up = "{:s}_{:s}_{:s}".format(gs_id, sc_id, ts_str) self.fn_dn = fn_dn = "{:s}_{:s}_{:s}".format(sc_id, gs_id, ts_str) self.fp_up = fp_up = "/gnuradio/captures/{:s}".format(fn_up) self.fp_dn = fp_dn = "/gnuradio/captures/{:s}".format(fn_dn) ################################################## # Blocks ################################################## self.vcc_insert_time_tag_bb_0_0 = vcc.insert_time_tag_bb( 'core:datetime', 'packet_len') self.vcc_insert_time_tag_bb_0 = vcc.insert_time_tag_bb( 'core:datetime', 'packet_len') self.vcc_insert_src_callsign_pdu_0 = vcc.insert_src_callsign_pdu( callsign=callsign, ssid=ssid, verbose=bool(verbose)) self.vcc_burst_scramble_bb_0 = vcc.burst_scramble_bb(0x21, 0x0, 16) self.sigmf_sink_1 = gr_sigmf.sink("ri8", fp_dn, gr_sigmf.sigmf_time_mode_absolute, False) self.sigmf_sink_1.set_global_meta("core:sample_rate", 0) self.sigmf_sink_1.set_global_meta( "core:description", 'Wallops Flight Facility Interface, Downlink') self.sigmf_sink_1.set_global_meta("core:author", 'Zach Leffke, [email protected]') self.sigmf_sink_1.set_global_meta("core:license", 'MIT') self.sigmf_sink_1.set_global_meta("core:hw", 'WFF UHF Ground Station') self.sigmf_sink_1.set_global_meta('vcc:spacecraft', 'VCC-A') self.sigmf_sink_1.set_global_meta('vcc:ground_station', 'WFF') self.sigmf_sink_1.set_global_meta('vcc:callsign', 'WJ2XMS-0') self.sigmf_sink_1.set_global_meta( 'vcc:tap_point', 'Packed Bytes, NRZ-I decoded, before descrambling') self.sigmf_sink_0 = gr_sigmf.sink("ri8", fp_up, gr_sigmf.sigmf_time_mode_absolute, False) self.sigmf_sink_0.set_global_meta("core:sample_rate", 0) self.sigmf_sink_0.set_global_meta( "core:description", 'Wallops Flight Facility Interface, Uplink') self.sigmf_sink_0.set_global_meta("core:author", 'Zach Leffke, [email protected]') self.sigmf_sink_0.set_global_meta("core:license", 'MIT') self.sigmf_sink_0.set_global_meta("core:hw", 'WFF UHF Ground Station') self.sigmf_sink_0.set_global_meta('vcc:spacecraft', 'VCC-A') self.sigmf_sink_0.set_global_meta('vcc:ground_station', 'WFF') self.sigmf_sink_0.set_global_meta('vcc:uplink_callsign', 'WJ2XMS-0') self.sigmf_sink_0.set_global_meta('vcc:tap_point', 'KISS input') self.pdu_utils_pack_unpack_0 = pdu_utils.pack_unpack( pdu_utils.MODE_PACK_BYTE, pdu_utils.BIT_ORDER_MSB_FIRST) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=pre_bytes, postamble_bytes=post_bytes) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.blocks_socket_pdu_2 = blocks.socket_pdu("TCP_SERVER", server_ip, wallops_dn_port, 1500, False) self.blocks_socket_pdu_1 = blocks.socket_pdu("TCP_SERVER", server_ip, wallops_up_port, 1500, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", server_ip, client_port, 1024, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.blocks_socket_pdu_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.vcc_burst_scramble_bb_0, 'in')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.vcc_insert_src_callsign_pdu_0, 'in')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.pdu_utils_pack_unpack_0, 'pdu_out'), (self.blocks_socket_pdu_1, 'pdus')) self.msg_connect((self.vcc_burst_scramble_bb_0, 'out'), (self.pdu_utils_pack_unpack_0, 'pdu_in')) self.msg_connect((self.vcc_insert_src_callsign_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.vcc_insert_time_tag_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.vcc_insert_time_tag_bb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.vcc_insert_time_tag_bb_0, 0), (self.kiss_kiss_to_pdu_0, 0)) self.connect((self.vcc_insert_time_tag_bb_0, 0), (self.sigmf_sink_0, 0)) self.connect((self.vcc_insert_time_tag_bb_0_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.vcc_insert_time_tag_bb_0_0, 0), (self.sigmf_sink_1, 0))
def __init__( self, EbN0=0, esprit_decimation=128, fc=436e6, mx=4, my=4, n=1, phi=50, rs_decimation=8, theta=30, ): gr.top_block.__init__(self, "BER Simulation") ################################################## # Parameters ################################################## self.EbN0 = EbN0 self.esprit_decimation = esprit_decimation self.fc = fc self.mx = mx self.my = my self.n = n self.phi = phi self.rs_decimation = rs_decimation self.theta = theta ################################################## # Variables ################################################## self.sps = sps = 5 self.N_BITS = N_BITS = 1e5 self.samp_rate = samp_rate = 32000 self.noise_voltage = noise_voltage = 1.0 / math.sqrt( 1 / float(sps) * 10**(float(EbN0) / 10)) self.intdump_decim = intdump_decim = min(int(N_BITS / 10), 100000) self.const = const = digital.constellation_bpsk().base() self.alpha = alpha = 0.35 self.SKIP = SKIP = 1000 self.RAND_SEED = RAND_SEED = 42 ################################################## # Blocks ################################################## self.lilacsat1_ber_bpsk_0 = lilacsat1_ber_bpsk( bfo=12000, callsign="", ip="::", latitude=0, longitude=0, port=7355, recstart="", ) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=const, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=alpha, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_voltage, frequency_offset=0.0, epsilon=1.0, taps=( 0, 0, (1 + 1j) / numpy.sqrt(2), ), noise_seed=RAND_SEED, block_tags=False, ) self.blocks_vector_to_stream_0 = blocks.vector_to_stream( gr.sizeof_gr_complex * 1, mx * my) self.blocks_vector_source_x_0 = blocks.vector_source_b([1], True, 1, []) self.blocks_vector_sink_x_0_0_0 = blocks.vector_sink_f(1, 1024) self.blocks_vector_sink_x_0_0 = blocks.vector_sink_f(1, 1024) self.blocks_vector_sink_x_0 = blocks.vector_sink_f(1, 1024) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_stream_to_vector_0 = blocks.stream_to_vector( gr.sizeof_gr_complex * 1, mx * my) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_char * 1, SKIP) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_not_xx_0 = blocks.not_bb() self.blocks_multiply_const_vxx_1 = blocks.multiply_const_cc(0.1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_ff( 1.0 / intdump_decim) self.blocks_integrate_xx_0 = blocks.integrate_ff(intdump_decim, 1) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, int(N_BITS)) self.blocks_and_const_xx_0 = blocks.and_const_bb(1) self.beamforming_randomsampler_py_cc_0_0 = beamforming.randomsampler_py_cc( mx * my, rs_decimation) self.beamforming_phasedarray_py_cc_0 = beamforming.phasedarray_py_cc( mx, my, theta, phi, fc, 0) self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf( 128, mx, my, fc, n) self.beamforming_beamformer_py_cc_0 = beamforming.beamformer_py_cc( mx, my, fc, 0, 0, 8 * 128) ################################################## # Connections ################################################## self.connect( (self.beamforming_beamformer_py_cc_0, 0), (self.blocks_multiply_const_vxx_1, 0), ) self.connect( (self.beamforming_doaesprit_py_cf_0, 0), (self.beamforming_beamformer_py_cc_0, 1), ) self.connect( (self.beamforming_doaesprit_py_cf_0, 1), (self.beamforming_beamformer_py_cc_0, 2), ) self.connect((self.beamforming_doaesprit_py_cf_0, 0), (self.blocks_vector_sink_x_0_0, 0)) self.connect( (self.beamforming_doaesprit_py_cf_0, 1), (self.blocks_vector_sink_x_0_0_0, 0), ) self.connect( (self.beamforming_phasedarray_py_cc_0, 0), (self.blocks_vector_to_stream_0, 0), ) self.connect( (self.beamforming_randomsampler_py_cc_0_0, 0), (self.beamforming_doaesprit_py_cf_0, 0), ) self.connect((self.blocks_and_const_xx_0, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_head_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_integrate_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.lilacsat1_ber_bpsk_0, 0)) self.connect((self.blocks_not_xx_0, 0), (self.blocks_and_const_xx_0, 0)) self.connect( (self.blocks_pack_k_bits_bb_0, 0), (self.digital_constellation_modulator_0, 0), ) self.connect((self.blocks_skiphead_0, 0), (self.blocks_not_xx_0, 0)) self.connect( (self.blocks_stream_to_vector_0, 0), (self.beamforming_beamformer_py_cc_0, 0), ) self.connect( (self.blocks_stream_to_vector_0, 0), (self.beamforming_randomsampler_py_cc_0_0, 0), ) self.connect((self.blocks_uchar_to_float_0, 0), (self.blocks_integrate_xx_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect( (self.digital_constellation_modulator_0, 0), (self.beamforming_phasedarray_py_cc_0, 0), ) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_skiphead_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.lilacsat1_ber_bpsk_0, 0), (self.digital_diff_decoder_bb_0, 0))
def __init__(self, freq=0, gain=40, loopbw=100, loopbw_0=100, fllbw=0.002): gr.top_block.__init__(self, "Rx Gui") Qt.QWidget.__init__(self) self.setWindowTitle("Rx Gui") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "rx_gui") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.loopbw_0 = loopbw_0 self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps*(200e3/(1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j] self.barker_code_one_dim = barker_code_one_dim = sqrt(2)*numpy.real([-1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j]) self.rrc_delay = rrc_delay = int(round(-44*excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate/target_samp_rate) self.constellation = constellation = qpsk_const if (const_choice=="qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if (const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat(barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps*nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if (dec_factor % 1 == 1) else (dec_factor+1) self.const_order = const_order = pow(2,constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate/even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts*sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len*n_codewords/int(numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # 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, 'PMF Out') 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, 'Abs PMF Out') 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, 'FLL In') self.tabs_widget_3 = Qt.QWidget() self.tabs_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_3) self.tabs_grid_layout_3 = Qt.QGridLayout() self.tabs_layout_3.addLayout(self.tabs_grid_layout_3) self.tabs.addTab(self.tabs_widget_3, 'FLL Out') self.tabs_widget_4 = Qt.QWidget() self.tabs_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_4) self.tabs_grid_layout_4 = Qt.QGridLayout() self.tabs_layout_4.addLayout(self.tabs_grid_layout_4) self.tabs.addTab(self.tabs_widget_4, 'FLL State') self.tabs_widget_5 = Qt.QWidget() self.tabs_layout_5 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_5) self.tabs_grid_layout_5 = Qt.QGridLayout() self.tabs_layout_5.addLayout(self.tabs_grid_layout_5) self.tabs.addTab(self.tabs_widget_5, 'PFB Sync Out') self.tabs_widget_6 = Qt.QWidget() self.tabs_layout_6 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_6) self.tabs_grid_layout_6 = Qt.QGridLayout() self.tabs_layout_6.addLayout(self.tabs_grid_layout_6) self.tabs.addTab(self.tabs_widget_6, 'Costas State') self.tabs_widget_7 = Qt.QWidget() self.tabs_layout_7 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_7) self.tabs_grid_layout_7 = Qt.QGridLayout() self.tabs_layout_7.addLayout(self.tabs_grid_layout_7) self.tabs.addTab(self.tabs_widget_7, 'Demod Bits') self.tabs_widget_8 = Qt.QWidget() self.tabs_layout_8 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_8) self.tabs_grid_layout_8 = Qt.QGridLayout() self.tabs_layout_8.addLayout(self.tabs_grid_layout_8) self.tabs.addTab(self.tabs_widget_8, 'Costas Sym Out') self.tabs_widget_9 = Qt.QWidget() self.tabs_layout_9 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tabs_widget_9) self.tabs_grid_layout_9 = Qt.QGridLayout() self.tabs_layout_9.addLayout(self.tabs_grid_layout_9) self.tabs.addTab(self.tabs_widget_9, 'Payload Symbols') self.top_layout.addWidget(self.tabs) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + '' ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.qtgui_time_sink_x_2 = qtgui.time_sink_c( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 1) self.qtgui_time_sink_x_2.set_y_label('Amplitude', "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(True) self.qtgui_time_sink_x_2.enable_grid(False) self.qtgui_time_sink_x_2.enable_axis_labels(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_2.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.tabs_layout_0.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_1_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0.set_y_axis(-128, 128) self.qtgui_time_sink_x_1_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0.enable_tags(-1, False) self.qtgui_time_sink_x_1_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-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_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_0_win) self.qtgui_time_sink_x_1_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0.enable_grid(False) self.qtgui_time_sink_x_1_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_win = sip.wrapinstance(self.qtgui_time_sink_x_1_0.pyqwidget(), Qt.QWidget) self.tabs_layout_7.addWidget(self._qtgui_time_sink_x_1_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #name 3 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['FLL Freq (PI Output)', 'FLL Phase Accum', 'FLL Error', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_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_4.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_3 = qtgui.time_sink_f( 1024*4, #size samp_rate, #samp_rate "Error", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_3.set_update_time(0.10) self.qtgui_time_sink_x_0_3.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_3.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_3.enable_tags(-1, True) self.qtgui_time_sink_x_0_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_3.enable_autoscale(False) self.qtgui_time_sink_x_0_3.enable_grid(False) self.qtgui_time_sink_x_0_3.enable_axis_labels(True) self.qtgui_time_sink_x_0_3.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_3.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_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_3.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_3.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_3.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_3.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_3.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_3.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_3_win = sip.wrapinstance(self.qtgui_time_sink_x_0_3.pyqwidget(), Qt.QWidget) self.tabs_layout_6.addWidget(self._qtgui_time_sink_x_0_3_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( preamble_size + payload_size, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['Mag Sq', 'Mag', '', '', '', '', '', '', '', ''] 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_layout_1.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_sink_x_5 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_5.set_update_time(1.0/10) self._qtgui_sink_x_5_win = sip.wrapinstance(self.qtgui_sink_x_5.pyqwidget(), Qt.QWidget) self.tabs_layout_3.addWidget(self._qtgui_sink_x_5_win) self.qtgui_sink_x_5.enable_rf_freq(False) self.qtgui_sink_x_1 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_1.set_update_time(1.0/10) self._qtgui_sink_x_1_win = sip.wrapinstance(self.qtgui_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_2.addWidget(self._qtgui_sink_x_1_win) self.qtgui_sink_x_1.enable_rf_freq(False) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name False, #plotfreq False, #plotwaterfall False, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_5.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) 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.tabs_layout_2.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-2, 2) self.qtgui_const_sink_x_1.set_x_axis(-2, 2) self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_1.enable_autoscale(False) self.qtgui_const_sink_x_1.enable_grid(False) self.qtgui_const_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_1.set_line_label(i, labels[i]) self.qtgui_const_sink_x_1.set_line_width(i, widths[i]) self.qtgui_const_sink_x_1.set_line_color(i, colors[i]) self.qtgui_const_sink_x_1.set_line_style(i, styles[i]) self.qtgui_const_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_1_win = sip.wrapinstance(self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget) self.tabs_layout_9.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.tabs_layout_8.addWidget(self._qtgui_const_sink_x_0_win) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast(pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff(1, ( numpy.ones(n_barker_rep*barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc(1, ( numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*pi/50, (rrc_taps), nfilts, nfilts/2, pi/8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1,- 1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc(sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(2*pi/loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_pack_k_bits_bb_1 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1.0/sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1.0/(preamble_size*sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1_0, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.qtgui_time_sink_x_1_0_0, 0)) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.qtgui_sink_x_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pack_k_bits_bb_1, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 1), (self.qtgui_time_sink_x_0_3, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_pack_k_bits_bb_1, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.qtgui_sink_x_5, 0)) self.connect((self.digital_fll_band_edge_cc_1, 3), (self.qtgui_time_sink_x_1, 2)) self.connect((self.digital_fll_band_edge_cc_1, 1), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_fll_band_edge_cc_1, 2), (self.qtgui_time_sink_x_1, 1)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_frame_sync_fast_0, 0), (self.qtgui_const_sink_x_1, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0))
def __init__(self, callsign='', invert=1, ip='::', latitude=0, longitude=0, port=7355, recstart=''): gr.top_block.__init__(self, "GOMX-3 decoder") ################################################## # Parameters ################################################## self.callsign = callsign self.invert = invert self.ip = ip self.latitude = latitude self.longitude = longitude self.port = port self.recstart = recstart ################################################## # Variables ################################################## self.threshold = threshold = 6 self.access_code = access_code = "10010011000010110101000111011110" ################################################## # Blocks ################################################## self.sync_to_pdu_packed_0_0 = sync_to_pdu_packed( packlen=256, sync=access_code, threshold=threshold, ) self.sync_to_pdu_packed_0 = sync_to_pdu_packed( packlen=256, sync=access_code, threshold=threshold, ) self.sids_submit_0 = sids.submit( 'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 40949, callsign, longitude, latitude, recstart) self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S') self.digital_descrambler_bb_0_0 = digital.descrambler_bb( 0x21, 0x00, 16) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x00, 16) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff( 10, 0.25 * 0.175 * 0.175, 0.1, 0.175, 0.005) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( 2.5, 0.25 * 0.175 * 0.175, 0.1, 0.175, 0.005) self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb() self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.csp_check_crc_0 = csp.check_crc(False, False, False) self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, ip, port, 1472, False) self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767.0) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff( (invert * 10, )) self.ax100_gomx3_rs_decode_0 = ax100.gomx3_rs_decode(False) self.ax100_beacon_parser_0 = ax100.beacon_parser() ################################################## # Connections ################################################## self.msg_connect((self.ax100_gomx3_rs_decode_0, 'out'), (self.csp_check_crc_0, 'in')) self.msg_connect((self.csp_check_crc_0, 'ok'), (self.sids_print_timestamp_0, 'in')) self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.ax100_beacon_parser_0, 'in')) self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.sids_submit_0, 'in')) self.msg_connect((self.sync_to_pdu_packed_0, 'out'), (self.ax100_gomx3_rs_decode_0, 'in')) self.msg_connect((self.sync_to_pdu_packed_0_0, 'out'), (self.ax100_gomx3_rs_decode_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_udp_source_0, 0), (self.blocks_short_to_float_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_descrambler_bb_0_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, 0), (self.digital_binary_slicer_fb_0_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.sync_to_pdu_packed_0, 0)) self.connect((self.digital_descrambler_bb_0_0, 0), (self.sync_to_pdu_packed_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.samp_per_sym = samp_per_sym = 5 ################################################## # Blocks ################################################## self.satellites_pdu_to_kiss_0 = satellites.pdu_to_kiss() self.satellites_nrzi_encode_0 = satellites.nrzi_encode() self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_kiss_to_pdu_0 = satellites.kiss_to_pdu(True) self.satellites_hdlc_framer_0 = satellites.hdlc_framer( preamble_bytes=50, postamble_bytes=7) self.satellites_hdlc_deframer_0 = satellites.hdlc_deframer( check_fcs=True, max_length=10000) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 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.digital_scrambler_bb_0 = digital.scrambler_bb(0x21, 0x0, 16) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samp_per_sym * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '', '52001', 10000, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, samp_per_sym) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.5, )) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_0 = blocks.add_const_vff((-0.5, )) self.audio_source_0 = audio.source(samp_rate, '', True) self.audio_sink_0 = audio.sink(samp_rate, '', True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self.satellites_pdu_to_kiss_0, 'in')) self.msg_connect((self.satellites_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.satellites_kiss_to_pdu_0, 'out'), (self.satellites_hdlc_framer_0, 'in')) self.msg_connect((self.satellites_pdu_to_kiss_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.audio_source_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.audio_source_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.satellites_kiss_to_pdu_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.satellites_hdlc_deframer_0, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.satellites_nrzi_encode_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.satellites_nrzi_encode_0, 0), (self.blocks_repeat_0, 0))
def __init__(self, baudrate=9600, costas_loop_bw=2*math.pi/200, excess_bw=0.5, fll_loop_bw=2*math.pi/350, max_cfo=4e3, rf_samp_rate=2.4e6, symbol_Sync_loop_bw=2*math.pi/100): gr.hier_block2.__init__(self, "bpsk_ax25_demod", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signaturev(3, 3, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1]) ) # Output signature self.message_port_register_hier_out("out") ################################################## # Parameters ################################################## self.baudrate = baudrate self.costas_loop_bw = costas_loop_bw self.excess_bw = excess_bw self.fll_loop_bw = fll_loop_bw self.max_cfo = max_cfo self.rf_samp_rate = rf_samp_rate self.symbol_Sync_loop_bw = symbol_Sync_loop_bw ################################################## # Variables ################################################## self.samp_rate = samp_rate = 9600*20 self.sps = sps = int(samp_rate/baudrate) self.nfilts = nfilts = 64 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 11*sps*nfilts) self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk().base() ################################################## # Blocks ################################################## self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( samp_rate/rf_samp_rate, taps=None, flt_size=32) self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) self.low_pass_filter_0_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, ((1.0 + excess_bw) * baudrate/2.0) + min(baudrate, abs(1000*1.2)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass( 1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76)) self.hsl_rms_agc_0 = hsl.rms_agc(alpha=1e-2, reference=0.5, ) self.hsl_kiss_encoder_0 = hsl.kiss_encoder() self.digital_symbol_sync_xx_0_0 = digital.symbol_sync_cc(digital.TED_SIGNUM_TIMES_SLOPE_ML, sps, symbol_Sync_loop_bw, 1/math.sqrt(2.0), 1, 2*math.pi/100, 1, digital.constellation_bpsk().base(), digital.IR_PFB_MF, nfilts, (rrc_taps)) self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(15, 500) self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(15, 500) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, excess_bw, 300, fll_loop_bw) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(costas_loop_bw, 2, False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(bpsk_constellation) self.blocks_not_xx_0_0_0 = blocks.not_bb() self.blocks_message_debug_0 = blocks.message_debug() self.blocks_and_const_xx_0_0_0 = blocks.and_const_bb(1) ################################################## # Connections ################################################## self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.hsl_kiss_encoder_0, 'packet')) self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.hsl_kiss_encoder_0, 'packet')) self.msg_connect((self.hsl_kiss_encoder_0, 'encoded_packet'), (self, 'out')) self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_hdlc_deframer_bp_0_0, 0)) self.connect((self.blocks_not_xx_0_0_0, 0), (self.blocks_and_const_xx_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_symbol_sync_xx_0_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self, 1)) self.connect((self.digital_descrambler_bb_0, 0), (self.digital_hdlc_deframer_bp_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_not_xx_0_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0_0_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self, 2)) self.connect((self.digital_symbol_sync_xx_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_symbol_sync_xx_0_0, 0), (self, 0)) self.connect((self.hsl_rms_agc_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.hsl_rms_agc_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.low_pass_filter_0_0_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self, 0), (self.pfb_arb_resampler_xxx_0, 0)) self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
def __init__(self, freq=0, gain=0, loopbw=100, fllbw=0.002): gr.top_block.__init__(self, "Rx") ################################################## # Parameters ################################################## self.freq = freq self.gain = gain self.loopbw = loopbw self.fllbw = fllbw ################################################## # Variables ################################################## self.sps = sps = 8 self.excess_bw = excess_bw = 0.25 self.target_samp_rate = target_samp_rate = sps * (200e3 / (1 + excess_bw)) self.qpsk_const = qpsk_const = digital.constellation_qpsk().base() self.dsp_rate = dsp_rate = 100e6 self.const_choice = const_choice = "qpsk" self.bpsk_const = bpsk_const = digital.constellation_bpsk().base() self.barker_code_two_dim = barker_code_two_dim = [ -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j ] self.barker_code_one_dim = barker_code_one_dim = sqrt(2) * numpy.real([ -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j, 1.0000 + 1.0000j, -1.0000 - 1.0000j ]) self.rrc_delay = rrc_delay = int(round(-44 * excess_bw + 33)) self.nfilts = nfilts = 32 self.n_barker_rep = n_barker_rep = 10 self.dec_factor = dec_factor = ceil(dsp_rate / target_samp_rate) self.constellation = constellation = qpsk_const if ( const_choice == "qpsk") else bpsk_const self.barker_code = barker_code = barker_code_two_dim if ( const_choice == "qpsk") else barker_code_one_dim self.preamble_syms = preamble_syms = numpy.matlib.repmat( barker_code, 1, n_barker_rep)[0] self.n_rrc_taps = n_rrc_taps = rrc_delay * int(sps * nfilts) self.n_codewords = n_codewords = 1 self.even_dec_factor = even_dec_factor = dec_factor if ( dec_factor % 1 == 1) else (dec_factor + 1) self.const_order = const_order = pow(2, constellation.bits_per_symbol()) self.codeword_len = codeword_len = 18444 self.usrp_rx_addr = usrp_rx_addr = "192.168.10.2" self.samp_rate = samp_rate = dsp_rate / even_dec_factor self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, excess_bw, n_rrc_taps) self.rf_center_freq = rf_center_freq = 1428.4309e6 self.preamble_size = preamble_size = len(preamble_syms) self.pmf_peak_threshold = pmf_peak_threshold = 0.6 self.payload_size = payload_size = codeword_len * n_codewords / int( numpy.log2(const_order)) self.dataword_len = dataword_len = 6144 self.barker_len = barker_len = 13 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(0, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(0, 0) self.mods_turbo_decoder_0 = mods.turbo_decoder(codeword_len, dataword_len) self.mods_frame_sync_fast_0 = mods.frame_sync_fast( pmf_peak_threshold, preamble_size, payload_size, 0, 1, 1, int(const_order)) self.mods_fifo_async_sink_0 = mods.fifo_async_sink('/tmp/async_rx') self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_fff( 1, (numpy.ones(n_barker_rep * barker_len))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0 = filter.interp_fir_filter_ccc( 1, (numpy.flipud(numpy.conj(preamble_syms)))) self.interp_fir_filter_xxx_0.declare_sample_delay(0) self.framers_gr_hdlc_deframer_b_0 = framers.gr_hdlc_deframer_b(0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 2 * pi / 50, (rrc_taps), nfilts, nfilts / 2, pi / 8, 1) self.digital_map_bb_0_0_0 = digital.map_bb(([1, -1])) self.digital_fll_band_edge_cc_1 = digital.fll_band_edge_cc( sps, excess_bw, rrc_delay * int(sps) + 1, fllbw) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0x7F, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( 2 * pi / loopbw, 2**constellation.bits_per_symbol(), False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( constellation.base()) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb( constellation.bits_per_symbol()) self.blocks_rms_xx_1 = blocks.rms_cf(0.0001) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc( (1.0 / sqrt(2), )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc( (1.0 / (preamble_size * sqrt(2)), )) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_divide_xx_1 = blocks.divide_ff(1) self.blocks_divide_xx_0 = blocks.divide_cc(1) self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_1 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.framers_gr_hdlc_deframer_b_0, 'pdu'), (self.mods_fifo_async_sink_0, 'async_pdu')) self.connect((self.blocks_complex_to_mag_1, 0), (self.blocks_divide_xx_1, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.digital_fll_band_edge_cc_1, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_divide_xx_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.mods_frame_sync_fast_0, 2)) self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_complex_to_mag_1, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.mods_frame_sync_fast_0, 1)) self.connect((self.blocks_rms_xx_1, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_map_bb_0_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.interp_fir_filter_xxx_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.mods_frame_sync_fast_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.framers_gr_hdlc_deframer_b_0, 0)) self.connect((self.digital_fll_band_edge_cc_1, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.digital_map_bb_0_0_0, 0), (self.mods_turbo_decoder_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.interp_fir_filter_xxx_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.blocks_divide_xx_1, 1)) self.connect((self.mods_frame_sync_fast_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.mods_turbo_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rms_xx_1, 0))
def __init__(self, addr='0.0.0.0', baud=10000, fsk_dev=10000, lpf_cutoff=15e3, lpf_trans=1e3, port='52001', rx_correct=0, rx_freq=433e6): gr.top_block.__init__(self, "Cmd Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Cmd Rx") 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", "cmd_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.addr = addr self.baud = baud self.fsk_dev = fsk_dev self.lpf_cutoff = lpf_cutoff self.lpf_trans = lpf_trans self.port = port self.rx_correct = rx_correct self.rx_freq = rx_freq ################################################## # Variables ################################################## self.samp_rate = samp_rate = 100000 self.decim = decim = 2 self.samps_per_symb = samps_per_symb = int(samp_rate / decim / baud) self.rx_gain = rx_gain = 20 ################################################## # Blocks ################################################## self._rx_gain_tool_bar = Qt.QToolBar(self) self._rx_gain_tool_bar.addWidget(Qt.QLabel("rx_gain" + ": ")) self._rx_gain_line_edit = Qt.QLineEdit(str(self.rx_gain)) self._rx_gain_tool_bar.addWidget(self._rx_gain_line_edit) self._rx_gain_line_edit.returnPressed.connect(lambda: self.set_rx_gain( eng_notation.str_to_num( str(self._rx_gain_line_edit.text().toAscii())))) self.top_layout.addWidget(self._rx_gain_tool_bar) self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq( uhd.tune_request(rx_freq + rx_correct, samp_rate / 2), 0) self.uhd_usrp_source_0_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0_0.set_antenna('RX2', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) 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_ccf( 1, firdes.low_pass(1, samp_rate / decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=256) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_socket_pdu_1 = blocks.socket_pdu("TCP_SERVER", addr, '52001', 10000, False) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf( samp_rate / (2 * math.pi * fsk_dev / 8.0)) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_1, 'pdus')) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.analog_agc2_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wff Gui V1") Qt.QWidget.__init__(self) self.setWindowTitle("Wff Gui V1") 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", "wff_gui_v1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.verbose_choose = verbose_choose = True self.ssid = ssid = 0 self.scramble_label = scramble_label = '' self.output_label = output_label = '' self.kiss_label = kiss_label = '' self.input_label = input_label = '' self.hdlc_label = hdlc_label = '' self.callsign = callsign = 'WJ2XMS' self.ax25_label = ax25_label = '' ################################################## # Blocks ################################################## self._verbose_choose_options = ( True, False, ) self._verbose_choose_labels = ( 'True', 'False', ) self._verbose_choose_group_box = Qt.QGroupBox('Verbose') self._verbose_choose_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._verbose_choose_button_group = variable_chooser_button_group() self._verbose_choose_group_box.setLayout(self._verbose_choose_box) for i, label in enumerate(self._verbose_choose_labels): radio_button = Qt.QRadioButton(label) self._verbose_choose_box.addWidget(radio_button) self._verbose_choose_button_group.addButton(radio_button, i) self._verbose_choose_callback = lambda i: Qt.QMetaObject.invokeMethod( self._verbose_choose_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._verbose_choose_options.index(i))) self._verbose_choose_callback(self.verbose_choose) self._verbose_choose_button_group.buttonClicked[int].connect( lambda i: self.set_verbose_choose(self._verbose_choose_options[i])) self.top_grid_layout.addWidget(self._verbose_choose_group_box, 5, 0, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._ssid_tool_bar = Qt.QToolBar(self) self._ssid_tool_bar.addWidget(Qt.QLabel('SSID' + ": ")) self._ssid_line_edit = Qt.QLineEdit(str(self.ssid)) self._ssid_tool_bar.addWidget(self._ssid_line_edit) self._ssid_line_edit.returnPressed.connect(lambda: self.set_ssid( int(str(self._ssid_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._ssid_tool_bar, 5, 2, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self._callsign_tool_bar = Qt.QToolBar(self) self._callsign_tool_bar.addWidget(Qt.QLabel('Callsign' + ": ")) self._callsign_line_edit = Qt.QLineEdit(str(self.callsign)) self._callsign_tool_bar.addWidget(self._callsign_line_edit) self._callsign_line_edit.returnPressed.connect( lambda: self.set_callsign( str(str(self._callsign_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._callsign_tool_bar, 5, 1, 1, 1) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0_1_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_1_0_win = self.vcc_qt_hex_text_0_1_0 self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_1_0_win, 3, 1, 1, 2) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0_1 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_1_win = self.vcc_qt_hex_text_0_1 self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_1_win, 2, 1, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0_0_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_0_0_win = self.vcc_qt_hex_text_0_0_0 self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_0_0_win, 2, 3, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 5): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_0_win = self.vcc_qt_hex_text_0_0 self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_0_win, 1, 3, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 5): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_win = self.vcc_qt_hex_text_0 self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_win, 1, 1, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_insert_src_callsign_pdu_0 = vcc.insert_src_callsign_pdu( callsign=callsign, ssid=ssid, verbose=verbose_choose) self.vcc_burst_scramble_bb_0 = vcc.burst_scramble_bb(0x21, 0x0, 16) self._scramble_label_tool_bar = Qt.QToolBar(self) if None: self._scramble_label_formatter = None else: self._scramble_label_formatter = lambda x: str(x) self._scramble_label_tool_bar.addWidget(Qt.QLabel('SCRAMBLE' + ": ")) self._scramble_label_label = Qt.QLabel( str(self._scramble_label_formatter(self.scramble_label))) self._scramble_label_tool_bar.addWidget(self._scramble_label_label) self.top_grid_layout.addWidget(self._scramble_label_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._output_label_tool_bar = Qt.QToolBar(self) if None: self._output_label_formatter = None else: self._output_label_formatter = lambda x: str(x) self._output_label_tool_bar.addWidget(Qt.QLabel('OUTPUT' + ": ")) self._output_label_label = Qt.QLabel( str(self._output_label_formatter(self.output_label))) self._output_label_tool_bar.addWidget(self._output_label_label) self.top_grid_layout.addWidget(self._output_label_tool_bar, 0, 3, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 5): self.top_grid_layout.setColumnStretch(c, 1) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self._kiss_label_tool_bar = Qt.QToolBar(self) if None: self._kiss_label_formatter = None else: self._kiss_label_formatter = lambda x: str(x) self._kiss_label_tool_bar.addWidget(Qt.QLabel('KISS' + ": ")) self._kiss_label_label = Qt.QLabel( str(self._kiss_label_formatter(self.kiss_label))) self._kiss_label_tool_bar.addWidget(self._kiss_label_label) self.top_grid_layout.addWidget(self._kiss_label_tool_bar, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=64) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self._input_label_tool_bar = Qt.QToolBar(self) if None: self._input_label_formatter = None else: self._input_label_formatter = lambda x: str(x) self._input_label_tool_bar.addWidget(Qt.QLabel('Input' + ": ")) self._input_label_label = Qt.QLabel( str(self._input_label_formatter(self.input_label))) self._input_label_tool_bar.addWidget(self._input_label_label) self.top_grid_layout.addWidget(self._input_label_tool_bar, 0, 1, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self._hdlc_label_tool_bar = Qt.QToolBar(self) if None: self._hdlc_label_formatter = None else: self._hdlc_label_formatter = lambda x: str(x) self._hdlc_label_tool_bar.addWidget(Qt.QLabel('HDLC' + ": ")) self._hdlc_label_label = Qt.QLabel( str(self._hdlc_label_formatter(self.hdlc_label))) self._hdlc_label_tool_bar.addWidget(self._hdlc_label_label) self.top_grid_layout.addWidget(self._hdlc_label_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '8000', 1024, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self._ax25_label_tool_bar = Qt.QToolBar(self) if None: self._ax25_label_formatter = None else: self._ax25_label_formatter = lambda x: str(x) self._ax25_label_tool_bar.addWidget(Qt.QLabel('AX.25' + ": ")) self._ax25_label_label = Qt.QLabel( str(self._ax25_label_formatter(self.ax25_label))) self._ax25_label_tool_bar.addWidget(self._ax25_label_label) self.top_grid_layout.addWidget(self._ax25_label_tool_bar, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.vcc_qt_hex_text_0, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.vcc_qt_hex_text_0_0_0, 'pdus')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.vcc_burst_scramble_bb_0, 'in')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.vcc_qt_hex_text_0_1_0, 'pdus')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.vcc_insert_src_callsign_pdu_0, 'in')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.vcc_qt_hex_text_0_0, 'pdus')) self.msg_connect((self.vcc_burst_scramble_bb_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.vcc_insert_src_callsign_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.vcc_insert_src_callsign_pdu_0, 'out'), (self.vcc_qt_hex_text_0_1, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.kiss_kiss_to_pdu_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "PW-Sat2 Demodulator", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out("frames") Qt.QWidget.__init__(self) self.top_layout = Qt.QVBoxLayout() self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.setLayout(self.top_layout) ################################################## # Variables ################################################## self.symb_rate = symb_rate = 1200 self.samp_per_sym = samp_per_sym = 10 self.samp_rate = samp_rate = symb_rate * samp_per_sym self.frequency_offset = frequency_offset = -20e3 self.decimation = decimation = 16 self.bpsk = bpsk = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 2, 1).base() self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._frequency_offset_range = Range(-40e3, 40e3, 10, -20e3, 200) self._frequency_offset_win = RangeWidget(self._frequency_offset_range, self.set_frequency_offset, 'Frequency Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._frequency_offset_win) self._decimation_options = ( 16, 8, 4, 2, ) self._decimation_labels = ( '1200', '2400', '4800', '9600', ) self._decimation_tool_bar = Qt.QToolBar(self) self._decimation_tool_bar.addWidget(Qt.QLabel('Symbol Rate' + ": ")) self._decimation_combo_box = Qt.QComboBox() self._decimation_tool_bar.addWidget(self._decimation_combo_box) for label in self._decimation_labels: self._decimation_combo_box.addItem(label) self._decimation_callback = lambda i: Qt.QMetaObject.invokeMethod( self._decimation_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._decimation_options.index(i))) self._decimation_callback(self.decimation) self._decimation_combo_box.currentIndexChanged.connect( lambda i: self.set_decimation(self._decimation_options[i])) self.top_grid_layout.addWidget(self._decimation_tool_bar) self._alpha_range = Range(0, 1, 1e-3, 0.5, 200) self._alpha_win = RangeWidget(self._alpha_range, self.set_alpha, "alpha", "counter_slider", float) self.top_grid_layout.addWidget(self._alpha_win) self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_deframer_0 = satellites.hdlc_deframer( check_fcs=True, max_length=10000) self.root_raised_cosine_filter_0_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, alpha, 300)) self.qtgui_waterfall_sink_x_1 = qtgui.waterfall_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 192000, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_1.set_update_time(0.10) self.qtgui_waterfall_sink_x_1.enable_grid(False) self.qtgui_waterfall_sink_x_1.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_1.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_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_1.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_1.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_1.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_1.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_1_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_1_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(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 192000, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0_0.set_update_time(0.10) self.qtgui_freq_sink_x_0_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0_0.set_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(False) if not True: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win) 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_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 128, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(False) self.qtgui_const_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc( 1, (firdes.low_pass(1, 192000, 40000, 1000)), frequency_offset, 192000) self.fractional_resampler_xx_0 = filter.fractional_resampler_cc( 0, decimation) self.digital_symbol_sync_xx_0 = digital.symbol_sync_cc( digital.TED_ZERO_CROSSING, samp_per_sym, 0.045, 1.0, 1, 0.1, 1, digital.constellation_bpsk().base(), digital.IR_MMSE_8TAP, 128, ([])) self.digital_descrambler_bb_0_1 = digital.descrambler_bb( 0x21, 0x00, 16) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.1, 2, False) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( bpsk) self.analog_agc_xx_0 = analog.agc_cc(1e-3, 1, 1.0) self.analog_agc_xx_0.set_max_gain(30) ################################################## # Connections ################################################## self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self, 'frames')) self.connect((self.analog_agc_xx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_descrambler_bb_0_1, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.root_raised_cosine_filter_0_0, 0)) self.connect((self.digital_descrambler_bb_0_1, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_symbol_sync_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.fractional_resampler_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.fractional_resampler_xx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self, 0), (self.freq_xlating_fir_filter_xxx_0, 0)) self.connect((self, 0), (self.qtgui_waterfall_sink_x_1, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.digital_symbol_sync_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.satellites_hdlc_deframer_0, 0))
def __init__(self, addr='0.0.0.0', port='52001', rx_gain=38): gr.top_block.__init__(self, "Fsk Rx 1") Qt.QWidget.__init__(self) self.setWindowTitle("Fsk Rx 1") 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", "fsk_rx_1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.addr = addr self.port = port self.rx_gain = rx_gain ################################################## # Variables ################################################## self.samp_rate = samp_rate = 500000 self.baud = baud = 10e3 self.samps_per_symb = samps_per_symb = int(samp_rate/baud) self.mult = mult = (samp_rate)/2/3.141593 self.freq = freq = 433e6 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self.uhd_usrp_source_0_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0_0.set_subdev_spec('A:B', 0) self.uhd_usrp_source_0_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0_0.set_center_freq(uhd.tune_request(freq, samp_rate/2), 0) self.uhd_usrp_source_0_0.set_gain(rx_gain, 0) self.uhd_usrp_source_0_0.set_antenna('RX2', 0) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=10000) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=samps_per_symb, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", addr, port, 1024, True) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.uhd_usrp_source_0_0, 0), (self.digital_gmsk_demod_0, 0))
def __init__(self): gr.top_block.__init__(self, "Gfsk Loopback") Qt.QWidget.__init__(self) self.setWindowTitle("Gfsk Loopback") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "gfsk_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 8 self.samp_rate = samp_rate = 32000 self.fm_sensitivity = fm_sensitivity = 1 self.enc = enc = fec.tpc_encoder_make(([3]), ([43]), 26, 6, 9, 3); self.dec = dec = fec.tpc_decoder_make(([3]), ([43]), 26, 6, 9, 3, 6, 0); ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'TX_BITS', #name 1 #number of inputs ) self.qtgui_time_sink_x_1_1.set_update_time(0.10) self.qtgui_time_sink_x_1_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_1.enable_tags(-1, True) self.qtgui_time_sink_x_1_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1_1.enable_autoscale(False) self.qtgui_time_sink_x_1_1.enable_grid(False) self.qtgui_time_sink_x_1_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_1.enable_control_panel(False) self.qtgui_time_sink_x_1_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1_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_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_1_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate 'RX_BITS', #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name True, #plotfreq True, #plotwaterfall True, #plottime True, #plotconst ) self.qtgui_sink_x_0.set_update_time(1.0/10) self._qtgui_sink_x_0_win = sip.wrapinstance(self.qtgui_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self._fm_sensitivity_range = Range(0, 10, 0.01, 1, 200) self._fm_sensitivity_win = RangeWidget(self._fm_sensitivity_range, self.set_fm_sensitivity, "fm_sensitivity", "counter_slider", float) self.top_grid_layout.addWidget(self._fm_sensitivity_win) self.fec_extended_encoder_0 = fec.extended_encoder(encoder_obj_list=enc, threading= None, puncpat='11') self.fec_extended_decoder_0 = fec.extended_decoder(decoder_obj_list=dec, threading= None, ann=None, puncpat='11', integration_period=10000) self.digital_scrambler_bb_0 = digital.scrambler_bb(0x8A, 0x7F, 7) self.digital_map_bb_0 = digital.map_bb(([-1, 1])) self.digital_gmsk_mod_0 = digital.gmsk_mod( samples_per_symbol=4, bt=0.35, verbose=False, log=False, ) self.digital_gmsk_demod_0 = digital.gmsk_demod( samples_per_symbol=4, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x8A, 0x7F, 7) self.blocks_vector_source_x_0 = blocks.vector_source_b((0, 0, 0x55, 0x55), True, 1, []) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(8) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_time_sink_x_1_1, 0)) self.connect((self.blocks_char_to_float_0_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.fec_extended_decoder_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gmsk_mod_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.digital_gmsk_demod_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.qtgui_sink_x_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.digital_scrambler_bb_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.blocks_char_to_float_0_0, 0)) self.connect((self.digital_gmsk_demod_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_gmsk_mod_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.digital_scrambler_bb_0, 0), (self.fec_extended_encoder_0, 0)) self.connect((self.fec_extended_decoder_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.fec_extended_encoder_0, 0), (self.blocks_pack_k_bits_bb_0, 0))
def __init__(self): gr.top_block.__init__(self, "OPS-SAT UHF demodulator/decoder") Qt.QWidget.__init__(self) self.setWindowTitle("OPS-SAT UHF demodulator/decoder") 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", "os_demod_decode") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 57600 self.baud_rate = baud_rate = 9600 self.gaussian_taps = gaussian_taps = firdes.gaussian( 1.5, 2 * (samp_rate / baud_rate), 0.5, 12) self.gain_mu = gain_mu = 0.175 ################################################## # Blocks ################################################## self.zeromq_sub_source_0 = zeromq.sub_source(gr.sizeof_gr_complex, 1, 'tcp://127.0.0.1:5555', 100, False, -1) self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, 'tcp://127.0.0.1:38211', 100, False, -1) self.satellites_strip_ax25_header_0 = satellites.strip_ax25_header() self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_deframer_0_0 = satellites.hdlc_deframer( check_fcs=True, max_length=1000) self.satellites_decode_rs_0 = satellites.decode_rs(True, 0) self.satellites_check_address_0 = satellites.check_address( 'DP0OPS', "from") self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 512, #size firdes.WIN_HAMMING, #wintype 0, #fc samp_rate, #bw "OPS-SAT UHF BEACON", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.03) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance( self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 512, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(0.1) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.fir_filter_xxx_0 = filter.fir_filter_fff(1, (gaussian_taps)) self.fir_filter_xxx_0.declare_sample_delay(0) self.digital_descrambler_bb_0_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff( (samp_rate / baud_rate) * (1 + 0.0), 0.25 * gain_mu * gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.digital_additive_scrambler_bb_0_0 = digital.additive_scrambler_bb( 0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key="packet_len") self.blocks_unpacked_to_packed_xx_0_0_0_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_tagged_stream_to_pdu_0_0_0_0_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_message_debug_0 = blocks.message_debug() self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf( 2 * (samp_rate / baud_rate) / (math.pi)) ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 'pdus'), (self.satellites_decode_rs_0, 'in')) self.msg_connect((self.satellites_check_address_0, 'ok'), (self.satellites_strip_ax25_header_0, 'in')) self.msg_connect((self.satellites_decode_rs_0, 'out'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.satellites_decode_rs_0, 'out'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.satellites_hdlc_deframer_0_0, 'out'), (self.satellites_check_address_0, 'in')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.fir_filter_xxx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_additive_scrambler_bb_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0_0_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0_0_0_0, 0)) self.connect((self.digital_additive_scrambler_bb_0_0, 0), (self.blocks_unpacked_to_packed_xx_0_0_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0_0, 0), (self.satellites_hdlc_deframer_0_0, 0)) self.connect((self.fir_filter_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_descrambler_bb_0_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.zeromq_sub_source_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
def __init__(self, fsk_dev=10000, lpf_cutoff=10e3, lpf_trans=1e3): gr.top_block.__init__(self, "Afsk Test") Qt.QWidget.__init__(self) self.setWindowTitle("Afsk Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "afsk_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fsk_dev = fsk_dev self.lpf_cutoff = lpf_cutoff self.lpf_trans = lpf_trans ################################################## # Variables ################################################## self.samp_rate = samp_rate = 48000 self.baud = baud = 1200 self.samps_per_symb = samps_per_symb = int(samp_rate/baud) self.noise_amp = noise_amp = 0.3 self.mult = mult = (samp_rate)/2/3.141593 self.decim = decim = 2 self.bb_gain = bb_gain = .75 self.alpha = alpha = 0.5 ################################################## # Blocks ################################################## self._noise_amp_range = Range(0, 1, 0.005, 0.3, 200) self._noise_amp_win = RangeWidget(self._noise_amp_range, self.set_noise_amp, "noise_amp", "counter_slider", float) self.top_grid_layout.addWidget(self._noise_amp_win, 6,0,1,4) self._bb_gain_range = Range(0, 1, .01, .75, 200) self._bb_gain_win = RangeWidget(self._bb_gain_range, self.set_bb_gain, 'bb_gain', "counter_slider", float) self.top_grid_layout.addWidget(self._bb_gain_win, 5,0,1,4) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.10) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not False) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_waterfall_sink_x_0_win) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 8192, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) self.qtgui_time_sink_x_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2048, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) self.qtgui_time_sink_x_0.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4,4,3,4) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate/decim, #bw "RX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.10) self.qtgui_freq_sink_x_1_0.set_y_axis(-80, 10) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0,4,4,4) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "TX Spectrum", #name 1 #number of inputs ) self.qtgui_freq_sink_x_1.set_update_time(0.10) self.qtgui_freq_sink_x_1.set_y_axis(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_win = sip.wrapinstance(self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0,0,4,4) self.pyqt_text_output_0 = pyqt.text_output() self._pyqt_text_output_0_win = self.pyqt_text_output_0; self.top_layout.addWidget(self._pyqt_text_output_0_win) self.pyqt_text_input_0 = pyqt.text_input() self._pyqt_text_input_0_win = self.pyqt_text_input_0; self.top_grid_layout.addWidget(self._pyqt_text_input_0_win, 4,0,1,4) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate/decim, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_nrzi_encode_0 = kiss.nrzi_encode() self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=16) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samps_per_symb, sensitivity=0.06, bt=1, verbose=False, log=False, ) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0)/decim, 0.25*0.175*0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_gr_complex * 1, False) self.blocks_tag_gate_0.set_single_key("packet_len") self.blocks_socket_pdu_0_2 = blocks.socket_pdu("UDP_SERVER", '0.0.0.0', '52002', 1024, False) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((bb_gain, )) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.audio_sink_0 = audio.sink(samp_rate, '', True) self.analog_sig_source_x_0 = analog.sig_source_f(samp_rate, analog.GR_COS_WAVE, 1700, 1, 0) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_dev/8.0)) self.analog_nbfm_tx_0 = analog.nbfm_tx( audio_rate=samp_rate, quad_rate=samp_rate, tau=75e-6, max_dev=5e3, fh=-1.0, ) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_amp, 0, 8192) self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.blocks_socket_pdu_0_2, 'pdus')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.pyqt_text_output_0, 'pdus')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.pyqt_text_input_0, 'pdus'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.analog_agc2_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.analog_nbfm_tx_0, 0), (self.blocks_add_xx_1, 1)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_add_xx_1, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_nbfm_tx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.kiss_nrzi_encode_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.kiss_nrzi_encode_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wff File Test") Qt.QWidget.__init__(self) self.setWindowTitle("Wff File Test") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wff_file_test") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.scramble_label = scramble_label = '' self.output_label = output_label = '' self.kiss_label = kiss_label = '' self.hdlc_label = hdlc_label = '' self.ax25_label = ax25_label = '' ################################################## # Blocks ################################################## self.vcc_qt_hex_text_0_0_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_0_0_win = self.vcc_qt_hex_text_0_0_0 self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_0_0_win, 2, 3, 1, 2) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 5): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_0_win = self.vcc_qt_hex_text_0_0 self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_0_win, 1, 3, 1, 2) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 5): self.top_grid_layout.setColumnStretch(c, 1) self._scramble_label_tool_bar = Qt.QToolBar(self) if None: self._scramble_label_formatter = None else: self._scramble_label_formatter = lambda x: str(x) self._scramble_label_tool_bar.addWidget(Qt.QLabel('SCRAMBLE' + ": ")) self._scramble_label_label = Qt.QLabel( str(self._scramble_label_formatter(self.scramble_label))) self._scramble_label_tool_bar.addWidget(self._scramble_label_label) self.top_grid_layout.addWidget(self._scramble_label_tool_bar, 4, 0, 1, 1) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._output_label_tool_bar = Qt.QToolBar(self) if None: self._output_label_formatter = None else: self._output_label_formatter = lambda x: str(x) self._output_label_tool_bar.addWidget(Qt.QLabel('OUTPUT' + ": ")) self._output_label_label = Qt.QLabel( str(self._output_label_formatter(self.output_label))) self._output_label_tool_bar.addWidget(self._output_label_label) self.top_grid_layout.addWidget(self._output_label_tool_bar, 0, 3, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 5): self.top_grid_layout.setColumnStretch(c, 1) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self._kiss_label_tool_bar = Qt.QToolBar(self) if None: self._kiss_label_formatter = None else: self._kiss_label_formatter = lambda x: str(x) self._kiss_label_tool_bar.addWidget(Qt.QLabel('KISS' + ": ")) self._kiss_label_label = Qt.QLabel( str(self._kiss_label_formatter(self.kiss_label))) self._kiss_label_tool_bar.addWidget(self._kiss_label_label) self.top_grid_layout.addWidget(self._kiss_label_tool_bar, 1, 0, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self._hdlc_label_tool_bar = Qt.QToolBar(self) if None: self._hdlc_label_formatter = None else: self._hdlc_label_formatter = lambda x: str(x) self._hdlc_label_tool_bar.addWidget(Qt.QLabel('HDLC' + ": ")) self._hdlc_label_label = Qt.QLabel( str(self._hdlc_label_formatter(self.hdlc_label))) self._hdlc_label_tool_bar.addWidget(self._hdlc_label_label) self.top_grid_layout.addWidget(self._hdlc_label_tool_bar, 3, 0, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0xFF, 16) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( 1, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_char * 1, '/home/zleffke/Downloads/AX25_Scrambled.dat', False) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self._ax25_label_tool_bar = Qt.QToolBar(self) if None: self._ax25_label_formatter = None else: self._ax25_label_formatter = lambda x: str(x) self._ax25_label_tool_bar.addWidget(Qt.QLabel('AX.25' + ": ")) self._ax25_label_label = Qt.QLabel( str(self._ax25_label_formatter(self.ax25_label))) self._ax25_label_tool_bar.addWidget(self._ax25_label_label) self.top_grid_layout.addWidget(self._ax25_label_tool_bar, 2, 0, 1, 1) for r in range(2, 3): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.vcc_qt_hex_text_0_0_0, 'pdus')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.vcc_qt_hex_text_0_0, 'pdus')) self.connect((self.blocks_file_source_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_hdlc_deframer_0, 0))
def __init__(self, lpf_cutoff=24e3, lpf_cutoff_2=8e3, lpf_trans=1e3): gr.top_block.__init__(self, "Burst Detect Es6") Qt.QWidget.__init__(self) self.setWindowTitle("Burst Detect Es6") 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", "burst_detect_es6") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.lpf_cutoff = lpf_cutoff self.lpf_cutoff_2 = lpf_cutoff_2 self.lpf_trans = lpf_trans ################################################## # Variables ################################################## self.samp_rate = samp_rate = 250000 self.interp = interp = 24*2 self.decim = decim = int(samp_rate/2000) self.baud = baud = 9600 self.samps_per_symb = samps_per_symb = int((samp_rate/decim*interp)/baud) self.offset = offset = 0 self.max_symbols = max_symbols = samps_per_symb*300*8 *2 self.interp_2 = interp_2 = 1 self.fsk_dev = fsk_dev = 10000 self.decim_2 = decim_2 = 2 self.avg_len_snr = avg_len_snr = 100.0 self.avg_len_det = avg_len_det = 100.0 ################################################## # Blocks ################################################## self._offset_tool_bar = Qt.QToolBar(self) self._offset_tool_bar.addWidget(Qt.QLabel("offset"+": ")) self._offset_line_edit = Qt.QLineEdit(str(self.offset)) self._offset_tool_bar.addWidget(self._offset_line_edit) self._offset_line_edit.returnPressed.connect( lambda: self.set_offset(eng_notation.str_to_num(str(self._offset_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._offset_tool_bar, 4, 4, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._avg_len_snr_tool_bar = Qt.QToolBar(self) self._avg_len_snr_tool_bar.addWidget(Qt.QLabel("avg_len_snr"+": ")) self._avg_len_snr_line_edit = Qt.QLineEdit(str(self.avg_len_snr)) self._avg_len_snr_tool_bar.addWidget(self._avg_len_snr_line_edit) self._avg_len_snr_line_edit.returnPressed.connect( lambda: self.set_avg_len_snr(eng_notation.str_to_num(str(self._avg_len_snr_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._avg_len_snr_tool_bar, 6, 4, 1, 2) for r in range(6, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self._avg_len_det_tool_bar = Qt.QToolBar(self) self._avg_len_det_tool_bar.addWidget(Qt.QLabel("avg_len_det"+": ")) self._avg_len_det_line_edit = Qt.QLineEdit(str(self.avg_len_det)) self._avg_len_det_tool_bar.addWidget(self._avg_len_det_line_edit) self._avg_len_det_line_edit.returnPressed.connect( lambda: self.set_avg_len_det(eng_notation.str_to_num(str(self._avg_len_det_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._avg_len_det_tool_bar, 5, 4, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 6): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_qt_hex_text_0 = vcc.qt_hex_text() self._vcc_qt_hex_text_0_win = self.vcc_qt_hex_text_0; self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_win, 4, 0, 3, 4) for r in range(4, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.vcc_burst_snr_0 = vcc.burst_snr(int(avg_len_snr)) self.vcc_burst_cfo_est_gmsk_0 = vcc.burst_cfo_est_gmsk(samp_rate * interp / decim) self.rational_resampler_xxx_1_0 = filter.rational_resampler_ccc( interpolation=interp_2, decimation=decim_2, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_1 = filter.rational_resampler_ccc( interpolation=interp_2, decimation=decim_2, taps=None, fractional_bw=None, ) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interp, decimation=decim, taps=None, fractional_bw=None, ) self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim*interp, #bw "RX Spectrum", #name 1 #number of inputs ) self.qtgui_waterfall_sink_x_0.set_update_time(0.010) self.qtgui_waterfall_sink_x_0.enable_grid(False) self.qtgui_waterfall_sink_x_0.enable_axis_labels(True) if not True: self.qtgui_waterfall_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i]) self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i]) self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i]) self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10) self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 4, 2, 4) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate / decim*interp, #bw "RX Spectrum", #name 2 #number of inputs ) self.qtgui_freq_sink_x_1_0.set_update_time(0.010) self.qtgui_freq_sink_x_1_0.set_y_axis(-150, 0) self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1_0.enable_autoscale(False) self.qtgui_freq_sink_x_1_0.enable_grid(True) self.qtgui_freq_sink_x_1_0.set_fft_average(1.0) self.qtgui_freq_sink_x_1_0.enable_axis_labels(True) self.qtgui_freq_sink_x_1_0.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True) labels = ['pre-d', 'agc_filt', '', '', '', '', '', '', '', ''] 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_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0, 2, 4) for r in range(0, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 2048, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate*interp/decim*interp_2/decim_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(-140, 10) self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(True) self.qtgui_freq_sink_x_1.enable_grid(True) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_axis_labels(True) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not 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 = ['', '', '', '', '', '', '', '', '', ''] 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 2, 0, 2, 4) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.pyqt_meta_text_output_0 = pyqt.meta_text_output() self._pyqt_meta_text_output_0_win = self.pyqt_meta_text_output_0; self.top_grid_layout.addWidget(self._pyqt_meta_text_output_0_win, 4, 6, 3, 2) for r in range(4, 7): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.pyqt_ctime_plot_0 = pyqt.ctime_plot('') self._pyqt_ctime_plot_0_win = self.pyqt_ctime_plot_0; self.top_grid_layout.addWidget(self._pyqt_ctime_plot_0_win, 2, 4, 2, 4) for r in range(2, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(4, 8): self.top_grid_layout.setColumnStretch(c, 1) self.low_pass_filter_0_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate / decim *interp / decim_2 *interp_2, lpf_cutoff_2, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf(1, firdes.low_pass( 1, samp_rate / decim *interp, lpf_cutoff, lpf_trans, firdes.WIN_HAMMING, 6.76)) self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss() self.kiss_nrzi_decode_0 = kiss.nrzi_decode() self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True, max_length=300) self.es_trigger_edge_f_0 = es.trigger_edge_f(-2,baud*samps_per_symb,int(avg_len_det*2),gr.sizeof_gr_complex,300) self.es_sink_0 = es.sink(1*[gr.sizeof_gr_complex],4,64,0,2,0) self.es_handler_pdu_0 = es.es_make_handler_pdu(es.es_handler_print.TYPE_C32) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samps_per_symb*(1+0.0) / decim_2, 0.25*0.175*0.175, 0.25, 0.175, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.burst_length_detect_c_0 = burst.length_detect_c() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_sub_xx_0 = blocks.sub_ff(1) self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float*1, 1) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'est_len') (self.blocks_pdu_to_tagged_stream_0_0).set_min_output_buffer(96000) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'est_len') (self.blocks_pdu_to_tagged_stream_0).set_min_output_buffer(96000) self.blocks_pdu_remove_0 = blocks.pdu_remove(pmt.intern("es::event_buffer")) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_moving_average_xx_0 = blocks.moving_average_ff(int(avg_len_det), 1/avg_len_det, 4000, 1) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/zleffke/captures/lithium_20180327/downlink_data_1.fc32', True) self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL) self.blocks_add_const_vxx_0 = blocks.add_const_vff((3, )) self.blocks_abs_xx_0 = blocks.abs_ff(1) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -1*offset, 1, 0) self.analog_quadrature_demod_cf_1_0 = analog.quadrature_demod_cf((samp_rate/decim*interp/decim_2*interp_2)/(2*math.pi*fsk_dev/8.0)) self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf((samp_rate/decim*interp)/(2*math.pi*fsk_dev/8.0)) self.analog_agc2_xx_0 = analog.agc2_cc(10, 1e-1, 65536, 1) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.msg_connect((self.blocks_pdu_remove_0, 'pdus'), (self.burst_length_detect_c_0, 'cpdus')) self.msg_connect((self.burst_length_detect_c_0, 'cpdus'), (self.vcc_burst_snr_0, 'in')) self.msg_connect((self.es_handler_pdu_0, 'pdus_out'), (self.blocks_pdu_remove_0, 'pdus')) self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'), (self.es_handler_pdu_0, 'handle_event')) self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'), (self.es_sink_0, 'schedule_event')) self.msg_connect((self.kiss_hdlc_deframer_0, 'out'), (self.kiss_pdu_to_kiss_0, 'in')) self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.vcc_qt_hex_text_0, 'pdus')) self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'corrected'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'out'), (self.pyqt_ctime_plot_0, 'cpdus')) self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'out'), (self.pyqt_meta_text_output_0, 'pdus')) self.msg_connect((self.vcc_burst_snr_0, 'out'), (self.vcc_burst_cfo_est_gmsk_0, 'in')) self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.blocks_skiphead_0, 0)) self.connect((self.analog_quadrature_demod_cf_1, 0), (self.blocks_sub_xx_0, 0)) self.connect((self.analog_quadrature_demod_cf_1_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_abs_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_add_const_vxx_0, 0), (self.es_trigger_edge_f_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.rational_resampler_xxx_1_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.rational_resampler_xxx_1, 0)) self.connect((self.blocks_skiphead_0, 0), (self.blocks_sub_xx_0, 1)) self.connect((self.blocks_sub_xx_0, 0), (self.blocks_abs_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_descrambler_bb_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.kiss_nrzi_decode_0, 0)) self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0)) self.connect((self.kiss_nrzi_decode_0, 0), (self.kiss_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_quadrature_demod_cf_1, 0)) self.connect((self.low_pass_filter_0, 0), (self.es_trigger_edge_f_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_1_0, 1)) self.connect((self.low_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.analog_quadrature_demod_cf_1_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.qtgui_freq_sink_x_1, 1)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.qtgui_freq_sink_x_1_0, 0)) self.connect((self.rational_resampler_xxx_1, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.rational_resampler_xxx_1_0, 0), (self.qtgui_freq_sink_x_1, 0))