예제 #1
0
    def test_001_t(self):
        # set up fg
        test_len = 1024

        packet_len = test_len
        samp_rate = 2000

        center_freq = 1e9
        velocity = (5, 15, 20)

        src = radar.signal_generator_cw_c(packet_len, samp_rate, (0, 0), 1)
        head = blocks.head(8, test_len)
        sim = radar.static_target_simulator_cc(
            (10, 10, 10), velocity, (1e12, 1e12, 1e12), (0, 0, 0), (0,), samp_rate, center_freq, 1, True, False
        )
        mult = blocks.multiply_cc()
        fft = radar.ts_fft_cc(packet_len)
        cfar = radar.os_cfar_c(samp_rate, 5, 0, 0.78, 10, True)
        est = radar.estimator_cw(center_freq)
        res1 = radar.print_results()
        res2 = radar.print_results()
        gate = radar.msg_gate(("velocity", "bla"), (8, 8), (17, 17))
        debug1 = blocks.message_debug()
        debug2 = blocks.message_debug()

        self.tb.connect(src, head, (mult, 1))
        self.tb.connect(head, sim, (mult, 0))
        self.tb.connect(mult, fft, cfar)
        self.tb.msg_connect(cfar, "Msg out", est, "Msg in")
        self.tb.msg_connect(est, "Msg out", res1, "Msg in")
        self.tb.msg_connect(est, "Msg out", debug1, "store")
        self.tb.msg_connect(est, "Msg out", gate, "Msg in")
        self.tb.msg_connect(gate, "Msg out", debug2, "store")
        self.tb.msg_connect(gate, "Msg out", res2, "Msg in")

        self.tb.start()
        sleep(0.5)
        self.tb.stop()
        self.tb.wait()

        # check data
        msg1 = debug1.get_message(0)  # msg without gate
        msg2 = debug2.get_message(0)  # msg with gate
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(0, (pmt.nth(1, msg1))))
        )  # check velocity message part (symbol), 1
        self.assertEqual(
            "velocity", pmt.symbol_to_string(pmt.nth(0, (pmt.nth(1, msg2))))
        )  # check velocity message part (symbol), 2
        self.assertEqual(pmt.length(pmt.nth(1, pmt.nth(1, msg1))), 3)  # check number of targets without gate
        self.assertEqual(pmt.length(pmt.nth(1, pmt.nth(1, msg2))), 1)  # check nubmer of targets with gate
        self.assertAlmostEqual(
            1, velocity[1] / pmt.f32vector_ref(pmt.nth(1, (pmt.nth(1, msg2))), 0), 1
        )  # check velocity value
예제 #2
0
    def test_packet_format_async_counter(self):
        bps = 2
        ac = packet_utils.default_access_code
        hdr_format = digital.header_format_counter(ac, 0, 2)

        formatter = digital.protocol_formatter_async(hdr_format)
        snk_hdr = blocks.message_debug()
        snk_pld = blocks.message_debug()

        self.tb.msg_connect(formatter, 'header', snk_hdr, 'store')
        self.tb.msg_connect(formatter, 'payload', snk_pld, 'store')


        send_str = "Hello World" + 1000*"xxx"
        send_pmt = pmt.make_u8vector(len(send_str), ord(' '))
        for i in range(len(send_str)):
            pmt.u8vector_set(send_pmt, i, ord(send_str[i]))
        msg = pmt.cons(pmt.PMT_NIL, send_pmt)

        port = pmt.intern("in")
        formatter.to_basic_block()._post(port, msg)

        self.tb.start()
        while (snk_hdr.num_messages() < 1) and (snk_pld.num_messages() < 1):
            time.sleep(0.1)
        self.tb.stop()
        self.tb.wait()

        result_hdr_pmt = pmt.cdr(snk_hdr.get_message(0))
        result_pld_pmt = pmt.cdr(snk_pld.get_message(0))

        result_hdr = pmt.u8vector_elements(result_hdr_pmt)
        result_pld = pmt.u8vector_elements(result_pld_pmt)
        header = "".join([chr(r) for r in result_hdr])
        payload = "".join([chr(r) for r in result_pld])

        access_code = packet_utils.conv_1_0_string_to_packed_binary_string(packet_utils.default_access_code)[0]
        rx_access_code = header[0:len(access_code)]

        length = len(send_str)
        rx_length = struct.unpack_from("!H", header, len(access_code))[0]
        rx_bps = struct.unpack_from("!H", header, len(access_code)+4)[0]
        rx_counter = struct.unpack_from("!H", header, len(access_code)+6)[0]

        self.assertEqual(access_code, rx_access_code)
        self.assertEqual(length, rx_length)
        self.assertEqual(bps, rx_bps)
        self.assertEqual(0, rx_counter)
        self.assertEqual(length, len(payload))
        self.assertEqual(send_str, payload[0:length])
예제 #3
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Joystick 101")

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 48000

		##################################################
		# Blocks
		##################################################
		self.openavionics_joystick_interface_0 = openavionics.joystick_interface()
		self.openavionics_audio_ptt_0 = openavionics.audio_ptt()
		self.blocks_tag_debug_0 = blocks.tag_debug(gr.sizeof_float*1, "")
		self.blocks_message_debug_0 = blocks.message_debug()
		self.audio_source_0 = audio.source(samp_rate, "", True)

		##################################################
		# Connections
		##################################################
		self.connect((self.openavionics_audio_ptt_0, 0), (self.blocks_tag_debug_0, 0))
		self.connect((self.audio_source_0, 0), (self.openavionics_audio_ptt_0, 0))

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.openavionics_joystick_interface_0, "out", self.openavionics_audio_ptt_0, "in2")
		self.msg_connect(self.openavionics_joystick_interface_0, "out", self.blocks_message_debug_0, "print")
예제 #4
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Top Block")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.simple_mac_0_0 = mac.simple_mac(1,0.1,10)
        self.simple_mac_0 = mac.simple_mac(0,0.1,10)
        self.mac_virtual_channel_encoder_0 = mac.virtual_channel_encoder(0,0)
        self.blocks_random_pdu_0 = blocks.random_pdu(5, 5)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.simple_mac_0, "to_radio", self.simple_mac_0_0, "from_radio")
        self.msg_connect(self.simple_mac_0_0, "to_radio", self.simple_mac_0, "from_radio")
        self.msg_connect(self.blocks_message_strobe_0, "strobe", self.blocks_random_pdu_0, "generate")
        self.msg_connect(self.blocks_random_pdu_0, "pdus", self.mac_virtual_channel_encoder_0, "in")
        self.msg_connect(self.mac_virtual_channel_encoder_0, "out", self.simple_mac_0_0, "from_app")
        self.msg_connect(self.simple_mac_0, "to_app", self.blocks_message_debug_0, "print_pdu")
예제 #5
0
	def test_003_t (self):
		# test cut frequency negative freq
		# set up fg
		test_len = 1000
		samp_rate = 2000
		freq1 = -200
		freq2 = -205
		ampl = 1
		packet_len = test_len
		threshold = -100
		samp_protect = 2
		
		src1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq1, ampl*0.2)
		src2 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq2, ampl)
		add = blocks.add_cc();
		head = blocks.head(8,test_len)
		s2ts = blocks.stream_to_tagged_stream(8,1,packet_len,"packet_len")
		fft = radar.ts_fft_cc(packet_len)
		peak = radar.find_max_peak_c(samp_rate, threshold, samp_protect, (-200,200), True)
		debug = blocks.message_debug()
		
		self.tb.connect((src1,0), (add,0))
		self.tb.connect((src2,0), (add,1))
		self.tb.connect(add,head,s2ts,fft,peak)
		self.tb.msg_connect(peak,"Msg out",debug,"store")
		#self.tb.msg_connect(peak,"Msg out",debug,"print")
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check frequency in os_cfar message with given one
		msg = debug.get_message(0)
		self.assertAlmostEqual(freq1,pmt.f32vector_ref(pmt.nth(1,pmt.nth(1,msg)),0),8)
예제 #6
0
 def test_001_t (self):
     """
     First header: Packet length 4, packet num 0
     Second header: Packet 2, packet num 1
     Third header: Invalid (parity bit does not check) (would be len 4, num 2)
     """
     encoded_headers = (
         #   | Number of bytes                    | Packet number                                  | Parity
             0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  1, 0, 0, 0,
             0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0,
             0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,  0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,  1, 0, 0, 0
     )
     packet_len_tagname = "packet_len"
     random_tag = gr.tag_t()
     random_tag.offset = 5
     random_tag.key = pmt.string_to_symbol("foo")
     random_tag.value = pmt.from_long(42)
     src = blocks.vector_source_b(encoded_headers, tags=(random_tag,))
     parser = digital.packet_headerparser_b(32, packet_len_tagname)
     sink = blocks.message_debug()
     self.tb.connect(src, parser)
     self.tb.msg_connect(parser, "header_data", sink, "store")
     self.tb.start()
     time.sleep(1)
     self.tb.stop()
     self.tb.wait()
     self.assertEqual(sink.num_messages(), 3)
     msg1 = pmt.to_python(sink.get_message(0))
     msg2 = pmt.to_python(sink.get_message(1))
     msg3 = pmt.to_python(sink.get_message(2))
     self.assertEqual(msg1, {'packet_len': 4, 'packet_num': 0, 'foo': 42})
     self.assertEqual(msg2, {'packet_len': 2, 'packet_num': 1})
     self.assertEqual(msg3, False)
예제 #7
0
    def encode_decode_test(self, payload_str="TEST", whitening=False, encode_crc=False, decode_crc=False):
        preamble = "01010101"
        sync1 = 0x2
        sync2 = 0x3
        sync_length = 2
        payload = [ord(c) for c in payload_str]

        strobe = blocks.message_strobe(pmt.cons(pmt.PMT_NIL, pmt.to_pmt(payload)), 200)
        encoder = cc11xx_encoder.cc11xx_encoder(preamble=[int(preamble, 2)], syncword=[sync1, sync2], whitening=whitening, crc=encode_crc)
        pdu_to_stream = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        debug = blocks.message_debug()
        self.tb.msg_connect(strobe, "strobe", encoder, "in")
        self.tb.msg_connect(encoder, "out", pdu_to_stream, "pdus")

        unpack = blocks.packed_to_unpacked_bb(1, 0)

        acc_code_block =  digital.correlate_access_code_tag_bb(preamble, 0, "preamble")
        deframer = cc11xx.cc11xx_deframer_bb(sync1 ,sync2, whitening, decode_crc, sync_length)

        self.tb.connect(pdu_to_stream,unpack)
        self.tb.connect(unpack, acc_code_block)
        self.tb.connect(acc_code_block, deframer)
        self.tb.msg_connect((deframer, 'out'), (debug, 'store'))
        self.tb.start()
        time.sleep(1)
        self.tb.stop()
        #Please get rid of this sleep if you know how!
        time.sleep(0.1)
        self.tb.stop()

        result_data = [i for i in pmt.to_python(pmt.cdr(debug.get_message(0)))]
        self.assertEqual(payload, result_data)
예제 #8
0
    def test_003_asm_mask (self):
        # asm with errors
        asm = (0x1f, 0xcf, 0xf0, 0x1d)
        frame_len = 223
        random_data = tuple(random.randint(0, 255) for _ in range(frame_len))

        data_in = asm + random_data
        
        src = blocks.vector_source_b(data_in, repeat=True)
        unpack = blocks.unpack_k_bits_bb(8)
        mapper = digital.map_bb((1,0))
        # mask to ignore errors
        corr = ccsds.correlator(0x1acffc1d, 0xf0fff0ff, 0, frame_len)
        dbg = blocks.message_debug()
        self.tb.connect(src, unpack, mapper, corr)
        self.tb.msg_connect((corr, 'out'), (dbg, 'store'))
        self.tb.start()

        while dbg.num_messages() < 1:
            time.sleep(0.001)

        self.tb.stop()
        self.tb.wait()

        msg = dbg.get_message(0)
        data_out = tuple(pmt.to_python(pmt.cdr(msg)))
        
        assert frame_len == len(data_out)
        assert random_data == data_out
예제 #9
0
    def test_010_t (self):
        # PHR prefixer to removal
        data_in = pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(2*self.c.phy_packetsize_bytes,170))
        self.src = blocks.message_strobe(data_in,100)
        self.snk = blocks.message_debug()

        self.tb.msg_connect(self.src, "strobe", self.fragmentation, "in")
        self.tb.msg_connect(self.fragmentation, "out", self.phr_prefixer, "in")
        self.tb.msg_connect(self.phr_prefixer, "out", self.zeropadding, "in")
        self.tb.connect(self.zeropadding, self.demux)
        self.tb.connect((self.demux,0), self.codeword_mapper_I, self.interleaver_I, self.preamble_sfd_prefixer_I, (self.qpsk_mapper,0))
        self.tb.connect((self.demux,1), self.codeword_mapper_Q, self.interleaver_Q, self.preamble_sfd_prefixer_Q, (self.qpsk_mapper,1))
        self.tb.connect(self.qpsk_mapper, self.dqpsk_mapper, self.dqcsk_mapper, self.dqcsk_demapper, self.dqpsk_demapper, self.qpsk_demapper)
        self.tb.connect((self.qpsk_demapper,0), self.preamble_sfd_removal_I, self.deinterleaver_I, self.codeword_demapper_I, (self.mux,0))        
        self.tb.connect((self.qpsk_demapper,1), self.preamble_sfd_removal_Q, self.deinterleaver_Q, self.codeword_demapper_Q, (self.mux,1)) 
        self.tb.connect(self.mux, self.zeropadding_removal) 
        self.tb.msg_connect(self.zeropadding_removal, "out", self.phr_removal, "in") 
        self.tb.msg_connect(self.phr_removal, "out", self.snk, "store")

        self.tb.start()
        time.sleep(0.3)
        self.tb.stop()

        msg_out1 = self.snk.get_message(0)
        msg_out2 = self.snk.get_message(1)
        data_out1 = pmt.to_python(msg_out1)[1]
        data_out2 = pmt.to_python(msg_out2)[1]
        ref = pmt.to_python(data_in)[1]
        self.assertTrue((data_out1==ref[:len(data_out1)]).all() and (data_out2==ref[:len(data_out2)]).all())  
예제 #10
0
    def test_003_es_sink (self):
        print "test_003_es_sink"
        iv = [0,1,2,3,4,5,6,7,8,9];
        src = blocks.vector_source_f(iv, repeat=True);
        hd = blocks.head(gr.sizeof_float, 10000);
        snk = es.sink([gr.sizeof_float], 8);
        t = es.trigger_sample_timer(gr.sizeof_float, 10, 5, 10, 10);
        tb = gr.top_block();
        pduh = es.es_make_handler_pdu(es.es_handler_print.TYPE_F32);
        msgdb = blocks.message_debug()
        tb.connect(src, hd, t, snk);   
        tb.msg_connect( t, "which_stream", snk, "schedule_event" )
        tb.msg_connect( t, "sample_timer_event", pduh, "handle_event" )
        tb.msg_connect( pduh, "pdus_out", msgdb, "store" )
        tb.run();
 
        # expected output of each event in the periodic sequence   
        sv = numpy.array( iv[5:] + iv[:5], dtype=numpy.float32 );

        # verify each received message
        nm = msgdb.num_messages();
        print "nm = %d"%(nm);
        for i in range(0, nm):
            m = msgdb.get_message(i);
            mp = pmt.to_python(pmt.cdr(m));
            print mp;
            self.assertEqual( sv.all(), mp.all() );
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 0.01

        ##################################################
        # Blocks
        ##################################################
        self.ccsds_asm_deframer_pdu_0 = ccsds.asm_deframer_pdu(0, 1, False, 255)
        self.blocks_vector_source_x_0_0 = blocks.vector_source_b(range(255)+range(255), False, 1, [])
        self.blocks_vector_source_x_0 = blocks.vector_source_b((0x1A, 0xCF, 0xFC, 0x1D), False, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_stream_mux_0 = blocks.stream_mux(gr.sizeof_char*1, (4, 510))
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ccsds_asm_deframer_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu'))    
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.ccsds_asm_deframer_pdu_0, 0))    
        self.connect((self.blocks_stream_mux_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))    
        self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_mux_0, 0))    
        self.connect((self.blocks_vector_source_x_0_0, 0), (self.blocks_stream_mux_0, 1))    
예제 #12
0
파일: strobe.py 프로젝트: mbr0wn/gr-fosdem
    def __init__(self):
        gr.top_block.__init__(self, "Strobe")

        ##################################################
        # Blocks
        ##################################################
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len")
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons( pmt.PMT_NIL, pmt.make_u8vector(64,0) ), 750)
        self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_copy_0 = blocks.copy(gr.sizeof_char*1)
        self.blocks_copy_0.set_enabled(True)

        ##################################################
        # Connections
        ##################################################
        self.connect((self.blocks_copy_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_copy_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.blocks_message_strobe_0, "strobe", self.blocks_message_debug_0, "print")
        self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")
        self.msg_connect(self.blocks_tagged_stream_to_pdu_0, "pdus", self.blocks_message_debug_0, "print_pdu")
예제 #13
0
    def test_001_t (self):
        # set up fg
        src = fifo_async_source('/tmp/pipe_in', 100000, 2);
        snk = blocks.message_debug()
        self.tb.msg_connect((src,'async_pdu'), (snk, 'print_pdu'))    

        self.tb.run ()
예제 #14
0
 def test_001(self):
     #test complementary operation of framer & deframer
     #want to frame some random data that has enough consecutive bits to
     #stuff at least a few bits
     npkts = 20
     src_data = [0xFE, 0xDA, 0xAC, 0x29, 0x7F, 0xA2, 0x90, 0x0F, 0xF8]
     frame   = digital.hdlc_framer_pb("wat")
     corr    = digital.correlate_access_code_tag_bb("01111110", 0, "frame")
     deframe = digital.hdlc_deframer_bp("frame", 32, 500)
     debug   = blocks.message_debug()
     self.tb.connect(frame, corr, deframe)
     self.tb.msg_connect(deframe, "out", debug, "store")
     self.tb.start()
     msg = pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(len(src_data),src_data))
     for i in xrange(npkts):
         frame.to_basic_block()._post(pmt.intern("in"), msg)
     sleep(0.2)
     self.tb.stop()
     self.tb.wait()
     rxmsg = debug.get_message(0)
     result_len = pmt.blob_length(pmt.cdr(rxmsg))
     msg_data = []
     for j in xrange(result_len):
         msg_data.append(pmt.u8vector_ref(pmt.cdr(rxmsg), j))
     self.assertEqual(src_data, msg_data)
예제 #15
0
 def setUp (self):
     self.tb = gr.top_block ()
     
     key = "subframe"
     msg_buf_name = "cfi"
     print "setup test"
     
     data = []
     for i in range(3):
         cfi = get_cfi_sequence(i+1)
         data.extend(nrz_encoding(cfi))
     
     reps = 5
     taglist = get_tag_list(3*reps, key, 10)
     
     data = [float(data[i]) for i in range(len(data))]
     ext_data = []
     for i in range(reps):
         ext_data.extend(data)
     data = ext_data
     
     self.src = blocks.vector_source_f(data, False, 32, taglist)
     self.cfi = lte.cfi_unpack_vf(key, msg_buf_name)
     self.dbg = blocks.message_debug()
     
     self.tb.connect(self.src, self.cfi)
     #self.tb.msg_connect(self.cfi, msg_buf_name, self.dbg, "print")
     print "setup finished"
예제 #16
0
	def __init__(self, baudrate=19200, device="/dev/pts/4"):
		grc_wxgui.top_block_gui.__init__(self, title="Simple Message Passing Example")

		##################################################
		# Parameters
		##################################################
		self.baudrate = baudrate
		self.device = device

		##################################################
		# Variables
		##################################################
		self.samp_rate = samp_rate = 32000

		##################################################
		# Blocks
		##################################################
		self.openavionics_serial_io_0 = openavionics.serial_io(device,0,baudrate,0,1,False)
		self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000)
		self.blocks_message_debug_0 = blocks.message_debug()

		##################################################
		# Asynch Message Connections
		##################################################
		self.msg_connect(self.blocks_message_strobe_0, "strobe", self.openavionics_serial_io_0, "in")
		self.msg_connect(self.openavionics_serial_io_0, "out", self.blocks_message_debug_0, "print")
예제 #17
0
    def test_001_t (self):
        ''' Test fixed length packet '''
        # set up fg
        sync = map(int, bin(0xd391)[2:].zfill(16))
        data = map(int, bin(0xdeadbeef)[2:].zfill(32))
        stream = ([0] * 30) + sync + data + ([0] * 30)

        src = blocks.vector_source_b(stream)
        test_blk = reveng.packet_deframer('boop', sync, True, len(data), 0, 0, 0, False)
        sink = blocks.message_debug()

        self.tb.connect(src, test_blk)
        self.tb.msg_connect(test_blk, 'out', sink, 'store')
        self.tb.run()

        # check data
        rec_msg = pmt.to_python(sink.get_message(0))

        self.assertTrue(isinstance(rec_msg, tuple))
        self.assertTrue(len(rec_msg) == 2)

        (meta, bits) = rec_msg
        self.assertTrue(isinstance(meta, dict))
        self.assertTrue(isinstance(bits, numpy.ndarray))
        self.assertTrue(list(bits) == data)
예제 #18
0
    def test_002_t (self):
        '''
        Test variable length packet. Length byte straight after sync, no
        additional bytes.
        '''
        # set up fg
        sync = map(int, bin(0xd391)[2:].zfill(16))
        plen = map(int, bin(4)[2:].zfill(8))
        data = map(int, bin(0xdeadbeef)[2:].zfill(32))

        pkt = plen + data
        stream = ([0] * 30) + sync + pkt + ([0] * 30)

        src = blocks.vector_source_b(stream)
        test_blk = reveng.packet_deframer('boop', sync, False, 0, 0, 0, 0, False)
        sink = blocks.message_debug()

        self.tb.connect(src, test_blk)
        self.tb.msg_connect(test_blk, 'out', sink, 'store')
        self.tb.run()

        # check data
        rec_msg = pmt.to_python(sink.get_message(0))

        self.assertTrue(isinstance(rec_msg, tuple))
        self.assertTrue(len(rec_msg) == 2)

        (meta, bits) = rec_msg
        self.assertTrue(isinstance(meta, dict))
        self.assertTrue(meta.get('name') == "boop")

        self.assertTrue(isinstance(bits, numpy.ndarray))
        self.assertTrue(list(bits) == pkt)
