def test_packet_encoder_bpsk (self): preamble = (1,-1,-1,1) src_data = (0b11001000,0b01111111,0b01100001,0b11110100) constel_header = digital.constellation_calcdist(([1,-1]), ([0, 1]), 2, 1).base() constel_payload = digital.constellation_calcdist(([1,-1]), ([0, 1]), 2, 1).base() header_formatter = digital.packet_header_default(32/constel_header.bits_per_symbol(), "packet_len", "packet_num", constel_header.bits_per_symbol()) expected_result = preamble + \ ((1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j)) # Manual verification: # PREAMBLE: # ( 1+0j), (-1+0j), (-1+0j), ( 1+0j), # HEADER : Bits 0-11: payload length in symbols (take care of order! LSB more to the 'left'!), bits 12-23: packet number, bits 24-31 8-BIT CRC # # (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), # (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), # (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (1+0j), # (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (1+0j) # which is 00000100 0000|0000 00000000|11111000 (packet length of 32 symbols) # # PAYLOAD : # (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), # (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), # (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), # (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j)) # which is 00010011 11111110 10000110 00101111 # so each byte is reversed because its read LSB first, which is correct src = blocks.vector_source_b (src_data, repeat=False) packet_len = len(src_data) tagger = blocks.stream_to_tagged_stream(1, 1, packet_len, "packet_len") repacker = blocks.repack_bits_bb(8, 1, "packet_len", False, gr.GR_LSB_FIRST) #arguments: preamble, constel_header, constel_payload, header_formatter, lengthtagname, zero_padding, whiten, itemsize penc = packetizer.packet_encoder (preamble, constel_header, constel_payload, header_formatter, "packet_len",0, False,1 ) snk = blocks.vector_sink_c(1) self.tb.connect (src, tagger) self.tb.connect (tagger, repacker) self.tb.connect (repacker, penc) self.tb.connect (penc, snk) self.tb.run () result_data = snk.data () #print "\n RESULT DATA",result_data,"\n" self.assertFloatTuplesAlmostEqual (expected_result, result_data)
def __init__(self, constellation=[-1, 1]): gr.top_block.__init__(self, "Channel Model Gui") ################################################## # Parameters ################################################## self.constellation = constellation ################################################## # Variables ################################################## self.const_points = const_points = constellation self.taps = taps = [1.0, 0.25-0.25j, 0.50 + 0.10j, 0.3 + 0.2j] self.samp_rate = samp_rate = 8e6 self.noise_level = noise_level = 0.3 self.frequency = frequency = 2000000 self.const_type = const_type = 1 self.const_dist = const_dist = digital.constellation_calcdist(const_points,[],0,1) self.const = const = digital.constellation_qpsk() ################################################## # Blocks ################################################## self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(const_dist.base()) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const_dist.base()) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((const_dist.points()), 1) self.custom_ber_0 = custom_ber( n_bits=10000, bits_per_symbol=3, ) self.channels_channel_model_0_0 = channels.channel_model( noise_voltage=0, frequency_offset=0, epsilon=1, taps=([1,0,0,0]), noise_seed=0, block_tags=False ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise_level, frequency_offset=0, epsilon=1, taps=(taps), noise_seed=0, block_tags=False ) self.blocks_vector_sink_x_1 = blocks.vector_sink_f(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, len(const_points), 10000)), False) ################################################## # Connections ################################################## self.connect((self.custom_ber_0, 0), (self.blocks_vector_sink_x_1, 0)) self.connect((self.channels_channel_model_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.custom_ber_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.custom_ber_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.channels_channel_model_0_0, 0)) self.connect((self.channels_channel_model_0_0, 0), (self.digital_constellation_decoder_cb_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "shippingUDPTester") Qt.QWidget.__init__(self) self.setWindowTitle("shippingUDPTester") 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", "shippingTester1") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10000 self.msg_str = msg_str = 'AAA000000' self.QPSK = QPSK = digital.constellation_calcdist(([1+1j, -1+1j, 1-1j, -1-1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self._msg_str_tool_bar = Qt.QToolBar(self) self._msg_str_tool_bar.addWidget(Qt.QLabel("msg_str"+": ")) self._msg_str_line_edit = Qt.QLineEdit(str(self.msg_str)) self._msg_str_tool_bar.addWidget(self._msg_str_line_edit) self._msg_str_line_edit.returnPressed.connect( lambda: self.set_msg_str(str(str(self._msg_str_line_edit.text().toAscii())))) self.top_grid_layout.addWidget(self._msg_str_tool_bar) self.gnuShipping_shippingSender_0 = gnuShipping.shippingSender(5) self.gnuShipping_shippingReciever_0 = gnuShipping.shippingReciever(msg_str) self.digital_crc32_async_bb_1 = digital.crc32_async_bb(False) self.digital_crc32_async_bb_0 = digital.crc32_async_bb(True) self.blocks_socket_pdu_1 = blocks.socket_pdu("UDP_CLIENT", 'localhost', '10000', 10000, False) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_1, 'pdus'), (self.digital_crc32_async_bb_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_0, 'out'), (self.gnuShipping_shippingReciever_0, 'in')) self.msg_connect((self.digital_crc32_async_bb_1, 'out'), (self.blocks_socket_pdu_1, 'pdus')) self.msg_connect((self.gnuShipping_shippingSender_0, 'out'), (self.digital_crc32_async_bb_1, 'in'))
def twod_constell(): """ """ points = ((1 + 0j), (0 + 1j), (-1 + 0j), (0 - 1j)) rot_sym = 2 dim = 2 return digital.constellation_calcdist(points, [], rot_sym, dim)
def threed_constell(): oned_points = ((1 + 0j), (0 + 1j), (-1 + 0j), (0 - 1j)) points = [] r4 = list(range(0, 4)) for ia in r4: for ib in r4: for ic in r4: points += [oned_points[ia], oned_points[ib], oned_points[ic]] rot_sym = 4 dim = 3 return digital.constellation_calcdist(points, [], rot_sym, dim)
def threed_constell(): oned_points = ((1+0j), (0+1j), (-1+0j), (0-1j)) points = [] r4 = range(0, 4) for ia in r4: for ib in r4: for ic in r4: points += [oned_points[ia], oned_points[ib], oned_points[ic]] rot_sym = 4 dim = 3 return digital.constellation_calcdist(points, [], rot_sym, dim)
def constellation_ook(): ''' 0 1 ''' constellation_points = [0, 1] gray_code = [0, 1] return digital.constellation_calcdist( constellation_points, gray_code, 1, # rotational symmetry 1 # dimensionality ).base()
def constellation_4_pam(): ''' 0 1 3 2 ''' constellation_points = [0, 1, 2, 3] gray_code = [0, 1, 3, 2] return digital.constellation_calcdist( constellation_points, gray_code, 1, # rotational symmetry 1 # dimensionality ).base()
def constellation_8_pam(): ''' 6 2 3 1 0 4 5 7 ''' constellation_points = [0, 1, 2, 3, 4, 5, 6, 7] gray_code = [6, 2, 3, 1, 0, 4, 5, 7] return digital.constellation_calcdist( constellation_points, gray_code, 1, # rotational symmetry 1 # dimensionality ).base()
def constellation_8qam_rectangular(): ''' 2 3 1 0 6 7 5 4 ''' constellation_points = [ -3 + 1j, -1 + 1j, 1 + 1j, 3 + 1j, -3 - 1j, -1 - 1j, 1 - 1j, 3 - 1j ] gray_code = [2, 3, 1, 0, 6, 7, 5, 4] return digital.constellation_calcdist( constellation_points, gray_code, 2, # rotational symmetry 1 # dimensionality ).base()
def __init__(self,EbN0db,semente): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.d = d = 0.1633 self.dj = dj = d*1j self.cj = cj = d*3j self.c = c = 3*d self.bj = bj = d*5j self.b = b = 5*d self.aj = aj = d*7j self.a = a = 7*d self.value = value = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63 self.symbol = symbol = (-a-aj),(-b-aj),(-c-aj),(-d-aj),(+a-aj),(+b-aj),(+c-aj),(+d-aj),(-a-bj),(-b-bj),(-c-bj),(-d-bj),(+a-bj),(+b-bj),(+c-bj),(+d-bj),(-a-cj),(-b-cj),(-c-cj),(-d-cj),(+a-cj),(+b-cj),(+c-cj),(+d-cj),(-a-dj),(-b-dj),(-c-dj),(-d-dj),(+a-dj),(+b-dj),(+c-dj),(+d-dj),(-a+aj),(-b+aj),(-c+aj),(-d+aj),(+a+aj),(+b+aj),(+c+aj),(+d+aj),(-a+bj),(-b+bj),(-c+bj),(-d+bj),(+a+bj),(+b+bj),(+c+bj),(+d+bj),(-a+cj),(-b+cj),(-c+cj),(-d+cj),(+a+cj),(+b+cj),(+c+cj),(+d+cj),(-a+dj),(-b+dj),(-c+dj),(-d+dj),(+a+dj),(+b+dj),(+c+dj),(+d+dj) self.samp_rate = samp_rate = 200000 self.constellation = constellation = digital.constellation_calcdist((symbol), (value), 0, 1).base() ################################################## # Blocks ################################################## self.vectorSink = blocks.vector_sink_f(1) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((symbol), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000000, bits_per_symbol=int(math.log(len(symbol))/math.log(2)), ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 64, 4000000)), False) self.analog_noise_source_x_0 =analog.noise_source_c(analog.GR_GAUSSIAN,self.EbN0_to_noise_voltage(EbN0db,int(6)),semente) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.vectorSink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1))
def constellation_8qam_circular(): ''' 1 5 4 2 0 6 7 3 ''' constellation_points = [ complex(0, 1 + np.sqrt(3)), -1 + 1j, 1 + 1j, -1 - np.sqrt(3), 1 + np.sqrt(3), -1 - 1j, 1 - 1j, complex(0, -1 - np.sqrt(3)) ] gray_code = [1, 5, 4, 2, 0, 6, 7, 3] return digital.constellation_calcdist( constellation_points, gray_code, 4, # rotational symmetry 1 # dimensionality ).base()
def constellation_16_psk(): ''' 6 7 2 5 3 4 1 12 0 13 8 15 9 14 11 10 ''' constellation_points = np.exp(2j * np.linspace(0, np.pi * 15 / 16.0, 16)) gray_code = [6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 0, 1, 3, 2] return digital.constellation_calcdist( constellation_points, gray_code, 16, # rotational symmetry 1 # dimensionality ).base()
def __init__(self,EbN0db,semente): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.value = value = 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 self.symbol = symbol = (0.33333+1/3j),(0.33333+1j),1+1/3j,1+1j,-0.33333+1/3j,-1+1/3j,-0.33333+1j,-1+1j,-0.33333-1/3j,-0.33333-1j,-1-1/3j,-1-1j,0.33333-1/3j,1-1/3j,0.33333-1j,1-1j self.samp_rate = samp_rate = 200000 self.constellation = constellation = digital.constellation_calcdist((symbol), (value), 4, 1).base() ################################################## # Blocks ################################################## self.vectorSink = blocks.vector_sink_f(1) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((symbol), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=10000000, bits_per_symbol=int(math.log(len(symbol))/math.log(2)), ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 16, 10000000)), False) self.analog_noise_source_x_0 =analog.noise_source_c(analog.GR_GAUSSIAN,self.EbN0_to_noise_voltage(EbN0db,int(4)),semente) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.vectorSink, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 1))
def constellation_16_psk(): ''' 6 7 2 5 3 4 1 12 0 13 8 15 9 14 11 10 ''' constellation_points = np.exp(2j * np.linspace(0, np.pi * 15 / 16.0, 16)) # This is not quite a gray-code, but an optimal mapping. # This was taken from the MATLAB generated 32-QAM mapping gray_code = [6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 0, 1, 3, 2] return digital.constellation_calcdist( constellation_points, gray_code, 16, # rotational symmetry 1 # dimensionality ).base()
def helper_no_lut(self, prec, src_data, const_gen, const_sd_gen): cnst_pts, code = const_gen() cnst = digital.constellation_calcdist(cnst_pts, code, 2, 1) expected_result = list() for s in src_data: res = digital.calc_soft_dec(s, cnst.points(), code) expected_result += res src = blocks.vector_source_c(src_data) op = digital.constellation_soft_decoder_cf(cnst.base()) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() actual_result = dst.data() # fetch the contents of the sink # print "actual result", actual_result # print "expected result", expected_result # Double vs. float precision issues between Python and C++, so # use only 4 decimals in comparisons. self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 4)
def helper_with_lut(self, prec, src_data, const_gen, const_sd_gen): cnst_pts, code = const_gen() Es = max([abs(c) for c in cnst_pts]) lut = digital.soft_dec_table_generator(const_sd_gen, prec, Es) expected_result = list() for s in src_data: res = digital.calc_soft_dec_from_table(s, lut, prec, sqrt(2.0)) expected_result += res cnst = digital.constellation_calcdist(cnst_pts, code, 2, 1) cnst.set_soft_dec_lut(lut, int(prec)) src = blocks.vector_source_c(src_data) op = digital.constellation_soft_decoder_cf(cnst.base()) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() actual_result = dst.data() # fetch the contents of the sink # print "actual result", actual_result # print "expected result", expected_result self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 5)
def helper_with_lut(self, prec, src_data, const_gen, const_sd_gen): cnst_pts, code = const_gen() Es = max([abs(c) for c in cnst_pts]) lut = digital.soft_dec_table_generator(const_sd_gen, prec, Es) expected_result = list() for s in src_data: res = digital.calc_soft_dec_from_table(s, lut, prec, sqrt(2.0)) expected_result += res cnst = digital.constellation_calcdist(cnst_pts, code, 2, 1) cnst.set_soft_dec_lut(lut, int(prec)) src = blocks.vector_source_c(src_data) op = digital.constellation_soft_decoder_cf(cnst.base()) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() actual_result = dst.data() # fetch the contents of the sink #print "actual result", actual_result #print "expected result", expected_result self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 5)
def helper_no_lut(self, prec, src_data, const_gen, const_sd_gen): cnst_pts, code = const_gen() cnst = digital.constellation_calcdist(cnst_pts, code, 2, 1) expected_result = list() for s in src_data: res = digital.calc_soft_dec(s, cnst.points(), code) expected_result += res src = blocks.vector_source_c(src_data) op = digital.constellation_soft_decoder_cf(cnst.base()) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() actual_result = dst.data() # fetch the contents of the sink #print "actual result", actual_result #print "expected result", expected_result # Double vs. float precision issues between Python and C++, so # use only 4 decimals in comparisons. self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 4)
def qam32(sps, excess_bw=0.35): qam32_constellation = digital.constellation_calcdist(([ x / math.sqrt(20) for x in [ -3 + 5j, -1 + 5j, 1 + 5j, 3 + 5j, -5 + 3j, -3 + 3j, -1 + 3j, 1 + 3j, 3 + 3j, 5 + 3j, -5 + 1j, -3 + 1j, -1 + 1j, 1 + 1j, 3 + 1j, 5 + 1j, -5 - 1j, -3 - 1j, -1 - 1j, 1 - 1j, 3 - 1j, 5 - 1j, -5 - 3j, -3 - 3j, -1 - 3j, 1 - 3j, 3 - 3j, 5 - 3j, -3 - 5j, -1 - 5j, 1 - 5j, 3 - 5j ] ]), ([ 0, 1, 29, 28, 4, 8, 12, 16, 20, 24, 5, 9, 13, 17, 21, 25, 6, 10, 14, 18, 22, 26, 7, 11, 15, 19, 23, 27, 3, 2, 30, 31 ]), 4, 1).base() return digital.generic_mod( constellation=qam32_constellation, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=excess_bw, verbose=False, log=False, )
def test_constellation_soft_decoder_cf_qam16(self): prec = 8 src_data = (0.5 + 0.5j, 0.1 - 1.2j, -0.8 - 0.1j, -0.45 + 0.8j, 0.8 + 1.0j, -0.5 + 0.1j, 0.1 - 1.2j, 1+1j) lut = digital.soft_dec_table_generator(digital.sd_qam_16_0x0_0_1_2_3, prec) expected_result = list() for s in src_data: expected_result += digital.calc_soft_dec_from_table(s, lut, prec) cnst_pts = digital.qam_16_0x0_0_1_2_3() cnst = digital.constellation_calcdist(cnst_pts[0], cnst_pts[1], 2, 1) cnst.set_soft_dec_lut(lut, int(prec)) src = blocks.vector_source_c(src_data) op = digital.constellation_soft_decoder_cf(cnst.base()) dst = blocks.vector_sink_f() self.tb.connect(src, op) self.tb.connect(op, dst) self.tb.run() # run the graph and wait for it to finish actual_result = dst.data() # fetch the contents of the sink #print "actual result", actual_result #print "expected result", expected_result self.assertFloatTuplesAlmostEqual(expected_result, actual_result, 5)
def __init__(self): gr.top_block.__init__(self, "Psk Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Psk 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", "psk_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.samp_rate = samp_rate = 1e6 self.my_constellation = my_constellation = digital.constellation_calcdist(([-1,1]), ([0, 1]), 2, 1).base() self.freq = freq = 2.4e9 ################################################## # Blocks ################################################## self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "hackrf=0x000000000x000000000x457863c80x320c831f" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (filter.firdes.root_raised_cosine(32,32*sps,1.0,0.35,11*32*sps)), 32, 16, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.35, 55, 6.28/100.0) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(my_constellation, 6.28/100.0, -0.25, 0.25) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/ubuntu/recv.b", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.analog_agc2_xx_0 = analog.agc2_cc(0.06, 0.001, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_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_constellation_receiver_cb_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab8") Qt.QWidget.__init__(self) self.setWindowTitle("Lab8") 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", "lab8") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.std_dev = std_dev = 0.05 self.samp_rate = samp_rate = 32000 self.p_xy = p_xy = 0 self.npts = npts = 8192 self.mimo_option = mimo_option = 0 self.lw = lw = 0.5 self.const_qam = const_qam = digital.constellation_calcdist( digital.qam_16()[0], digital.qam_16()[1], 2, 1).base() self.const_psk = const_psk = digital.constellation_calcdist( digital.psk_4()[0], digital.psk_4()[1], 2, 1).base() ################################################## # Blocks ################################################## self.tab = Qt.QTabWidget() self.tab_widget_0 = Qt.QWidget() self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0) self.tab_grid_layout_0 = Qt.QGridLayout() self.tab_layout_0.addLayout(self.tab_grid_layout_0) self.tab.addTab(self.tab_widget_0, 'Transmitted') self.tab_widget_1 = Qt.QWidget() self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1) self.tab_grid_layout_1 = Qt.QGridLayout() self.tab_layout_1.addLayout(self.tab_grid_layout_1) self.tab.addTab(self.tab_widget_1, 'Received') self.tab_widget_2 = Qt.QWidget() self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2) self.tab_grid_layout_2 = Qt.QGridLayout() self.tab_layout_2.addLayout(self.tab_grid_layout_2) self.tab.addTab(self.tab_widget_2, 'Histogram') self.top_grid_layout.addWidget(self.tab, 1, 0, 8, 7) for r in range(1, 9): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 7): self.top_grid_layout.setColumnStretch(c, 1) self._std_dev_range = Range(0, 1, 0.001, 0.05, 200) self._std_dev_win = RangeWidget(self._std_dev_range, self.set_std_dev, 'Noise Std. Dev', "counter_slider", float) self.top_grid_layout.addWidget(self._std_dev_win, 0, 0, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 3): self.top_grid_layout.setColumnStretch(c, 1) self._p_xy_range = Range(0, 0.99, 0.001, 0, 200) self._p_xy_win = RangeWidget(self._p_xy_range, self.set_p_xy, 'Correlation Pxy', "counter_slider", float) self.top_grid_layout.addWidget(self._p_xy_win, 0, 3, 1, 3) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 6): self.top_grid_layout.setColumnStretch(c, 1) # Create the options list self._mimo_option_options = ( 0, 1, ) # Create the labels list self._mimo_option_labels = ( 'Alamouti', 'MIMO', ) # Create the combo box # Create the radio buttons self._mimo_option_group_box = Qt.QGroupBox('MIMO Option' + ": ") self._mimo_option_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._mimo_option_button_group = variable_chooser_button_group() self._mimo_option_group_box.setLayout(self._mimo_option_box) for i, _label in enumerate(self._mimo_option_labels): radio_button = Qt.QRadioButton(_label) self._mimo_option_box.addWidget(radio_button) self._mimo_option_button_group.addButton(radio_button, i) self._mimo_option_callback = lambda i: Qt.QMetaObject.invokeMethod( self._mimo_option_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._mimo_option_options.index(i))) self._mimo_option_callback(self.mimo_option) self._mimo_option_button_group.buttonClicked[int].connect( lambda i: self.set_mimo_option(self._mimo_option_options[i])) self.top_grid_layout.addWidget(self._mimo_option_group_box, 0, 6, 1, 2) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(6, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 4096, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(0, 20) self.qtgui_time_sink_x_0.set_y_label('Eigenvalue Ratio (dB)', "") self.qtgui_time_sink_x_0.enable_tags(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(True) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(True) self.qtgui_time_sink_x_0.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(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, 9, 0, 2, 8) for r in range(9, 11): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 8): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_histogram_sink_x_0 = qtgui.histogram_sink_f( npts, 200, -2, 2, "Histogram", 1) self.qtgui_histogram_sink_x_0.set_update_time(0.10) self.qtgui_histogram_sink_x_0.enable_autoscale(True) self.qtgui_histogram_sink_x_0.enable_accumulate(False) self.qtgui_histogram_sink_x_0.enable_grid(True) self.qtgui_histogram_sink_x_0.enable_axis_labels(True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark 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 range(1): if len(labels[i]) == 0: self.qtgui_histogram_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_histogram_sink_x_0.set_line_label(i, labels[i]) self.qtgui_histogram_sink_x_0.set_line_width(i, widths[i]) self.qtgui_histogram_sink_x_0.set_line_color(i, colors[i]) self.qtgui_histogram_sink_x_0.set_line_style(i, styles[i]) self.qtgui_histogram_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_histogram_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_histogram_sink_x_0_win = sip.wrapinstance( self.qtgui_histogram_sink_x_0.pyqwidget(), Qt.QWidget) self.tab_layout_2.addWidget(self._qtgui_histogram_sink_x_0_win) self.qtgui_const_sink_x_1 = qtgui.const_sink_c( 1024, #size "De-Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_1.set_update_time(0.10) self.qtgui_const_sink_x_1.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_1.set_x_axis(-1.5, 1.5) 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(True) self.qtgui_const_sink_x_1.enable_axis_labels(True) 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, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): 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.tab_layout_1.addWidget(self._qtgui_const_sink_x_1_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "Correlated Constellation", #name 2 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-4, 4) self.qtgui_const_sink_x_0.set_x_axis(-4, 4) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0.enable_autoscale(False) self.qtgui_const_sink_x_0.enable_grid(True) self.qtgui_const_sink_x_0.enable_axis_labels(True) 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, 2, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, -1, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 0.2, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(2): 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.tab_layout_0.addWidget(self._qtgui_const_sink_x_0_win) self.ofdm_alamouti_cc_0 = ofdm.alamouti_cc(p_xy, std_dev, mimo_option) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( const_psk.points(), 1) self.blocks_nlog10_ff_0 = blocks.nlog10_ff(10, 1, 0) self.blocks_moving_average_xx_0 = blocks.moving_average_ff( 4096, 1 / 4096, 4096, 1) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_deinterleave_0 = blocks.deinterleave( gr.sizeof_float * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.analog_random_source_x_0 = blocks.vector_source_b( list(map(int, numpy.random.randint(0, 4, 1000))), True) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.qtgui_histogram_sink_x_0, 0)) self.connect((self.blocks_deinterleave_0, 1), (self.blocks_divide_xx_0, 1)) self.connect((self.blocks_deinterleave_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.blocks_moving_average_xx_0, 0)) self.connect((self.blocks_moving_average_xx_0, 0), (self.blocks_nlog10_ff_0, 0)) self.connect((self.blocks_nlog10_ff_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.ofdm_alamouti_cc_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.blocks_complex_to_real_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 2), (self.blocks_deinterleave_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 1)) self.connect((self.ofdm_alamouti_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 0)) self.connect((self.ofdm_alamouti_cc_0, 1), (self.qtgui_const_sink_x_1, 1))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry(self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry", type=QtCore.QByteArray)) ################################################## # Variables ################################################## self.sps = sps = 45 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 45*nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'fc', "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if "float" == "float" or "float" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=BPSK, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.25, verbose=False, log=False, ) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_complex_to_real_1 = blocks.complex_to_real(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blks2_tcp_source_0 = grc_blks2.tcp_source( itemsize=gr.sizeof_char*1, addr='127.0.0.1', port=1235, server=True, ) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=1, bits_per_symbol=1, preamble='', access_code='', pad_for_usrp=False, ), payload_length=1, ) self.audio_sink_0 = audio.sink(44100, '', True) self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) ################################################## # Connections ################################################## self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.blocks_complex_to_real_1, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_real_1, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") 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") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Variables ################################################## self.MiconstellationObject = MiconstellationObject = digital.constellation_calcdist( digital.constellation_qpsk().points(), (0, 1, 2, 3), 4, 1).base() self.Constelacion = Constelacion = MiconstellationObject.points() self.M = M = len(Constelacion) self.samp_rate_usrp_rx = samp_rate_usrp_rx = 100e6 self.Rb = Rb = 100 self.Bps = Bps = int(math.log(M, 2)) self.samp_rate_to_usrp = samp_rate_to_usrp = int(samp_rate_usrp_rx / 512) self.samp_rate_audio = samp_rate_audio = 11000 self.ntaps = ntaps = 128 self.Sps = Sps = 160 self.Rs = Rs = Rb / Bps self.Rolloff = Rolloff = 0.5 self.NbpS = NbpS = 8 self.samp_rate_0 = samp_rate_0 = int(Rs * Sps) self.samp_rate = samp_rate = Rb * Sps self.run_stop = run_stop = True self.mapinverse = mapinverse = coding.inverse_map(Constelacion) self.mapdirect = mapdirect = coding.direct_map(Constelacion) self.h_rrc = h_rrc = wform.rrcos(Sps, ntaps, Rolloff) self.Vp = Vp = 1. self.Tupdate = Tupdate = 1. / Rb self.Sps_0 = Sps_0 = int(math.floor(samp_rate_to_usrp / Rs)) self.Rb_0 = Rb_0 = NbpS * samp_rate_audio self.P = P = 0. self.NnivelesQ = NnivelesQ = int(math.pow(2, NbpS)) self.Kf = Kf = 200 self.F = F = 0. self.BW = BW = (Rs / 2) * (1 + Rolloff) self.Ar = Ar = 0. self.A = A = 1. ################################################## # Blocks ################################################## self._P_range = Range(-2. * math.pi, 2. * math.pi, (4. * math.pi) / 360., 0., 200) self._P_win = RangeWidget(self._P_range, self.set_P, 'Fase', "counter_slider", float) self.top_grid_layout.addWidget(self._P_win, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._Ar_range = Range(0, 4., (4.) / 50., 0., 200) self._Ar_win = RangeWidget(self._Ar_range, self.set_Ar, 'Ruido', "counter_slider", float) self.top_grid_layout.addWidget(self._Ar_win, 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) self._A_range = Range(-1.5, 1.5, (1.5) / 100., 1., 200) self._A_win = RangeWidget(self._A_range, self.set_A, 'A', "counter_slider", float) self.top_grid_layout.addWidget(self._A_win, 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) _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict( (v, k) for k, v in self._run_stop_choices.items()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod( _run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect( lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_1 = qtgui.time_sink_f( 1024, #size samp_rate_audio, #samp_rate 'Nuevo', #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_0_1.set_y_axis(-128, 128) self.qtgui_time_sink_x_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_0_1.enable_tags(True) self.qtgui_time_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_0_1.enable_grid(False) self.qtgui_time_sink_x_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_0_1.enable_stem_plot(False) labels = [ 'Signal 1', 'Signal 2', 'Signal 3', 'Signal 4', 'Signal 5', 'Signal 6', 'Signal 7', 'Signal 8', 'Signal 9', 'Signal 10' ] 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_1.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_1.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_1_win) self.qtgui_time_sink_x_0_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "compararacion entre mensaje y EC", #name 3 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0_0.enable_stem_plot(False) labels = [ 'Mensaje', 'FSK parte real', 'FSK parte Imaginaria', '', '', '', '', '', '', '' ] widths = [3, 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_0_win, 4, 1, 1, 2) for r in range(4, 5): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de Amplitud", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-1.5, 1.5) self.qtgui_time_sink_x_0_0_0_0.set_y_label('Amplitud', 'volts') self.qtgui_time_sink_x_0_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win, 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.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de Fase", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0_0.set_y_axis(-2 * math.pi, 2 * math.pi) self.qtgui_time_sink_x_0_0_0.set_y_label('Fase', 'radianes') self.qtgui_time_sink_x_0_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win, 3, 1, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size (samp_rate), #samp_rate "Nivel de frecuencia", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0.set_update_time(Tupdate) self.qtgui_time_sink_x_0_0.set_y_axis(-2.5, 2.5) self.qtgui_time_sink_x_0_0.set_y_label('Frecuencia', 'Hz') self.qtgui_time_sink_x_0_0.enable_tags(True) self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0.enable_grid(False) self.qtgui_time_sink_x_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_0_0.enable_control_panel(False) self.qtgui_time_sink_x_0_0.enable_stem_plot(False) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [3, 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] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] for i in range(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, 3, 2, 1, 1) for r in range(3, 4): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c( 8, #size '', #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0.set_update_time(Tupdate) self.qtgui_const_sink_x_0_0.set_y_axis(-1.5, 1.5) self.qtgui_const_sink_x_0_0.set_x_axis(-1.5, 1.5) 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) labels = ['.', '', '', '', '', '', '', '', '', ''] widths = [4, 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 range(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, 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.epy_block_0 = epy_block_0.blk() self.e_VCO_fase_fc_0 = e_VCO_fase_fc_0.blk() self.digital_map_bb_0 = digital.map_bb(mapdirect) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(M) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( MiconstellationObject.points(), 1) self.d_freq_cf_assign_freq_cf_0 = d_freq_cf.assign_freq_cf() self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb( Bps, gr.GR_LSB_FIRST) self.blocks_multiply_xx_0 = blocks.multiply_vff(1) self.blocks_multiply_const_vxx_0_0_0_1_0_0 = blocks.multiply_const_ff( Kf * 2 * math.pi / samp_rate) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_1 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vff(1) self.b_quantizer_fb_0 = b_quantizer_fb( NivelesQ=NnivelesQ, Vmax=Vp, ) self.b_bipolar_to_unipolar_ff_0 = b_bipolar_to_unipolar_ff() self.b_binary_bipolar_source_f_0 = b_binary_bipolar_source_f( Am=1., Spb=Sps, ) self.b_PSD_c_0 = b_PSD_c( Ensayos=1000000, Fc=0, N=1024, Ymax=1e-5, samp_rate_audio=samp_rate, ) self.top_grid_layout.addWidget(self.b_PSD_c_0, 5, 1, 1, 2) for r in range(5, 6): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 3): self.top_grid_layout.setColumnStretch(c, 1) self.analog_noise_source_x_1 = analog.noise_source_c( analog.GR_GAUSSIAN, Ar, 0) self.analog_const_source_x_0_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, P) self.analog_const_source_x_0_0 = analog.sig_source_f( 0, analog.GR_CONST_WAVE, 0, 0, A) self._F_range = Range(-2.4, 2.4, (2 * 2.4) / 1000., 0., 200) self._F_win = RangeWidget(self._F_range, self.set_F, 'Frecuencia', "counter_slider", float) self.top_grid_layout.addWidget(self._F_win, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.analog_const_source_x_0_0, 0), (self.e_VCO_fase_fc_0, 1)) self.connect((self.analog_const_source_x_0_0, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_const_source_x_0_0_0, 0), (self.qtgui_time_sink_x_0_0_0, 0)) self.connect((self.analog_noise_source_x_1, 0), (self.blocks_add_xx_1, 1)) self.connect((self.b_binary_bipolar_source_f_0, 0), (self.b_bipolar_to_unipolar_ff_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.b_quantizer_fb_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.epy_block_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.b_bipolar_to_unipolar_ff_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 0)) self.connect((self.b_quantizer_fb_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.e_VCO_fase_fc_0, 0)) self.connect((self.blocks_add_xx_1, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_0_0_0_0_0, 1)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_0_0_0_0_0, 2)) self.connect((self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.d_freq_cf_assign_freq_cf_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.d_freq_cf_assign_freq_cf_0, 0), (self.qtgui_time_sink_x_0_0_1, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.b_PSD_c_0, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.d_freq_cf_assign_freq_cf_0, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.qtgui_const_sink_x_0_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.digital_chunks_to_symbols_xx, 0)) self.connect((self.e_VCO_fase_fc_0, 0), (self.blocks_add_xx_1, 0)) self.connect((self.epy_block_0, 0), (self.blocks_multiply_const_vxx_0_0_0_1_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Meteor QPSK LRPT") ################################################## # Variables ################################################## self.freq = freq = 137900000 self.symb_rate = symb_rate = 72000 self.samp_rate = samp_rate = 128000 self.doppler_freq = doppler_freq = freq self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0) self.samp_rate_rtlsdr = samp_rate_rtlsdr = 1536000 self.pll_alpha = pll_alpha = float(sys.argv[2]) self.doppler_shift = doppler_shift = doppler_freq - freq self.decim = decim = 8 self.clock_alpha = clock_alpha = .001 self.bitstream_name = bitstream_name = sys.argv[1] + '.s' ################################################## # Blocks ################################################## self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=int(samp_rate_rtlsdr / samp_rate), taps=None, fractional_bw=None, ) self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + '') self.osmosdr_source_0.set_sample_rate(samp_rate_rtlsdr) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(44, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna('', 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq, "localhost", 4532, True) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, bitstream_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_sig_source_x_1 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, doppler_shift, 1, 0) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_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.snr_db = snr_db = 0 self.samp_rate = samp_rate = 32000 self.max_items = max_items = 80 self.const = const = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (const.points()), 1) self.blocks_vector_sink_x_1 = blocks.vector_sink_b(1) self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 1, const.bits_per_symbol(), "", False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( const.bits_per_symbol(), 8, "", False, gr.GR_LSB_FIRST) self.blocks_head_0_0 = blocks.head(gr.sizeof_char * 1, max_items) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, max_items) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 2, 1000000)), True) self.analog_fastnoise_source_x_0_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 10**(-snr_db / 20.0), 0, 2**16) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 10**(-snr_db / 20.0), 0, 2**16) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.blocks_head_0_0, 0), (self.blocks_vector_sink_x_1, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_head_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_repack_bits_bb_0, 0))
def __init__(self, bw_clock_sync=2*math.pi/100, bw_fll=math.pi/1600, bw_costas=2*math.pi/100, n_filts=32, len_sym_srrc=7, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=5, alfa=0.35, bits_per_sym=2, alpha_probe=0.1, th_probe=0): gr.hier_block2.__init__( self, "Hier Rx", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_char*1), ) ################################################## # Parameters ################################################## self.bw_clock_sync = bw_clock_sync self.bw_fll = bw_fll self.bw_costas = bw_costas self.n_filts = n_filts self.len_sym_srrc = len_sym_srrc self.constellation = constellation self.samp_per_sym = samp_per_sym self.alfa = alfa self.bits_per_sym = bits_per_sym self.alpha_probe = alpha_probe self.th_probe = th_probe ################################################## # Variables ################################################## self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) ################################################## # Blocks ################################################## self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(th_probe, alpha_probe) #self.analog_agc2_xx_0 = analog.agc2_cc(1e-4, 5e-4, 6, 15) self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-2, 1e-3, 2, 15) self.analog_agc2_xx_0.set_max_gain(15) if DEBUG: self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "./file_rx_fin", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_char*1, "./file_rx_out_diff", False) self.blocks_file_sink_1.set_unbuffered(True) self.blocks_file_sink_2 = blocks.file_sink(gr.sizeof_gr_complex*1, "./file_rx_sym", False) self.blocks_file_sink_2.set_unbuffered(True) ################################################## # Connections ################################################## self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_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_0, 0)) self.connect((self, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self, 0)) if DEBUG: self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_file_sink_1, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.blocks_file_sink_2, 0)) self.connect((self, 0), (self.analog_probe_avg_mag_sqrd_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Packet Loopback Hier") Qt.QWidget.__init__(self) self.setWindowTitle("Packet Loopback Hier") 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", "packet_loopback_hier") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.nfilts = nfilts = 32 self.eb = eb = 0.22 self.tx_rrc_taps = tx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0, eb, 5 * sps * nfilts) self.time_offset = time_offset = 1.0 self.samp_rate = samp_rate = 300000 self.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine( nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts) self.rep = rep = 3 self.rate = rate = 2 self.polys = polys = [109, 79] self.noise = noise = 0.0 self.k = k = 7 self.hdr_format = hdr_format = digital.header_format_default( digital.packet_utils.default_access_code, 0) self.freq_offset = freq_offset = 0 self.amp = amp = 1.0 self.Const_PLD = Const_PLD = digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_PLD.gen_soft_dec_lut(8) self.Const_HDR = Const_HDR = digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() self.Const_HDR.gen_soft_dec_lut(8) ################################################## # Blocks ################################################## self._time_offset_range = Range(0.99, 1.01, 0.00001, 1.0, 200) self._time_offset_win = RangeWidget(self._time_offset_range, self.set_time_offset, 'Time Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._time_offset_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.tab1 = Qt.QTabWidget() self.tab1_widget_0 = Qt.QWidget() self.tab1_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_0) self.tab1_grid_layout_0 = Qt.QGridLayout() self.tab1_layout_0.addLayout(self.tab1_grid_layout_0) self.tab1.addTab(self.tab1_widget_0, 'Time') self.tab1_widget_1 = Qt.QWidget() self.tab1_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_1) self.tab1_grid_layout_1 = Qt.QGridLayout() self.tab1_layout_1.addLayout(self.tab1_grid_layout_1) self.tab1.addTab(self.tab1_widget_1, 'Freq.') self.tab1_widget_2 = Qt.QWidget() self.tab1_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab1_widget_2) self.tab1_grid_layout_2 = Qt.QGridLayout() self.tab1_layout_2.addLayout(self.tab1_grid_layout_2) self.tab1.addTab(self.tab1_widget_2, 'Const.') self.top_grid_layout.addWidget(self.tab1, 1, 2, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) self.tab0 = Qt.QTabWidget() self.tab0_widget_0 = Qt.QWidget() self.tab0_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_0) self.tab0_grid_layout_0 = Qt.QGridLayout() self.tab0_layout_0.addLayout(self.tab0_grid_layout_0) self.tab0.addTab(self.tab0_widget_0, 'Time') self.tab0_widget_1 = Qt.QWidget() self.tab0_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_1) self.tab0_grid_layout_1 = Qt.QGridLayout() self.tab0_layout_1.addLayout(self.tab0_grid_layout_1) self.tab0.addTab(self.tab0_widget_1, 'Freq.') self.tab0_widget_2 = Qt.QWidget() self.tab0_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab0_widget_2) self.tab0_grid_layout_2 = Qt.QGridLayout() self.tab0_layout_2.addLayout(self.tab0_grid_layout_2) self.tab0.addTab(self.tab0_widget_2, 'Const.') self.top_grid_layout.addWidget(self.tab0, 1, 1, 1, 1) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._noise_range = Range(0, 5, 0.01, 0.0, 200) self._noise_win = RangeWidget(self._noise_range, self.set_noise, 'Noise Amp', "counter_slider", float) self.top_grid_layout.addWidget(self._noise_win, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self._freq_offset_range = Range(-0.5, 0.5, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, 'Freq. Offset', "counter_slider", float) self.top_grid_layout.addWidget(self._freq_offset_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._amp_range = Range(0, 2, 0.01, 1.0, 200) self._amp_win = RangeWidget(self._amp_range, self.set_amp, 'Amplitude', "counter_slider", float) self.top_grid_layout.addWidget(self._amp_win) self.qtgui_time_sink_x_1_0_0_1 = qtgui.time_sink_c( 125, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_1.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0_1.set_y_axis(-2, 2) self.qtgui_time_sink_x_1_0_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_1_0_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_1.set_trigger_mode( qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 25, 0, "payload symbols") self.qtgui_time_sink_x_1_0_0_1.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0_1.enable_grid(False) self.qtgui_time_sink_x_1_0_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0_1.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0_1.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_1_0_0_1.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -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_1_0_0_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0_1.pyqwidget(), Qt.QWidget) self.tab1_grid_layout_0.addWidget(self._qtgui_time_sink_x_1_0_0_1_win) self.qtgui_time_sink_x_1_0_0_0 = qtgui.time_sink_c( 1250, #size 1, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_1_0_0_0.set_y_axis(-150, 150) self.qtgui_time_sink_x_1_0_0_0.set_y_label('Correlation', "") self.qtgui_time_sink_x_1_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_1_0_0_0.set_trigger_mode( qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 50, 0, "corr_est") self.qtgui_time_sink_x_1_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_1_0_0_0.enable_grid(False) self.qtgui_time_sink_x_1_0_0_0.enable_axis_labels(True) self.qtgui_time_sink_x_1_0_0_0.enable_control_panel(False) self.qtgui_time_sink_x_1_0_0_0.enable_stem_plot(False) if not False: self.qtgui_time_sink_x_1_0_0_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1_0_0_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_0_0_0_win = sip.wrapinstance( self.qtgui_time_sink_x_1_0_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_0_0_0_win, 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.qtgui_time_sink_x_1 = qtgui.time_sink_c( 2500, #size 1, #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(-2, 2) 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, 'packet_len') 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 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(2): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_1.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance( self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.tab0_grid_layout_0.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Tx Data', #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, 256) 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_length_tag_key') self.qtgui_time_sink_x_0_0.enable_autoscale(False) 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 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_grid_layout.addWidget(self._qtgui_time_sink_x_0_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 100 * 2, #size samp_rate, #samp_rate 'Rx Data', #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, 256) 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_length_tag_key') 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) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc 1, #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 False: self.qtgui_freq_sink_x_0_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "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.tab1_grid_layout_1.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 1, #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 False: self.qtgui_freq_sink_x_0.disable_legend() if "complex" == "float" or "complex" == "msg_float": self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [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.tab0_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_win) self.qtgui_const_sink_x_0_0_0 = qtgui.const_sink_c( 800, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0_0_0.set_update_time(0.10) self.qtgui_const_sink_x_0_0_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "") self.qtgui_const_sink_x_0_0_0.enable_autoscale(False) self.qtgui_const_sink_x_0_0_0.enable_grid(False) self.qtgui_const_sink_x_0_0_0.enable_axis_labels(True) if not False: self.qtgui_const_sink_x_0_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_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_0_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.tab1_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_0_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1024, #size "", #name 1 #number of inputs ) self.qtgui_const_sink_x_0.set_update_time(0.10) self.qtgui_const_sink_x_0.set_y_axis(-2, 2) self.qtgui_const_sink_x_0.set_x_axis(-2, 2) self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 'packet_len') 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 False: 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.tab0_grid_layout_2.addWidget(self._qtgui_const_sink_x_0_win) self.packet_tx_0 = packet_tx( hdr_const=Const_HDR, hdr_format=hdr_format, pkt_len=42, pld_const=Const_PLD, psf_taps=tx_rrc_taps, puncpat='11', samp_rate=samp_rate, sps=sps, ) self.packet_rx_0 = packet_rx( eb=eb, hdr_const=Const_HDR, hdr_format=hdr_format, pkt_len=42, pld_const=Const_PLD, psf_taps=rx_rrc_taps, puncpat='11', samp_rate=samp_rate, sps=sps, ) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, eb, 44, 0.05) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=True) self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, )) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_char * 1, '/home/andre/git/investigacao/Testes/EVOLUCAO/TESTES_SLACK/book2.txt', False) self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL) self.blocks_file_sink_0_0_0 = blocks.file_sink( gr.sizeof_char * 1, '/home/andre/git/investigacao/Testes/EVOLUCAO/TESTES_SLACK/depois.txt', False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_char_to_float_1_0_0 = blocks.char_to_float(1, 1) self.blocks_char_to_float_1_0 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_1_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_char_to_float_1_0_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.blocks_char_to_float_1_0_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.packet_tx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blocks_throttle_0_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_throttle_0_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.packet_rx_0, 0)) self.connect((self.packet_rx_0, 0), (self.blocks_char_to_float_1_0, 0)) self.connect((self.packet_rx_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_const_sink_x_0_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_time_sink_x_1_0_0_0, 0)) self.connect((self.packet_rx_0, 1), (self.qtgui_time_sink_x_1_0_0_1, 0)) self.connect((self.packet_tx_0, 0), (self.channels_channel_model_0, 0))
def __init__(self): gr.top_block.__init__(self, "SER Simulation") Qt.QWidget.__init__(self) self.setWindowTitle("SER Simulation") 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", "ser_simulation") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.const = const = [(1. + 0.j), (0. + 1.j), (-1. + 0.j), (0. - 1.j)] self.samp_rate = samp_rate = 100e3 self.Sps = Sps = 16 self.M = M = len(const) self.Rs = Rs = samp_rate / Sps self.Bps = Bps = int(math.log(M, 2)) self.run_stop = run_stop = True self.Rb = Rb = Rs * Bps self.N_snr = N_snr = 128 self.MiconstellationObject = MiconstellationObject = digital.constellation_calcdist( (const), (), 4, 1).base() self.MaxErrors = MaxErrors = 1000 self.MaxCount = MaxCount = int(1e7) self.EsN0min = EsN0min = 0. self.EsN0max = EsN0max = 20. ################################################## # Blocks ################################################## _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict( (v, k) for k, v in self._run_stop_choices.iteritems()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod( _run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect( lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( MiconstellationObject) self.digital_chunks_to_symbols_xx = digital.chunks_to_symbols_bc( (const), 1) self.blocks_throttle = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.analog_random_source_x = blocks.vector_source_b( map(int, numpy.random.randint(0, M, 10000000)), True) self.SERTool_Channel_1 = SERTool_Channel( B=samp_rate, EsN0max=EsN0max, EsN0min=EsN0min, N_snr=N_snr, Rs=Rs, ) self.top_grid_layout.addWidget(self.SERTool_Channel_1) ################################################## # Connections ################################################## self.connect((self.SERTool_Channel_1, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_random_source_x, 0), (self.blocks_throttle, 0)) self.connect((self.blocks_throttle, 0), (self.SERTool_Channel_1, 1)) self.connect((self.blocks_throttle, 0), (self.digital_chunks_to_symbols_xx, 0)) self.connect((self.digital_chunks_to_symbols_xx, 0), (self.SERTool_Channel_1, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.SERTool_Channel_1, 2))
def __init__(self): gr.top_block.__init__(self, "Psk Rx") Qt.QWidget.__init__(self) self.setWindowTitle("Psk 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", "psk_rx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 2 self.samp_rate = samp_rate = 1e6 self.my_constellation = my_constellation = digital.constellation_calcdist(([-1,1]), ([0, 1]), 2, 1).base() self.freq = freq = 2.4e9 ################################################## # Blocks ################################################## self.qtgui_sink_x_0 = qtgui.sink_c( 1024, #fftsize firdes.WIN_BLACKMAN_hARRIS, #wintype freq, #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_layout.addWidget(self._qtgui_sink_x_0_win) self.qtgui_sink_x_0.enable_rf_freq(False) 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) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(0, 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 6.28/100.0, (filter.firdes.root_raised_cosine(32,32*sps,1.0,0.35,11*32*sps)), 32, 16, 1.5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, 0.35, 55, 6.28/100.0) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2) self.digital_constellation_receiver_cb_0 = digital.constellation_receiver_cb(my_constellation, 6.28/100.0, -0.25, 0.25) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(1) self.blocks_null_sink_0_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/ubuntu/recv.b", False) self.blocks_file_sink_0.set_unbuffered(False) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_c(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.analog_agc2_xx_0 = analog.agc2_cc(0.06, 0.001, 1.0, 1.0) self.analog_agc2_xx_0.set_max_gain(65536) ################################################## # Connections ################################################## self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 2), (self.blocks_null_sink_0_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 3), (self.blocks_null_sink_0_1, 0)) self.connect((self.digital_constellation_receiver_cb_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.digital_constellation_receiver_cb_0, 4), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_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_constellation_receiver_cb_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.qtgui_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.my_constellation = my_constellation = digital.constellation_calcdist(([-1, -1j,1,1j]), ([0, 1,2,3]), 4, 1).base() ################################################## # Blocks ################################################## self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 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(True) self.qtgui_const_sink_x_0.enable_grid(False) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "red", "red", "red", "red", "red", "red", "red", "red"] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance(self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(my_constellation) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc((1, 1j, -1, -1j), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_head_0_1 = blocks.head(gr.sizeof_char*1, 100000) self.blocks_head_0_0_0 = blocks.head(gr.sizeof_char*1, 100000) self.blocks_file_sink_0_0_1 = blocks.file_sink(gr.sizeof_char*1, "/home/ubuntu/trx_qpsk_30.bin", False) self.blocks_file_sink_0_0_1.set_unbuffered(True) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, "/home/ubuntu/rx_qpsk_30.bin", False) self.blocks_file_sink_0_0_0.set_unbuffered(True) self.blocks_add_xx_0 = blocks.add_vcc(1) self.blks2_error_rate_0 = grc_blks2.error_rate( type='BER', win_size=1000, bits_per_symbol=1, ) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 4, 100000)), True) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 30, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blks2_error_rate_0, 1)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_head_0_1, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blks2_error_rate_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.blocks_head_0_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_head_0_1, 0), (self.blocks_file_sink_0_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blks2_error_rate_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_head_0_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Sender1") ################################################## # Variables ################################################## self.sps = sps = 8 self.nfilts = nfilts = 32 self.transistion = transistion = 100 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), 0.35, 11*sps*nfilts) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.payload_size = payload_size = 10 self.interpolation = interpolation = 2000 self.gap = gap = 0 self.eb = eb = 0.35 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.const_type = const_type = 1 self.const = const = (digital.constellation_bpsk(), digital.constellation_qpsk(), digital.constellation_8psk()) self.carrier = carrier = 10000 self.arity = arity = 2 ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=interpolation, decimation=decimation, taps=None, fractional_bw=None, ) self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (firdes.band_pass (0.5,samp_rate,10000-sideband,10000+sideband,transistion)), -carrier, samp_rate) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=True, samples_per_symbol=sps, pre_diff_code=True, excess_bw=0.35, verbose=False, log=False, ) self.blocks_wavfile_sink_1 = blocks.wavfile_sink("BPSK_output.wav", 1, 48000, 16) self.blocks_unpack_k_bits_bb_0_0 = blocks.unpack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0.1, )) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "TestData2", False) self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char*1, "inputBinary", False) self.blocks_file_sink_0_0_0.set_unbuffered(False) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "inputBinary2", False) self.blocks_file_sink_0_0.set_unbuffered(False) script, sdelay= argv self.blocks_delay_0_0 = blocks.delay(gr.sizeof_char*1, int(sdelay)) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_file_sink_0_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_unpack_k_bits_bb_0_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_wavfile_sink_1, 0)) self.connect((self.blocks_unpack_k_bits_bb_0_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Bpsk Receiverpoly") ################################################## # Variables ################################################## self.sps = sps = 8 self.probe_var = probe_var = 0 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.SNR = SNR = 500 self.transistion = transistion = 100 self.timing_loop_bw = timing_loop_bw = 6.28/100.0 self.sideband_rx = sideband_rx = 500 self.sideband = sideband = 500 self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts/16, nfilts/16, 1.0/float(sps), 0.35, 11*sps*nfilts/16) self.qpsk = qpsk = digital.constellation_rect(([0.707+0.707j, -0.707+0.707j, -0.707-0.707j, 0.707-0.707j]), ([0, 1, 2, 3]), 4, 2, 2, 1, 1).base() self.probe_var_n = probe_var_n = 0 self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase_bw = phase_bw = 6.28/100.0 self.noise_amp = noise_amp = probe_var/(10**(SNR/20)) self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.interpolation = interpolation = 2000 self.eq_gain = eq_gain = 0.01 self.delay = delay = 0 self.decimation = decimation = 1 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.carrier = carrier = 10000 self.arity = arity = 2 ################################################## # Blocks ################################################## self.probe_rms = blocks.probe_signal_f() self.probe_avg_n = blocks.probe_signal_f() self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc( interpolation=decimation, decimation=interpolation, taps=(rrc_taps), fractional_bw=None, ) def _probe_var_n_probe(): while True: val = self.probe_avg_n.level() try: self.set_probe_var_n(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_n_thread = threading.Thread(target=_probe_var_n_probe) _probe_var_n_thread.daemon = True _probe_var_n_thread.start() def _probe_var_probe(): while True: val = self.probe_rms.level() try: self.set_probe_var(val) except AttributeError: pass time.sleep(1.0 / (10)) _probe_var_thread = threading.Thread(target=_probe_var_probe) _probe_var_thread.daemon = True _probe_var_thread.start() self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(1, (filter.firdes.low_pass(1, samp_rate*10, sideband_rx,1000)), carrier, samp_rate) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, timing_loop_bw, (rrc_taps), nfilts, nfilts/2, 1.5, 1) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constel) script, SNRinput, inputwav, outputBinary, delay= argv self.blocks_wavfile_source_0 = blocks.wavfile_source(inputwav, False) self.blocks_throttle_1_0_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_rms_xx_1 = blocks.rms_cf(0.01) self.blocks_rms_xx_0 = blocks.rms_cf(0.01) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, outputBinary, False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_delay_1 = blocks.delay(gr.sizeof_char*1, int(delay)) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, noise_amp, 0) ################################################## # Connections ################################################## self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_rms_xx_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_delay_1, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.freq_xlating_fir_filter_xxx_0_0, 0)) self.connect((self.blocks_rms_xx_0, 0), (self.probe_rms, 0)) self.connect((self.blocks_rms_xx_1, 0), (self.probe_avg_n, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_throttle_1_0_0, 0), (self.blocks_rms_xx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_delay_1, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.rational_resampler_xxx_0_0, 0), (self.blocks_throttle_1_0_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "Hier Tx Ch Rx", gr.io_signature(1, 1, gr.sizeof_char*1), gr.io_signature(1, 1, gr.sizeof_char*1), ) ################################################## # Variables ################################################## self.samp_per_sym = samp_per_sym = 3 self.n_filts = n_filts = 32 self.len_sym_srrc = len_sym_srrc = 7 self.alfa = alfa = 0.35 self.pulso = pulso = firdes.root_raised_cosine(samp_per_sym,samp_per_sym,1.0,alfa,samp_per_sym*len_sym_srrc) self.gain = gain = 15 self.frec = frec = 850e3 self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) self.bits_per_sym = bits_per_sym = 2 ################################################## # Blocks ################################################## self.pfb_interpolator_ccf_0 = pfb.interpolator_ccf( samp_per_sym, (pulso), 100) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, 2*math.pi/100, (filtro_srrc), n_filts, 16, 5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, math.pi/1600) self.digital_diff_encoder_bb_0 = digital.diff_encoder_bb(2**bits_per_sym) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(2*math.pi/100, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base()) self.digital_chunks_to_symbols_xx_0_0 = digital.chunks_to_symbols_bc(([-1-1j,1-1j, 1+1j, -1+1j]), 1) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.0, frequency_offset=0.0, epsilon=1.00, taps=(1+0.5j, ), noise_seed=0, block_tags=False ) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bits_per_sym, gr.GR_MSB_FIRST) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((0.4, )) self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder( samples_per_symbol=samp_per_sym, bits_per_symbol=bits_per_sym, preamble="", access_code="", pad_for_usrp=True, ), payload_length=1, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload), ), ) self.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.connect((self.pfb_interpolator_ccf_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.digital_diff_encoder_bb_0, 0), (self.digital_chunks_to_symbols_xx_0_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0_0, 0), (self.pfb_interpolator_ccf_0, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_diff_encoder_bb_0, 0)) self.connect((self.blks2_packet_encoder_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self, 0)) self.connect((self, 0), (self.blks2_packet_encoder_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_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_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.analog_agc2_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_0, 0))
def __init__(self, bfo=1500, callsign='', ip='::', latitude=0, longitude=0, port=7355, recstart=''): gr.top_block.__init__(self, "Nayif-1 decoder") ################################################## # Parameters ################################################## self.bfo = bfo self.callsign = callsign self.ip = ip self.latitude = latitude self.longitude = longitude self.port = port self.recstart = recstart ################################################## # Variables ################################################## self.sps = sps = 8 self.nfilts = nfilts = 16 self.alpha = alpha = 0.35 self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.samp_rate = samp_rate = 48000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts) ################################################## # Blocks ################################################## self.sids_submit_0 = sids.submit( 'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 42017, callsign, longitude, latitude, recstart) self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S') self.funcube_telemetry_parser_0 = ao40.funcube_telemetry_parser() self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_fcf( 5, (firdes.low_pass(1, samp_rate, 1300, 500)), bfo, samp_rate) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 0.1, (rrc_taps), nfilts, nfilts / 2, 0.05, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, 0.350, 100, 0.01) 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) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, )) self.blocks_multiply_conjugate_cc_0 = blocks.multiply_conjugate_cc(1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.ao40_fec_decoder_0 = ao40_fec_decoder() self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2) ################################################## # Connections ################################################## self.msg_connect((self.ao40_fec_decoder_0, 'out'), (self.sids_print_timestamp_0, 'in')) self.msg_connect((self.ao40_fec_decoder_0, 'out'), (self.sids_submit_0, 'in')) self.msg_connect((self.sids_print_timestamp_0, 'out'), (self.funcube_telemetry_parser_0, 'in')) self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_multiply_conjugate_cc_0, 1)) self.connect((self.blocks_multiply_conjugate_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.freq_xlating_fir_filter_xxx_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.ao40_fec_decoder_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.blocks_delay_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.blocks_multiply_conjugate_cc_0, 0)) self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.analog_feedforward_agc_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 400000 self.preamble = preamble = [ -0.70711 + 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 - 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 + 0.70711j, 0.70711 - 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 + 0.70711j, -0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, 0.70711 + 0.70711j, 0.70711 + 0.70711j, 0.70711 - 0.70711j, -0.70711 + 0.70711j, 0.70711 + 0.70711j, -0.70711 - 0.70711j, 0.70711 - 0.70711j, 0.70711 + 0.70711j] self.audio_rate = audio_rate = 8000 self.audio_interp = audio_interp = 2 self.voice_gain = voice_gain = 0 self.tau = tau = 75e-6 self.rx_channel = rx_channel = 110 self.quadrature_rate = quadrature_rate = audio_rate*audio_interp self.qpsk_constellation = qpsk_constellation = digital.constellation_calcdist(([(sqrt(2)/2)+(sqrt(2)/2)*1j,-(sqrt(2)/2)+(sqrt(2)/2)*1j,(sqrt(2)/2)-(sqrt(2)/2)*1j,-(sqrt(2)/2)-(sqrt(2)/2)*1j]), (digital.psk_4()[1]), 4, 1).base() self.qpsk_constellation.gen_soft_dec_lut(8) self.preamble_size = preamble_size = len(preamble) self.poly_taps = poly_taps = firdes.low_pass(2.0, samp_rate, 20000, 1000, firdes.WIN_HAMMING, 6.76) self.payload_size = payload_size = 100 self.num_channels = num_channels = 4 self.max_deviation = max_deviation = 3500 self.guard_size = guard_size = 10 self.codec_rate = codec_rate = 64000 self.bpsk_rate = bpsk_rate = 400000 ################################################## # Blocks ################################################## self._voice_gain_range = Range(0, 2, 0.01, 0, 200) self._voice_gain_win = RangeWidget(self._voice_gain_range, self.set_voice_gain, "voice_gain", "counter_slider", float) self.top_layout.addWidget(self._voice_gain_win) self.tab2 = Qt.QTabWidget() self.tab2_widget_0 = Qt.QWidget() self.tab2_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab2_widget_0) self.tab2_grid_layout_0 = Qt.QGridLayout() self.tab2_layout_0.addLayout(self.tab2_grid_layout_0) self.tab2.addTab(self.tab2_widget_0, "Preamble Correlation") self.tab2_widget_1 = Qt.QWidget() self.tab2_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab2_widget_1) self.tab2_grid_layout_1 = Qt.QGridLayout() self.tab2_layout_1.addLayout(self.tab2_grid_layout_1) self.tab2.addTab(self.tab2_widget_1, "Received Analog Voice") self.top_grid_layout.addWidget(self.tab2, 1,1,1,1) self._rx_channel_options = (110, 110*2, 110*3, 0, ) self._rx_channel_labels = ("0", "1", "2", "3", ) self._rx_channel_group_box = Qt.QGroupBox("rx_channel") self._rx_channel_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._rx_channel_button_group = variable_chooser_button_group() self._rx_channel_group_box.setLayout(self._rx_channel_box) for i, label in enumerate(self._rx_channel_labels): radio_button = Qt.QRadioButton(label) self._rx_channel_box.addWidget(radio_button) self._rx_channel_button_group.addButton(radio_button, i) self._rx_channel_callback = lambda i: Qt.QMetaObject.invokeMethod(self._rx_channel_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._rx_channel_options.index(i))) self._rx_channel_callback(self.rx_channel) self._rx_channel_button_group.buttonClicked[int].connect( lambda i: self.set_rx_channel(self._rx_channel_options[i])) self.top_layout.addWidget(self._rx_channel_group_box) self.vocoder_ulaw_decode_bs_0 = vocoder.ulaw_decode_bs() self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("serial=309AF9C", "")), 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(433e6, 0) self.uhd_usrp_source_0.set_gain(5, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.root_raised_cosine_filter_1 = filter.fir_filter_ccf(2, firdes.root_raised_cosine( 1, bpsk_rate, bpsk_rate/2, 0.35, 101)) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size bpsk_rate/2, #samp_rate "Preamble Correlation", #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, False) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_control_panel(False) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.tab2_layout_0.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_time_raster_sink_x_0_0 = qtgui.time_raster_sink_b( codec_rate, 100, (guard_size+payload_size)*num_channels, ([]), ([]), "Received TDM Frame", 1, ) self.qtgui_time_raster_sink_x_0_0.set_update_time(0.10) self.qtgui_time_raster_sink_x_0_0.set_intensity_range(-1, 1) self.qtgui_time_raster_sink_x_0_0.enable_grid(False) labels = ["", "", "", "", "", "", "", "", "", ""] colors = [2, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_raster_sink_x_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_raster_sink_x_0_0.set_line_label(i, labels[i]) self.qtgui_time_raster_sink_x_0_0.set_color_map(i, colors[i]) self.qtgui_time_raster_sink_x_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_raster_sink_x_0_0_win = sip.wrapinstance(self.qtgui_time_raster_sink_x_0_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_raster_sink_x_0_0_win, 1,2,1,1) self.qtgui_freq_sink_x_3 = qtgui.freq_sink_f( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc audio_rate, #bw "Received Analog Voice", #name 1 #number of inputs ) self.qtgui_freq_sink_x_3.set_update_time(0.10) self.qtgui_freq_sink_x_3.set_y_axis(-140, 10) self.qtgui_freq_sink_x_3.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_3.enable_autoscale(False) self.qtgui_freq_sink_x_3.enable_grid(False) self.qtgui_freq_sink_x_3.set_fft_average(1.0) self.qtgui_freq_sink_x_3.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_3.disable_legend() if float == type(float()): self.qtgui_freq_sink_x_3.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_3.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_3.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_3.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_3.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_3.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_3_win = sip.wrapinstance(self.qtgui_freq_sink_x_3.pyqwidget(), Qt.QWidget) self.tab2_layout_1.addWidget(self._qtgui_freq_sink_x_3_win) self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Received 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_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_1.enable_autoscale(False) self.qtgui_freq_sink_x_1.enable_grid(False) self.qtgui_freq_sink_x_1.set_fft_average(1.0) self.qtgui_freq_sink_x_1.enable_control_panel(False) if not False: self.qtgui_freq_sink_x_1.disable_legend() if complex == type(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,1,1) self.digital_map_bb_0_0 = digital.map_bb((digital.psk_4()[1])) self.digital_corr_est_cc_0 = digital.corr_est_cc((preamble), 1, 0, 0.15) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(qpsk_constellation) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(2) self.blocks_tagged_stream_align_0 = blocks.tagged_stream_align(gr.sizeof_gr_complex*1, "corr_start") self.blocks_short_to_float_0 = blocks.short_to_float(1, 2000) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((voice_gain, )) self.blocks_keep_m_in_n_1 = blocks.keep_m_in_n(gr.sizeof_char, payload_size, num_channels*(payload_size+guard_size), rx_channel) self.blocks_keep_m_in_n_0 = blocks.keep_m_in_n(gr.sizeof_gr_complex, num_channels*(payload_size+guard_size)/2, num_channels*(payload_size+guard_size)/2 + preamble_size, preamble_size) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 2*(num_channels*(payload_size+guard_size)/2+preamble_size)-1) self.audio_sink_0 = audio.sink(8000, "", True) ################################################## # Connections ################################################## self.connect((self.blocks_delay_0, 0), (self.blocks_keep_m_in_n_0, 0)) self.connect((self.blocks_keep_m_in_n_0, 0), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.blocks_keep_m_in_n_1, 0), (self.vocoder_ulaw_decode_bs_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.audio_sink_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_keep_m_in_n_1, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.qtgui_time_raster_sink_x_0_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_short_to_float_0, 0), (self.qtgui_freq_sink_x_3, 0)) self.connect((self.blocks_tagged_stream_align_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.digital_map_bb_0_0, 0)) self.connect((self.digital_corr_est_cc_0, 0), (self.blocks_tagged_stream_align_0, 0)) self.connect((self.digital_corr_est_cc_0, 1), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_map_bb_0_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.root_raised_cosine_filter_1, 0), (self.digital_corr_est_cc_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.qtgui_freq_sink_x_1, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.root_raised_cosine_filter_1, 0)) self.connect((self.vocoder_ulaw_decode_bs_0, 0), (self.blocks_short_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, "Frame Sync") Qt.QWidget.__init__(self) self.setWindowTitle("Frame Sync") 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", "frame_sync") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.header_format = header_format = digital.header_format_default( digital.packet_utils.default_access_code, 0) self.header_const = header_const = digital.constellation_calcdist( (digital.psk_2()[0]), (digital.psk_2()[1]), 2, 1).base() ################################################## # Blocks ################################################## self.show_text_0 = display.show_text() self._show_text_0_win = sip.wrapinstance(self.show_text_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._show_text_0_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, 'packet_len_2') 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) if not False: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue" ] styles = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [0, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2 * 1): if len(labels[i]) == 0: if (i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label( i, "Re{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label( i, "Im{{Data {0}}}".format(i / 2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance( self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.STRING, 'test', '123123123', False, False, '') self._qtgui_edit_box_msg_0_win = sip.wrapinstance( self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_edit_box_msg_0_win) self.message_to_packet_0 = message_to_packet( header_const=header_const, header_format=header_format, length_tag_name="packet_len", ) self.digital_correlate_access_code_xx_ts_0 = digital.correlate_access_code_bb_ts( digital.packet_utils.default_access_code, 0, 'packet_len_2') self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (header_const.points()), 1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len_2') self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_char * 1, False) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 1, 8, 'packet_len_2', False, gr.GR_MSB_FIRST) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'), (self.message_to_packet_0, 'msg in')) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.show_text_0, 0)) self.connect((self.blocks_tag_gate_0, 0), (self.digital_correlate_access_code_xx_ts_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_tag_gate_0, 0)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.digital_correlate_access_code_xx_ts_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.message_to_packet_0, 0), (self.blocks_throttle_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Direct-sequence spread spectrum") ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 2, 1).base() self.samp_sym = samp_sym = 32 self.samp_rate = samp_rate = 500e3 self.samp_chip = samp_chip = 2 self.init = init = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 self.generator = generator = 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Despread Signal ", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0_0.win, 2, 3, 1, 2) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title="Received DS Signal", peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 1, 1, 2) self.digital_dxpsk_mod_0 = digital.dbpsk_mod( samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod( samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28/100.0, phase_bw=6.28/100.0, timing_bw=6.28/100.0, mod_code="gray", verbose=False, log=False ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.3, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False ) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char*1, samp_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n(gr.sizeof_char*1, 32) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, 1000) self.Spread_sync_0 = Spread.sync() self.Spread_rx_sync_0 = Spread.rx_sync(12) self.Spread_preamble_0 = Spread.preamble_bb(1389, (64*(1, 1))) self.Spread_msg_source_0 = Spread.msg_source(100, 100) self.Spread_framer_0 = Spread.framer(0) self.Spread_ds_spreader_0 = Spread.ds_spreader(samp_chip, (generator), (init)) self.Spread_ds_despreader_0 = Spread.ds_despreader(samp_chip, 1024, 2045, (generator), (init)) self.Spread_deframer_0 = Spread.deframer(0) ################################################## # Connections ################################################## self.connect((self.blocks_throttle_0, 0), (self.Spread_ds_despreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.Spread_sync_0, 0), (self.Spread_preamble_0, 0)) self.connect((self.Spread_preamble_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.Spread_rx_sync_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.Spread_ds_spreader_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.Spread_framer_0, "out", self.Spread_sync_0, "in") self.msg_connect(self.Spread_msg_source_0, "out", self.Spread_framer_0, "in") self.msg_connect(self.Spread_rx_sync_0, "out", self.Spread_deframer_0, "in")
def __init__(self): gr.top_block.__init__(self, "Meteor QPSK LRPT") # get some variables in place for inputs # # Arguments: # 1. Full path and name of stream file (including file extension) # 2. Gain to be used # 3. Frequency offset (PPM) # 4. SDR Device ID from settings.yml (for RTL-SDR source block) # 5. Bias-T (0/1 for RTL-SDR) stream_name = sys.argv[1] gain = float(sys.argv[2]) freq_offset = int(sys.argv[3]) sdr_dev_id = sys.argv[4] bias_t_string = sys.argv[5] bias_t = "1" if not bias_t_string: bias_t = "0" ################################################## # Variables ################################################## self.samp_rate_airspy = samp_rate_airspy = 1250000 self.decim = decim = 8 self.symb_rate = symb_rate = 72000 self.samp_rate = samp_rate = samp_rate_airspy / decim self.sps = sps = (samp_rate * 1.0) / (symb_rate * 1.0) self.pll_alpha = pll_alpha = 0.006 self.freq = freq = 137100000 self.clock_alpha = clock_alpha = 0.002 self.bitstream_name = bitstream_name = stream_name ############################################################################################################################################## # Blocks -- *** NOTE HOW THE VARIABLES ARE CARRIED IN FROM settings.yml - this has to be re-done every time you export the .py from gnuradio ############################################################################################################################################### self.rtlsdr_source_0 = osmosdr.source(args='numchan=' + str(1) + ' ' + 'rtl=' + str(sdr_dev_id) + ',bias=' + bias_t + '') self.rtlsdr_source_0.set_sample_rate(samp_rate_airspy) self.rtlsdr_source_0.set_center_freq(freq, 0) self.rtlsdr_source_0.set_freq_corr(freq_offset, 0) self.rtlsdr_source_0.set_dc_offset_mode(0, 0) self.rtlsdr_source_0.set_iq_balance_mode(0, 0) # determine if gain is specified or if auto-gain should be used if (gain == 0): self.rtlsdr_source_0.set_gain_mode(True, 0) else: self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(0, 0) self.rtlsdr_source_0.set_bb_gain(0, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(1500000, 0) self.root_raised_cosine_filter_0 = filter.fir_filter_ccf( 1, firdes.root_raised_cosine(1, samp_rate, symb_rate, 0.6, 361)) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=1, decimation=decim, taps=None, fractional_bw=None, ) self.digital_costas_loop_cc_0 = digital.costas_loop_cc( pll_alpha, 4, False) self.digital_constellation_soft_decoder_cf_1 = digital.constellation_soft_decoder_cf( digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base()) self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_cc( sps, clock_alpha**2 / 4.0, 0.5, clock_alpha, 0.005) self.blocks_float_to_char_0 = blocks.float_to_char(1, 127) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1, bitstream_name, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_rail_ff_0 = analog.rail_ff(-1, 1) self.analog_agc_xx_0 = analog.agc_cc(1000e-4, 0.5, 1.0) self.analog_agc_xx_0.set_max_gain(4000) ################################################## # Connections ################################################## self.connect((self.analog_agc_xx_0, 0), (self.root_raised_cosine_filter_0, 0)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_char_0, 0)) self.connect((self.blocks_float_to_char_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_constellation_soft_decoder_cf_1, 0)) self.connect((self.digital_constellation_soft_decoder_cf_1, 0), (self.analog_rail_ff_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_clock_recovery_mm_xx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.analog_agc_xx_0, 0)) self.connect((self.root_raised_cosine_filter_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.rational_resampler_xxx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Test Corr And Sync") Qt.QWidget.__init__(self) self.setWindowTitle("Test Corr And Sync") 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", "test_corr_and_sync") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 4 self.nfilts = nfilts = 32 self.eb = eb = 0.35 self.time_offset = time_offset = 1 self.samp_rate = samp_rate = 100000 self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), eb, 5*sps*nfilts) self.preamble = preamble = [1,-1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,-1,-1] self.phase = phase = 0 self.payload_size = payload_size = 992 self.noise = noise = 0 self.matched_filter = matched_filter = firdes.root_raised_cosine(nfilts, nfilts, 1, eb, int(11*sps*nfilts)) self.gap = gap = 20000 self.freq_offset = freq_offset = 0 self.constel = constel = digital.constellation_calcdist(([1,- 1]), ([0,1]), 2, 1).base() self.bb_filter = bb_filter = firdes.root_raised_cosine(sps, sps, 1, eb, 101) ################################################## # Blocks ################################################## self._time_offset_layout = Qt.QVBoxLayout() self._time_offset_label = Qt.QLabel("Timing Offset") self._time_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._time_offset_slider.setRange(0.995, 1.005, 0.00001) self._time_offset_slider.setValue(self.time_offset) self._time_offset_slider.setMinimumWidth(200) self._time_offset_slider.valueChanged.connect(self.set_time_offset) self._time_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._time_offset_layout.addWidget(self._time_offset_label) self._time_offset_layout.addWidget(self._time_offset_slider) self.top_grid_layout.addLayout(self._time_offset_layout, 4,1,1,1) self._noise_layout = Qt.QVBoxLayout() self._noise_label = Qt.QLabel("Noise") self._noise_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._noise_slider.setRange(0, 1, 0.005) self._noise_slider.setValue(self.noise) self._noise_slider.setMinimumWidth(200) self._noise_slider.valueChanged.connect(self.set_noise) self._noise_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._noise_layout.addWidget(self._noise_label) self._noise_layout.addWidget(self._noise_slider) self.top_grid_layout.addLayout(self._noise_layout, 3,0,1,1) self._freq_offset_layout = Qt.QVBoxLayout() self._freq_offset_label = Qt.QLabel("Frequency Offset") self._freq_offset_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._freq_offset_slider.setRange(-0.001, 0.001, 0.00002) self._freq_offset_slider.setValue(self.freq_offset) self._freq_offset_slider.setMinimumWidth(200) self._freq_offset_slider.valueChanged.connect(self.set_freq_offset) self._freq_offset_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._freq_offset_layout.addWidget(self._freq_offset_label) self._freq_offset_layout.addWidget(self._freq_offset_slider) self.top_grid_layout.addLayout(self._freq_offset_layout, 4,0,1,1) self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 80000, #size samp_rate, #samp_rate "QT GUI Plot", #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(-200, 400) self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 200, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) labels = ["|corr|^2", "Re{corr}", "Im{corr}", "", "", "", "", "", "", ""] 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.top_grid_layout.addWidget(self._qtgui_time_sink_x_1_win, 1,0,1,2) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 50000, #size samp_rate, #samp_rate "QT GUI Plot", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 1, 0.1, 0, "time_est") self.qtgui_time_sink_x_0.enable_autoscale(False) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 0,0,1,1) (self.qtgui_time_sink_x_0).set_processor_affinity([0]) self.qtgui_const_sink_x_0 = qtgui.const_sink_c( 1000, #size "QT GUI Plot", #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_TAG, qtgui.TRIG_SLOPE_POS, 0, 0, "time_est") self.qtgui_const_sink_x_0.enable_autoscale(False) 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, 0,1,1,1) self._phase_layout = Qt.QVBoxLayout() self._phase_label = Qt.QLabel("Phase offset") self._phase_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._phase_slider.setRange(-2*scipy.pi, 2*scipy.pi, 0.1) self._phase_slider.setValue(self.phase) self._phase_slider.setMinimumWidth(200) self._phase_slider.valueChanged.connect(self.set_phase) self._phase_label.setAlignment(Qt.Qt.AlignBottom | Qt.Qt.AlignHCenter) self._phase_layout.addWidget(self._phase_label) self._phase_layout.addWidget(self._phase_slider) self.top_grid_layout.addLayout(self._phase_layout, 3,1,1,1) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(sps, 2*3.14/100.0, (rrc_taps), nfilts, 0, 0.5, 1) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(1*3.14/50.0, 2) self.digital_correlate_and_sync_cc_0 = digital.correlate_and_sync_cc((preamble), (matched_filter), sps) self.digital_constellation_modulator_0 = digital.generic_mod( constellation=constel, differential=False, samples_per_symbol=sps, pre_diff_code=True, excess_bw=eb, verbose=False, log=False, ) self.channels_channel_model_0 = channels.channel_model( noise_voltage=noise, frequency_offset=freq_offset, epsilon=time_offset, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_vector_source_x_0_0 = blocks.vector_source_b(map(lambda x: (-x+1)/2, preamble), True, 1, []) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True) self.blocks_stream_mux_0_0_0 = blocks.stream_mux(gr.sizeof_char*1, (len(preamble)/8,payload_size)) self.blocks_stream_mux_0_0 = blocks.stream_mux(gr.sizeof_gr_complex*1, ((len(preamble)+8*payload_size)*sps, gap)) self.blocks_pack_k_bits_bb_0 = blocks.pack_k_bits_bb(8) self.blocks_null_source_0_0 = blocks.null_source(gr.sizeof_gr_complex*1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 256, 100000)), True) ################################################## # Connections ################################################## self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.qtgui_time_sink_x_1, 1)) self.connect((self.blocks_complex_to_mag_0, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.blocks_null_source_0_0, 0), (self.blocks_stream_mux_0_0, 1)) self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_pack_k_bits_bb_0, 0)) self.connect((self.blocks_stream_mux_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.qtgui_time_sink_x_1, 2)) self.connect((self.channels_channel_model_0, 0), (self.digital_correlate_and_sync_cc_0, 0)) self.connect((self.blocks_stream_mux_0_0_0, 0), (self.digital_constellation_modulator_0, 0)) self.connect((self.digital_constellation_modulator_0, 0), (self.blocks_stream_mux_0_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_complex_to_mag_0, 0)) self.connect((self.digital_correlate_and_sync_cc_0, 1), (self.blocks_complex_to_float_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.blocks_pack_k_bits_bb_0, 0), (self.blocks_stream_mux_0_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_stream_mux_0_0_0, 1)) self.connect((self.digital_costas_loop_cc_0, 0), (self.qtgui_const_sink_x_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.sps = sps = 45 self.nfilts = nfilts = 25 self.samp_rate = samp_rate = 44.1E3 self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), 0.35, 45 * nfilts) self.fc_slider = fc_slider = 2200 self.BPSK = BPSK = digital.constellation_calcdist(([-1, 1]), ([0, 1]), 4, 1).base() ################################################## # Blocks ################################################## self._fc_slider_range = Range(0, 18200, 200, 2200, 150) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, "fc", "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.qtgui_time_sink_x_0_0 = qtgui.time_sink_f( 1024, #size samp_rate, #samp_rate "Sinal capturado pelo mic", #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_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_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.5) 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(True) if not True: self.qtgui_const_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "red", "red", "red", "red", "red", "red", "red", "red" ] styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_const_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_const_sink_x_0.set_line_label(i, labels[i]) self.qtgui_const_sink_x_0.set_line_width(i, widths[i]) self.qtgui_const_sink_x_0.set_line_color(i, colors[i]) self.qtgui_const_sink_x_0.set_line_style(i, styles[i]) self.qtgui_const_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_const_sink_x_0_win = sip.wrapinstance( self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_const_sink_x_0_win) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 1.1E3, .6E3, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, .063, (rrc_taps), nfilts, nfilts / 2, 1.5, 1) self.digital_lms_dd_equalizer_cc_0 = digital.lms_dd_equalizer_cc( 8, .01, 1, BPSK) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2) self.digital_costas_loop_cc_0 = digital.costas_loop_cc(.05, 2, False) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) self.blks2_tcp_sink_0 = grc_blks2.tcp_sink( itemsize=gr.sizeof_char * 1, addr="127.0.0.1", port=1234, server=False, ) self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b( grc_blks2.packet_decoder( access_code="", threshold=-1, callback=lambda ok, payload: self.blks2_packet_decoder_0. recv_pkt(ok, payload), ), ) self.audio_source_0 = audio.source(44100, "", True) self.analog_sig_source_x_0_0 = analog.sig_source_c( samp_rate, analog.GR_COS_WAVE, fc_slider, 1, 0) self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 1) ################################################## # Connections ################################################## self.connect((self.analog_feedforward_agc_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.analog_sig_source_x_0_0, 0), (self.blocks_multiply_xx_0_0, 1)) self.connect((self.audio_source_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.audio_source_0, 0), (self.qtgui_time_sink_x_0_0, 0)) self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_multiply_xx_0_0, 0)) self.connect((self.blocks_multiply_xx_0_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_lms_dd_equalizer_cc_0, 0)) self.connect((self.digital_diff_decoder_bb_0, 0), (self.blks2_packet_decoder_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_lms_dd_equalizer_cc_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.analog_feedforward_agc_cc_0, 0))
def __init__(self, bw_clock_sync=2*math.pi/100, bw_fll=math.pi/1600, bits_per_sym=2, bw_costas=2*math.pi/100, n_filts=32, len_sym_srrc=7, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=3, alfa=0.35): gr.hier_block2.__init__( self, "Hier Rx", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_char*1), ) ################################################## # Parameters ################################################## self.bw_clock_sync = bw_clock_sync self.bw_fll = bw_fll self.bits_per_sym = bits_per_sym self.bw_costas = bw_costas self.n_filts = n_filts self.len_sym_srrc = len_sym_srrc self.constellation = constellation self.samp_per_sym = samp_per_sym self.alfa = alfa ################################################## # Variables ################################################## self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) ################################################## # Blocks ################################################## self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) 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.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_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_0, 0)) self.connect((self, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self, 0)) sw_decim = 1 self._chbw_factor=1 chan_coeffs = filter.firdes.low_pass (1.0, # gain sw_decim * self.samp_per_sym, # sampling rate self._chbw_factor, # midpoint of trans. band 0.5, # width of trans. band filter.firdes.WIN_HANN) # filter type self.channel_filter = filter.fft_filter_ccc(sw_decim, chan_coeffs) # Carrier Sensing Blocks alpha = 0.001 thresh = 30 # in dB, will have to adjust self.probe = analog.probe_avg_mag_sqrd_c(thresh,alpha) self.connect(self, self.channel_filter) # connect the channel input filter to the carrier power detector self.connect(self.channel_filter, self.probe)
def __init__(self, n_filts=32, bits_per_sym=2, alpha_probe=0.1, th_probe=0, constellation=digital.constellation_calcdist([-1-1j, 1-1j, 1+1j, -1+1j], [], 4, 1).base(), samp_per_sym=5, bw_costas=2*math.pi/100, bw_clock_sync=2*math.pi/100, bw_fll=2*math.pi/100, len_sym_srrc=11, alfa=0.45): grc_wxgui.top_block_gui.__init__(self, title="Test Hier Rx Usrp") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Parameters ################################################## self.n_filts = n_filts self.bits_per_sym = bits_per_sym self.alpha_probe = alpha_probe self.th_probe = th_probe self.constellation = constellation self.samp_per_sym = samp_per_sym self.bw_costas = bw_costas self.bw_clock_sync = bw_clock_sync self.bw_fll = bw_fll self.len_sym_srrc = len_sym_srrc self.alfa = alfa ################################################## # Variables ################################################## self.filtro_srrc = filtro_srrc = firdes.root_raised_cosine(n_filts,samp_per_sym*n_filts,1.0,alfa,samp_per_sym*len_sym_srrc*n_filts) ################################################## # Blocks ################################################## self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=250000/samp_per_sym, v_scale=0.3, v_offset=0, t_scale=0.3, ac_couple=False, xy_mode=True, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.Add(self.wxgui_scopesink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(50000*samp_per_sym) self.uhd_usrp_source_0.set_center_freq(850000000, 0) self.uhd_usrp_source_0.set_gain(18, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(samp_per_sym, bw_clock_sync, (filtro_srrc), n_filts, 16, 5, 1) self.digital_mpsk_snr_est_cc_0 = digital.mpsk_snr_est_cc(2, 1000, 0.1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(samp_per_sym, alfa, len_sym_srrc*samp_per_sym, bw_fll) self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2**bits_per_sym) self.digital_costas_loop_cc_0_0_0 = digital.costas_loop_cc(bw_costas, 2**bits_per_sym) self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(constellation) self.blocks_vector_sink_x_0 = blocks.vector_sink_b(1) self.blocks_unpack_k_bits_bb_0 = blocks.unpack_k_bits_bb(bits_per_sym) self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/belza/pruebasUSRP/file_rx_sym", False) self.blocks_file_sink_0_0.set_unbuffered(True) self.analog_agc2_xx_0 = analog.agc2_cc(0.6e-1, 1e-3, 2, 15) self.analog_agc2_xx_0.set_max_gain(15) ################################################## # Connections ################################################## self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_unpack_k_bits_bb_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0)) self.connect((self.analog_agc2_xx_0, 0), (self.digital_fll_band_edge_cc_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.analog_agc2_xx_0, 0)) self.connect((self.blocks_unpack_k_bits_bb_0, 0), (self.blocks_vector_sink_x_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.blocks_file_sink_0_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.digital_costas_loop_cc_0_0_0, 0), (self.digital_mpsk_snr_est_cc_0, 0)) self.connect((self.digital_mpsk_snr_est_cc_0, 0), (self.digital_constellation_decoder_cb_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__( self, title="Direct-sequence spread spectrum") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.samp_sym = samp_sym = 32 self.samp_rate = samp_rate = 500e3 self.samp_chip = samp_chip = 2 self.init = init = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 self.generator = generator = 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1 ################################################## # Blocks ################################################## self.wxgui_fftsink2_0_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='Despread Signal ', peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0_0.win, 2, 3, 1, 2) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=1024, fft_rate=15, average=False, avg_alpha=None, title='Received DS Signal', peak_hold=False, ) self.GridAdd(self.wxgui_fftsink2_0.win, 2, 1, 1, 2) self.digital_dxpsk_mod_0 = digital.dbpsk_mod(samples_per_symbol=2, excess_bw=0.35, mod_code="gray", verbose=False, log=False) self.digital_dxpsk_demod_0 = digital.dbpsk_demod(samples_per_symbol=2, excess_bw=0.35, freq_bw=6.28 / 100.0, phase_bw=6.28 / 100.0, timing_bw=6.28 / 100.0, mod_code="gray", verbose=False, log=False) self.channels_channel_model_0 = channels.channel_model( noise_voltage=0.3, frequency_offset=0.0, epsilon=1.0, taps=(1.0 + 1.0j, ), noise_seed=0, block_tags=False) self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb( 1, gr.GR_MSB_FIRST) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, samp_sym) self.blocks_keep_one_in_n_0 = blocks.keep_one_in_n( gr.sizeof_char * 1, 32) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex * 1, 1000) self.Spread_sync_0 = Spread.sync() self.Spread_rx_sync_0 = Spread.rx_sync(12) self.Spread_preamble_0 = Spread.preamble_bb(1389, (64 * (1, 1))) self.Spread_msg_source_0 = Spread.msg_source(100, 100) self.Spread_framer_0 = Spread.framer(0) self.Spread_ds_spreader_0 = Spread.ds_spreader(samp_chip, (generator), (init)) self.Spread_ds_despreader_0 = Spread.ds_despreader( samp_chip, 1024, 2045, (generator), (init)) self.Spread_deframer_0 = Spread.deframer(0) ################################################## # Connections ################################################## self.msg_connect((self.Spread_framer_0, 'out'), (self.Spread_sync_0, 'in')) self.msg_connect((self.Spread_msg_source_0, 'out'), (self.Spread_framer_0, 'in')) self.msg_connect((self.Spread_rx_sync_0, 'out'), (self.Spread_deframer_0, 'in')) self.connect((self.Spread_ds_despreader_0, 0), (self.digital_dxpsk_demod_0, 0)) self.connect((self.Spread_ds_despreader_0, 0), (self.wxgui_fftsink2_0_0, 0)) self.connect((self.Spread_ds_spreader_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0)) self.connect((self.Spread_preamble_0, 0), (self.blocks_repeat_0, 0)) self.connect((self.Spread_sync_0, 0), (self.Spread_preamble_0, 0)) self.connect((self.blocks_delay_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_keep_one_in_n_0, 0), (self.Spread_rx_sync_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.Spread_ds_spreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.Spread_ds_despreader_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.digital_dxpsk_mod_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.blocks_delay_0, 0)) self.connect((self.digital_dxpsk_demod_0, 0), (self.blocks_keep_one_in_n_0, 0)) self.connect((self.digital_dxpsk_mod_0, 0), (self.channels_channel_model_0, 0))
def __init__(self, eve_noise_db=1, channel_noise_db=1, max_items=8): gr.top_block.__init__(self, "Eve Re Learn Testbed Graph") ################################################## # Variables ################################################## self.snr_db = snr_db = 0 self.samp_rate = samp_rate = 10000000 self.max_items = max_items self.eve_noise_db = eve_noise_db self.channel_noise_db = channel_noise_db self.const = const = digital.constellation_calcdist( ([-1 - 1j, -1 + 1j, 1 + 1j, 1 - 1j]), ([0, 1, 3, 2]), 4, 1).base() ################################################## # Blocks ################################################## self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb( const) self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc( (const.points()), 1) self.blocks_vector_sink_alice = blocks.vector_sink_b(1) self.blocks_vector_sink_bob = blocks.vector_sink_b(1) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_repack_bits_bb_1 = blocks.repack_bits_bb( 1, 8, "", False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0_0 = blocks.repack_bits_bb( 1, const.bits_per_symbol(), "", False, gr.GR_LSB_FIRST) self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb( const.bits_per_symbol(), 8, "", False, gr.GR_LSB_FIRST) self.blocks_head_0_0 = blocks.head(gr.sizeof_char * 1, max_items) self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, max_items) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, np.random.randint(0, 2, 1000000)), True) self.analog_fastnoise_source_x_0_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 10**(self.eve_noise_db / 20.0), 0, 2**16) self.analog_fastnoise_source_x_0 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, 10**(self.channel_noise_db / 20.0), 0, 2**16) ################################################## # Connections ################################################## self.connect((self.analog_fastnoise_source_x_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.analog_fastnoise_source_x_0_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_repack_bits_bb_0_0, 0)) self.connect((self.analog_random_source_x_0, 0), (self.blocks_repack_bits_bb_1, 0)) self.connect((self.blocks_add_xx_0, 0), (self.digital_constellation_decoder_cb_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_vector_sink_bob, 0)) self.connect((self.blocks_head_0_0, 0), (self.blocks_vector_sink_alice, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_repack_bits_bb_0_0, 0), (self.digital_chunks_to_symbols_xx_0, 0)) self.connect((self.blocks_repack_bits_bb_1, 0), (self.blocks_head_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_repack_bits_bb_0, 0))
def __init__(self, bfo=12000, callsign='', ip='::', latitude=0, longitude=0, port=7355, recstart=''): gr.hier_block2.__init__( self, "LilacSat-1 decoder", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signaturev(2, 2, [gr.sizeof_char * 1, gr.sizeof_char * 1]), ) ################################################## # Parameters ################################################## self.bfo = bfo self.callsign = callsign self.ip = ip self.latitude = latitude self.longitude = longitude self.port = port self.recstart = recstart ################################################## # Variables ################################################## self.sps = sps = 5 self.samp_per_sym = samp_per_sym = 5 self.nfilts = nfilts = 16 self.alpha = alpha = 0.35 self.variable_constellation_0_0 = variable_constellation_0_0 = digital.constellation_calcdist( ([-1, 1]), ([0, 1]), 2, 1).base() self.threshold = threshold = 3 self.samp_rate = samp_rate = 48000 self.rrc_taps_0 = rrc_taps_0 = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(samp_per_sym), 0.35, 11 * samp_per_sym * nfilts) self.rrc_taps = rrc_taps = firdes.root_raised_cosine( nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts) self.nfilts_0 = nfilts_0 = 16 ################################################## # Blocks ################################################## self.rms_agc_0 = rms_agc( alpha=1e-2, reference=0.5, ) self.low_pass_filter_0_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 10000, 1000, firdes.WIN_HAMMING, 6.76)) self.low_pass_filter_0 = filter.fir_filter_ccf( 1, firdes.low_pass(1, samp_rate, 6000, 500, firdes.WIN_HAMMING, 6.76)) self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf( sps, 0.05, (rrc_taps), nfilts, nfilts / 2, 0.01, 1) self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc( sps, 0.350, 100, 0.001) self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(0.1, 2, False) self.ccsds_viterbi_0_0 = ccsds_viterbi() self.ccsds_viterbi_0 = ccsds_viterbi() self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1) self.blocks_complex_to_real_0 = blocks.complex_to_real(1) ################################################## # Connections ################################################## self.connect((self.blocks_complex_to_real_0, 0), (self.blocks_delay_0, 0)) self.connect((self.blocks_complex_to_real_0, 0), (self.ccsds_viterbi_0, 0)) self.connect((self.blocks_delay_0, 0), (self.ccsds_viterbi_0_0, 0)) self.connect((self.ccsds_viterbi_0, 0), (self, 0)) self.connect((self.ccsds_viterbi_0_0, 0), (self, 1)) self.connect((self.digital_costas_loop_cc_0_0, 0), (self.blocks_complex_to_real_0, 0)) self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0, 0)) self.connect((self.digital_pfb_clock_sync_xxx_0, 0), (self.digital_costas_loop_cc_0_0, 0)) self.connect((self, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.low_pass_filter_0, 0), (self.digital_pfb_clock_sync_xxx_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.rms_agc_0, 0)) self.connect((self.rms_agc_0, 0), (self.digital_fll_band_edge_cc_0, 0))
def __init__(self): gr.top_block.__init__(self, "Lab Total") Qt.QWidget.__init__(self) self.setWindowTitle("Lab Total") 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", "Lab_total") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.m = m = 9 self.samp_rate_usrp = samp_rate_usrp = 100000000 self.Kd = Kd = math.pow(2,m) self.Constelacion = Constelacion = [1.+0.j, -1.+0.j ] self.samp_rate = samp_rate = int(samp_rate_usrp/Kd) self.Sps = Sps = 16 self.M = M = len(Constelacion) self.rolloff = rolloff = 0.35 self.ntaps = ntaps = 128 self.Rs = Rs = samp_rate/Sps self.Bps = Bps = int(math.log(M,2)) self.run_stop = run_stop = True self.hrrc = hrrc = wform.rrcos(Sps,ntaps,rolloff) self.hrc = hrc = wform.rcos(Sps,ntaps,rolloff) self.hr = hr = wform.rect(Sps,ntaps) self.hn = hn = wform.nyq(Sps,ntaps) self.Tmax_scope = Tmax_scope = 64./Rs self.TimingDelay = TimingDelay = 0 self.Rb = Rb = Rs*Bps self.NodB = NodB = -65 self.MiconstellationObject = MiconstellationObject = digital.constellation_calcdist((Constelacion), (), 4, 1).base() self.Fc = Fc = 80e6 self.BW = BW = samp_rate/2. ################################################## # Blocks ################################################## self.pestana = Qt.QTabWidget() self.pestana_widget_0 = Qt.QWidget() self.pestana_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.pestana_widget_0) self.pestana_grid_layout_0 = Qt.QGridLayout() self.pestana_layout_0.addLayout(self.pestana_grid_layout_0) self.pestana.addTab(self.pestana_widget_0, 'Osciloscopio Wave Forming') self.pestana_widget_1 = Qt.QWidget() self.pestana_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.pestana_widget_1) self.pestana_grid_layout_1 = Qt.QGridLayout() self.pestana_layout_1.addLayout(self.pestana_grid_layout_1) self.pestana.addTab(self.pestana_widget_1, 'PSD Wave Forming') self.pestana_widget_2 = Qt.QWidget() self.pestana_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.pestana_widget_2) self.pestana_grid_layout_2 = Qt.QGridLayout() self.pestana_layout_2.addLayout(self.pestana_grid_layout_2) self.pestana.addTab(self.pestana_widget_2, 'Osciloscopio Acoplamiento') self.pestana_widget_3 = Qt.QWidget() self.pestana_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.pestana_widget_3) self.pestana_grid_layout_3 = Qt.QGridLayout() self.pestana_layout_3.addLayout(self.pestana_grid_layout_3) self.pestana.addTab(self.pestana_widget_3, 'PSD Acoplamiento') self.pestana_widget_4 = Qt.QWidget() self.pestana_layout_4 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.pestana_widget_4) self.pestana_grid_layout_4 = Qt.QGridLayout() self.pestana_layout_4.addLayout(self.pestana_grid_layout_4) self.pestana.addTab(self.pestana_widget_4, 'Diagrama de Ojo') self.top_grid_layout.addWidget(self.pestana, 1, 0, 1, 4) for r in range(1, 2): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 4): self.top_grid_layout.setColumnStretch(c, 1) self.ojo = Qt.QTabWidget() self.ojo_widget_0 = Qt.QWidget() self.ojo_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ojo_widget_0) self.ojo_grid_layout_0 = Qt.QGridLayout() self.ojo_layout_0.addLayout(self.ojo_grid_layout_0) self.ojo.addTab(self.ojo_widget_0, 'Rectangular') self.ojo_widget_1 = Qt.QWidget() self.ojo_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ojo_widget_1) self.ojo_grid_layout_1 = Qt.QGridLayout() self.ojo_layout_1.addLayout(self.ojo_grid_layout_1) self.ojo.addTab(self.ojo_widget_1, 'Nyquist') self.ojo_widget_2 = Qt.QWidget() self.ojo_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ojo_widget_2) self.ojo_grid_layout_2 = Qt.QGridLayout() self.ojo_layout_2.addLayout(self.ojo_grid_layout_2) self.ojo.addTab(self.ojo_widget_2, 'Raised Cosine') self.ojo_widget_3 = Qt.QWidget() self.ojo_layout_3 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.ojo_widget_3) self.ojo_grid_layout_3 = Qt.QGridLayout() self.ojo_layout_3.addLayout(self.ojo_grid_layout_3) self.ojo.addTab(self.ojo_widget_3, 'Root Raised Cosine') self.pestana_grid_layout_4.addWidget(self.ojo) self._TimingDelay_range = Range(0, Sps-1, 1, 0, 200) self._TimingDelay_win = RangeWidget(self._TimingDelay_range, self.set_TimingDelay, 'Timing', "counter_slider", int) self.top_grid_layout.addWidget(self._TimingDelay_win, 0, 3, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(3, 4): self.top_grid_layout.setColumnStretch(c, 1) _run_stop_check_box = Qt.QCheckBox('Inicial/Parar') self._run_stop_choices = {True: True, False: False} self._run_stop_choices_inv = dict((v,k) for k,v in self._run_stop_choices.iteritems()) self._run_stop_callback = lambda i: Qt.QMetaObject.invokeMethod(_run_stop_check_box, "setChecked", Qt.Q_ARG("bool", self._run_stop_choices_inv[i])) self._run_stop_callback(self.run_stop) _run_stop_check_box.stateChanged.connect(lambda i: self.set_run_stop(self._run_stop_choices[bool(i)])) self.top_grid_layout.addWidget(_run_stop_check_box, 0, 0, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(0, 1): self.top_grid_layout.setColumnStretch(c, 1) self.qtgui_time_sink_x_0_1 = qtgui.time_sink_c( int(Tmax_scope*samp_rate)/4, #size samp_rate, #samp_rate "Wave Forming", #name 4 #number of inputs ) self.qtgui_time_sink_x_0_1.set_update_time(0.10) self.qtgui_time_sink_x_0_1.set_y_axis(-3, 3) self.qtgui_time_sink_x_0_1.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0_1.enable_tags(-1, True) self.qtgui_time_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0_1.enable_autoscale(False) self.qtgui_time_sink_x_0_1.enable_grid(False) self.qtgui_time_sink_x_0_1.enable_axis_labels(True) self.qtgui_time_sink_x_0_1.enable_control_panel(False) self.qtgui_time_sink_x_0_1.enable_stem_plot(False) if not True: self.qtgui_time_sink_x_0_1.disable_legend() labels = ['Re', 'Im', 'Re.Nyq', 'Re.Nyq', 'Re.RC', 'Re.RC', 'Re.RRC', 'Re.RRC', '', ''] 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(8): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_1.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_1_win = sip.wrapinstance(self.qtgui_time_sink_x_0_1.pyqwidget(), Qt.QWidget) self.pestana_grid_layout_0.addWidget(self._qtgui_time_sink_x_0_1_win, 0, 0, 1, 1) for r in range(0, 1): self.pestana_grid_layout_0.setRowStretch(r, 1) for c in range(0, 1): self.pestana_grid_layout_0.setColumnStretch(c, 1) self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype 0, #fc samp_rate, #bw "Wave Forming.PSD", #name 4 #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(-80, 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(0.05) self.qtgui_freq_sink_x_0_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0_0.enable_control_panel(True) 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 = ['Rect', 'Nyq', 'RC', 'RRC', '', '', '', '', '', ''] widths = [3, 3, 3, 3, 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(4): 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.pestana_grid_layout_1.addWidget(self._qtgui_freq_sink_x_0_0_win, 0, 0, 1, 1) for r in range(0, 1): self.pestana_grid_layout_1.setRowStretch(r, 1) for c in range(0, 1): self.pestana_grid_layout_1.setColumnStretch(c, 1) self.interp_fir_filter_xxx_0_0_2 = filter.interp_fir_filter_ccc(1, (numpy.multiply(hrc,1./Sps))) self.interp_fir_filter_xxx_0_0_2.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_1_0 = filter.interp_fir_filter_ccc(1, (numpy.multiply(hrrc,1./Sps))) self.interp_fir_filter_xxx_0_0_1_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_1 = filter.interp_fir_filter_ccc(1, (numpy.multiply(hn,1./Sps))) self.interp_fir_filter_xxx_0_0_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_0_0_1 = filter.interp_fir_filter_ccc(Sps, (hrrc)) self.interp_fir_filter_xxx_0_0_0_0_1.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_0_0_0 = filter.interp_fir_filter_ccc(Sps, (hrc)) self.interp_fir_filter_xxx_0_0_0_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_0_0 = filter.interp_fir_filter_ccc(Sps, (hn)) self.interp_fir_filter_xxx_0_0_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0_0 = filter.interp_fir_filter_ccc(Sps, (hr)) self.interp_fir_filter_xxx_0_0_0.declare_sample_delay(0) self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccc(1, (numpy.multiply(hr,1./Sps))) self.interp_fir_filter_xxx_0_0.declare_sample_delay(0) self.digital_constellation_decoder_cb_0_0 = digital.constellation_decoder_cb(MiconstellationObject) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_char*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.b_sampler_cc_0_0 = b_sampler_cc( DelayDiez=TimingDelay, Sps=Sps, ) self.b_Mod_BPSK_bc_0 = b_Mod_BPSK_bc() self.b_Eye_Diagram_simple_c_0_0_1 = b_Eye_Diagram_simple_c( AlphaLineas=0.5, Delay_i=0, GrosorLineas=20, Kint=1, N_eyes=2, Samprate1=samp_rate, Sps1=Sps, Title="Acoplamiento.RRC", Ymax=3, Ymin=-3, ) self.ojo_grid_layout_3.addWidget(self.b_Eye_Diagram_simple_c_0_0_1) self.b_Eye_Diagram_simple_c_0_0_0 = b_Eye_Diagram_simple_c( AlphaLineas=0.5, Delay_i=0, GrosorLineas=20, Kint=1, N_eyes=2, Samprate1=samp_rate, Sps1=Sps, Title="Acoplamiento.RC", Ymax=3, Ymin=-3, ) self.ojo_grid_layout_2.addWidget(self.b_Eye_Diagram_simple_c_0_0_0) self.b_Eye_Diagram_simple_c_0_0 = b_Eye_Diagram_simple_c( AlphaLineas=0.5, Delay_i=0, GrosorLineas=20, Kint=1, N_eyes=2, Samprate1=samp_rate, Sps1=Sps, Title="Acoplamiento.Nyq", Ymax=3, Ymin=-3, ) self.ojo_grid_layout_1.addWidget(self.b_Eye_Diagram_simple_c_0_0) self.b_Eye_Diagram_simple_c_0 = b_Eye_Diagram_simple_c( AlphaLineas=0.5, Delay_i=0, GrosorLineas=20, Kint=1, N_eyes=2, Samprate1=samp_rate, Sps1=Sps, Title="Acoplamiento.Rect", Ymax=3, Ymin=-3, ) self.ojo_grid_layout_0.addWidget(self.b_Eye_Diagram_simple_c_0) self.analog_random_source_x_0 = blocks.vector_source_b(map(int, numpy.random.randint(0, 2, 1000)), True) self._NodB_range = Range(-140., 0., 1., -65, 200) self._NodB_win = RangeWidget(self._NodB_range, self.set_NodB, 'No (in dB for white noise)', "counter_slider", float) self.top_grid_layout.addWidget(self._NodB_win, 0, 1, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(1, 2): self.top_grid_layout.setColumnStretch(c, 1) self._BW_range = Range(0., samp_rate/2., (samp_rate/2)/128., samp_rate/2., 200) self._BW_win = RangeWidget(self._BW_range, self.set_BW, 'LPF BW (Hz)', "counter_slider", float) self.top_grid_layout.addWidget(self._BW_win, 0, 2, 1, 1) for r in range(0, 1): self.top_grid_layout.setRowStretch(r, 1) for c in range(2, 3): self.top_grid_layout.setColumnStretch(c, 1) ################################################## # Connections ################################################## self.connect((self.analog_random_source_x_0, 0), (self.b_Mod_BPSK_bc_0, 0)) self.connect((self.b_Mod_BPSK_bc_0, 0), (self.interp_fir_filter_xxx_0_0_0, 0)) self.connect((self.b_Mod_BPSK_bc_0, 0), (self.interp_fir_filter_xxx_0_0_0_0, 0)) self.connect((self.b_Mod_BPSK_bc_0, 0), (self.interp_fir_filter_xxx_0_0_0_0_0, 0)) self.connect((self.b_Mod_BPSK_bc_0, 0), (self.interp_fir_filter_xxx_0_0_0_0_1, 0)) self.connect((self.b_sampler_cc_0_0, 0), (self.blocks_null_sink_0, 0)) self.connect((self.b_sampler_cc_0_0, 1), (self.digital_constellation_decoder_cb_0_0, 0)) self.connect((self.digital_constellation_decoder_cb_0_0, 0), (self.blocks_null_sink_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.b_Eye_Diagram_simple_c_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0, 0), (self.b_sampler_cc_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0, 0), (self.interp_fir_filter_xxx_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0, 0), (self.qtgui_time_sink_x_0_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0_0, 0), (self.interp_fir_filter_xxx_0_0_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 1)) self.connect((self.interp_fir_filter_xxx_0_0_0_0, 0), (self.qtgui_time_sink_x_0_1, 1)) self.connect((self.interp_fir_filter_xxx_0_0_0_0_0, 0), (self.interp_fir_filter_xxx_0_0_2, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0_0_0, 0), (self.qtgui_freq_sink_x_0_0, 2)) self.connect((self.interp_fir_filter_xxx_0_0_0_0_0, 0), (self.qtgui_time_sink_x_0_1, 2)) self.connect((self.interp_fir_filter_xxx_0_0_0_0_1, 0), (self.interp_fir_filter_xxx_0_0_1_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0_0_0_1, 0), (self.qtgui_freq_sink_x_0_0, 3)) self.connect((self.interp_fir_filter_xxx_0_0_0_0_1, 0), (self.qtgui_time_sink_x_0_1, 3)) self.connect((self.interp_fir_filter_xxx_0_0_1, 0), (self.b_Eye_Diagram_simple_c_0_0, 0)) self.connect((self.interp_fir_filter_xxx_0_0_1_0, 0), (self.b_Eye_Diagram_simple_c_0_0_1, 0)) self.connect((self.interp_fir_filter_xxx_0_0_2, 0), (self.b_Eye_Diagram_simple_c_0_0_0, 0))
def __init__( self, scrambler, fieldSize = 4, codewordLength = 12, augmentingLength = 3, continuous = True, noisePower = 0.09, maxErrors = 10000, maxSymbols = long(1e7), selectionMethod = 'MSW'): gr.top_block.__init__(self, "Guided Scrambling Error Rate Simulation") ################################################## # Variables ################################################## scramblingPolynomial = scrambler constellation = gs.defaultConstellation_f(fieldSize) constellationObj = digital.constellation_calcdist((constellation), (range(fieldSize)), 0, 1).base() self.maxErrors = maxErrors self.maxSymbols = maxSymbols ################################################## # Blocks ################################################## self.symbolGenerator = gs.SymbolGenerator_b(([1] * fieldSize), '') self.bareSymbolMapper = gs.SymbolMapper_bc((constellation)) self.bareChannelNoise = analog.noise_source_c(analog.GR_GAUSSIAN, np.sqrt(noisePower*(codewordLength-augmentingLength)/codewordLength), 0) self.bareNoiseAdder = blocks.add_vcc(1) self.bareDetectorMultiplier = blocks.multiply_const_vcc((constellationObj.points()[0].real/constellation[0].real, )) self.bareDetector = digital.constellation_decoder_cb(constellationObj) self.bareErrorRate = gs.ErrorCount_bf(False, '', 0, 0) self.guidedScrambler = gs.GuidedScrambler_bb(fieldSize, codewordLength, augmentingLength, continuous, (scramblingPolynomial), 0, 'MSW', '') self.gsSymbolMapper = gs.SymbolMapper_bc((constellation)) self.gsChannelNoise = analog.noise_source_c(analog.GR_GAUSSIAN, np.sqrt(noisePower), 0) self.gsNoiseAdder = blocks.add_vcc(1) self.mlDetectorMultiplier = blocks.multiply_const_vcc((constellationObj.points()[0].real/constellation[0].real, )) self.mlDetector = digital.constellation_decoder_cb(constellationObj) self.mlErrorRate = gs.ErrorCount_bf(False, '', 0, 0) self.mapDetector = gs.Detector_cb(fieldSize, codewordLength, augmentingLength, noisePower) self.mapErrorRate = gs.ErrorCount_bf(False, '', maxErrors, maxSymbols) self.descrambler = gs.Descrambler_bb(fieldSize, codewordLength, augmentingLength, continuous, (scramblingPolynomial), '') self.descrambledErrorRate = gs.ErrorCount_bf(False, '', 0, 0) ################################################## # Connections ################################################## self.connect((self.symbolGenerator, 0), (self.guidedScrambler, 0)) self.connect((self.symbolGenerator, 0), (self.bareErrorRate, 0)) self.connect((self.symbolGenerator, 0), (self.bareSymbolMapper, 0)) self.connect((self.bareSymbolMapper, 0), (self.bareNoiseAdder, 0)) self.connect((self.bareChannelNoise, 0), (self.bareNoiseAdder, 1)) self.connect((self.bareNoiseAdder, 0), (self.bareDetectorMultiplier, 0)) self.connect((self.bareDetectorMultiplier, 0), (self.bareDetector, 0)) self.connect((self.bareDetector, 0), (self.bareErrorRate, 1)) self.connect((self.guidedScrambler, 0), (self.gsSymbolMapper, 0)) self.connect((self.gsSymbolMapper, 0), (self.gsNoiseAdder, 0)) self.connect((self.gsChannelNoise, 0), (self.gsNoiseAdder, 1)) self.connect((self.guidedScrambler, 0), (self.mlErrorRate, 0)) self.connect((self.gsNoiseAdder, 0), (self.mlDetectorMultiplier, 0)) self.connect((self.mlDetectorMultiplier, 0), (self.mlDetector, 0)) self.connect((self.mlDetector, 0), (self.mlErrorRate, 1)) self.connect((self.guidedScrambler, 0), (self.mapErrorRate, 0)) self.connect((self.gsNoiseAdder, 0), (self.mapDetector, 0)) self.connect((self.mapDetector, 0), (self.mapErrorRate, 1)) self.connect((self.symbolGenerator, 0), (self.descrambledErrorRate, 0)) self.connect((self.mapDetector, 0), (self.descrambler, 0)) self.connect((self.descrambler, 0), (self.descrambledErrorRate, 1))