예제 #19
0
    def test_001_t(self):
        data = [ord("a"), ord("b"), ord("c"), ord("d")]
        msg = pmt.list1(pmt.list2(pmt.string_to_symbol("msg_clear"), pmt.init_u8vector(len(data), data)))
        filename_key = "secret.a"
        nacl.generate_key(filename_key)

        strobe = blocks.message_strobe(msg, 100)
        encrypt_secret = nacl.encrypt_secret(filename_key)
        decrypt_secret = nacl.decrypt_secret(filename_key)
        debug = blocks.message_debug()

        self.tb.msg_connect(strobe, "strobe", encrypt_secret, "Msg clear")
        self.tb.msg_connect(encrypt_secret, "Msg encrypted", decrypt_secret, "Msg encrypted")
        self.tb.msg_connect(decrypt_secret, "Msg decrypted", debug, "store")

        self.tb.start()
        sleep(0.15)
        self.tb.stop()
        self.tb.wait()

        # check results
        msg_out = debug.get_message(0)
        msg_symbol = pmt.symbol_to_string(pmt.nth(0, pmt.nth(0, msg_out)))
        msg_decrypted = pmt.u8vector_elements(pmt.nth(1, pmt.nth(0, msg_out)))
        print msg_symbol, msg_decrypted
        print "msg_clear", data

        for k in range(len(data)):
            self.assertEqual(data[k], msg_decrypted[k])
예제 #20
0
    def test_010_t (self):
        '''
        Test two back-to-back variable length packets. Length is indexed one
        byte after sync. Two additional bytes for checksum after data packet.
        '''
        # set up fg
        sync = map(int, bin(0xd391)[2:].zfill(16))
        txid = map(int, bin(0x0001)[2:].zfill(16))
        plen = map(int, bin(4)[2:].zfill(8))
        data = map(int, bin(0xdeadbeef)[2:].zfill(32))
        csum = map(int, bin(0xa55a)[2:].zfill(16))

        pkt = txid + plen + data + csum
        stream = ([0] * 30) + sync + pkt + sync + pkt + ([0] * 30)

        src = blocks.vector_source_b(stream)
        test_blk = reveng.packet_deframer('boop', sync, False, 0, 0, 2, 2, True)
        sink = blocks.message_debug()

        self.tb.connect(src, test_blk)
        self.tb.msg_connect(test_blk, 'out', sink, 'store')
        self.tb.run()

        for idx in xrange(2):
            rec_msg = pmt.to_python(sink.get_message(idx))

            self.assertTrue(isinstance(rec_msg, tuple))
            self.assertTrue(len(rec_msg) == 2)

            (meta, bytez) = rec_msg
            self.assertTrue(isinstance(meta, dict))
            self.assertTrue(isinstance(bytez, numpy.ndarray))
            self.assertTrue(list(bytez) == [0x00, 0x01, 0x04, 0xde, 0xad, 0xbe, 0xef, 0xa5, 0x5a])
예제 #21
0
    def test_004 (self):
        # Test that the TCP server can stream PDUs <= the MTU size.
        port = str(random.Random().randint(0, 30000) + 10000)
        mtu = 10000
        srcdata = tuple(x % 256 for x in range(mtu))
        data = pmt.init_u8vector(srcdata.__len__(), srcdata)
        pdu_msg = pmt.cons(pmt.PMT_NIL, data)

        self.pdu_source = blocks.message_strobe(pdu_msg, 500)
        self.pdu_send = blocks.socket_pdu("TCP_SERVER", "localhost", port, mtu)
        self.pdu_recv = blocks.socket_pdu("TCP_CLIENT", "localhost", port, mtu)
        self.pdu_sink = blocks.message_debug()

        self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus")
        self.tb.msg_connect(self.pdu_recv, "pdus", self.pdu_sink, "store")

        self.tb.start()
        time.sleep(1)
        self.tb.stop()
        self.tb.wait()

        received = self.pdu_sink.get_message(0)
        received_data = pmt.cdr(received)
        msg_data = []
        for i in range(mtu):
            msg_data.append(pmt.u8vector_ref(received_data, i))
        self.assertEqual(srcdata, tuple(msg_data))
예제 #22
0
    def test_002 (self):
        # Send a PDU through a pair of UDP sockets
        port = str(random.Random().randint(0, 30000) + 10000)
        srcdata = (0x64, 0x6f, 0x67, 0x65)
        data = pmt.init_u8vector(srcdata.__len__(), srcdata)
        pdu_msg = pmt.cons(pmt.PMT_NIL, data)

        self.pdu_source = blocks.message_strobe(pdu_msg, 500)
        self.pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port)
        self.pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", port)

        self.dbg = blocks.message_debug()

        self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus")
        self.tb.msg_connect(self.pdu_recv, "pdus", self.dbg, "store")

        self.tb.start ()
        time.sleep(1)
        self.tb.stop()
        self.tb.wait()
        self.pdu_send = None
        self.pdu_recv = None

        received = self.dbg.get_message(0)
        received_data = pmt.cdr(received)
        msg_data = []
        for i in range(4):
            msg_data.append(pmt.u8vector_ref(received_data, i))
        self.assertEqual(srcdata, tuple(msg_data))
예제 #23
0
 def test_004_ofdm_scramble(self):
     """
     Test scrambling for OFDM header gen
     """
     header_len = 32
     packet_length = 23
     packet_len_tagname = "packet_len"
     frame_len_tagname = "frame_len"
     data, tags = tagged_streams.packets_to_vectors([range(packet_length),range(packet_length),], packet_len_tagname)
     src = blocks.vector_source_b(data, False, 1, tags)
     header_formatter = digital.packet_header_ofdm(
             (range(32),), # 32 carriers are occupied (which doesn't matter here)
             1,         # 1 OFDM symbol per header (= 32 bits)
             packet_len_tagname,
             frame_len_tagname,
             "packet_num",
             1,         # 1 bit per header symbols (BPSK)
             2,          # 2 bits per payload symbol (QPSK)
             scramble_header=True
     )
     header_gen = digital.packet_headergenerator_bb(header_formatter.base())
     header_parser = digital.packet_headerparser_b(header_formatter.base())
     sink = blocks.message_debug()
     self.tb.connect(src, header_gen, header_parser)
     self.tb.msg_connect(header_parser, "header_data", sink, "store")
     self.tb.start()
     time.sleep(1)
     self.tb.stop()
     self.tb.wait()
     msg = pmt.to_python(sink.get_message(0))
     self.assertEqual(msg, {'packet_len': packet_length, 'packet_num': 0, 'frame_len': 4})
     msg = pmt.to_python(sink.get_message(1))
     self.assertEqual(msg, {'packet_len': packet_length, 'packet_num': 1, 'frame_len': 4})
예제 #24
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Ahrs Gps Eis To Fg")

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.openavionics_serial_io_0_0_0 = openavionics.serial_io("/dev/pts/14",0,19200,0,1,False)
        self.openavionics_serial_io_0_0 = openavionics.serial_io("/dev/pts/12",0,19200,0,1,False)
        self.openavionics_serial_io_0 = openavionics.serial_io("/dev/pts/10",0,19200,0,1,False)
        self.openavionics_gns430_to_fg_0 = openavionics.gns430_to_fg("127.0.0.1",5502)
        self.openavionics_gns430_parser_0 = openavionics.gns430_parser()
        self.openavionics_eis_parser_0 = openavionics.eis_parser()
        self.openavionics_ahrs_to_fg_0 = openavionics.ahrs_to_fg("127.0.0.1",5501)
        self.openavionics_ahrs_parser_0 = openavionics.ahrs_parser()
        self.blocks_message_debug_0_0_0 = blocks.message_debug()

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self.openavionics_serial_io_0_0_0, "out", self.openavionics_gns430_parser_0, "in")
        self.msg_connect(self.openavionics_gns430_parser_0, "out", self.openavionics_gns430_to_fg_0, "in")
        self.msg_connect(self.openavionics_ahrs_parser_0, "out", self.openavionics_ahrs_to_fg_0, "in")
        self.msg_connect(self.openavionics_serial_io_0, "out", self.openavionics_ahrs_parser_0, "in")
        self.msg_connect(self.openavionics_serial_io_0_0, "out", self.openavionics_eis_parser_0, "in")
        self.msg_connect(self.openavionics_gns430_parser_0, "out", self.blocks_message_debug_0_0_0, "print")
예제 #25
0
 def test_001_t (self):
     data = [ord('t'),ord('e'),ord('s'),ord('t')]
     msg = pmt.list1(pmt.list2(pmt.string_to_symbol("msg_clear"),pmt.init_u8vector(len(data),data)))
     filename_sk = "secret.key"
     filename_pk = "public.key"
     nacl.generate_keypair(filename_sk,filename_pk)
     
     strobe = blocks.message_strobe(msg, 100)
     encrypt_public = nacl.encrypt_public(filename_pk,filename_sk)
     debug = blocks.message_debug()
     
     self.tb.msg_connect(strobe,"strobe",encrypt_public,"Msg clear")
     self.tb.msg_connect(encrypt_public,"Msg encrypted",debug,"store")
     
     self.tb.start()
     sleep(0.15)
     self.tb.stop()
     self.tb.wait()
     
     # check results
     msg_stored = debug.get_message(0)
     nonce = pmt.nth(0,msg_stored)
     msg_encrypted = pmt.nth(1,msg_stored)
     print pmt.symbol_to_string(pmt.nth(0,nonce)), pmt.u8vector_elements(pmt.nth(1,nonce))
     print pmt.symbol_to_string(pmt.nth(0,msg_encrypted)), pmt.u8vector_elements(pmt.nth(1,msg_encrypted))
예제 #26
0
	def test_002_t (self):
		# set up fg
		test_len = 2**15
		samp_rate = 250000
		freq = -2000
		ampl = 1
		packet_len = test_len
		min_output_buffer = 2*packet_len
		compare_sample = 5
		protect_sample = 0
		rel_threshold = 0.78
		mult_threshold = 10
		
		src = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, ampl)
		src.set_min_output_buffer(min_output_buffer)
		head = blocks.head(8,test_len)
		head.set_min_output_buffer(min_output_buffer)
		s2ts = blocks.stream_to_tagged_stream(8,1,packet_len,"packet_len")
		s2ts.set_min_output_buffer(min_output_buffer)
		fft = radar.ts_fft_cc(packet_len)
		fft.set_min_output_buffer(min_output_buffer)
		cfar = radar.os_cfar_c(samp_rate, compare_sample, protect_sample, rel_threshold, mult_threshold)
		debug = blocks.message_debug()
		
		self.tb.connect(src,head,s2ts,fft,cfar)
		self.tb.msg_connect(cfar,"Msg out",debug,"store")
		self.tb.msg_connect(cfar,"Msg out",debug,"print")
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check frequency in os_cfar message with given one
		msg = debug.get_message(0)
		self.assertAlmostEqual(freq/pmt.f32vector_ref(pmt.nth(1,pmt.nth(1,msg)),0),1,2)
예제 #27
0
	def test_001_t (self):
		# test on positive frequencies
		# set up fg
		test_len = 1000
		samp_rate = 2000
		freq = 200
		ampl = 1
		packet_len = test_len
		threshold = -100
		samp_protect = 2
		
		src = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, freq, ampl)
		head = blocks.head(8,test_len)
		s2ts = blocks.stream_to_tagged_stream(8,1,packet_len,"packet_len")
		fft = radar.ts_fft_cc(packet_len)
		peak = radar.find_max_peak_c(samp_rate, threshold, samp_protect, (0,0), False)
		debug = blocks.message_debug()
		
		self.tb.connect(src,head,s2ts,fft,peak)
		self.tb.msg_connect(peak,"Msg out",debug,"store")
		#self.tb.msg_connect(peak,"Msg out",debug,"print")
		self.tb.start()
		sleep(0.5)
		self.tb.stop()
		self.tb.wait()
		
		# check frequency in os_cfar message with given one
		msg = debug.get_message(0)
		self.assertAlmostEqual(freq,pmt.f32vector_ref(pmt.nth(1,pmt.nth(1,msg)),0),8)
예제 #28
0
    def test_000 (self):
        if enable_vw_testing:
            return

        print "test_000"
        payload_sizes = [28, 60, 92, 124, 156, 188, 220]
        codeword_sizes = [47, 79, 111, 159, 191, 223 ,255]

        enc = nuts.ngham_encoder(self.tsb_key)
        dec = nuts.ngham_decoder(verbose=True)
        dbg = blocks.message_debug()
        self.tb.connect(enc,dec)
        self.tb.msg_connect(dec, "out", dbg, "store")
        port_in = pmt.intern("in")

        print "starting up"
        self.tb.start()
        i = 0
        #for i in range(len(payload_sizes)*0 + 1):
        src_data = [x for x in range(payload_sizes[i])]
        src_vec = pmt.init_u8vector(len(src_data), src_data)
        msg = pmt.cons(pmt.PMT_NIL, src_vec)
        print "posting msg"
        enc.to_basic_block()._post(port_in, msg)
        #while dbg.num_messages() < 1:
            #print "waiting..."
        time.sleep(1)
        self.tb.stop()
        self.tb.wait()
        result_msg = dbg.get_message(0)
        vector = pmt.u8vector_elements(pmt.cdr(result_msg))
        print metadata
        print vector
예제 #29
0
파일: qa_pdu.py 프로젝트: Appiah/gnuradio
 def test_002_tags_plus_data(self):
     packet_len = 16
     src_data = range(packet_len)
     tag1 = gr.tag_t()
     tag1.offset = 0
     tag1.key = pmt.string_to_symbol('spam')
     tag1.value = pmt.from_long(23)
     tag2 = gr.tag_t()
     tag2.offset = 10 # Must be < packet_len
     tag2.key = pmt.string_to_symbol('eggs')
     tag2.value = pmt.from_long(42)
     src = blocks.vector_source_f(src_data, tags=(tag1, tag2))
     s2ts = blocks.stream_to_tagged_stream(gr.sizeof_float, vlen=1, packet_len=packet_len, len_tag_key="packet_len")
     ts2pdu = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len")
     dbg = blocks.message_debug()
     self.tb.connect(src, s2ts, ts2pdu)
     self.tb.msg_connect(ts2pdu, "pdus", dbg, "store")
     self.tb.start()
     while dbg.num_messages() < 1:
         time.sleep(0.1)
     self.tb.stop()
     self.tb.wait()
     result_msg = dbg.get_message(0)
     metadata = pmt.to_python(pmt.car(result_msg))
     vector   = pmt.f32vector_elements(pmt.cdr(result_msg))
     self.assertEqual(metadata, {'eggs': 42, 'spam': 23})
     self.assertFloatTuplesAlmostEqual(tuple(vector), src_data)
    def test_001_t (self):
        # set up fg
        data_in = (0,1,2,3,0,0,4,5,6,7,0,0,8,9,10,11,0,0)
        self.src = blocks.vector_source_b(data_in)
        self.zeropadding_removal = ieee802_15_4.zeropadding_removal_b(phr_payload_len=4, nzeros=2)
        self.msgsink = blocks.message_debug()

        self.tb.connect(self.src, self.zeropadding_removal)
        self.tb.msg_connect(self.zeropadding_removal, "out", self.msgsink, "store")
        self.tb.start()
        time.sleep(2)
        self.tb.stop()
        # check data
        num_messages = self.msgsink.num_messages()
        self.assertTrue(num_messages == 3)
        data_out = []
        for i in range(num_messages):
            tmp = pmt.to_python(self.msgsink.get_message(i))
            data_out = np.concatenate((data_out,tmp[1]))

        ref = range(12)
        print "num messages:", self.msgsink.num_messages()
        print "ref:", ref
        print "data_out:", data_out
        self.assertFloatTuplesAlmostEqual(data_out, ref)
예제 #31
0
    def __init__(self):
        gr.top_block.__init__(
            self, "Downlink from TVAC (This should run all the time)")

        ##################################################
        # Variables
        ##################################################
        self.block_len_enc = block_len_enc = 1024 / 8 * 2

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 4, 1).base()

        self.samp_rate_factor = samp_rate_factor = 5
        self.samp_rate = samp_rate = 250000
        self.rgain = rgain = 0
        self.payload = payload = block_len_enc + 4
        self.freq_offset = freq_offset = 0
        self.freq = freq = 145.95e6

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1,
            decimation=5,
            taps=None,
            fractional_bw=None,
        )
        self.fir_filter_xxx_0 = filter.fir_filter_ccc(samp_rate_factor, (1, ))
        self.fir_filter_xxx_0.declare_sample_delay(0)
        self.digital_mpsk_receiver_cc_0_0 = digital.mpsk_receiver_cc(
            2, 0, cmath.pi / 100.0, -0.05, 0.05, 0.25, 0.05, 4, 4, 0.005)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(
            variable_constellation_0)
        self.ccsds_softbits_msg_to_bytes_b_0 = ccsds.softbits_msg_to_bytes_b()
        self.ccsds_randomiser_softbits_0 = ccsds.randomiser_softbits(
            0x95, 0xFF)
        self.ccsds_mpsk_ambiguity_resolver_f_0 = ccsds.mpsk_ambiguity_resolver_f(
            2, '49E0DCC7', 32, 1, 0.8, block_len_enc, 0)
        self.ccsds_message_info_0 = ccsds.message_info(
            "Block received and sent to Nanolink: ", 20)
        self.ccsds_ldpc_decoder_0 = ccsds.ldpc_decoder(
            '/tmp/AR4JA_r12_k1024n.a', ccsds.LDPC_SYS_FRONT,
            ccsds.LDPC_PUNCT_BACK, 512, tuple(([])))
        self.ccsds_blob_msg_sink_b_0 = ccsds.blob_msg_sink_b(256 / 2)
        self.blocks_wavfile_source_0 = blocks.wavfile_source(
            '/app/input/source.wav', True)
        self.blocks_udp_sink_0_1 = blocks.udp_sink(gr.sizeof_char * 1,
                                                   '127.0.0.1', 5431, 256,
                                                   True)
        self.blocks_udp_sink_0_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                   '127.0.0.1', 5433, 1472,
                                                   True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_char * 1)
        self.blocks_multiply_xx_0_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_debug_1_0_0 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 0.5)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((-1, ))
        self.band_pass_filter_0 = filter.fir_filter_ccc(
            1,
            firdes.complex_band_pass(1, samp_rate * samp_rate_factor, -220e3,
                                     -180e3, 6e3, firdes.WIN_HAMMING, 6.76))
        self.analog_sig_source_x_0_0 = analog.sig_source_c(
            samp_rate * samp_rate_factor, analog.GR_COS_WAVE, -freq_offset, 1,
            0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -50000, 1, 0)
        self.analog_agc_xx_0 = analog.agc_cc(1e-4, 0.5, 1.0)
        self.analog_agc_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'),
                         (self.blocks_message_debug_1_0_0, 'print_pdu'))
        self.msg_connect((self.ccsds_blob_msg_sink_b_0, 'out'),
                         (self.ccsds_message_info_0, 'in'))
        self.msg_connect((self.ccsds_ldpc_decoder_0, 'out'),
                         (self.ccsds_softbits_msg_to_bytes_b_0, 'in'))
        self.msg_connect((self.ccsds_mpsk_ambiguity_resolver_f_0, 'out'),
                         (self.ccsds_randomiser_softbits_0, 'in'))
        self.msg_connect((self.ccsds_randomiser_softbits_0, 'out'),
                         (self.ccsds_ldpc_decoder_0, 'in'))
        self.connect((self.analog_agc_xx_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.analog_sig_source_x_0_0, 0),
                     (self.blocks_multiply_xx_0_0, 0))
        self.connect((self.band_pass_filter_0, 0), (self.fir_filter_xxx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.ccsds_mpsk_ambiguity_resolver_f_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.analog_agc_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0_0, 0),
                     (self.band_pass_filter_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_xx_0_0, 1))
        self.connect((self.blocks_wavfile_source_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_wavfile_source_0, 1),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0),
                     (self.blocks_null_sink_1, 0))
        self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0),
                     (self.blocks_udp_sink_0_1, 0))
        self.connect((self.ccsds_softbits_msg_to_bytes_b_0, 0),
                     (self.ccsds_blob_msg_sink_b_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0),
                     (self.blocks_udp_sink_0_0, 0))
        self.connect((self.digital_mpsk_receiver_cc_0_0, 0),
                     (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.fir_filter_xxx_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.digital_mpsk_receiver_cc_0_0, 0))
예제 #32
0
    def __init__(self, div=200, fc=683e6, gain=0, samp_rate=6e6):
        gr.top_block.__init__(self, "Uhdgps Rssi Log")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhdgps Rssi Log")
        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", "uhdgps_rssi_log")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.div = div
        self.fc = fc
        self.gain = gain
        self.samp_rate = samp_rate

        ##################################################
        # Blocks
        ##################################################
        self.uhdgps_meta_to_json_file_0 = uhdgps.meta_to_json_file(
            '/tmp/WAMU_RSSI_all_the_test%(time)s.json')
        self.uhdgps_cpdu_average_power_0 = uhdgps.cpdu_average_power(-60)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("addr=192.168.10.7", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_rate(120e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(fc, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.frequency_hopper_frequency_sweeper_0 = frequency_hopper.frequency_sweeper(
            fc, 6e6, 887e6)
        self.es_trigger_sample_timer_0 = es.trigger_sample_timer(
            gr.sizeof_gr_complex,
            int(samp_rate) / div, int(3e3),
            int(samp_rate) / div, 1024)
        self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 8, 64, 2, 2, 0)
        self.es_handler_pdu_0 = es.es_make_handler_pdu(
            es.es_handler_print.TYPE_C32)
        self.blocks_pdu_remove_0 = blocks.pdu_remove(
            pmt.intern("es::event_buffer"))
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 1e6 / div)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.frequency_hopper_frequency_sweeper_0, 'clock'))
        self.msg_connect((self.blocks_pdu_remove_0, 'pdus'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.blocks_pdu_remove_0, 'pdus'),
                         (self.uhdgps_meta_to_json_file_0, 'pdus'))
        self.msg_connect((self.es_handler_pdu_0, 'pdus_out'),
                         (self.uhdgps_cpdu_average_power_0, 'cpdus'))
        self.msg_connect(
            (self.es_trigger_sample_timer_0, 'sample_timer_event'),
            (self.es_handler_pdu_0, 'handle_event'))
        self.msg_connect((self.es_trigger_sample_timer_0, 'which_stream'),
                         (self.es_sink_0, 'schedule_event'))
        self.msg_connect(
            (self.frequency_hopper_frequency_sweeper_0, 'msg_out'),
            (self.uhd_usrp_source_0, 'command'))
        self.msg_connect((self.uhdgps_cpdu_average_power_0, 'cpdus'),
                         (self.blocks_pdu_remove_0, 'pdus'))
        self.connect((self.es_trigger_sample_timer_0, 0), (self.es_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.es_trigger_sample_timer_0, 0))
예제 #33
0
    def __init__(self, apply_address_check=1, destination_address=3, frame_index=2, frame_type=1, increase_index=1, len_destination_address=1, len_frame_index=1, len_frame_type=1, len_payload_length=1, len_reserved_field_I=2, len_reserved_field_II=2, len_source_address=1, reserved_field_I=5, reserved_field_II=6, source_address=4, system_time_granularity_us=5):
        gr.top_block.__init__(self, "Test tx rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test tx rx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "Test_tx_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.apply_address_check = apply_address_check
        self.destination_address = destination_address
        self.frame_index = frame_index
        self.frame_type = frame_type
        self.increase_index = increase_index
        self.len_destination_address = len_destination_address
        self.len_frame_index = len_frame_index
        self.len_frame_type = len_frame_type
        self.len_payload_length = len_payload_length
        self.len_reserved_field_I = len_reserved_field_I
        self.len_reserved_field_II = len_reserved_field_II
        self.len_source_address = len_source_address
        self.reserved_field_I = reserved_field_I
        self.reserved_field_II = reserved_field_II
        self.source_address = source_address
        self.system_time_granularity_us = system_time_granularity_us

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 15
        self.range_mu = range_mu = 0.6
        self.threshold = threshold = 40
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain
        
        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)
          
        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.preamble = preamble = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.mu = mu = range_mu
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_num_transmission = len_num_transmission = 1
        self.experiment_duration_s = experiment_duration_s = 1000
        self.diff_preamble_256 = diff_preamble_256 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0]
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.develop_mode_list = develop_mode_list = [0]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'TX')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'RX')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Demod')
        self.top_layout.addWidget(self.tab)
        self.send_frame_0 = send_frame(
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=destination_address,
            develop_mode_list=develop_mode_list,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=source_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.receive_frame_0 = receive_frame(
            apply_address_check=apply_address_check,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode_list=[10],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=destination_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=30,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 15, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, 'Rx Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_noise_range = Range(0, 0.01, 0.00001, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, 'noise', "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, 'BB Derotation Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self.inets_null_message_source_0 = inets.null_message_source()
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle((develop_mode_list), experiment_duration_s, max_num_retransmission, max_buffer_size, frame_type, len_frame_type, frame_index, len_frame_index, destination_address, len_destination_address, source_address, len_source_address, reserved_field_I, len_reserved_field_I, reserved_field_II, len_reserved_field_II, len_payload_length, increase_index, len_num_transmission)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", 'localhost', '52001', 10000, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost', '52001', 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(pmt.from_bool(True), blocks.STROBE_POISSON, 10000, 5000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_bool(True), 1000)
        self.blocks_message_debug_0_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'), (self.receive_frame_0, 'rx_switch_in'))    
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.inets_idle_0, 'data_in'))    
        self.msg_connect((self.inets_idle_0, 'successful_transmission'), (self.inets_message_tomb_0, 'message_in'))    
        self.msg_connect((self.inets_idle_0, 'data_out'), (self.send_frame_0, 'in'))    
        self.msg_connect((self.inets_null_message_source_0, 'null_message_out'), (self.inets_idle_0, 'reset_idle'))    
        self.msg_connect((self.receive_frame_0, 'rx_frame_info_out'), (self.blocks_message_debug_0_0, 'print'))    
        self.msg_connect((self.send_frame_0, 'tx_frame_info_out'), (self.inets_message_tomb_0, 'message_in'))    
        self.connect((self.send_frame_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.send_frame_0, 0), (self.receive_frame_0, 0))    
예제 #34
0
    def test_13(self):
        """
        Test case generated by test-case generator
        """
        ##################################################
        # Variables
        ##################################################
        # Input data into the system
        src_data = "PKdhtXMmr18n2L9K88eMlGn7CcctT9RwKSB1FebW397VI5uG1yhc3uavuaOb9vyJ"
        self.bw = bw = 250000
        self.sf = sf = 7
        self.samp_rate = samp_rate = bw
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 1
        self.impl_head = impl_head = False
        self.has_crc = has_crc = True
        self.frame_period = frame_period = 200
        self.cr = cr = 0

        ##################################################
        # Blocks
        ##################################################
        self.lora_sdr_hier_tx_0 = lora_sdr.hier_tx(pay_len, n_frame, src_data,
                                                   cr, sf, impl_head, has_crc,
                                                   samp_rate, bw, 200, [8, 16],
                                                   True)
        self.lora_sdr_hier_rx_0_1_0_0_1_0 = lora_sdr.hier_rx(
            samp_rate, bw, sf, impl_head, cr, pay_len, has_crc, [8, 16], True)
        self.interp_fir_filter_xxx_0_0 = filter.interp_fir_filter_ccf(
            4, (-0.128616616593872, -0.212206590789194, -0.180063263231421,
                3.89817183251938e-17, 0.300105438719035, 0.636619772367581,
                0.900316316157106, 1, 0.900316316157106, 0.636619772367581,
                0.300105438719035, 3.89817183251938e-17, -0.180063263231421,
                -0.212206590789194, -0.128616616593872))
        self.interp_fir_filter_xxx_0_0.declare_sample_delay(0)
        self.interp_fir_filter_xxx_0_0.set_min_output_buffer(20000)
        self.blocks_throttle_0_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                   samp_rate * 10, True)
        #get the output
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.tb.connect((self.blocks_throttle_0_0, 0),
                        (self.interp_fir_filter_xxx_0_0, 0))
        self.tb.connect((self.interp_fir_filter_xxx_0_0, 0),
                        (self.lora_sdr_hier_rx_0_1_0_0_1_0, 0))
        self.tb.connect((self.lora_sdr_hier_tx_0, 0),
                        (self.blocks_throttle_0_0, 0))
        #output msg connection
        self.tb.msg_connect((self.lora_sdr_hier_rx_0_1_0_0_1_0, 'msg'),
                            (self.blocks_message_debug_0, 'store'))

        def get_bw(self):
            return self.bw

        def set_bw(self, bw):
            with self._lock:
                self.bw = bw
                self.set_samp_rate(self.bw)

        def get_sf(self):
            return self.sf

        def set_sf(self, sf):
            with self._lock:
                self.sf = sf

        def get_samp_rate(self):
            return self.samp_rate

        def set_samp_rate(self, samp_rate):
            with self._lock:
                self.samp_rate = samp_rate
                self.blocks_throttle_0_0.set_sample_rate(self.samp_rate)

        def get_pay_len(self):
            return self.pay_len

        def set_pay_len(self, pay_len):
            with self._lock:
                self.pay_len = pay_len

        def get_n_frame(self):
            return self.n_frame

        def set_n_frame(self, n_frame):
            with self._lock:
                self.n_frame = n_frame

        def get_multi_control(self):
            return self.multi_control

        def set_multi_control(self, multi_control):
            with self._lock:
                self.multi_control = multi_control

        def get_mult_const(self):
            return self.mult_const

        def set_mult_const(self, mult_const):
            with self._lock:
                self.mult_const = mult_const

        def get_mean(self):
            return self.mean

        def set_mean(self, mean):
            with self._lock:
                self.mean = mean

        def get_impl_head(self):
            return self.impl_head

        def set_impl_head(self, impl_head):
            with self._lock:
                self.impl_head = impl_head

        def get_has_crc(self):
            return self.has_crc

        def set_has_crc(self, has_crc):
            with self._lock:
                self.has_crc = has_crc

        def get_frame_period(self):
            return self.frame_period

        def set_frame_period(self, frame_period):
            with self._lock:
                self.frame_period = frame_period

        def get_cr(self):
            return self.cr

        def set_cr(self, cr):
            with self._lock:
                self.cr = cr

        # run the flowgraph, since we use a message strobe we have to run and stop the flowgraph with some computation time inbetween
        self.tb.start()
        # time.sleep(10)
        # self.tb.stop()
        self.tb.wait()
        num_messages = self.blocks_message_debug_0.num_messages()
        if num_messages > 1:
            # try to get get the message from the store port of the message debug printer and convert to string from pmt message
            try:
                msg = pmt.symbol_to_string(
                    self.blocks_message_debug_0.get_message(1))
            except:
                # if not possible set message to be None
                msg = None
        else:
            # try to get get the message from the store port of the message debug printer and convert to string from pmt message
            try:
                msg = pmt.symbol_to_string(
                    self.blocks_message_debug_0.get_message(0))
            except:
                # if not possible set message to be None
                msg = None

        # check if message received is the same as the message decoded
        self.assertMultiLineEqual(
            src_data,
            msg,
            msg="Error decoded data {0} is not the same as input data {1}".
            format(msg, src_data))
예제 #35
0
 def setUp(self):
     self.tb = gr.top_block()
     self.emitter = pdu_utils.message_emitter()
     self.debug = blocks.message_debug()
예제 #36
0
    def __init__(self):
        gr.top_block.__init__(self, "gr_zigbee_simulation")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("gr_zigbee_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", "gr_ZiGbee")

        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.zigbee_channel = zigbee_channel = 11
        self.transition_width = transition_width = 100e3
        self.samp_rate = samp_rate = 5000000
        self.cutoff_freq = cutoff_freq = 750e3
        self.channel_spacing = channel_spacing = 5e6
        self.central_frequency = central_frequency = 2405e6
        self.squelch_threshold = squelch_threshold = -80
        self.payload_mod = payload_mod = digital.constellation_qpsk()
        self.lowpass_filter = lowpass_filter = firdes.low_pass(
            1, samp_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING,
            6.76)
        self.iq_output = iq_output = "ble2.iq"
        self.half_preamble_len = half_preamble_len = 2 * 32 * 2
        self.freq_channel = freq_channel = central_frequency + (
            zigbee_channel - 11) * channel_spacing
        self.dsss_mode = dsss_mode = 32
        self.dsss_4_8 = dsss_4_8 = [(1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
                                    (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
                                    (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
                                    (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
                                    (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
                                    (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
                                    (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
                                    (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
                                    (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
                                    (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j),
                                    (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
                                    (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
                                    (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
                                    (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
                                    (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
                                    (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j)]
        self.dsss_4_64 = dsss_4_64 = [
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
            (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
            (1 + 1j), (1 - 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
            (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
            (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
            (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
            (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
            (-1 + 1j), (1 + 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 + 1j), (1 - 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
            (-1 + 1j), (-1 + 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j)
        ]
        self.dsss_4_32_LSB = dsss_4_32_LSB = [(1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 + 1j),
                                              (-1 + 1j), (-1 - 1j), (1 - 1j),
                                              (-1 - 1j), (1 - 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 + 1j),
                                              (-1 + 1j), (-1 - 1j), (1 - 1j),
                                              (-1 - 1j), (1 - 1j), (-1 - 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 + 1j),
                                              (-1 + 1j), (-1 - 1j), (1 - 1j),
                                              (-1 - 1j), (1 - 1j), (-1 - 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 + 1j),
                                              (-1 + 1j), (-1 + 1j), (-1 + 1j),
                                              (-1 - 1j), (1 - 1j), (-1 - 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 + 1j), (-1 + 1j), (-1 + 1j),
                                              (-1 - 1j), (1 - 1j), (-1 - 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 - 1j),
                                              (1 + 1j), (-1 - 1j), (-1 - 1j),
                                              (1 + 1j), (-1 + 1j), (-1 + 1j),
                                              (-1 - 1j), (1 - 1j), (-1 - 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (1 - 1j), (-1 + 1j),
                                              (1 + 1j), (-1 - 1j), (-1 - 1j),
                                              (1 + 1j), (-1 + 1j), (-1 + 1j),
                                              (-1 - 1j), (1 - 1j), (-1 - 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 - 1j), (-1 + 1j), (-1 + 1j),
                                              (1 - 1j), (-1 - 1j), (-1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 + 1j),
                                              (1 + 1j), (1 - 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 - 1j), (-1 + 1j), (-1 + 1j),
                                              (1 - 1j), (-1 - 1j), (-1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 + 1j),
                                              (1 + 1j), (-1 + 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 - 1j), (-1 + 1j), (-1 + 1j),
                                              (1 - 1j), (-1 - 1j), (-1 - 1j),
                                              (-1 + 1j), (1 + 1j), (-1 + 1j),
                                              (1 + 1j), (-1 + 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 - 1j), (-1 + 1j), (-1 + 1j),
                                              (1 - 1j), (-1 - 1j), (-1 - 1j),
                                              (-1 - 1j), (-1 - 1j), (-1 + 1j),
                                              (1 + 1j), (-1 + 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 - 1j), (-1 + 1j), (-1 + 1j),
                                              (1 - 1j), (-1 + 1j), (1 - 1j),
                                              (-1 - 1j), (-1 - 1j), (-1 + 1j),
                                              (1 + 1j), (-1 + 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 - 1j), (-1 + 1j), (1 - 1j),
                                              (-1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 - 1j), (-1 - 1j), (-1 + 1j),
                                              (1 + 1j), (-1 + 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (-1 - 1j), (1 + 1j), (-1 - 1j),
                                              (1 + 1j), (-1 - 1j), (1 - 1j),
                                              (-1 + 1j), (-1 + 1j), (1 - 1j),
                                              (-1 - 1j), (-1 - 1j), (-1 + 1j),
                                              (1 + 1j), (-1 + 1j), (1 + 1j),
                                              (1 - 1j), (1 + 1j), (1 - 1j),
                                              (-1 - 1j)]
        self.dsss_4_32 = dsss_4_32 = [
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 - 1j), (-1 - 1j),
            (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
            (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
            (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
            (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
            (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j),
            (1 + 1j), (-1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
            (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (1 + 1j),
            (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
            (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
            (1 + 1j), (-1 - 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
            (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 + 1j), (1 + 1j),
            (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j),
            (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
            (-1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
            (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j)
        ]
        self.dsss_4_16 = dsss_4_16 = [
            (-1 - 1j), (1 + 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
            (-1 + 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (1 - 1j), (1 + 1j),
            (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (-1 - 1j), (1 - 1j),
            (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 + 1j), (1 + 1j), (1 - 1j),
            (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 - 1j),
            (1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 + 1j),
            (1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
            (-1 + 1j), (1 - 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j),
            (-1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
            (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (-1 - 1j),
            (1 + 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 - 1j), (-1 + 1j), (1 - 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
            (1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
            (-1 + 1j), (-1 - 1j), (1 + 1j), (1 + 1j), (1 + 1j), (-1 + 1j),
            (1 + 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 - 1j), (1 - 1j),
            (1 - 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 + 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j),
            (1 - 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 + 1j),
            (1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j),
            (1 - 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
            (-1 - 1j), (-1 + 1j)
        ]
        self.csv_file = csv_file = "packet_index2.csv"

        ##################################################
        # Blocks
        ##################################################
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
            1024,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(False)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.qtgui_const_sink_x_0_1 = qtgui.const_sink_c(
            1024,  #size
            "after filtering",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_1.enable_autoscale(True)
        self.qtgui_const_sink_x_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_1_win)
        self.qtgui_const_sink_x_0_0_1 = qtgui.const_sink_c(
            1024,  #size
            "after filter",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0_1.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                       qtgui.TRIG_SLOPE_POS,
                                                       0.0, 0, "")
        self.qtgui_const_sink_x_0_0_1.enable_autoscale(True)
        self.qtgui_const_sink_x_0_0_1.enable_grid(False)
        self.qtgui_const_sink_x_0_0_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_1_win)
        self.qtgui_const_sink_x_0_0 = qtgui.const_sink_c(
            1024,  #size
            "after filter",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                     qtgui.TRIG_SLOPE_POS, 0.0,
                                                     0, "")
        self.qtgui_const_sink_x_0_0.enable_autoscale(True)
        self.qtgui_const_sink_x_0_0.enable_grid(False)
        self.qtgui_const_sink_x_0_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_0_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024,  #size
            "after noise",  #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)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.oqpsk_dsss_packet_sink_0 = oqpsk_dsss.packet_sink(
            12, dsss_mode, 0, 0, csv_file, zigbee_channel, int(samp_rate))
        self.oqpsk_dsss_access_code_prefixer_0 = oqpsk_dsss.access_code_prefixer(
            0x00, 0x000000a7)
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True, 0x8841, 0, 0x1aaa,
                                                   0x0000, 0x1780)
        self.freq_xlating_fir_filter_lp = filter.freq_xlating_fir_filter_ccc(
            1, (lowpass_filter), 0, samp_rate)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2, 0.000225, 0.5, 0.03, 0.0002)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            (dsss_4_32), 16)
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc(
            (([])), 0, 4, False, "pdu_length")
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            [0, sin(pi / 4), 1, sin(3 * pi / 4)], True, 1, [])
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, 'pdu_length', 512)
        self.blocks_tag_gate_0 = blocks.tag_gate(gr.sizeof_float * 1, False)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 4)
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'pdu_length')
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            4, gr.GR_LSB_FIRST)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float * 1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(
            pmt.intern("Hello World!\n"), 120)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_file_sink_1 = blocks.file_sink(
            gr.sizeof_char * 1, '/home/ousseynou/ZIGBEE.pcap', False)
        self.blocks_file_sink_1.set_unbuffered(True)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 2)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(2)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0.5, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0_0, 'strobe'),
                         (self.ieee802_15_4_rime_stack_0, 'bcin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.oqpsk_dsss_access_code_prefixer_0, 'in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))
        self.msg_connect((self.oqpsk_dsss_access_code_prefixer_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.oqpsk_dsss_packet_sink_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_delay_0, 0), (self.blocks_tag_gate_0, 0))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.blocks_add_xx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_repeat_0, 0), (self.qtgui_const_sink_x_1, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_tag_gate_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.freq_xlating_fir_filter_lp, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.blocks_null_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.oqpsk_dsss_packet_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_1, 0))
        self.connect((self.freq_xlating_fir_filter_lp, 0),
                     (self.qtgui_const_sink_x_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_lp, 0),
                     (self.qtgui_const_sink_x_0_1, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
예제 #37
0
    def __init__(self, radio_id='USRP', sat_name='SIM'):
        gr.top_block.__init__(self, "/home/zleffke/captures/misc/SIM_USRP_20181103_180104.292187_UTC_250k.fc32")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("/home/zleffke/captures/misc/SIM_USRP_20181103_180104.292187_UTC_250k.fc32")
        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", "nbfm_afsk_file")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())


        ##################################################
        # Parameters
        ##################################################
        self.radio_id = radio_id
        self.sat_name = sat_name

        ##################################################
        # Variables
        ##################################################
        self.ts_str = ts_str = dt.strftime(dt.utcnow(), "%Y%m%d_%H%M%S.%f" )+'_UTC'
        self.samp_rate = samp_rate = 250e3
        self.fn = fn = "{:s}_{:s}_{:s}_{:s}k.fc32".format(sat_name, radio_id, ts_str, str(int(samp_rate)/1000))
        self.baud = baud = 1200

        self.xlate_taps = xlate_taps = firdes.low_pass(1.0, samp_rate, samp_rate/2, 1000, firdes.WIN_HAMMING, 6.76)

        self.volume = volume = 0.02
        self.throttle_factor = throttle_factor = 1.0
        self.samps_per_symb = samps_per_symb = 48000 / baud
        self.rx_freq = rx_freq = 440.389e6
        self.offset = offset = 1e3
        self.fsk_deviation_hz = fsk_deviation_hz = 4000
        self.fp = fp = "/home/zleffke/captures/misc/{:s}".format(fn)
        self.fll_loop_bw = fll_loop_bw = math.pi/200
        self.decim = decim = 5
        self.audio_lpf_cutoff = audio_lpf_cutoff = 10e3

        ##################################################
        # Blocks
        ##################################################
        self._volume_tool_bar = Qt.QToolBar(self)
        self._volume_tool_bar.addWidget(Qt.QLabel("volume"+": "))
        self._volume_line_edit = Qt.QLineEdit(str(self.volume))
        self._volume_tool_bar.addWidget(self._volume_line_edit)
        self._volume_line_edit.returnPressed.connect(
        	lambda: self.set_volume(eng_notation.str_to_num(str(self._volume_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._volume_tool_bar, 10, 2, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 3):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._throttle_factor_tool_bar = Qt.QToolBar(self)
        self._throttle_factor_tool_bar.addWidget(Qt.QLabel('Throttle'+": "))
        self._throttle_factor_line_edit = Qt.QLineEdit(str(self.throttle_factor))
        self._throttle_factor_tool_bar.addWidget(self._throttle_factor_line_edit)
        self._throttle_factor_line_edit.returnPressed.connect(
        	lambda: self.set_throttle_factor(eng_notation.str_to_num(str(self._throttle_factor_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._throttle_factor_tool_bar, 10, 0, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel('OFFSET'+": "))
        self._offset_line_edit = Qt.QLineEdit(str(self.offset))
        self._offset_tool_bar.addWidget(self._offset_line_edit)
        self._offset_line_edit.returnPressed.connect(
        	lambda: self.set_offset(eng_notation.str_to_num(str(self._offset_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 10, 5, 1, 2)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(5, 7):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._audio_lpf_cutoff_tool_bar = Qt.QToolBar(self)
        self._audio_lpf_cutoff_tool_bar.addWidget(Qt.QLabel("audio_lpf_cutoff"+": "))
        self._audio_lpf_cutoff_line_edit = Qt.QLineEdit(str(self.audio_lpf_cutoff))
        self._audio_lpf_cutoff_tool_bar.addWidget(self._audio_lpf_cutoff_line_edit)
        self._audio_lpf_cutoff_line_edit.returnPressed.connect(
        	lambda: self.set_audio_lpf_cutoff(eng_notation.str_to_num(str(self._audio_lpf_cutoff_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._audio_lpf_cutoff_tool_bar, 10, 3, 1, 2)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(3, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.vtgs_ax25_deframer_0 = vtgs.ax25_deframer()
        self.vtgs_afskdemod_0 = vtgs.afskdemod(samps_per_symb, baud, 1200, 2200)
        self.vcc_qt_hex_text_0 = vcc.qt_hex_text()
        self._vcc_qt_hex_text_0_win = self.vcc_qt_hex_text_0;
        self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_win, 4, 4, 2, 4)
        for r in range(4, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)

        self._rx_freq_tool_bar = Qt.QToolBar(self)
        self._rx_freq_tool_bar.addWidget(Qt.QLabel('FREQ'+": "))
        self._rx_freq_line_edit = Qt.QLineEdit(str(self.rx_freq))
        self._rx_freq_tool_bar.addWidget(self._rx_freq_line_edit)
        self._rx_freq_line_edit.returnPressed.connect(
        	lambda: self.set_rx_freq(eng_notation.str_to_num(str(self._rx_freq_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._rx_freq_tool_bar, 10, 1, 1, 1)
        for r in range(10, 11):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(1, 2):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, -40)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0, 4, 4, 4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
        	1024, #size
        	samp_rate / decim / 50 * 48, #samp_rate
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
          self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "blue"]
        styles = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1,
                   -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 4, 0, 2, 4)
        for r in range(4, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.010)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, -40)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(True)

        if not True:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["blue", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 0, 0, 4, 4)
        for r in range(0, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.low_pass_filter_0_0_0 = filter.fir_filter_fff(1, firdes.low_pass(
        	1, samp_rate/decim/50*48, audio_lpf_cutoff, 2e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(decim, firdes.low_pass(
        	1, samp_rate, 25e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss()
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(1, (xlate_taps), offset, samp_rate)
        self._fll_loop_bw_tool_bar = Qt.QToolBar(self)
        self._fll_loop_bw_tool_bar.addWidget(Qt.QLabel("fll_loop_bw"+": "))
        self._fll_loop_bw_line_edit = Qt.QLineEdit(str(self.fll_loop_bw))
        self._fll_loop_bw_tool_bar.addWidget(self._fll_loop_bw_line_edit)
        self._fll_loop_bw_line_edit.returnPressed.connect(
        	lambda: self.set_fll_loop_bw(eng_notation.str_to_num(str(self._fll_loop_bw_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._fll_loop_bw_tool_bar, 6, 2, 1, 2)
        for r in range(6, 7):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(2, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate * throttle_factor,True)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '8000', 10000, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((volume, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/zleffke/captures/misc/SIM_USRP_20181102_011046.737916_UTC_250k.fc32', True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(samp_rate/(2*math.pi*fsk_deviation_hz/8.0))
        self.analog_agc2_xx_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0.set_max_gain(65536)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.blocks_socket_pdu_0, 'pdus'))
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'), (self.vcc_qt_hex_text_0, 'pdus'))
        self.msg_connect((self.vtgs_ax25_deframer_0, 'valid_frames'), (self.kiss_pdu_to_kiss_0, 'in'))
        self.connect((self.analog_agc2_xx_0, 0), (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.low_pass_filter_0_0_0, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.vtgs_afskdemod_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.low_pass_filter_0_0_0, 0), (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.vtgs_afskdemod_0, 0), (self.vtgs_ax25_deframer_0, 0))
예제 #38
0
    def __init__(self):
        gr.top_block.__init__(self, "Uhd Ais 2")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Uhd Ais 2")
        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", "uhd_ais_2")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250e3
        self.decim = decim = 5
        self.baud = baud = 9600
        self.samp_per_sym = samp_per_sym = (samp_rate/decim/50*48)/baud
        self.fsk_deviation = fsk_deviation = 10e3
        self.freq = freq = 162e6
        self.filter_taps = filter_taps = firdes.low_pass(1,samp_rate, samp_rate/2, 50000, firdes.WIN_FLATTOP, 6.76)

        ##################################################
        # Blocks
        ##################################################
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_fff(
                interpolation=48,
                decimation=50,
                taps=None,
                fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"AIS-B", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_0_win, 0,4,2,4)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
        	1024, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate, #bw
        	"AIS-A", #name
                1 #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
          self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        colors = [0, 0, 0, 0, 0,
                  0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 0,0,2,4)
        self.qtgui_freq_sink_x_0_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"AIS-B", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0_0.set_y_axis(-60, 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(True)
        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 = ["green", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_0_win, 2,4,2,4)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
        	2048, #size
        	firdes.WIN_BLACKMAN_hARRIS, #wintype
        	0, #fc
        	samp_rate/decim, #bw
        	"AIS-A", #name
        	1 #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.01)
        self.qtgui_freq_sink_x_0.set_y_axis(-60, 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(True)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
          self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
          self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '',
                  '', '', '', '', '']
        widths = [1, 1, 1, 1, 1,
                  1, 1, 1, 1, 1]
        colors = ["green", "red", "green", "black", "cyan",
                  "magenta", "yellow", "dark red", "dark green", "dark blue"]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0,
                  1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 2,0,2,4)
        self.pyqt_text_output_0_0 = pyqt.text_output()
        self._pyqt_text_output_0_0_win = self.pyqt_text_output_0_0;
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_0_win, 4,0,2,4)
        self.pyqt_text_output_0 = pyqt.text_output()
        self._pyqt_text_output_0_win = self.pyqt_text_output_0;
        self.top_grid_layout.addWidget(self._pyqt_text_output_0_win, 4,4,2,4)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(decim, firdes.low_pass(
        	1, samp_rate, 7e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(decim, firdes.low_pass(
        	1, samp_rate, 7e3, 1e3, firdes.WIN_HAMMING, 6.76))
        self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(11, 1000)
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(11, 1000)
        self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(samp_per_sym*(1+0.0), 0.25*0.175*0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_0_0 = digital.binary_slicer_fb()
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_xx_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_debug_0_1 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, '/home/leffke/sandbox/ais/captures/ais_20161216_250k_9.32fc', False)
        self.analog_sig_source_x_1 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, 25e3+400, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, -25e3+400, 1, 0)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_deviation/8.0))
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf((samp_rate/decim)/(2*math.pi*fsk_deviation/8.0))
        self.analog_agc2_xx_0_0 = analog.agc2_cc(1e-1, 1e-2, 1.0, 1.0)
        self.analog_agc2_xx_0_0.set_max_gain(65536)
        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)
        self.ais_pdu_to_nmea_0_0 = ais.pdu_to_nmea('B')
        self.ais_pdu_to_nmea_0 = ais.pdu_to_nmea('A')
        self.ais_invert_0_0 = ais.invert()
        self.ais_invert_0 = ais.invert()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ais_pdu_to_nmea_0, 'out'), (self.blocks_message_debug_0_1, 'print'))
        self.msg_connect((self.ais_pdu_to_nmea_0, 'out'), (self.pyqt_text_output_0_0, 'pdus'))
        self.msg_connect((self.ais_pdu_to_nmea_0_0, 'out'), (self.blocks_message_debug_0_1, 'print'))
        self.msg_connect((self.ais_pdu_to_nmea_0_0, 'out'), (self.pyqt_text_output_0, 'pdus'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.ais_pdu_to_nmea_0, 'to_nmea'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.ais_pdu_to_nmea_0_0, 'to_nmea'))
        self.connect((self.ais_invert_0, 0), (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.ais_invert_0_0, 0), (self.digital_hdlc_deframer_bp_0_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_agc2_xx_0, 0), (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.qtgui_freq_sink_x_0_0, 0))
        self.connect((self.analog_agc2_xx_0_0, 0), (self.qtgui_waterfall_sink_x_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_1, 0), (self.blocks_multiply_xx_1, 0))
        self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.blocks_multiply_xx_1, 0), (self.low_pass_filter_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_xx_1, 1))
        self.connect((self.digital_binary_slicer_fb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_binary_slicer_fb_0_0, 0), (self.digital_diff_decoder_bb_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0), (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.ais_invert_0, 0))
        self.connect((self.digital_diff_decoder_bb_0_0, 0), (self.ais_invert_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.analog_agc2_xx_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.analog_agc2_xx_0_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0), (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0))
예제 #39
0
 def setUp(self):
     self.tb = gr.top_block()
     self.debug = blocks.message_debug()
예제 #40
0
    def __init__(self,
                 callsign='',
                 ip='::',
                 latitude=0,
                 longitude=0,
                 port=7355,
                 recstart=''):
        gr.top_block.__init__(self, "GALASSIA decoder")

        ##################################################
        # Parameters
        ##################################################
        self.callsign = callsign
        self.ip = ip
        self.latitude = latitude
        self.longitude = longitude
        self.port = port
        self.recstart = recstart

        ##################################################
        # Variables
        ##################################################
        self.threshold = threshold = 4
        self.access_code = access_code = "11000011101010100110011001010101"

        ##################################################
        # Blocks
        ##################################################
        self.sync_to_pdu_packed_0 = sync_to_pdu_packed(
            packlen=255 + 3,
            sync=access_code,
            threshold=threshold,
        )
        self.sids_submit_0 = sids.submit(
            'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 41170, callsign,
            longitude, latitude, recstart)
        self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S')
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1, firdes.low_pass(1, 48000, 2600, 1000, firdes.WIN_HAMMING, 6.76))
        self.hilbert_fc_0 = filter.hilbert_fc(65, firdes.WIN_HAMMING, 6.76)
        self.digital_gmsk_demod_0 = digital.gmsk_demod(
            samples_per_symbol=10,
            gain_mu=0.175,
            mu=0.5,
            omega_relative_limit=0.005,
            freq_error=0.0,
            verbose=False,
            log=False,
        )
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_short * 1, ip,
                                                     port, 1472, False)
        self.blocks_short_to_float_0 = blocks.short_to_float(1, 32767.0)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_conjugate_cc_0 = blocks.conjugate_cc()
        self.ax100_gomx1_decode_0 = ax100.gomx1_decode(False)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            48000, analog.GR_COS_WAVE, -3600, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ax100_gomx1_decode_0, 'out'),
                         (self.sids_print_timestamp_0, 'in'))
        self.msg_connect((self.ax100_gomx1_decode_0, 'out'),
                         (self.sids_submit_0, 'in'))
        self.msg_connect((self.sids_print_timestamp_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.sync_to_pdu_packed_0, 'out'),
                         (self.ax100_gomx1_decode_0, 'in'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_conjugate_cc_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_conjugate_cc_0, 0))
        self.connect((self.blocks_short_to_float_0, 0), (self.hilbert_fc_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_short_to_float_0, 0))
        self.connect((self.digital_gmsk_demod_0, 0),
                     (self.sync_to_pdu_packed_0, 0))
        self.connect((self.hilbert_fc_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.low_pass_filter_0, 0),
                     (self.digital_gmsk_demod_0, 0))
예제 #41
0
    def test_001_t(self):
        for src_data, expected_result in (
                # 128 instead of -1 to get the types right.
            (
                [128, 1, 1, 1, 1, 1, 1, 1, 0],
                [127],
            ),
            (
                [
                    128,
                    1,
                    128,
                    1,
                    128,
                    1,
                    128,
                    1,
                    128,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    1,
                    128,
                    1,
                    128,
                    1,
                    128,
                    1,
                    128,
                    1,
                    0,
                ],
                [85, 127, 85],
            ),
        ):
            src = blocks.vector_source_b(src_data)
            decode = pn_decode_bb([0])
            dbg = blocks.message_debug()
            self.tb.connect(src, decode)
            self.tb.msg_connect(decode, "pdus", dbg, "store")

            self.tb.start()
            while dbg.num_messages() < 1:
                time.sleep(0.1)
            self.tb.stop()
            self.tb.wait()

            result_data = pmt.to_python(pmt.cdr(dbg.get_message(0)))

            try:
                self.assertFloatTuplesAlmostEqual(expected_result, result_data,
                                                  1)
            except AssertionError:
                print "--"
                print "Source: ", src_data
                print "Want", expected_result
                print "Got", result_data
                raise
예제 #42
0
    def __init__(self, ant_msg='RX2', gain_msg=0.8, lo_msg=0):
        gr.top_block.__init__(self, "UHD Message Tuner")

        ##################################################
        # Parameters
        ##################################################
        self.ant_msg = ant_msg
        self.gain_msg = gain_msg
        self.lo_msg = lo_msg

        ##################################################
        # Variables
        ##################################################
        self.channel = channel = 11
        self.freq_msg = freq_msg = 1000000 * (2400 + 5 * (channel - 10))
        self.samp_rate = samp_rate = 4e6
        self.initial_fc = initial_fc = 1000000 * (2400 + 5 * (11 - 10))
        self.gain = gain = 0.8
        self.cmd_msg = cmd_msg = pmt.to_pmt({'antenna': ant_msg, 'gain': gain_msg, 'chan': 0, 'freq': freq_msg, 'lo_offset': lo_msg})

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(('127.0.0.1', 57000), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0,1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(initial_fc, 0)
        self.uhd_usrp_source_0.set_rx_agc(True, 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_time_unknown_pps(uhd.time_spec())
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True,0x8841,0,0x1aaa,0xffff,0x3344)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_message_strobe_0 = blocks.message_strobe(cmd_msg, 500)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, '/tmp/sensor.pcap', False)
        self.blocks_file_sink_0.set_unbuffered(True)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.uhd_usrp_source_0, 'command'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'), (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'), (self.ieee802_15_4_mac_0, 'pdu in'))
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0), (self.blocks_null_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.ieee802_15_4_oqpsk_phy_0, 0))
예제 #43
0
    def __init__(self,
                 ansibleFreqRx=919.75e6,
                 ansibleFreqTx=919.75e6,
                 ansibleID='1',
                 bw=250e3,
                 offset=-250e3):
        gr.top_block.__init__(self, "Ansible Usrp 1Tx 1Rx")

        ##################################################
        # Parameters
        ##################################################
        self.ansibleFreqRx = ansibleFreqRx
        self.ansibleFreqTx = ansibleFreqTx
        self.ansibleID = ansibleID
        self.bw = bw
        self.offset = offset

        ##################################################
        # Variables
        ##################################################
        self.spreading_factor = spreading_factor = 8
        self.samp_rate = samp_rate = 1e6
        self.ldr = ldr = True
        self.header = header = False
        self.code_rate = code_rate = 4

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', '')),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            ansibleFreqRx + samp_rate / 2 + (samp_rate * int(ansibleID)), 0)
        self.uhd_usrp_source_0.set_gain(0, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            ansibleFreqTx + samp_rate / 2 + (samp_rate * int(ansibleID)), 0)
        self.uhd_usrp_sink_0.set_gain(0.7, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf(bw / samp_rate,
                                                               taps=None,
                                                               flt_size=32)
        self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0)

        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(samp_rate / bw,
                                                             taps=None,
                                                             flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.lora_mod_0 = lora.mod(spreading_factor, 0x12)
        self.lora_encode_0 = lora.encode(spreading_factor, code_rate, ldr,
                                         header)
        self.lora_demod_0 = lora.demod(spreading_factor, ldr, 25.0, 2)
        self.lora_decode_0 = lora.decode(spreading_factor, code_rate, ldr,
                                         header)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu('tap + ansibleID', 1000,
                                                     False)
        self.blocks_rotator_cc_0_0 = blocks.rotator_cc(
            (2 * math.pi * offset) / samp_rate)
        self.blocks_rotator_cc_0 = blocks.rotator_cc(
            (2 * math.pi * offset) / samp_rate)
        self.blocks_message_debug_0_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.lora_encode_0, 'in'))
        self.msg_connect((self.lora_decode_0, 'out'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.lora_demod_0, 'out'),
                         (self.lora_decode_0, 'in'))
        self.msg_connect((self.lora_encode_0, 'out'), (self.lora_mod_0, 'in'))
        self.connect((self.blocks_rotator_cc_0, 0),
                     (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.blocks_rotator_cc_0_0, 0),
                     (self.pfb_arb_resampler_xxx_0_0, 0))
        self.connect((self.lora_mod_0, 0), (self.blocks_rotator_cc_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0_0, 0),
                     (self.lora_demod_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.blocks_rotator_cc_0_0, 0))
예제 #44
0
    def __init__(self):
        gr.top_block.__init__(self, "zigbee_dual_channel_rx")

        ##################################################
        # Variables
        ##################################################
        self.transition_width = transition_width = 300e3
        self.sample_rate = sample_rate = 8e6
        self.cutoff_freq = cutoff_freq = 850e3
        self.channel_spacing = channel_spacing = 5e6
        self.channel = channel = 0
        self.base_freq = base_freq = int(2405e6)
        self.squelch_threshold = squelch_threshold = -75
        self.lowpass_filter = lowpass_filter = firdes.low_pass(
            1, sample_rate, cutoff_freq, transition_width, firdes.WIN_HAMMING,
            6.76)
        self.gmsk_sps = gmsk_sps = 4
        self.gmsk_omega_limit = gmsk_omega_limit = 0.035
        self.gmsk_mu = gmsk_mu = 0.5
        self.gmsk_gain_mu = gmsk_gain_mu = 0.7
        self.freq_offset = freq_offset = 2.5e6
        self.freq = freq = (base_freq + (channel_spacing * channel))
        self.decim = decim = 4

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                args='',
                channels=list(range(0, 1)),
            ),
        )
        self.uhd_usrp_source_0.set_center_freq(freq + freq_offset, 0)
        self.uhd_usrp_source_0.set_rx_agc(True, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_samp_rate(sample_rate)
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.single_pole_iir_filter_xx_0_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=1, decimation=decim, taps=None, fractional_bw=None)
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=1, decimation=decim, taps=None, fractional_bw=None)
        self.ieee802_15_4_packet_sink_0_0 = ieee802_15_4.packet_sink(10)
        self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10)
        self.freq_xlating_fir_filter_xxx_0_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, lowpass_filter, freq_offset, sample_rate)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            1, lowpass_filter, -freq_offset, sample_rate)
        self.foo_wireshark_connector_0_0 = foo.wireshark_connector(195, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(195, False)
        self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(
            sample_rate / 2e6 / decim, 0.000225, 0.5, 0.03, 0.0002)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            sample_rate / 2e6 / decim, 0.000225, 0.5, 0.03, 0.0002)
        self.blocks_sub_xx_0_0 = blocks.sub_ff(1)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_sink_0_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       '/tmp/sensor11.pcap',
                                                       False)
        self.blocks_file_sink_0_0_0.set_unbuffered(True)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                     '/tmp/sensor12.pcap',
                                                     False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.analog_simple_squelch_cc_1 = analog.simple_squelch_cc(
            squelch_threshold, 0.1)
        self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0_0, 'out'),
                         (self.foo_wireshark_connector_0_0, 'in'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.blocks_sub_xx_0_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0_0, 0),
                     (self.single_pole_iir_filter_xx_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
        self.connect((self.analog_simple_squelch_cc_1, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0_0, 0))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_sub_xx_0_0, 0),
                     (self.digital_clock_recovery_mm_xx_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.ieee802_15_4_packet_sink_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0_0, 0),
                     (self.ieee802_15_4_packet_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0_0, 0))
        self.connect((self.foo_wireshark_connector_0_0, 0),
                     (self.blocks_file_sink_0_0_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.analog_quadrature_demod_cf_0_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.single_pole_iir_filter_xx_0_0, 0),
                     (self.blocks_sub_xx_0_0, 1))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.analog_simple_squelch_cc_1, 0))
예제 #45
0
    def __init__(self,
                 chiprate=2000000,
                 data_seed_rx=2645625,
                 fec_tailbiting=True,
                 max_freq_hypo=1,
                 ovsf_code_index=0,
                 ovsf_spreading_factor=0,
                 preamble_len=32,
                 preamble_seed_rx=54321,
                 psdu_len=16,
                 roll_off=1,
                 sfd_present=False,
                 spread_factor=2**10,
                 sps=4):
        gr.top_block.__init__(self, "LECIM DSSS rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("LECIM DSSS rx")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.chiprate = chiprate
        self.data_seed_rx = data_seed_rx
        self.fec_tailbiting = fec_tailbiting
        self.max_freq_hypo = max_freq_hypo
        self.ovsf_code_index = ovsf_code_index
        self.ovsf_spreading_factor = ovsf_spreading_factor
        self.preamble_len = preamble_len
        self.preamble_seed_rx = preamble_seed_rx
        self.psdu_len = psdu_len
        self.roll_off = roll_off
        self.sfd_present = sfd_present
        self.spread_factor = spread_factor
        self.sps = sps

        ##################################################
        # Variables
        ##################################################
        self.taps_num = taps_num = 64
        self.samp_rate = samp_rate = 4e6
        self.len_tag_var = len_tag_var = "packet_len"
        self.freq_vec = freq_vec = lpwan.dsss_const.gen_freq_hypo_vec(
            spread_factor, chiprate, max_freq_hypo)
        self.fo = fo = 2000

        ##################################################
        # Blocks
        ##################################################
        self._fo_range = Range(-15000, 15000, 1, 2000, 200)
        self._fo_win = RangeWidget(self._fo_range, self.set_fo, "fo",
                                   "counter_slider", float)
        self.top_layout.addWidget(self._fo_win)
        self.root_raised_cosine_filter_0 = filter.fir_filter_ccf(
            1, firdes.root_raised_cosine(1, sps, 1, 1, taps_num))
        self.qtgui_time_sink_x_3_0 = qtgui.time_sink_f(
            5240000,  #size
            4e6,  #samp_rate
            "",  #name
            2  #number of inputs
        )
        self.qtgui_time_sink_x_3_0.set_update_time(0.10)
        self.qtgui_time_sink_x_3_0.set_y_axis(-1, 2e6)

        self.qtgui_time_sink_x_3_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_3_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_3_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 3,
                                                    40000, 0, "PSDU")
        self.qtgui_time_sink_x_3_0.enable_autoscale(True)
        self.qtgui_time_sink_x_3_0.enable_grid(False)
        self.qtgui_time_sink_x_3_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_3_0.enable_control_panel(True)

        if not True:
            self.qtgui_time_sink_x_3_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:
                self.qtgui_time_sink_x_3_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_3_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_3_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_3_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_3_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_3_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_3_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_3_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_3_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_3_0_win)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0,
                                                     qtgui.NUM_GRAPH_HORIZ, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title("")

        labels = ['', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, 0)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_number_sink_0_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.qtgui_const_sink_x_1 = qtgui.const_sink_c(
            psdu_len * 8,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_1.set_update_time(0.10)
        self.qtgui_const_sink_x_1.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_1.enable_autoscale(True)
        self.qtgui_const_sink_x_1.enable_grid(False)
        self.qtgui_const_sink_x_1.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_1.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_1.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_1.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_1_win = sip.wrapinstance(
            self.qtgui_const_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_1_win)
        self.lpwan_message_counter_0 = lpwan.message_counter(10, 1)
        self.lpwan_dsss_preamble_search_cc_0_0 = lpwan.dsss_preamble_search_cc(
            spread_factor, preamble_seed_rx, ovsf_code_index,
            ovsf_spreading_factor, (freq_vec), preamble_len, sfd_present, sps,
            0, chiprate, "oqpsk",
            (firdes.root_raised_cosine(1, sps, 1, roll_off, taps_num)))

        self.lpwan_dsss_normalize_ff_0 = lpwan.dsss_normalize_ff(len_tag_var)
        self.lpwan_dsss_filter_crc_packets_0 = lpwan.dsss_filter_crc_packets()
        self.lpwan_dsss_diff_decoding_ff_0 = lpwan.dsss_diff_decoding_ff(
            len_tag_var, True, preamble_len + (8 if sfd_present else 0))
        self.lpwan_dsss_despread_cc_0_0 = lpwan.dsss_despread_cc(
            spread_factor, data_seed_rx, preamble_seed_rx, ovsf_code_index,
            ovsf_spreading_factor, sps, psdu_len, 1, chiprate, False, False, 1,
            0.05, 0.8, 0.25)
        self.lpwan_dsss_deinterleaver_ff_0 = lpwan.dsss_deinterleaver_ff(
            len_tag_var)
        self.dsss_fec_dec_fb_0 = dsss_fec_dec_fb(
            len_tag_var=len_tag_var,
            tailbiting=fec_tailbiting,
        )
        self.digital_crc32_async_bb_1_0 = digital.crc32_async_bb(False)
        self.digital_crc32_async_bb_1 = digital.crc32_async_bb(True)
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'packet_len')
        self.blocks_null_sink_1_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((0, ))
        self.blocks_message_debug_0_0 = blocks.message_debug()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/media/maier/73083b7c-6150-4a9b-9a6d-38e866ba5fba/mathesis_iq_files/per_messung dachgeschoss cel/PER_Dachgeschoss1024_reference_txgain80.iq',
            True)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.blocks_complex_to_mag_0_0 = blocks.complex_to_mag(1)
        self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, fo, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.lpwan_dsss_filter_crc_packets_0, 'in_soft'))
        self.msg_connect((self.digital_crc32_async_bb_1, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.digital_crc32_async_bb_1, 'out'),
                         (self.digital_crc32_async_bb_1_0, 'in'))
        self.msg_connect((self.digital_crc32_async_bb_1, 'out'),
                         (self.lpwan_message_counter_0, 'in'))
        self.msg_connect(
            (self.digital_crc32_async_bb_1_0, 'out'),
            (self.lpwan_dsss_filter_crc_packets_0, 'in_hard_crc_ok'))
        self.msg_connect((self.dsss_fec_dec_fb_0, 'out'),
                         (self.digital_crc32_async_bb_1, 'in'))
        self.msg_connect((self.dsss_fec_dec_fb_0, 'out'),
                         (self.lpwan_dsss_filter_crc_packets_0, 'in_hard'))
        self.msg_connect((self.lpwan_dsss_filter_crc_packets_0, 'out_soft'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.blocks_complex_to_mag_0, 0),
                     (self.qtgui_time_sink_x_3_0, 0))
        self.connect((self.blocks_complex_to_mag_0_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.lpwan_dsss_deinterleaver_ff_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_time_sink_x_3_0, 1))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.root_raised_cosine_filter_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.qtgui_const_sink_x_1, 0))
        self.connect((self.lpwan_dsss_deinterleaver_ff_0, 0),
                     (self.lpwan_dsss_normalize_ff_0, 0))
        self.connect((self.lpwan_dsss_despread_cc_0_0, 0),
                     (self.lpwan_dsss_diff_decoding_ff_0, 0))
        self.connect((self.lpwan_dsss_diff_decoding_ff_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.lpwan_dsss_diff_decoding_ff_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.lpwan_dsss_normalize_ff_0, 0),
                     (self.dsss_fec_dec_fb_0, 0))
        self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 1),
                     (self.blocks_complex_to_mag_0, 0))
        self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 0),
                     (self.blocks_complex_to_mag_0_0, 0))
        self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 1),
                     (self.blocks_null_sink_1_0, 0))
        self.connect((self.lpwan_dsss_preamble_search_cc_0_0, 0),
                     (self.lpwan_dsss_despread_cc_0_0, 0))
        self.connect((self.lpwan_message_counter_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.root_raised_cosine_filter_0, 0),
                     (self.lpwan_dsss_preamble_search_cc_0_0, 0))
예제 #46
0
    def __init__(self):
        gr.top_block.__init__(self, "Test Qtgui Msg")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test Qtgui Msg")
        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_qtgui_msg")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-140, 10)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,
                                       0, 1, 2)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not 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.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 1, 0, 1,
                                       2)
        self.qtgui_edit_box_msg_0_0_0 = qtgui.edit_box_msg(
            qtgui.INT_VEC, '', '', False, False, '')
        self._qtgui_edit_box_msg_0_0_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_edit_box_msg_0_0_0_win, 3,
                                       0, 1, 1)
        self.qtgui_edit_box_msg_0_0 = qtgui.edit_box_msg(
            qtgui.INT_VEC, '', '', False, False, '')
        self._qtgui_edit_box_msg_0_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_edit_box_msg_0_0_win, 3, 1,
                                       1, 1)
        self.qtgui_edit_box_msg_0 = qtgui.edit_box_msg(qtgui.FLOAT, '',
                                                       'Frequency', True, True,
                                                       'freq')
        self._qtgui_edit_box_msg_0_win = sip.wrapinstance(
            self.qtgui_edit_box_msg_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_edit_box_msg_0_win, 0, 0, 1,
                                       1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1000, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'),
                         (self.qtgui_freq_sink_x_0, 'freq'))
        self.msg_connect((self.qtgui_edit_box_msg_0, 'msg'),
                         (self.qtgui_waterfall_sink_x_0, 'freq'))
        self.msg_connect((self.qtgui_edit_box_msg_0_0, 'msg'),
                         (self.qtgui_edit_box_msg_0_0_0, 'val'))
        self.msg_connect((self.qtgui_edit_box_msg_0_0_0, 'msg'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.qtgui_edit_box_msg_0_0_0, 'msg'),
                         (self.qtgui_edit_box_msg_0_0, 'val'))
        self.msg_connect((self.qtgui_freq_sink_x_0, 'freq'),
                         (self.qtgui_edit_box_msg_0, 'val'))
        self.msg_connect((self.qtgui_freq_sink_x_0, 'freq'),
                         (self.qtgui_freq_sink_x_0, 'freq'))
        self.msg_connect((self.qtgui_waterfall_sink_x_0, 'freq'),
                         (self.qtgui_edit_box_msg_0, 'val'))
        self.msg_connect((self.qtgui_waterfall_sink_x_0, 'freq'),
                         (self.qtgui_waterfall_sink_x_0, 'freq'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
예제 #47
0
파일: ss2.py 프로젝트: michaelld/gr-pyqt
    def __init__(self,
                 center_freq=0,
                 filename="/tmp/such_samples.cfile",
                 samp_rate=2.4e6):
        gr.top_block.__init__(
            self, "Such Samples 2, /tmp/such_samples.cfile Woww!!")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Such Samples 2, /tmp/such_samples.cfile Woww!!")
        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", "ss2")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.center_freq = center_freq
        self.filename = filename
        self.samp_rate = samp_rate

        ##################################################
        # Variables
        ##################################################
        self.ymin = ymin = -100
        self.ymax = ymax = -40
        self.samp_rate_f = samp_rate_f = samp_rate
        self.center_freq_f = center_freq_f = center_freq

        ##################################################
        # Blocks
        ##################################################
        self._ymin_range = Range(-160, 20, 5, -100, 200)
        self._ymin_win = RangeWidget(self._ymin_range, self.set_ymin, "ymin",
                                     "counter_slider", int)
        self.top_grid_layout.addWidget(self._ymin_win, 1, 0, 1, 1)
        self._ymax_range = Range(-160, 20, 5, -40, 200)
        self._ymax_win = RangeWidget(self._ymax_range, self.set_ymax, "ymax",
                                     "counter_slider", int)
        self.top_grid_layout.addWidget(self._ymax_win, 1, 1, 1, 1)
        self._samp_rate_f_tool_bar = Qt.QToolBar(self)
        self._samp_rate_f_tool_bar.addWidget(Qt.QLabel("Sample Rate" + ": "))
        self._samp_rate_f_line_edit = Qt.QLineEdit(str(self.samp_rate_f))
        self._samp_rate_f_tool_bar.addWidget(self._samp_rate_f_line_edit)
        self._samp_rate_f_line_edit.returnPressed.connect(
            lambda: self.set_samp_rate_f(
                eval(str(self._samp_rate_f_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._samp_rate_f_tool_bar, 0, 0, 1, 1)
        self._center_freq_f_tool_bar = Qt.QToolBar(self)
        self._center_freq_f_tool_bar.addWidget(
            Qt.QLabel("Center Frequency" + ": "))
        self._center_freq_f_line_edit = Qt.QLineEdit(str(self.center_freq_f))
        self._center_freq_f_tool_bar.addWidget(self._center_freq_f_line_edit)
        self._center_freq_f_line_edit.returnPressed.connect(
            lambda: self.set_center_freq_f(
                eng_notation.str_to_num(
                    str(self._center_freq_f_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._center_freq_f_tool_bar, 0, 1, 1,
                                       1)
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center_freq_f,  #fc
            samp_rate_f,  #bw
            "",  #name
            0  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.10)
        self.qtgui_waterfall_sink_x_0.enable_grid(False)

        if not False:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "msg_complex" == "float" or "msg_complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(ymin, ymax)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,
                                       0, 2, 2)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_c(
            1024,  #size
            samp_rate_f,  #samp_rate
            "",  #name
            0  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0.set_y_label("Amplitude", "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_time_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 2, 2, 1,
                                       1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            center_freq_f,  #fc
            samp_rate_f,  #bw
            "",  #name
            0  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(ymin, ymax)
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(True)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "msg_complex" == "float" or "msg_complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ["", "", "", "", "", "", "", "", "", ""]
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win, 3, 2, 1,
                                       1)
        self.pyqt_range_input_0 = pyqt.range_input()
        self._pyqt_range_input_0_win = self.pyqt_range_input_0
        self.top_grid_layout.addWidget(self._pyqt_range_input_0_win, 0, 2, 1,
                                       2)
        self.pyqt_open_0 = pyqt.file_open()
        self._pyqt_open_0_win = self.pyqt_open_0
        self.top_layout.addWidget(self._pyqt_open_0_win)
        self.pyqt_file_message_souce_0 = pyqt.file_message_source(
            filename, "complex64")
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.pyqt_file_message_souce_0, 'file_range'),
                         (self.pyqt_range_input_0, 'file_range'))
        self.msg_connect((self.pyqt_file_message_souce_0, 'pdus'),
                         (self.qtgui_freq_sink_x_0, 'in'))
        self.msg_connect((self.pyqt_file_message_souce_0, 'pdus'),
                         (self.qtgui_time_sink_x_0, 'in'))
        self.msg_connect((self.pyqt_file_message_souce_0, 'pdus'),
                         (self.qtgui_waterfall_sink_x_0, 'in'))
        self.msg_connect((self.pyqt_open_0, 'filename'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.pyqt_open_0, 'filename'),
                         (self.pyqt_file_message_souce_0, 'file_open'))
        self.msg_connect((self.pyqt_range_input_0, 'range'),
                         (self.pyqt_file_message_souce_0, 'range'))
예제 #48
0
    def __init__(self,
                 bb_gain=20,
                 callsign='',
                 freq_corr=0,
                 gpredict_port=4532,
                 if_gain=20,
                 latitude=0,
                 longitude=0,
                 rf_gain=40):
        gr.top_block.__init__(self, "LilacSat-2 decoder for RTL-SDR device")

        ##################################################
        # Parameters
        ##################################################
        self.bb_gain = bb_gain
        self.callsign = callsign
        self.freq_corr = freq_corr
        self.gpredict_port = gpredict_port
        self.if_gain = if_gain
        self.latitude = latitude
        self.longitude = longitude
        self.rf_gain = rf_gain

        ##################################################
        # Variables
        ##################################################
        self.sub_sps = sub_sps = 32
        self.sub_nfilts = sub_nfilts = 16
        self.sub_alpha = sub_alpha = 0.35
        self.sps = sps = 5
        self.nfilts = nfilts = 16
        self.freq = freq = 437.2e6
        self.alpha = alpha = 0.35

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 2, 1).base()

        self.threshold = threshold = 4
        self.sub_rrc_taps = sub_rrc_taps = firdes.root_raised_cosine(
            sub_nfilts, sub_nfilts, 1.0 / float(sub_sps), sub_alpha,
            11 * sub_sps * sub_nfilts)
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts, 1.0 / float(sps), alpha, 11 * sps * nfilts)
        self.rf_samp_rate = rf_samp_rate = 2.4e6
        self.offset = offset = 30e3
        self.if_samp_rate = if_samp_rate = 48000
        self.doppler_freq = doppler_freq = freq
        self.af_samp_rate = af_samp_rate = 9600

        ##################################################
        # Blocks
        ##################################################
        self.sync_to_pdu_0_1_0 = sync_to_pdu(
            packlen=(114 + 32) * 8,
            sync="00011010110011111111110000011101",
            threshold=threshold,
        )
        self.sync_to_pdu_0_1 = sync_to_pdu(
            packlen=(114 + 32) * 8,
            sync="00011010110011111111110000011101",
            threshold=threshold,
        )
        self.sync_to_pdu_0_0_0 = sync_to_pdu(
            packlen=(114 + 32) * 8,
            sync="00011010110011111111110000011101",
            threshold=threshold,
        )
        self.sync_to_pdu_0_0 = sync_to_pdu(
            packlen=(114 + 32) * 8,
            sync="00011010110011111111110000011101",
            threshold=threshold,
        )
        self.sync_to_pdu_0 = sync_to_pdu(
            packlen=(114 + 32) * 8,
            sync="00011010110011111111110000011101",
            threshold=threshold,
        )
        self.sids_submit_0 = sids.submit(
            'http://tlm.pe0sat.nl/tlmdb/frame_db.php', 40908, callsign,
            longitude, latitude, '')
        self.sids_print_timestamp_0 = sids.print_timestamp('%Y-%m-%d %H:%M:%S')
        self.osmosdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " +
                                               'rtl')
        self.osmosdr_source_0.set_sample_rate(rf_samp_rate)
        self.osmosdr_source_0.set_center_freq(freq - offset, 0)
        self.osmosdr_source_0.set_freq_corr(freq_corr, 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(rf_gain, 0)
        self.osmosdr_source_0.set_if_gain(if_gain, 0)
        self.osmosdr_source_0.set_bb_gain(bb_gain, 0)
        self.osmosdr_source_0.set_antenna('', 0)
        self.osmosdr_source_0.set_bandwidth(0, 0)

        self.low_pass_filter_3_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, if_samp_rate, 8e3, 2e3, firdes.WIN_HAMMING,
                            6.76))
        self.low_pass_filter_0 = filter.fir_filter_fff(
            1,
            firdes.low_pass(1, af_samp_rate, 200, 50, firdes.WIN_HAMMING,
                            6.76))
        self.libfec_decode_rs_0_0_0 = libfec.decode_rs(True, 0)
        self.libfec_decode_rs_0_0 = libfec.decode_rs(True, 0)
        self.libfec_decode_rs_0 = libfec.decode_rs(True, 0)
        self.kiss_kiss_to_pdu_0_1 = kiss.kiss_to_pdu(False)
        self.kiss_kiss_to_pdu_0_0 = kiss.kiss_to_pdu(False)
        self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(False)
        self.gpredict_doppler_0 = gpredict.doppler(self.set_doppler_freq,
                                                   "localhost", 4532, False)
        self.freq_xlating_fir_filter_xxx_0_0 = filter.freq_xlating_fir_filter_ccc(
            int(rf_samp_rate / if_samp_rate),
            (filter.firdes.low_pass(1, rf_samp_rate, 10000, 2000)),
            doppler_freq - freq + offset, rf_samp_rate)
        self.freq_xlating_fir_filter_xxx_0 = filter.freq_xlating_fir_filter_ccc(
            int(rf_samp_rate / if_samp_rate),
            (filter.firdes.low_pass(1, rf_samp_rate, 5000, 2000)),
            doppler_freq - freq + offset + 25e3, rf_samp_rate)
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_fff(
            sub_sps, 0.0628, (sub_rrc_taps), sub_nfilts, sub_nfilts / 2, 0.01,
            1)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, 0.100, (rrc_taps), nfilts, nfilts / 2, 1.5, 2)
        self.digital_lms_dd_equalizer_cc_0_0 = digital.lms_dd_equalizer_cc(
            2, 0.3, 2, variable_constellation_0)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            sps, 0.350, 100, 0.1)
        self.digital_diff_decoder_bb_0_0 = digital.diff_decoder_bb(2)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(0.4, 2, False)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            10, 0.25 * 0.175 * 0.175, 0.5, 0.175, 0.005)
        self.digital_binary_slicer_fb_1 = digital.binary_slicer_fb()
        self.dc_blocker_xx_0 = filter.dc_blocker_ff(1024, True)
        self.ccsds_viterbi_0_1 = ccsds_viterbi()
        self.ccsds_viterbi_0_0_0 = ccsds_viterbi()
        self.ccsds_viterbi_0_0 = ccsds_viterbi()
        self.ccsds_viterbi_0 = ccsds_viterbi()
        self.ccsds_descrambler_0_0_0 = ccsds_descrambler()
        self.ccsds_descrambler_0_0 = ccsds_descrambler()
        self.ccsds_descrambler_0 = ccsds_descrambler()
        self.blocks_pdu_to_tagged_stream_0_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_delay_0_0_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_delay_0_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(0.5)
        self.analog_nbfm_rx_0 = analog.nbfm_rx(
            audio_rate=af_samp_rate,
            quad_rate=if_samp_rate,
            tau=75e-6,
            max_dev=3.5e3,
        )
        self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ccsds_descrambler_0, 'out'),
                         (self.libfec_decode_rs_0, 'in'))
        self.msg_connect((self.ccsds_descrambler_0_0, 'out'),
                         (self.libfec_decode_rs_0_0, 'in'))
        self.msg_connect((self.ccsds_descrambler_0_0_0, 'out'),
                         (self.libfec_decode_rs_0_0_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'),
                         (self.sids_print_timestamp_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'),
                         (self.sids_submit_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0_0, 'out'),
                         (self.sids_print_timestamp_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0_0, 'out'),
                         (self.sids_submit_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0_1, 'out'),
                         (self.sids_print_timestamp_0, 'in'))
        self.msg_connect((self.kiss_kiss_to_pdu_0_1, 'out'),
                         (self.sids_submit_0, 'in'))
        self.msg_connect((self.libfec_decode_rs_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.libfec_decode_rs_0_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.libfec_decode_rs_0_0_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_1, 'pdus'))
        self.msg_connect((self.sids_print_timestamp_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.sync_to_pdu_0, 'out'),
                         (self.ccsds_descrambler_0, 'in'))
        self.msg_connect((self.sync_to_pdu_0_0, 'out'),
                         (self.ccsds_descrambler_0_0, 'in'))
        self.msg_connect((self.sync_to_pdu_0_0_0, 'out'),
                         (self.ccsds_descrambler_0_0_0, 'in'))
        self.msg_connect((self.sync_to_pdu_0_1, 'out'),
                         (self.ccsds_descrambler_0_0, 'in'))
        self.msg_connect((self.sync_to_pdu_0_1_0, 'out'),
                         (self.ccsds_descrambler_0_0_0, 'in'))
        self.connect((self.analog_feedforward_agc_cc_0, 0),
                     (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.analog_nbfm_rx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.blocks_delay_0_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.ccsds_viterbi_0_1, 0))
        self.connect((self.blocks_delay_0_0, 0), (self.ccsds_viterbi_0_0_0, 0))
        self.connect((self.blocks_delay_0_0_0, 0), (self.ccsds_viterbi_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.kiss_kiss_to_pdu_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.kiss_kiss_to_pdu_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0),
                     (self.kiss_kiss_to_pdu_0_1, 0))
        self.connect((self.ccsds_viterbi_0, 0), (self.sync_to_pdu_0_1_0, 0))
        self.connect((self.ccsds_viterbi_0_0, 0), (self.sync_to_pdu_0_0_0, 0))
        self.connect((self.ccsds_viterbi_0_0_0, 0),
                     (self.digital_diff_decoder_bb_0_0, 0))
        self.connect((self.ccsds_viterbi_0_1, 0),
                     (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.dc_blocker_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.digital_binary_slicer_fb_1, 0),
                     (self.sync_to_pdu_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.blocks_delay_0_0_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.ccsds_viterbi_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0),
                     (self.sync_to_pdu_0_1, 0))
        self.connect((self.digital_diff_decoder_bb_0_0, 0),
                     (self.sync_to_pdu_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0, 0),
                     (self.digital_costas_loop_cc_0_0, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_binary_slicer_fb_1, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.analog_feedforward_agc_cc_0, 0))
        self.connect((self.freq_xlating_fir_filter_xxx_0_0, 0),
                     (self.low_pass_filter_3_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.dc_blocker_xx_0, 0))
        self.connect((self.low_pass_filter_3_0_0, 0),
                     (self.analog_nbfm_rx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0, 0))
        self.connect((self.osmosdr_source_0, 0),
                     (self.freq_xlating_fir_filter_xxx_0_0, 0))
예제 #49
0
    def __init__(self):
        gr.top_block.__init__(self, "Packet Loopback Hier")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Packet Loopback Hier")
        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.Const_PLD = Const_PLD = digital.constellation_calcdist(
            (digital.psk_4()[0]), (digital.psk_4()[1]), 4, 1).base()

        self.Const_PLD.gen_soft_dec_lut(8)
        self.sps = sps = 2
        self.rep = rep = 3
        self.rate = rate = 2
        self.polys = polys = [109, 79]
        self.nfilts = nfilts = 32
        self.k = k = 7
        self.hdr_format = hdr_format = digital.header_format_counter(
            digital.packet_utils.default_access_code, 3,
            Const_PLD.bits_per_symbol())
        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.rx_rrc_taps = rx_rrc_taps = firdes.root_raised_cosine(
            nfilts, nfilts * sps, 1.0, eb, 11 * sps * nfilts)

        self.noise = noise = 0.0
        self.freq_offset = freq_offset = 0

        self.enc_hdr = enc_hdr = fec.repetition_encoder_make(8000, rep)

        self.enc = enc = fec.cc_encoder_make(8000, k, rate, (polys), 0,
                                             fec.CC_TERMINATED, False)

        self.dec_hdr = dec_hdr = fec.repetition_decoder.make(
            hdr_format.header_nbits(), rep, 0.5)

        self.dec = dec = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1,
                                             fec.CC_TERMINATED, False)

        self.amp = amp = 1.0

        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)
        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)
        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)
        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)
        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)
        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_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)

        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 * 1):
            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_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)

        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 * 1):
            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)
        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)

        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 * 1):
            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_layout_0.addWidget(self._qtgui_time_sink_x_1_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_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_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_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_layout_2.addWidget(self._qtgui_const_sink_x_0_win)
        self.packet_tx_0 = packet_tx(
            hdr_const=Const_HDR,
            hdr_enc=enc_hdr,
            hdr_format=hdr_format,
            pld_const=Const_PLD,
            pld_enc=enc,
            psf_taps=tx_rrc_taps,
            sps=sps,
        )
        self.packet_rx_0 = packet_rx(
            eb=eb,
            hdr_const=Const_HDR,
            hdr_dec=dec_hdr,
            hdr_format=hdr_format,
            pld_const=Const_PLD,
            pld_dec=dec,
            psf_taps=rx_rrc_taps,
            sps=sps,
        )
        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=True)
        self.blocks_random_pdu_0 = blocks.random_pdu(20, 200, chr(0xFF), 2)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((amp, ))
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 100)
        self.blocks_message_debug_0_0_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.blocks_random_pdu_0, 'generate'))
        self.msg_connect((self.blocks_random_pdu_0, 'pdus'),
                         (self.packet_tx_0, 'in'))
        self.msg_connect((self.packet_rx_0, 'pkt out'),
                         (self.blocks_message_debug_0_0_0, 'print_pdu'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.packet_rx_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.blocks_multiply_const_vxx_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.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, 4),
                     (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))
예제 #50
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver Juan")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 15
        self.samp_rate_0 = samp_rate_0 = 20e6
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 5
        self.oversampling = oversampling = 4
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[5e6, 10e6, 20e6],
            labels=["5MHz", "10 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            label='mult',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._mult_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_mult_sizer)
        self._encoding_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.encoding,
            callback=self.set_encoding,
            label="Encoding",
            choices=[0, 1, 2, 3, 4, 5, 6, 7],
            labels=[
                "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
                "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
            ],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=5000,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_gain_sizer,
            value=self.tx_gain,
            callback=self.set_tx_gain,
            label='tx_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_gain_sizer,
            value=self.tx_gain,
            callback=self.set_tx_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tx_gain_sizer)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_gain_sizer,
            value=self.rx_gain,
            callback=self.set_rx_gain,
            label='rx_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_gain_sizer,
            value=self.rx_gain,
            callback=self.set_rx_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rx_gain_sizer)
        self._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e6, 11e6],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0,
                2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0,
                2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0,
                2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0,
                5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0,
                5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0,
                5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0,
                5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0,
                5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0,
                5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0,
                5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0,
                5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0,
                5920000000.0
            ],
            labels=[
                '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
                '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g',
                '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g',
                '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
                '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g',
                ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g',
                ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
                ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a',
                ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a',
                ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
                ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a',
                ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a',
                ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a',
                '100 | 5500.0 | 11a', '104 | 5520.0 | 11a',
                '108 | 5540.0 | 11a', '112 | 5560.0 | 11a',
                '116 | 5580.0 | 11a', '120 | 5600.0 | 11a',
                '124 | 5620.0 | 11a', '128 | 5640.0 | 11a',
                '132 | 5660.0 | 11a', '136 | 5680.0 | 11a',
                '140 | 5700.0 | 11a', '149 | 5745.0 | 11a',
                '153 | 5765.0 | 11a', '157 | 5785.0 | 11a',
                '161 | 5805.0 | 11a', '165 | 5825.0 | 11a',
                '172 | 5860.0 | 11p', '174 | 5870.0 | 11p',
                '176 | 5880.0 | 11p', '178 | 5890.0 | 11p',
                '180 | 5900.0 | 11p', '182 | 5910.0 | 11p',
                '184 | 5920.0 | 11p'
            ],
        )
        self.Add(self._freq_chooser)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=.5**.5,
            frequency_offset=0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "192.168.200.2", 1234, 100,
                                                 True)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_throttle_0 = blocks.throttle(
            gr.sizeof_char * 1,
            2 * 4e3 + 0 * samp_rate / 40 / (oversampling * 8 * 2), True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            "/media/juan/d6aba572-c85c-40cc-9258-ae1538dfb8c5/home/juan/Music/de_mi.mp3",
            True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.ieee802_11_ether_encap_0, 'from tap'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_ofdm_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ofdm_mac_0, 'phy in'))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_udp_sink_0, 0))
        self.connect((self.channels_channel_model_0, 0),
                     (self.wifi_phy_hier_0, 0))
        self.connect((self.foo_packet_pad2_0, 0),
                     (self.channels_channel_model_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))
예제 #51
0
    def __init__(self):
        gr.top_block.__init__(self, "OFDM PU Phy")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("OFDM PU Phy")
        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", "tx_ofdm")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 10e6
        self.taps = taps = filter.firdes.low_pass(1, samp_rate, 0.98e6, 0.5e6)
        self.sync_word2 = sync_word2 = [
            0, 0, 0, 0, 0, 0, -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, 0, 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, 0, 0, 0, 0, 0
        ]
        self.sync_word1 = sync_word1 = [
            0., 0., 0., 0., 0., 0., 0., 1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., -1.41421356, 0., -1.41421356, 0.,
            1.41421356, 0., -1.41421356, 0., 1.41421356, 0., -1.41421356, 0.,
            -1.41421356, 0., -1.41421356, 0., -1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            -1.41421356, 0., 1.41421356, 0., 1.41421356, 0., 1.41421356, 0.,
            0., 0., 0., 0., 0.
        ]
        self.pilot_symbols = pilot_symbols = ((
            1,
            1,
            1,
            -1,
        ), )
        self.pilot_carriers = pilot_carriers = ((
            -21,
            -7,
            7,
            21,
        ), )
        self.packet_len = packet_len = 64
        self.occupied_carriers = occupied_carriers = (
            range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) +
            range(8, 21) + range(22, 27), )
        self.len_tag_key = len_tag_key = "packet_len"
        self.interp_factor = interp_factor = 5
        self.fft_len = fft_len = 64
        self.decim_factor = decim_factor = 1

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            "",  #",".join(("addr=192.168.10.2", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(pu_params.frequency, 0)
        self.uhd_usrp_sink_0.set_gain(15, 0)
        self.uhd_usrp_sink_0.set_antenna(pu_params.antenna, 0)
        self.rational_resampler_xxx_0_0_1_1 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_1_0 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0_1 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0_0 = filter.rational_resampler_ccc(
            interpolation=interp_factor,
            decimation=decim_factor,
            taps=(taps),
            fractional_bw=None,
        )
        self.digital_ofdm_tx_0_2 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_tx_0_1 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_tx_0_0 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        self.digital_ofdm_tx_0 = digital.ofdm_tx(
            fft_len=fft_len,
            cp_len=fft_len / 4,
            packet_length_tag_key=len_tag_key,
            occupied_carriers=occupied_carriers,
            pilot_carriers=pilot_carriers,
            pilot_symbols=pilot_symbols,
            sync_word1=sync_word1,
            sync_word2=sync_word2,
            bps_header=1,
            bps_payload=2,
            rolloff=0,
            debug_log=False,
            scramble_bits=False)
        if type(pu_params.gain) is list and len(pu_params.gain) > 1:
            gain_incr = pu_params.gain[1] - pu_params.gain[0]
            gain_max = pu_params.gain[-1]
            gain_min = pu_params.gain[0]
            static_gain = -1
        else:
            gain_incr = 0
            gain_max = pu_params.gain
            gain_min = pu_params.gain
            static_gain = pu_params.gain
            print "gain range: [", gain_min, ":", gain_incr, ":", gain_max, "]"
        self.dbconnect_pktgen_0 = dbconnect.pktgen(1, packet_len, False, False, False, pu_params.db_ip, 5003, 5, 10, 2, 20, 50, 100, 60000, 0.05, 6643, gain_min, gain_max, pu_params.gain_period, gain_incr,\
        pu_params.scenario,pu_params.channel1,pu_params.channel2,static_gain) # scenario,ch1,ch2,gain. Use -1 for default challenge
        self.dbconnect_pdu_fillpath_cpp_0_0_1 = dbconnect.pdu_fillpath_cpp()
        self.dbconnect_pdu_fillpath_cpp_0_0_0 = dbconnect.pdu_fillpath_cpp()
        self.dbconnect_pdu_fillpath_cpp_0_0 = dbconnect.pdu_fillpath_cpp()
        self.dbconnect_pdu_fillpath_cpp_0 = dbconnect.pdu_fillpath_cpp()
        self.blocks_tagged_stream_to_pdu_0_3_1 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_tagged_stream_to_pdu_0_3_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_tagged_stream_to_pdu_0_3 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(
            blocks.complex_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0_0_1 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")
        self.blocks_multiply_xx_0_3 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_2 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0_1 = blocks.multiply_vcc(1)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.18, ))
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_add_xx_2 = blocks.add_vcc(1)
        self.analog_sig_source_x_0_3 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -3.75e6, 1, 0)
        self.analog_sig_source_x_0_2 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 3.75e6, 1, 0)
        self.analog_sig_source_x_0_1 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1.25e6, 1, 0)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, 1.25e6, 1, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0, 'in0'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0_0, 'in0'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_0, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0_0_0, 'in0'))
        self.msg_connect((self.blocks_tagged_stream_to_pdu_0_3_1, 'pdus'),
                         (self.dbconnect_pdu_fillpath_cpp_0_0_1, 'in0'))
        self.msg_connect((self.dbconnect_pktgen_0, 'cmd'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out0'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out1'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out2'),
                         (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'out3'),
                         (self.blocks_pdu_to_tagged_stream_0_0_1, 'pdus'))
        self.msg_connect((self.dbconnect_pktgen_0, 'cmd'),
                         (self.uhd_usrp_sink_0, 'command'))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.analog_sig_source_x_0_1, 0),
                     (self.blocks_multiply_xx_0_1, 1))
        self.connect((self.analog_sig_source_x_0_2, 0),
                     (self.blocks_multiply_xx_0_2, 1))
        self.connect((self.analog_sig_source_x_0_3, 0),
                     (self.blocks_multiply_xx_0_3, 1))
        self.connect((self.blocks_add_xx_2, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_add_xx_2, 0))
        self.connect((self.blocks_multiply_xx_0_1, 0),
                     (self.blocks_add_xx_2, 1))
        self.connect((self.blocks_multiply_xx_0_2, 0),
                     (self.blocks_add_xx_2, 2))
        self.connect((self.blocks_multiply_xx_0_3, 0),
                     (self.blocks_add_xx_2, 3))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.digital_ofdm_tx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.digital_ofdm_tx_0_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0),
                     (self.digital_ofdm_tx_0_1, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_1, 0),
                     (self.digital_ofdm_tx_0_2, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0, 0),
                     (self.rational_resampler_xxx_0_0, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0_0, 0),
                     (self.rational_resampler_xxx_0_0_1, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_0, 0),
                     (self.rational_resampler_xxx_0_0_1_0, 0))
        self.connect((self.dbconnect_pdu_fillpath_cpp_0_0_1, 0),
                     (self.rational_resampler_xxx_0_0_1_1, 0))
        self.connect((self.digital_ofdm_tx_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0, 0))
        self.connect((self.digital_ofdm_tx_0_0, 0),
                     (self.blocks_tagged_stream_to_pdu_0_3, 0))
        self.connect((self.digital_ofdm_tx_0_1, 0),
                     (self.blocks_tagged_stream_to_pdu_0_3_0, 0))
        self.connect((self.digital_ofdm_tx_0_2, 0),
                     (self.blocks_tagged_stream_to_pdu_0_3_1, 0))
        self.connect((self.rational_resampler_xxx_0_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0_0_1, 0),
                     (self.blocks_multiply_xx_0_1, 0))
        self.connect((self.rational_resampler_xxx_0_0_1_0, 0),
                     (self.blocks_multiply_xx_0_2, 0))
        self.connect((self.rational_resampler_xxx_0_0_1_1, 0),
                     (self.blocks_multiply_xx_0_3, 0))
예제 #52
0
    def __init__(self):
        gr.top_block.__init__(self, "Demod Node 1: BPSK 9k6")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Demod Node 1: BPSK 9k6")
        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", "demod_node1_bpsk_9k6")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 5
        self.nfilts = nfilts = 16
        self.alpha = alpha = 0.35

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_calcdist(
            ([-1, 1]), ([0, 1]), 2, 1).base()

        self.timing_loop_bw = timing_loop_bw = 0.05
        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)
        self.phase_bw = phase_bw = 0.02
        self.fll_bw = fll_bw = 0.01
        self.equalizer_gain = equalizer_gain = 0.05
        self.digigain = digigain = 20

        ##################################################
        # 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, 'Spectrum')
        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, 'Loop')
        self.top_grid_layout.addWidget(self.tab, 2, 0, 1, 2)
        self._timing_loop_bw_range = Range(0.0, 0.2, 0.01, 0.05, 200)
        self._timing_loop_bw_win = RangeWidget(self._timing_loop_bw_range,
                                               self.set_timing_loop_bw,
                                               'Time: Bandwidth',
                                               "counter_slider", float)
        self.tab_grid_layout_1.addWidget(self._timing_loop_bw_win, 1, 0)
        self._phase_bw_range = Range(0.0, 1.0, 0.01, 0.02, 200)
        self._phase_bw_win = RangeWidget(self._phase_bw_range,
                                         self.set_phase_bw, 'Phase: Bandwidth',
                                         "counter_slider", float)
        self.tab_grid_layout_1.addWidget(self._phase_bw_win, 2, 0)
        self._fll_bw_range = Range(0.0, 0.2, 0.001, 0.01, 200)
        self._fll_bw_win = RangeWidget(self._fll_bw_range, self.set_fll_bw,
                                       'FLL: Bandwidth', "counter_slider",
                                       float)
        self.tab_grid_layout_1.addWidget(self._fll_bw_win, 0, 0)
        self._equalizer_gain_range = Range(0.0, 0.2, 0.01, 0.05, 200)
        self._equalizer_gain_win = RangeWidget(self._equalizer_gain_range,
                                               self.set_equalizer_gain,
                                               'Equalizer: Gain',
                                               "counter_slider", float)
        self.tab_grid_layout_1.addWidget(self._equalizer_gain_win, 3, 0)
        self._digigain_tool_bar = Qt.QToolBar(self)
        self._digigain_tool_bar.addWidget(Qt.QLabel("digigain" + ": "))
        self._digigain_line_edit = Qt.QLineEdit(str(self.digigain))
        self._digigain_tool_bar.addWidget(self._digigain_line_edit)
        self._digigain_line_edit.returnPressed.connect(
            lambda: self.set_digigain(
                eng_notation.str_to_num(
                    str(self._digigain_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._digigain_tool_bar, 0, 0)
        self.qtgui_number_sink_0 = qtgui.number_sink(gr.sizeof_float, 0.001,
                                                     qtgui.NUM_GRAPH_NONE, 1)
        self.qtgui_number_sink_0.set_update_time(0.10)
        self.qtgui_number_sink_0.set_title('')

        labels = ['RSSI', '', '', '', '', '', '', '', '', '']
        units = ['', '', '', '', '', '', '', '', '', '']
        colors = [("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black"), ("black", "black"), ("black", "black"),
                  ("black", "black")]
        factor = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        for i in xrange(1):
            self.qtgui_number_sink_0.set_min(i, -1)
            self.qtgui_number_sink_0.set_max(i, 1)
            self.qtgui_number_sink_0.set_color(i, colors[i][0], colors[i][1])
            if len(labels[i]) == 0:
                self.qtgui_number_sink_0.set_label(i, "Data {0}".format(i))
            else:
                self.qtgui_number_sink_0.set_label(i, labels[i])
            self.qtgui_number_sink_0.set_unit(i, units[i])
            self.qtgui_number_sink_0.set_factor(i, factor[i])

        self.qtgui_number_sink_0.enable_autoscale(False)
        self._qtgui_number_sink_0_win = sip.wrapinstance(
            self.qtgui_number_sink_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_number_sink_0_win, 0, 1)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            48e3,  #bw
            "",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-100, 0)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.tab_layout_0.addWidget(self._qtgui_freq_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(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['A', 'B', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_const_sink_x_0_win, 1, 0, 1,
                                       2)
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 10e3, 2e3, firdes.WIN_HAMMING, 6.76))
        self.lilacsat_vitfilt27_fb_0_0 = lilacsat.vitfilt27_fb()
        self.lilacsat_vitfilt27_fb_0 = lilacsat.vitfilt27_fb()
        self.lilacsat_plan13_cc_0 = lilacsat.plan13_cc(True, tle_line1,
                                                       tle_line2, lon, lat,
                                                       alt, 437200000,
                                                       samp_rate, False, True)
        self.lilacsat_kiss_decode_pdu_0 = lilacsat.kiss_decode_pdu()
        self.lilacsat_fec_decode_b_0_0_0 = lilacsat.fec_decode_b(
            114, True, False, False)
        self.lilacsat_fec_decode_b_0_0 = lilacsat.fec_decode_b(
            114, True, False, False)
        self.digital_pfb_clock_sync_xxx_0 = digital.pfb_clock_sync_ccf(
            sps, timing_loop_bw, (rrc_taps), nfilts, nfilts / 2, 0.05, 2)
        self.digital_lms_dd_equalizer_cc_0_0 = digital.lms_dd_equalizer_cc(
            2, equalizer_gain, 2, variable_constellation_0)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(
            sps, alpha, 100, fll_bw)
        self.digital_costas_loop_cc_0_0 = digital.costas_loop_cc(
            phase_bw, 2, False)
        self.blocks_unpack_k_bits_bb_0_0_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_unpack_k_bits_bb_0_0_0 = blocks.unpack_k_bits_bb(8)
        self.blocks_udp_source_0 = blocks.udp_source(gr.sizeof_gr_complex * 1,
                                                     '127.0.0.1', 7200, 1472,
                                                     False)
        self.blocks_rms_xx_0 = blocks.rms_cf(0.0001)
        self.blocks_nlog10_ff_0 = blocks.nlog10_ff(20, 1, 0)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (10**(digigain / 20), ))
        self.blocks_message_debug_1 = blocks.message_debug()
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 1)
        self.blocks_complex_to_real_0 = blocks.complex_to_real(1)
        self.analog_feedforward_agc_cc_0 = analog.feedforward_agc_cc(1024, 2)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.lilacsat_fec_decode_b_0_0, 'out'),
                         (self.lilacsat_kiss_decode_pdu_0, 'in'))
        self.msg_connect((self.lilacsat_fec_decode_b_0_0_0, 'out'),
                         (self.lilacsat_kiss_decode_pdu_0, 'in'))
        self.msg_connect((self.lilacsat_kiss_decode_pdu_0, 'out'),
                         (self.blocks_message_debug_1, 'print_pdu'))
        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_delay_0, 0))
        self.connect((self.blocks_complex_to_real_0, 0),
                     (self.lilacsat_vitfilt27_fb_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.lilacsat_vitfilt27_fb_0_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.lilacsat_plan13_cc_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        self.connect((self.blocks_nlog10_ff_0, 0),
                     (self.qtgui_number_sink_0, 0))
        self.connect((self.blocks_rms_xx_0, 0), (self.blocks_nlog10_ff_0, 0))
        self.connect((self.blocks_udp_source_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0_0, 0),
                     (self.lilacsat_fec_decode_b_0_0_0, 0))
        self.connect((self.blocks_unpack_k_bits_bb_0_0_0_0, 0),
                     (self.lilacsat_fec_decode_b_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0_0, 0),
                     (self.digital_lms_dd_equalizer_cc_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0),
                     (self.qtgui_freq_sink_x_0, 1))
        self.connect((self.digital_lms_dd_equalizer_cc_0_0, 0),
                     (self.blocks_complex_to_real_0, 0))
        self.connect((self.digital_lms_dd_equalizer_cc_0_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, 0))
        self.connect((self.lilacsat_plan13_cc_0, 0),
                     (self.low_pass_filter_0, 0))
        self.connect((self.lilacsat_vitfilt27_fb_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0_0, 0))
        self.connect((self.lilacsat_vitfilt27_fb_0_0, 0),
                     (self.blocks_unpack_k_bits_bb_0_0_0_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_feedforward_agc_cc_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.blocks_rms_xx_0, 0))
예제 #53
0
    def __init__(self, fc=436e6, mx=4, my=4, n=1):
        gr.top_block.__init__(self, "DoA Esprit Estimation - Test")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("DoA Esprit Estimation - Test")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "doaesprit_test")

        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

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.mx = mx
        self.my = my
        self.n = n

        ##################################################
        # Variables
        ##################################################
        self.const = const = digital.constellation_qpsk().base()
        self.theta = theta = 45
        self.samp_rate = samp_rate = 150000
        self.phi = phi = 70
        self.noise_voltage = noise_voltage = 0
        self.element_separation = element_separation = 0
        self.bps = bps = const.bits_per_symbol()

        ##################################################
        # Blocks
        ##################################################
        self._theta_range = Range(0, 90, 1, 45, 200)
        self._theta_win = RangeWidget(self._theta_range, self.set_theta, 'Elevation Angle', "counter_slider", float)
        self.top_grid_layout.addWidget(self._theta_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._phi_range = Range(-180, 180, 1, 70, 200)
        self._phi_win = RangeWidget(self._phi_range, self.set_phi, 'Azimut Angle', "counter_slider", float)
        self.top_grid_layout.addWidget(self._phi_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._noise_voltage_range = Range(0, 10, 0.001, 0, 200)
        self._noise_voltage_win = RangeWidget(self._noise_voltage_range, self.set_noise_voltage, 'Noise Voltage', "counter_slider", float)
        self.top_grid_layout.addWidget(self._noise_voltage_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._element_separation_range = Range(0, 10, 0.01, 0, 200)
        self._element_separation_win = RangeWidget(self._element_separation_range, self.set_element_separation, 'Element separation distance [%', "counter_slider", float)
        self.top_grid_layout.addWidget(self._element_separation_win, 5, 0, 1, 1)
        for r in range(5, 6):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            128, #size
            samp_rate, #samp_rate
            "", #name
            1 #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(0.10)
        self.qtgui_time_sink_x_0_0.set_y_axis(-1, 1)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0_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(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            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, 6, 0, 1, 1)
        for r in range(6, 7):
            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 = qtgui.time_sink_c(
            128, #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(True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(True)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        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(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2))
                else:
                    self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2))
            else:
                self.qtgui_time_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_time_sink_x_0_win, 7, 0, 1, 1)
        for r in range(7, 8):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            1024, #size
            "", #name
            1 #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)


        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 range(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, 8, 0, 1, 1)
        for r in range(8, 9):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 1):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(0, 10000, 0.001)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(const.base())
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(const.points(), 1)
        self.blocks_unpacked_to_packed_xx_0 = blocks.unpacked_to_packed_bb(bps, gr.GR_MSB_FIRST)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True)
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(bps, gr.GR_MSB_FIRST)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_char*1, '/home/grigosback/Documents/GNURadio/examples/source.txt', True, 0, 0)
        self.blocks_file_source_0_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, '/home/grigosback/Documents/GNURadio/examples/sink.txt', False)
        self.blocks_file_sink_0_0.set_unbuffered(False)
        self.blocks_add_xx_0 = blocks.add_vcc(mx*my)
        self.beamforming_randomsampler_0 = beamforming.randomsampler(mx*my, 8)
        self.beamforming_phasedarray_0 = beamforming.phasedarray(mx, my, theta, phi, 436e6, (299792458/(2*fc)), element_separation)
        self.beamforming_doaesprit_py_cf_0 = beamforming.doaesprit_py_cf(mx, my, fc, (299792458/(2*fc)), n, 128)
        self.beamforming_beamformer_0 = beamforming.beamformer(mx, my, 0)
        self.analog_vectornoise_source_0 = analog.vectornoise_source(noise_voltage, mx*my)



        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.beamforming_doaesprit_py_cf_0, 'doa_port'), (self.beamforming_beamformer_0, 'doa_port'))
        self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'), (self.blocks_message_debug_0, 'print'))
        self.connect((self.analog_vectornoise_source_0, 0), (self.blocks_add_xx_0, 1))
        self.connect((self.beamforming_beamformer_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.beamforming_beamformer_0, 0), (self.digital_probe_mpsk_snr_est_c_0, 0))
        self.connect((self.beamforming_beamformer_0, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.beamforming_beamformer_0, 0), (self.qtgui_time_sink_x_0, 0))
        self.connect((self.beamforming_phasedarray_0, 0), (self.blocks_add_xx_0, 0))
        self.connect((self.beamforming_randomsampler_0, 0), (self.beamforming_doaesprit_py_cf_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.beamforming_beamformer_0, 0))
        self.connect((self.blocks_add_xx_0, 0), (self.beamforming_randomsampler_0, 0))
        self.connect((self.blocks_file_source_0_0, 0), (self.blocks_throttle_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_unpacked_to_packed_xx_0, 0), (self.blocks_file_sink_0_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.beamforming_phasedarray_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0), (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.blocks_unpacked_to_packed_xx_0, 0))
예제 #54
0
    def __init__(self, baudrate=9600, costas_loop_bw=2*math.pi/200, excess_bw=0.5, fll_loop_bw=2*math.pi/350, max_cfo=4e3, rf_samp_rate=2.4e6, symbol_Sync_loop_bw=2*math.pi/100):
        gr.hier_block2.__init__(self,
            "bpsk_ax25_demod",
            gr.io_signature(1, 1, gr.sizeof_gr_complex),  # Input signature
            gr.io_signaturev(3, 3, [gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1, gr.sizeof_gr_complex*1])
            ) # Output signature

        self.message_port_register_hier_out("out")
        
        ##################################################
        # Parameters
        ##################################################
        self.baudrate = baudrate
        self.costas_loop_bw = costas_loop_bw
        self.excess_bw = excess_bw
        self.fll_loop_bw = fll_loop_bw
        self.max_cfo = max_cfo
        self.rf_samp_rate = rf_samp_rate
        self.symbol_Sync_loop_bw = symbol_Sync_loop_bw

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 9600*20
        self.sps = sps = int(samp_rate/baudrate)
        self.nfilts = nfilts = 64
        self.rrc_taps = rrc_taps = firdes.root_raised_cosine(nfilts, nfilts, 1.0/float(sps), excess_bw, 11*sps*nfilts)

        self.bpsk_constellation = bpsk_constellation = digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf(
        	  samp_rate/rf_samp_rate,
                  taps=None,
        	  flt_size=32)
        self.pfb_arb_resampler_xxx_0.declare_sample_delay(0)

        self.low_pass_filter_0_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, ((1.0 + excess_bw) * baudrate/2.0) + min(baudrate, abs(1000*1.2)), baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.interp_fir_filter_ccf(1, firdes.low_pass(
        	1, samp_rate, (max_cfo+baudrate/2), baudrate / 10.0, firdes.WIN_HAMMING, 6.76))
        self.hsl_rms_agc_0 = hsl.rms_agc(alpha=1e-2, reference=0.5, )
        self.hsl_kiss_encoder_0 = hsl.kiss_encoder()
        self.digital_symbol_sync_xx_0_0 = digital.symbol_sync_cc(digital.TED_SIGNUM_TIMES_SLOPE_ML, sps, symbol_Sync_loop_bw, 1/math.sqrt(2.0), 1, 2*math.pi/100, 1, digital.constellation_bpsk().base(), digital.IR_PFB_MF, nfilts, (rrc_taps))
        self.digital_hdlc_deframer_bp_0_0 = digital.hdlc_deframer_bp(15, 500)
        self.digital_hdlc_deframer_bp_0 = digital.hdlc_deframer_bp(15, 500)
        self.digital_fll_band_edge_cc_0 = digital.fll_band_edge_cc(sps, excess_bw, 300, fll_loop_bw)
        self.digital_diff_decoder_bb_0 = digital.diff_decoder_bb(2)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(costas_loop_bw, 2, False)
        self.digital_constellation_decoder_cb_0 = digital.constellation_decoder_cb(bpsk_constellation)
        self.blocks_not_xx_0_0_0 = blocks.not_bb()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_and_const_xx_0_0_0 = blocks.and_const_bb(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0, 'out'), (self.hsl_kiss_encoder_0, 'packet'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.digital_hdlc_deframer_bp_0_0, 'out'), (self.hsl_kiss_encoder_0, 'packet'))
        self.msg_connect((self.hsl_kiss_encoder_0, 'encoded_packet'), (self, 'out'))
        self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_descrambler_bb_0, 0))
        self.connect((self.blocks_and_const_xx_0_0_0, 0), (self.digital_hdlc_deframer_bp_0_0, 0))
        self.connect((self.blocks_not_xx_0_0_0, 0), (self.blocks_and_const_xx_0_0_0, 0))
        self.connect((self.digital_constellation_decoder_cb_0, 0), (self.digital_diff_decoder_bb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.digital_symbol_sync_xx_0_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self, 1))
        self.connect((self.digital_descrambler_bb_0, 0), (self.digital_hdlc_deframer_bp_0, 0))
        self.connect((self.digital_diff_decoder_bb_0, 0), (self.blocks_not_xx_0_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self.low_pass_filter_0_0_0, 0))
        self.connect((self.digital_fll_band_edge_cc_0, 0), (self, 2))
        self.connect((self.digital_symbol_sync_xx_0_0, 0), (self.digital_constellation_decoder_cb_0, 0))
        self.connect((self.digital_symbol_sync_xx_0_0, 0), (self, 0))
        self.connect((self.hsl_rms_agc_0, 0), (self.low_pass_filter_0_0, 0))
        self.connect((self.low_pass_filter_0, 0), (self.hsl_rms_agc_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.digital_fll_band_edge_cc_0, 0))
        self.connect((self.low_pass_filter_0_0_0, 0), (self.digital_costas_loop_cc_0, 0))
        self.connect((self, 0), (self.pfb_arb_resampler_xxx_0, 0))
        self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.low_pass_filter_0, 0))
예제 #55
0
파일: top_block.py 프로젝트: jkbecker/snout
    def __init__(self, channel=11, tx_gain=90):
        gr.top_block.__init__(self, "Top Block")

        ##################################################
        # Parameters
        ##################################################
        self.channel = channel
        self.tx_gain = tx_gain

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 4000000

        ##################################################
        # Blocks
        ##################################################
        self.zigbee_preamble_prefixer_scapy_0 = zigbee.preamble_prefixer_scapy(
        )
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ('localhost', 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            1000000 * (2400 + 5 * (channel - 10)), 0)
        self.uhd_usrp_source_0.set_gain(40, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.uhd_usrp_source_0.set_auto_dc_offset(False, 0)
        self.uhd_usrp_source_0.set_auto_iq_balance(False, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(('', "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            1000000 * (2400 + 5 * (channel - 10)), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna('TX\\RX', 0)
        self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(
            0.00016, 1)
        self.rftap_rftap_encap_0 = rftap.rftap_encap(2, 195, '')
        self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10)
        self.epy_block_0 = epy_block_0.blk()
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            2, 0.000225, 0.5, 0.03, 0.0002)
        self.digital_chunks_to_symbols_xx_0 = digital.chunks_to_symbols_bc(
            ([(1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
              (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
              (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 - 1j), (-1 - 1j),
              (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
              (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
              (1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
              (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
              (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
              (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
              (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
              (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
              (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
              (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
              (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
              (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
              (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
              (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j),
              (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
              (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
              (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j),
              (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j),
              (1 + 1j), (-1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
              (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (-1 - 1j), (1 + 1j),
              (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
              (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j),
              (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
              (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (-1 - 1j), (1 + 1j),
              (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j),
              (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j),
              (1 + 1j), (-1 - 1j), (-1 + 1j), (1 - 1j), (-1 - 1j), (-1 - 1j),
              (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j),
              (1 - 1j), (-1 - 1j), (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j),
              (-1 - 1j), (1 - 1j), (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j),
              (1 + 1j), (-1 + 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
              (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 + 1j), (1 + 1j),
              (-1 + 1j), (1 + 1j), (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j),
              (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
              (-1 - 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (1 + 1j), (-1 - 1j),
              (-1 - 1j), (1 + 1j), (-1 + 1j), (-1 + 1j), (-1 - 1j), (1 - 1j),
              (-1 - 1j), (1 - 1j), (1 + 1j), (1 - 1j), (1 + 1j), (-1 + 1j),
              (1 + 1j), (-1 - 1j), (1 - 1j), (-1 + 1j), (-1 + 1j), (1 - 1j),
              (-1 - 1j), (-1 - 1j), (-1 + 1j), (1 + 1j), (-1 + 1j), (1 + 1j),
              (1 - 1j), (1 + 1j), (1 - 1j), (-1 - 1j)]), 16)
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc(
            (([])), 0, 4, False, "pdu_length")
        self.blocks_vector_source_x_0 = blocks.vector_source_c(
            [0, sin(pi / 4), 1, sin(3 * pi / 4)], True, 1, [])
        self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(
            gr.sizeof_gr_complex * 1, 'pdu_length', 128)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0_0_0 = blocks.socket_pdu(
            "UDP_CLIENT", '127.0.0.1', '52002', 10000, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '127.0.0.1',
                                                     '52001', 10000, False)
        self.blocks_repeat_0 = blocks.repeat(gr.sizeof_gr_complex * 1, 4)
        self.blocks_pdu_to_tagged_stream_0_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'pdu_length')
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            4, gr.GR_LSB_FIRST)
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_message_debug_0_0 = blocks.message_debug()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_float_to_complex_0 = blocks.float_to_complex(1)
        self.blocks_delay_0 = blocks.delay(gr.sizeof_float * 1, 2)
        self.blocks_complex_to_float_0 = blocks.complex_to_float(1)
        self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(1)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.zigbee_preamble_prefixer_scapy_0, 'in'))
        self.msg_connect((self.epy_block_0, 'out'),
                         (self.rftap_rftap_encap_0, 'in'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'),
                         (self.epy_block_0, 'in'))
        self.msg_connect((self.rftap_rftap_encap_0, 'out'),
                         (self.blocks_socket_pdu_0_0_0, 'pdus'))
        self.msg_connect((self.zigbee_preamble_prefixer_scapy_0, 'out'),
                         (self.blocks_message_debug_0_0, 'print_pdu'))
        self.msg_connect((self.zigbee_preamble_prefixer_scapy_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus'))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_0, 0),
                     (self.single_pole_iir_filter_xx_0, 0))
        self.connect((self.blocks_complex_to_float_0, 1),
                     (self.blocks_delay_0, 0))
        self.connect((self.blocks_complex_to_float_0, 0),
                     (self.blocks_float_to_complex_0, 0))
        self.connect((self.blocks_delay_0, 0),
                     (self.blocks_float_to_complex_0, 1))
        self.connect((self.blocks_float_to_complex_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.blocks_tagged_stream_multiply_length_0, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.digital_chunks_to_symbols_xx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.blocks_tagged_stream_multiply_length_0, 0),
                     (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0),
                     (self.blocks_complex_to_float_0, 0))
        self.connect((self.digital_chunks_to_symbols_xx_0, 0),
                     (self.blocks_repeat_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.ieee802_15_4_packet_sink_0, 0))
        self.connect((self.single_pole_iir_filter_xx_0, 0),
                     (self.blocks_sub_xx_0, 1))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.analog_quadrature_demod_cf_0, 0))
예제 #56
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_idle")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_idle")
        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", "Test_idle")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.samp_rate = samp_rate = 320000
        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 0
        self.experiment_duration_s = experiment_duration_s = 1000
        self.develop_mode = develop_mode = 2
        self.destination_address = destination_address = 3
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'frame_type':
            2,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            0,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            0
        })

        ##################################################
        # Blocks
        ##################################################
        self.inets_null_message_source_0 = inets.null_message_source()
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle(
            2, 1, experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost',
                                                     '52001', 10000, False)
        self.blocks_message_strobe_random_0_0_0 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 0)
        self.blocks_message_strobe_random_0_0 = blocks.message_strobe_random(
            another_ack_info, blocks.STROBE_POISSON, 2000, 0)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.inets_idle_0, 'successful_transmission'),
                         (self.inets_message_tomb_0, 'message_in'))
        self.msg_connect(
            (self.inets_null_message_source_0, 'null_message_out'),
            (self.inets_idle_0, 'reset_idle'))
예제 #57
0
    def __init__(self,
                 center_freq=401.12e6,
                 lpf_cutoff=24e3,
                 lpf_cutoff_2=7.2e3,
                 lpf_trans=1e3):
        gr.top_block.__init__(self, "Burst Rx Gmsk")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Burst Rx Gmsk")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "burst_rx_gmsk")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.center_freq = center_freq
        self.lpf_cutoff = lpf_cutoff
        self.lpf_cutoff_2 = lpf_cutoff_2
        self.lpf_trans = lpf_trans

        ##################################################
        # Variables
        ##################################################
        self.samp_rate = samp_rate = 250000
        self.interp_2 = interp_2 = 1
        self.interp = interp = 24 * 2
        self.decim_2 = decim_2 = 2
        self.decim = decim = int(samp_rate / 2000)
        self.baud = baud = 9600
        self.samps_per_symb = samps_per_symb = int(
            (samp_rate / decim * interp / decim_2 * interp_2) / baud)
        self.offset = offset = 0
        self.fsk_dev = fsk_dev = 10000
        self.avg_len_snr = avg_len_snr = 100.0
        self.avg_len_det = avg_len_det = 100.0

        ##################################################
        # Blocks
        ##################################################
        self._offset_tool_bar = Qt.QToolBar(self)
        self._offset_tool_bar.addWidget(Qt.QLabel("offset" + ": "))
        self._offset_line_edit = Qt.QLineEdit(str(self.offset))
        self._offset_tool_bar.addWidget(self._offset_line_edit)
        self._offset_line_edit.returnPressed.connect(lambda: self.set_offset(
            eng_notation.str_to_num(
                str(self._offset_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._offset_tool_bar, 2, 4, 1, 1)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 5):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._avg_len_snr_tool_bar = Qt.QToolBar(self)
        self._avg_len_snr_tool_bar.addWidget(Qt.QLabel("avg_len_snr" + ": "))
        self._avg_len_snr_line_edit = Qt.QLineEdit(str(self.avg_len_snr))
        self._avg_len_snr_tool_bar.addWidget(self._avg_len_snr_line_edit)
        self._avg_len_snr_line_edit.returnPressed.connect(
            lambda: self.set_avg_len_snr(
                eng_notation.str_to_num(
                    str(self._avg_len_snr_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._avg_len_snr_tool_bar, 3, 6, 1, 2)
        for r in range(3, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self._avg_len_det_tool_bar = Qt.QToolBar(self)
        self._avg_len_det_tool_bar.addWidget(Qt.QLabel("avg_len_det" + ": "))
        self._avg_len_det_line_edit = Qt.QLineEdit(str(self.avg_len_det))
        self._avg_len_det_tool_bar.addWidget(self._avg_len_det_line_edit)
        self._avg_len_det_line_edit.returnPressed.connect(
            lambda: self.set_avg_len_det(
                eng_notation.str_to_num(
                    str(self._avg_len_det_line_edit.text().toAscii()))))
        self.top_grid_layout.addWidget(self._avg_len_det_tool_bar, 2, 6, 1, 2)
        for r in range(2, 3):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(6, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.vcc_vstp_aggregator_simple_0 = vcc.vstp_aggregator_simple(
            fc=center_freq, l_type="downlink", d_type="live")
        self.vcc_trigger_timestamp_pdu_0 = vcc.trigger_timestamp_pdu(
            threshold=-2)
        self.vcc_qt_hex_text_0 = vcc.qt_hex_text()
        self._vcc_qt_hex_text_0_win = self.vcc_qt_hex_text_0
        self.top_grid_layout.addWidget(self._vcc_qt_hex_text_0_win, 4, 0, 1, 4)
        for r in range(4, 5):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.vcc_burst_snr_0 = vcc.burst_snr(int(avg_len_snr),
                                             samp_rate * interp / decim / baud)
        self.vcc_burst_cfo_est_gmsk_0 = vcc.burst_cfo_est_gmsk(samp_rate *
                                                               interp / decim)
        self.rational_resampler_xxx_1_0 = filter.rational_resampler_ccc(
            interpolation=interp_2,
            decimation=decim_2,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_1 = filter.rational_resampler_ccc(
            interpolation=interp_2,
            decimation=decim_2,
            taps=None,
            fractional_bw=None,
        )
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=interp,
            decimation=decim,
            taps=None,
            fractional_bw=None,
        )
        self.qtgui_waterfall_sink_x_0 = qtgui.waterfall_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_waterfall_sink_x_0.set_update_time(0.0010)
        self.qtgui_waterfall_sink_x_0.enable_grid(True)
        self.qtgui_waterfall_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_waterfall_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_waterfall_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        colors = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_waterfall_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_waterfall_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_waterfall_sink_x_0.set_color_map(i, colors[i])
            self.qtgui_waterfall_sink_x_0.set_line_alpha(i, alphas[i])

        self.qtgui_waterfall_sink_x_0.set_intensity_range(-100, 20)

        self._qtgui_waterfall_sink_x_0_win = sip.wrapinstance(
            self.qtgui_waterfall_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_waterfall_sink_x_0_win, 2,
                                       0, 2, 4)
        for r in range(2, 4):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1_0 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate / decim * interp,  #bw
            "RX Spectrum",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_1_0.set_update_time(0.0010)
        self.qtgui_freq_sink_x_1_0.set_y_axis(-150, 0)
        self.qtgui_freq_sink_x_1_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0,
                                                    0, "")
        self.qtgui_freq_sink_x_1_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_1_0.enable_grid(True)
        self.qtgui_freq_sink_x_1_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1_0.enable_control_panel(False)

        if not False:
            self.qtgui_freq_sink_x_1_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1_0.set_plot_pos_half(not True)

        labels = ['pre-d', 'agc_filt', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1_0.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_0_win, 0, 0,
                                       2, 4)
        for r in range(0, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(0, 4):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.qtgui_freq_sink_x_1 = qtgui.freq_sink_c(
            2048,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate * interp / decim * interp_2 / decim_2,  #bw
            "Burst RX Spectrum",  #name
            2  #number of inputs
        )
        self.qtgui_freq_sink_x_1.set_update_time(0.10)
        self.qtgui_freq_sink_x_1.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_1.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_1.enable_autoscale(True)
        self.qtgui_freq_sink_x_1.enable_grid(True)
        self.qtgui_freq_sink_x_1.set_fft_average(1.0)
        self.qtgui_freq_sink_x_1.enable_axis_labels(True)
        self.qtgui_freq_sink_x_1.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_1.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_1.set_plot_pos_half(not True)

        labels = ['orig', 'corr', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(2):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_1.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_1.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_1.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_1.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_1.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_1_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_1.pyqwidget(), Qt.QWidget)
        self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_1_win, 0, 4, 1,
                                       4)
        for r in range(0, 1):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 8):
            self.top_grid_layout.setColumnStretch(c, 1)
        self.pyqt_meta_text_output_0 = pyqt.meta_text_output()
        self._pyqt_meta_text_output_0_win = self.pyqt_meta_text_output_0
        self.top_grid_layout.addWidget(self._pyqt_meta_text_output_0_win, 1, 7,
                                       1, 1)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(7, 8):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.pyqt_ctime_plot_0 = pyqt.ctime_plot('')
        self._pyqt_ctime_plot_0_win = self.pyqt_ctime_plot_0
        self.top_grid_layout.addWidget(self._pyqt_ctime_plot_0_win, 1, 4, 1, 3)
        for r in range(1, 2):
            self.top_grid_layout.setRowStretch(r, 1)
        for c in range(4, 7):
            self.top_grid_layout.setColumnStretch(c, 1)

        self.pdu_utils_extract_metadata_0_0 = pdu_utils.extract_metadata(
            pmt.intern("snr"), 1.0, 0.0)
        self.pdu_utils_extract_metadata_0 = pdu_utils.extract_metadata(
            pmt.intern("cfo_est"), 1.0, 0.0)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim * interp / decim_2 * interp_2,
                            lpf_cutoff_2, lpf_trans, firdes.WIN_HAMMING, 6.76))
        self.low_pass_filter_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate / decim * interp, lpf_cutoff,
                            lpf_trans, firdes.WIN_HAMMING, 6.76))
        self.kiss_pdu_to_kiss_0 = kiss.pdu_to_kiss()
        self.kiss_nrzi_decode_0 = kiss.nrzi_decode()
        self.kiss_hdlc_deframer_0 = kiss.hdlc_deframer(check_fcs=True,
                                                       max_length=300)
        self.es_trigger_edge_f_0 = es.trigger_edge_f(-2, baud * samps_per_symb,
                                                     int(avg_len_det * 2),
                                                     gr.sizeof_gr_complex, 300)
        self.es_sink_0 = es.sink(1 * [gr.sizeof_gr_complex], 4, 64, 0, 2, 0)
        self.es_handler_pdu_0 = es.es_make_handler_pdu(
            es.es_handler_print.TYPE_C32)
        self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16)
        self.digital_clock_recovery_mm_xx_0 = digital.clock_recovery_mm_ff(
            samps_per_symb * (1 + 0.0), 0.25 * 0.175 * 0.175, 0.25, 0.175,
            0.005)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.burst_length_detect_c_0 = burst.length_detect_c()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate * 8, True)
        self.blocks_sub_xx_0 = blocks.sub_ff(1)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", '127.0.0.1',
                                                     '52001', 10000, False)
        self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_float * 1, 1)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'est_len')
        (self.blocks_pdu_to_tagged_stream_0_0).set_min_output_buffer(48000)
        self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'est_len')
        (self.blocks_pdu_to_tagged_stream_0).set_min_output_buffer(48000)
        self.blocks_pdu_remove_0 = blocks.pdu_remove(
            pmt.intern("es::event_buffer"))
        self.blocks_multiply_xx_0 = blocks.multiply_vcc(1)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((-1, ))
        self.blocks_moving_average_xx_0 = blocks.moving_average_ff(
            int(avg_len_det), 1 / avg_len_det, 4000, 1)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_gr_complex * 1,
            '/home/zleffke/captures/lithium_20180327/downlink_data_1.fc32',
            True)
        self.blocks_file_source_0.set_begin_tag(pmt.PMT_NIL)
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((3, ))
        self.blocks_abs_xx_0 = blocks.abs_ff(1)
        self.analog_sig_source_x_0 = analog.sig_source_c(
            samp_rate, analog.GR_COS_WAVE, -1 * offset, 1, 0)
        self.analog_quadrature_demod_cf_1_0 = analog.quadrature_demod_cf(
            (samp_rate / decim * interp / decim_2 * interp_2) /
            (2 * math.pi * fsk_dev / 8.0))
        self.analog_quadrature_demod_cf_1 = analog.quadrature_demod_cf(
            (samp_rate / decim * interp) / (2 * math.pi * fsk_dev / 8.0))
        self.analog_agc2_xx_0 = analog.agc2_cc(10, 1e-1, 65536, 1)
        self.analog_agc2_xx_0.set_max_gain(65536)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_pdu_remove_0, 'pdus'),
                         (self.burst_length_detect_c_0, 'cpdus'))
        self.msg_connect((self.burst_length_detect_c_0, 'cpdus'),
                         (self.vcc_burst_snr_0, 'in'))
        self.msg_connect((self.es_handler_pdu_0, 'pdus_out'),
                         (self.blocks_pdu_remove_0, 'pdus'))
        self.msg_connect((self.es_trigger_edge_f_0, 'edge_event'),
                         (self.es_handler_pdu_0, 'handle_event'))
        self.msg_connect((self.es_trigger_edge_f_0, 'which_stream'),
                         (self.es_sink_0, 'schedule_event'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.kiss_pdu_to_kiss_0, 'in'))
        self.msg_connect((self.kiss_hdlc_deframer_0, 'out'),
                         (self.vcc_vstp_aggregator_simple_0, 'raw'))
        self.msg_connect((self.kiss_pdu_to_kiss_0, 'out'),
                         (self.vcc_qt_hex_text_0, 'pdus'))
        self.msg_connect((self.pdu_utils_extract_metadata_0, 'msg'),
                         (self.vcc_vstp_aggregator_simple_0, 'meta'))
        self.msg_connect((self.pdu_utils_extract_metadata_0_0, 'msg'),
                         (self.vcc_vstp_aggregator_simple_0, 'meta'))
        self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'out'),
                         (self.blocks_pdu_to_tagged_stream_0, 'pdus'))
        self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'corrected'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'corrected'),
                         (self.pdu_utils_extract_metadata_0, 'dict'))
        self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'out'),
                         (self.pyqt_ctime_plot_0, 'cpdus'))
        self.msg_connect((self.vcc_burst_cfo_est_gmsk_0, 'out'),
                         (self.pyqt_meta_text_output_0, 'pdus'))
        self.msg_connect((self.vcc_burst_snr_0, 'out'),
                         (self.pdu_utils_extract_metadata_0_0, 'dict'))
        self.msg_connect((self.vcc_burst_snr_0, 'out'),
                         (self.vcc_burst_cfo_est_gmsk_0, 'in'))
        self.msg_connect((self.vcc_trigger_timestamp_pdu_0, 'ts'),
                         (self.vcc_vstp_aggregator_simple_0, 'meta'))
        self.msg_connect((self.vcc_vstp_aggregator_simple_0, 'out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.vcc_vstp_aggregator_simple_0, 'out'),
                         (self.blocks_message_debug_0, 'print_pdu'))
        self.msg_connect((self.vcc_vstp_aggregator_simple_0, 'out'),
                         (self.blocks_socket_pdu_0, 'pdus'))
        self.connect((self.analog_agc2_xx_0, 0), (self.low_pass_filter_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0),
                     (self.blocks_skiphead_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1, 0),
                     (self.blocks_sub_xx_0, 0))
        self.connect((self.analog_quadrature_demod_cf_1_0, 0),
                     (self.digital_clock_recovery_mm_xx_0, 0))
        self.connect((self.analog_sig_source_x_0, 0),
                     (self.blocks_multiply_xx_0, 1))
        self.connect((self.blocks_abs_xx_0, 0),
                     (self.blocks_moving_average_xx_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.es_trigger_edge_f_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0),
                     (self.vcc_trigger_timestamp_pdu_0, 0))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_moving_average_xx_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_xx_0, 0),
                     (self.rational_resampler_xxx_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0, 0),
                     (self.rational_resampler_xxx_1_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.rational_resampler_xxx_1, 0))
        self.connect((self.blocks_skiphead_0, 0), (self.blocks_sub_xx_0, 1))
        self.connect((self.blocks_sub_xx_0, 0), (self.blocks_abs_xx_0, 0))
        self.connect((self.blocks_throttle_0, 0),
                     (self.blocks_multiply_xx_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.digital_descrambler_bb_0, 0))
        self.connect((self.digital_clock_recovery_mm_xx_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_descrambler_bb_0, 0),
                     (self.kiss_nrzi_decode_0, 0))
        self.connect((self.es_trigger_edge_f_0, 0), (self.es_sink_0, 0))
        self.connect((self.kiss_nrzi_decode_0, 0),
                     (self.kiss_hdlc_deframer_0, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.analog_quadrature_demod_cf_1, 0))
        self.connect((self.low_pass_filter_0, 0),
                     (self.es_trigger_edge_f_0, 1))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_freq_sink_x_1_0, 1))
        self.connect((self.low_pass_filter_0, 0),
                     (self.qtgui_waterfall_sink_x_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.analog_quadrature_demod_cf_1_0, 0))
        self.connect((self.low_pass_filter_0_0, 0),
                     (self.qtgui_freq_sink_x_1, 1))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.analog_agc2_xx_0, 0))
        self.connect((self.rational_resampler_xxx_0, 0),
                     (self.qtgui_freq_sink_x_1_0, 0))
        self.connect((self.rational_resampler_xxx_1, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.rational_resampler_xxx_1_0, 0),
                     (self.qtgui_freq_sink_x_1, 0))
예제 #58
0
    def test_4(self):
        """
        Test case generated by test-case generator
        """
        ##################################################
        # Variables
        ##################################################
        # Input data into the system
        src_data = "PKdhtXMmr18n2L9K88eMlGn7CcctT9RwKSB1FebW397VI5uG1yhc3uavuaOb9vyJ"
        self.bw = bw = 250000
        self.sf = sf = 7
        self.samp_rate = samp_rate = 250000
        self.pay_len = pay_len = 64
        self.n_frame = n_frame = 2
        self.impl_head = impl_head = True
        self.has_crc = has_crc = False
        self.frame_period = frame_period = 200
        self.cr = cr = 7

        ##################################################
        # Blocks
        ##################################################
        # Tx side
        self.lora_sdr_whitening_0 = lora_sdr.whitening()
        self.lora_sdr_modulate_0 = lora_sdr.modulate(sf, samp_rate, bw)
        self.lora_sdr_modulate_0.set_min_output_buffer(10000000)
        self.lora_sdr_interleaver_0 = lora_sdr.interleaver(cr, sf)
        self.lora_sdr_header_0 = lora_sdr.header(impl_head, has_crc, cr)
        self.lora_sdr_hamming_enc_0 = lora_sdr.hamming_enc(cr, sf)
        self.lora_sdr_gray_decode_0 = lora_sdr.gray_decode(sf)
        self.lora_sdr_data_source_0_1_0 = lora_sdr.data_source(
            pay_len, n_frame, src_data)
        self.lora_sdr_add_crc_0 = lora_sdr.add_crc(has_crc)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex * 1)
        self.blocks_message_strobe_random_0_1_0 = blocks.message_strobe_random(
            pmt.intern(''), blocks.STROBE_UNIFORM, frame_period, 5)
        # Rx side
        self.rational_resampler_xxx_0 = filter.rational_resampler_ccc(
            interpolation=4, decimation=1, taps=None, fractional_bw=None)
        self.lora_sdr_header_decoder_0 = lora_sdr.header_decoder(
            impl_head, cr, pay_len, has_crc)
        self.lora_sdr_hamming_dec_0 = lora_sdr.hamming_dec()
        self.lora_sdr_gray_enc_0 = lora_sdr.gray_enc()
        self.lora_sdr_frame_sync_0 = lora_sdr.frame_sync(
            samp_rate, bw, sf, impl_head)
        self.lora_sdr_fft_demod_0 = lora_sdr.fft_demod(samp_rate, bw, sf,
                                                       impl_head)
        self.lora_sdr_dewhitening_0 = lora_sdr.dewhitening()
        self.lora_sdr_deinterleaver_0 = lora_sdr.deinterleaver(sf)
        self.lora_sdr_crc_verif_0 = lora_sdr.crc_verif()
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                 samp_rate, True)

        ##################################################
        # Connections
        ##################################################
        # Tx side
        self.tb.msg_connect(
            (self.blocks_message_strobe_random_0_1_0, 'strobe'),
            (self.lora_sdr_data_source_0_1_0, 'trigg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_add_crc_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_header_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_interleaver_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_modulate_0, 'msg'))
        self.tb.msg_connect((self.lora_sdr_data_source_0_1_0, 'msg'),
                            (self.lora_sdr_whitening_0, 'msg'))
        self.tb.connect((self.lora_sdr_add_crc_0, 0),
                        (self.lora_sdr_hamming_enc_0, 0))
        self.tb.connect((self.lora_sdr_gray_decode_0, 0),
                        (self.lora_sdr_modulate_0, 0))
        self.tb.connect((self.lora_sdr_hamming_enc_0, 0),
                        (self.lora_sdr_interleaver_0, 0))
        self.tb.connect((self.lora_sdr_header_0, 0),
                        (self.lora_sdr_add_crc_0, 0))
        self.tb.connect((self.lora_sdr_interleaver_0, 0),
                        (self.lora_sdr_gray_decode_0, 0))
        self.tb.connect((self.lora_sdr_whitening_0, 0),
                        (self.lora_sdr_header_0, 0))
        self.tb.connect((self.lora_sdr_modulate_0, 0),
                        (self.blocks_throttle_0, 0))
        # Rx side

        self.tb.connect((self.blocks_throttle_0, 0),
                        (self.rational_resampler_xxx_0, 0))
        self.tb.msg_connect((self.lora_sdr_crc_verif_0, 'msg'),
                            (self.blocks_message_debug_0, 'store'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_deinterleaver_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_dewhitening_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_fft_demod_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_hamming_dec_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_frame_sync_0, 'new_frame'),
                            (self.lora_sdr_header_decoder_0, 'new_frame'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                            (self.lora_sdr_crc_verif_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                            (self.lora_sdr_crc_verif_0, 'CRC'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_deinterleaver_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                            (self.lora_sdr_dewhitening_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                            (self.lora_sdr_dewhitening_0, 'CRC'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_fft_demod_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_frame_sync_0, 'CR'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'err'),
                            (self.lora_sdr_frame_sync_0, 'err'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CRC'),
                            (self.lora_sdr_frame_sync_0, 'crc'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'pay_len'),
                            (self.lora_sdr_frame_sync_0, 'pay_len'))
        self.tb.msg_connect((self.lora_sdr_header_decoder_0, 'CR'),
                            (self.lora_sdr_hamming_dec_0, 'CR'))
        self.tb.connect((self.lora_sdr_deinterleaver_0, 0),
                        (self.lora_sdr_hamming_dec_0, 0))
        self.tb.connect((self.lora_sdr_dewhitening_0, 0),
                        (self.lora_sdr_crc_verif_0, 0))
        self.tb.connect((self.lora_sdr_fft_demod_0, 0),
                        (self.lora_sdr_gray_enc_0, 0))
        self.tb.connect((self.lora_sdr_frame_sync_0, 0),
                        (self.lora_sdr_fft_demod_0, 0))
        self.tb.connect((self.lora_sdr_gray_enc_0, 0),
                        (self.lora_sdr_deinterleaver_0, 0))
        self.tb.connect((self.lora_sdr_hamming_dec_0, 0),
                        (self.lora_sdr_header_decoder_0, 0))
        self.tb.connect((self.lora_sdr_header_decoder_0, 0),
                        (self.lora_sdr_dewhitening_0, 0))
        self.tb.connect((self.rational_resampler_xxx_0, 0),
                        (self.lora_sdr_frame_sync_0, 0))

        # run the flowgraph, since we use a message strobe we have to run and stop the flowgraph with some computation time inbetween
        self.tb.start()
        time.sleep(10)
        self.tb.stop()
        self.tb.wait()
        # try to get get the message from the store port of the message debug printer and convert to string from pmt message
        try:
            msg = pmt.symbol_to_string(
                self.blocks_message_debug_0.get_message(0))
        except:
            # if not possible set message to be None
            msg = None

        # check if message received is the same as the message decoded
        self.assertMultiLineEqual(
            src_data,
            msg,
            msg="Error decoded data {0} is not the same as input data {1}".
            format(msg, src_data))
예제 #59
0
    def __init__(self):
        gr.top_block.__init__(self, "Top Block")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Top Block")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "top_block")

        if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"):
            self.restoreGeometry(self.settings.value("geometry").toByteArray())
        else:
            self.restoreGeometry(
                self.settings.value("geometry", type=QtCore.QByteArray))

        ##################################################
        # Variables
        ##################################################

        self.variable_constellation_0 = variable_constellation_0 = digital.constellation_qpsk(
        ).base()

        self.taps = taps = firdes.root_raised_cosine(32, 32, 0.5, 0.35,
                                                     50 * 32)

        self.samp_rate = samp_rate = 32000

        ##################################################
        # Blocks
        ##################################################
        self.qtgui_time_sink_x_0_1 = qtgui.time_sink_f(
            400,  #size
            samp_rate,  #samp_rate
            "bits receiver",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_1.set_update_time(1)
        self.qtgui_time_sink_x_0_1.set_y_axis(-2, 2)

        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 = ['', '', '', '', '', '', '', '', '', '']
        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_1.set_line_label(
                    i, "Data {0}".format(i))
            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.top_layout.addWidget(self._qtgui_time_sink_x_0_1_win)
        self.qtgui_time_sink_x_0_0 = qtgui.time_sink_c(
            320,  #size
            samp_rate,  #samp_rate
            "receiver",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0_0.set_update_time(1)
        self.qtgui_time_sink_x_0_0.set_y_axis(-2, 2)

        self.qtgui_time_sink_x_0_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                    qtgui.TRIG_SLOPE_POS, 0.0,
                                                    0, 0, "")
        self.qtgui_time_sink_x_0_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0_0.enable_grid(False)
        self.qtgui_time_sink_x_0_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0_0.enable_control_panel(False)
        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(2):
            if len(labels[i]) == 0:
                if (i % 2 == 0):
                    self.qtgui_time_sink_x_0_0.set_line_label(
                        i, "Re{{Data {0}}}".format(i / 2))
                else:
                    self.qtgui_time_sink_x_0_0.set_line_label(
                        i, "Im{{Data {0}}}".format(i / 2))
            else:
                self.qtgui_time_sink_x_0_0.set_line_label(i, labels[i])
            self.qtgui_time_sink_x_0_0.set_line_width(i, widths[i])
            self.qtgui_time_sink_x_0_0.set_line_color(i, colors[i])
            self.qtgui_time_sink_x_0_0.set_line_style(i, styles[i])
            self.qtgui_time_sink_x_0_0.set_line_marker(i, markers[i])
            self.qtgui_time_sink_x_0_0.set_line_alpha(i, alphas[i])

        self._qtgui_time_sink_x_0_0_win = sip.wrapinstance(
            self.qtgui_time_sink_x_0_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_win)
        self.qtgui_time_sink_x_0 = qtgui.time_sink_f(
            400,  #size
            samp_rate,  #samp_rate
            "bits sender",  #name
            1  #number of inputs
        )
        self.qtgui_time_sink_x_0.set_update_time(1)
        self.qtgui_time_sink_x_0.set_y_axis(-2, 2)

        self.qtgui_time_sink_x_0.set_y_label('Amplitude', "")

        self.qtgui_time_sink_x_0.enable_tags(-1, True)
        self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                  qtgui.TRIG_SLOPE_POS, 0.0, 0,
                                                  0, "")
        self.qtgui_time_sink_x_0.enable_autoscale(False)
        self.qtgui_time_sink_x_0.enable_grid(False)
        self.qtgui_time_sink_x_0.enable_axis_labels(True)
        self.qtgui_time_sink_x_0.enable_control_panel(False)
        self.qtgui_time_sink_x_0.enable_stem_plot(False)

        if not True:
            self.qtgui_time_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "blue"
        ]
        styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

        for i in xrange(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(
            400,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(1)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pluto_source_0 = iio.pluto_source('ip:192.168.3.2',
                                               int(900000000), int(2000000),
                                               int(500000), 0x8000, True, True,
                                               True, "manual", 50, '', True)
        self.pluto_sink_0 = iio.pluto_sink('ip:192.168.2.1', int(900000000),
                                           int(2000000), int(1000000), 0x8000,
                                           False, 0, '', True)
        self.epy_block_3 = epy_block_3.blk(startString='10101010',
                                           escapeString='01111000',
                                           endString='01100110',
                                           preambleString='10000111',
                                           preambleLength=18)
        self.epy_block_2 = epy_block_2.blk(threshold=0.3)
        self.epy_block_1 = epy_block_1.blk()
        self.digital_pfb_clock_sync_xxx_0_0 = digital.pfb_clock_sync_ccf(
            4, 0.0628, (taps), 32, 16, 1.5, 1)
        self.digital_crc32_async_bb_0_0 = digital.crc32_async_bb(True)
        self.digital_crc32_async_bb_0 = digital.crc32_async_bb(False)
        self.digital_costas_loop_cc_0 = digital.costas_loop_cc(0.055, 4, True)
        self.digital_constellation_soft_decoder_cf_0 = digital.constellation_soft_decoder_cf(
            variable_constellation_0)
        self.digital_constellation_modulator_0 = digital.generic_mod(
            constellation=variable_constellation_0,
            differential=False,
            samples_per_symbol=4,
            pre_diff_code=True,
            excess_bw=0.35,
            verbose=False,
            log=False,
        )
        self.digital_cma_equalizer_cc_0 = digital.cma_equalizer_cc(
            30, 1, 0.001, 1)
        self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb()
        self.blocks_vector_source_x_0 = blocks.vector_source_b(
            (180, 180, 180, 180, 180, 180, 180, 180, 0), True, 1, [])
        self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(
            1, gr.GR_LSB_FIRST)
        self.blocks_message_strobe_0 = blocks.message_strobe(
            pmt.intern("TEST"), 0.001)
        self.blocks_message_debug_1 = blocks.message_debug()
        self.blocks_char_to_float_0_0 = blocks.char_to_float(1, 1)
        self.blocks_char_to_float_0 = blocks.char_to_float(1, 1)
        self.blocks_add_xx_0 = blocks.add_vcc(1)
        self.analog_noise_source_x_0 = analog.noise_source_c(
            analog.GR_GAUSSIAN, 0, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                         (self.epy_block_1, 'msg_in'))
        self.msg_connect((self.digital_crc32_async_bb_0, 'out'),
                         (self.epy_block_3, 'packet_in'))
        self.msg_connect((self.digital_crc32_async_bb_0_0, 'out'),
                         (self.blocks_message_debug_1, 'print_pdu'))
        self.msg_connect((self.epy_block_1, 'msg_out'),
                         (self.digital_crc32_async_bb_0, 'in'))
        self.connect((self.analog_noise_source_x_0, 0),
                     (self.blocks_add_xx_0, 1))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.digital_pfb_clock_sync_xxx_0_0, 0))
        self.connect((self.blocks_add_xx_0, 0),
                     (self.qtgui_time_sink_x_0_0, 0))
        self.connect((self.blocks_char_to_float_0, 0),
                     (self.qtgui_time_sink_x_0, 0))
        self.connect((self.blocks_char_to_float_0_0, 0),
                     (self.qtgui_time_sink_x_0_1, 0))
        self.connect((self.blocks_packed_to_unpacked_xx_0, 0),
                     (self.blocks_char_to_float_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.blocks_packed_to_unpacked_xx_0, 0))
        self.connect((self.blocks_vector_source_x_0, 0),
                     (self.digital_constellation_modulator_0, 0))
        self.connect((self.digital_binary_slicer_fb_0, 0),
                     (self.blocks_char_to_float_0_0, 0))
        self.connect((self.digital_cma_equalizer_cc_0, 0),
                     (self.digital_costas_loop_cc_0, 0))
        self.connect((self.digital_constellation_modulator_0, 0),
                     (self.pluto_sink_0, 0))
        self.connect((self.digital_constellation_soft_decoder_cf_0, 0),
                     (self.digital_binary_slicer_fb_0, 0))
        self.connect((self.digital_costas_loop_cc_0, 0), (self.epy_block_2, 0))
        self.connect((self.digital_pfb_clock_sync_xxx_0_0, 0),
                     (self.digital_cma_equalizer_cc_0, 0))
        self.connect((self.epy_block_2, 0),
                     (self.digital_constellation_soft_decoder_cf_0, 0))
        self.connect((self.epy_block_2, 0), (self.qtgui_const_sink_x_0, 0))
        self.connect((self.pluto_source_0, 0), (self.blocks_add_xx_0, 0))
예제 #60
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.x310 = x310 = "B:0"
        self.samp_rate = samp_rate = 2e6
        self.gain = gain = 0
        self.b210 = b210 = "A:B"

        ##################################################
        # Blocks
        ##################################################
        self._gain_range = Range(0, 70, 5, 0, 200)
        self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain",
                                     "counter_slider", float)
        self.top_layout.addWidget(self._gain_win)
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_subdev_spec(b210, 0)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(72e6, 0)
        self.uhd_usrp_source_0.set_gain(gain, 0)
        self.uhd_usrp_source_0.set_antenna('RX2', 0)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            samp_rate,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)
        self.digital_probe_mpsk_snr_est_c_0 = digital.probe_mpsk_snr_est_c(
            2, 10000000, 0.01)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.digital_probe_mpsk_snr_est_c_0, 'snr'),
                         (self.blocks_message_debug_0, 'print'))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.digital_probe_mpsk_snr_est_c_0, 0))
        self.connect((self.uhd_usrp_source_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))