def __init__(self, syncword_threshold=None, options=None): gr.hier_block2.__init__(self, "lilacsat_1_deframer", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) options_block.__init__(self, options) self.message_port_register_hier_out('out') self.message_port_register_hier_out('codec2') if syncword_threshold is None: syncword_threshold = self.options.syncword_threshold self.delay1 = blocks.delay(gr.sizeof_float, 1) self.viterbi0 = ccsds_viterbi() self.viterbi1 = ccsds_viterbi() self.differential0 = digital.diff_decoder_bb(2) self.differential1 = digital.diff_decoder_bb(2) self.tag0 = digital.correlate_access_code_tag_bb( _syncword, syncword_threshold, 'syncword') self.tag1 = digital.correlate_access_code_tag_bb( _syncword, syncword_threshold, 'syncword') self.scrambler0 = digital.additive_scrambler_bb( 0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword') self.scrambler1 = digital.additive_scrambler_bb( 0xA9, 0xFF, 7, count=0, bits_per_byte=1, reset_tag_key='syncword') self.demux0 = lilacsat1_demux('syncword') self.demux1 = lilacsat1_demux('syncword') self.pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.pack = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.multiply_length = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, 'packet_len', 1 / 8.0) self.tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.pdu2tag_codec2 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') self.pack_codec2 = blocks.unpacked_to_packed_bb(1, gr.GR_MSB_FIRST) self.multiply_length_codec2 = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, 'packet_len', 1 / 8.0) self.tag2pdu_codec2 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.connect(self, self.viterbi0, self.differential0, self.tag0, self.scrambler0, self.demux0) self.connect(self, self.delay1, self.viterbi1, self.differential1, self.tag1, self.scrambler1, self.demux1) self.connect(self.pdu2tag, self.pack, self.multiply_length, self.tag2pdu) self.connect(self.pdu2tag_codec2, self.pack_codec2, self.multiply_length_codec2, self.tag2pdu_codec2) self.msg_connect((self.demux0, 'kiss'), (self.pdu2tag, 'pdus')) self.msg_connect((self.demux1, 'kiss'), (self.pdu2tag, 'pdus')) self.msg_connect((self.demux0, 'codec2'), (self.pdu2tag_codec2, 'pdus')) self.msg_connect((self.demux1, 'codec2'), (self.pdu2tag_codec2, 'pdus')) self.msg_connect((self.tag2pdu, 'pdus'), (self, 'out')) self.msg_connect((self.tag2pdu_codec2, 'pdus'), (self, 'codec2'))
def createBlocks(self): self.rb_demux = rb_const_demux() self.rb_stream1 = blocks.pdu_to_tagged_stream(blocks.complex_t, self.tag) self.rb_stream2 = blocks.pdu_to_tagged_stream(blocks.complex_t, self.tag) self.rb_stream3 = blocks.pdu_to_tagged_stream(blocks.complex_t, self.tag) self.rb_stream4 = blocks.pdu_to_tagged_stream(blocks.complex_t, self.tag)
def __init__(self, gain=1): gr.hier_block2.__init__( self, "Split GMSK Modulator", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_float*1), ) ################################################## # Parameters ################################################## self.gain = gain ################################################## # Blocks ################################################## self.rational_resampler_xxx_0 = filter.rational_resampler_fff( interpolation=1, decimation=2, taps=(1, ), fractional_bw=None, ) self.pad_source_1 = None;self.message_port_register_hier_out("9k6") self.pad_source_0 = None;self.message_port_register_hier_out("4k8") self.digital_gmskmod_bc_0_0 = digital.gmskmod_bc(10, 3, 0.3) self.digital_gmskmod_bc_0 = digital.gmskmod_bc(10, 3, 0.3) 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_add_xx_0 = blocks.add_vff(1) self.analog_quadrature_demod_cf_0_0 = analog.quadrature_demod_cf(gain) self.analog_quadrature_demod_cf_0 = analog.quadrature_demod_cf(gain) ################################################## # Connections ################################################## self.connect((self.blocks_add_xx_0, 0), (self, 0)) self.connect((self.analog_quadrature_demod_cf_0_0, 0), (self.blocks_add_xx_0, 0)) self.connect((self.digital_gmskmod_bc_0_0, 0), (self.analog_quadrature_demod_cf_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_gmskmod_bc_0_0, 0)) self.connect((self.analog_quadrature_demod_cf_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.digital_gmskmod_bc_0, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.digital_gmskmod_bc_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self, "4k8", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self, "9k6", self.blocks_pdu_to_tagged_stream_0_0, "pdus")
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)
def __init__(self): gr.hier_block2.__init__( self, 'PN9 scrambler', gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_in('in') self.message_port_register_hier_out('out') ################################################## # Blocks ################################################## self.digital_additive_scrambler_bb_0 = ( digital.additive_scrambler_bb(0x21, 0x1FF, 8, count=0, bits_per_byte=8, reset_tag_key='packet_len')) 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')) ################################################## # Connections ################################################## self.msg_connect( (self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self, 'out')) self.msg_connect( (self, 'in'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect( (self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_additive_scrambler_bb_0, 0)) self.connect( (self.digital_additive_scrambler_bb_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
def test_001_t(self): pkt_tag = gr.tag_t() pkt_tag.key = pmt.intern("pkt") mod_types = ('BPSK', 'QPSK', '8PSK', 'QAM16', 'QAM64') for mod_type in mod_types: print("Testing {}...".format(mod_type)) modulator = modulator_classic(mod_type) demodulator = demodulator_classic(mod_type, 200) src_data = get_random_bits(1000 * modulator.bits_per_symbol) pkt_tag.value = pmt.to_pmt(len(src_data)) src = blocks.vector_source_b(src_data, False, 1, [pkt_tag]) snk = blocks.vector_sink_b() tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "pkt") pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, "pkt") self.tb.connect(src, tag2pdu) self.tb.msg_connect(tag2pdu, "pdus", modulator, "bits") self.tb.msg_connect(modulator, "symbols", demodulator, "symbols") self.tb.msg_connect(demodulator, "bits", pdu2tag, "pdus") self.tb.connect(pdu2tag, snk) self.tb.start() # check data while demodulator.packet_cnt < 1: time.sleep(0.1) self.tb.stop() self.tb.wait() result_data = snk.data() for i in range(1000 * modulator.bits_per_symbol): self.assertEqual(src_data[i], result_data[i])
def test_003(self): # Test that block stops when interacting with streaming interface port = str(random.Random().randint(0, 30000) + 10000) srcdata = (0x73, 0x75, 0x63, 0x68, 0x74, 0x65, 0x73, 0x74, 0x76, 0x65, 0x72, 0x79, 0x70, 0x61, 0x73, 0x73) tag_dict = {"offset": 0} tag_dict["key"] = pmt.intern("len") tag_dict["value"] = pmt.from_long(8) tag1 = gr.python_to_tag(tag_dict) tag_dict["offset"] = 8 tag2 = gr.python_to_tag(tag_dict) tags = [tag1, tag2] src = blocks.vector_source_b(srcdata, False, 1, tags) ts_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "len") pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", "4141") #pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port) pdu_to_ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "len") head = blocks.head(gr.sizeof_char, 10) sink = blocks.vector_sink_b(1) self.tb.connect(src, ts_to_pdu) self.tb.msg_connect(ts_to_pdu, "pdus", pdu_send, "pdus") # a UDP socket connects pdu_send to pdu_recv # TODO: test that the recv socket can be destroyed from downstream # that signals DONE. Also that we get the PDUs we sent #self.tb.msg_connect(pdu_recv, "pdus", pdu_to_ts, "pdus") #self.tb.connect(pdu_to_ts, head, sink) self.tb.run()
def test_003 (self): # Test that block stops when interacting with streaming interface port = str(random.Random().randint(0, 30000) + 10000) srcdata = (0x73, 0x75, 0x63, 0x68, 0x74, 0x65, 0x73, 0x74, 0x76, 0x65, 0x72, 0x79, 0x70, 0x61, 0x73, 0x73) tag_dict = {"offset": 0} tag_dict["key"] = pmt.intern("len") tag_dict["value"] = pmt.from_long(8) tag1 = gr.python_to_tag(tag_dict) tag_dict["offset"] = 8 tag2 = gr.python_to_tag(tag_dict) tags = [tag1, tag2] src = blocks.vector_source_b(srcdata, False, 1, tags) ts_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "len") pdu_send = blocks.socket_pdu("UDP_CLIENT", "localhost", "4141") #pdu_recv = blocks.socket_pdu("UDP_SERVER", "localhost", port) pdu_to_ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "len") head = blocks.head(gr.sizeof_char, 10) sink = blocks.vector_sink_b(1) self.tb.connect(src, ts_to_pdu) self.tb.msg_connect(ts_to_pdu, "pdus", pdu_send, "pdus") # a UDP socket connects pdu_send to pdu_recv # TODO: test that the recv socket can be destroyed from downstream # that signals DONE. Also that we get the PDUs we sent #self.tb.msg_connect(pdu_recv, "pdus", pdu_to_ts, "pdus") #self.tb.connect(pdu_to_ts, head, sink) self.tb.run()
def test_framer_deframer(self): """Connects an HDLC framer to a deframer and sends PDUs through""" framer = hdlc_framer(100, 20) deframer = hdlc_deframer(True, 10000) pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t) dbg = blocks.message_debug() self.tb.connect(pdu2tag, deframer) self.tb.msg_connect((framer, 'out'), (pdu2tag, 'pdus')) self.tb.msg_connect((deframer, 'out'), (dbg, 'store')) test_size = 150 test_number_frames = 7 test_data = [ bytes(np.random.randint(0, 256, test_size, dtype='uint8')) for _ in range(test_number_frames) ] for td in test_data: test_frame = pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(test_size, list(td))) framer.to_basic_block()._post(pmt.intern('in'), test_frame) framer.to_basic_block()._post( pmt.intern('system'), pmt.cons(pmt.intern('done'), pmt.from_long(1))) self.tb.start() self.tb.wait() for j, td in enumerate(test_data): result_data = bytes( pmt.u8vector_elements(pmt.cdr(dbg.get_message(j)))) self.assertEqual( td, result_data, 'HDLC deframer output does not match expected frame')
def test_001_t(self): # set up fg pkt_tag = gr.tag_t() pkt_tag.key = pmt.intern("pkt") mod_types = ['BPSK', 'QPSK', '8PSK', 'QAM16', 'QAM64'] for mod_type in mod_types: print("Testing {}...".format(mod_type)) modulator = modulator_classic(mod_type) src_data = get_random_bits(100 * modulator.bits_per_symbol) pkt_tag.value = pmt.to_pmt(len(src_data)) expected_data = modulator.modulate( bits_to_integers(data_b=src_data, bits_per_symbol=modulator.bits_per_symbol)) src = blocks.vector_source_b(src_data, False, 1, [pkt_tag]) tag2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "pkt") pdu2tag = blocks.pdu_to_tagged_stream(blocks.complex_t, "pkt") snk = blocks.vector_sink_c() self.tb.connect(src, tag2pdu) self.tb.msg_connect(tag2pdu, "pdus", modulator, "bits") self.tb.msg_connect(modulator, "symbols", pdu2tag, "pdus") self.tb.connect(pdu2tag, snk) self.tb.start() while modulator.packet_cnt < 1: time.sleep(0.1) self.tb.stop() self.tb.wait() # check data result_data = snk.data() self.assertComplexTuplesAlmostEqual(expected_data, result_data, 6)
def test_001_t(self): print("Enable plotting to manually verify result of wrapping") body = get_random_bits(256) src = tvsb(body.astype(numpy.int8), None, True, "body") mod = modulator_classic("BPSK") wrapper = echo_packet_wrapper(self.nfreq_samps, self.freqs, self.corr_reps) sink = blocks.vector_sink_c() pdu2strm = blocks.pdu_to_tagged_stream(blocks.complex_t, "frame") strm2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "body") # Connect blocks self.tb.connect(src, strm2pdu) self.tb.connect(pdu2strm, sink) self.tb.msg_connect(strm2pdu, "pdus", mod, "bits") self.tb.msg_connect(mod, "symbols", wrapper, "body") self.tb.msg_connect(wrapper, "frame", pdu2strm, "pdus") # Run self.tb.start() while wrapper.npackets < 1: time.sleep(0.1) self.tb.stop() self.tb.wait() # check data result = sink.data() # self.plot_outcome(result) self.assertEqual(len(result), self.nfreq_samps + 2 * self.corr_reps * 256 + 256, "Incorrect number of output bits")
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")
def __init__(self): gr.top_block.__init__(self, "Bit Padding Test") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_random_pdu_0 = blocks.random_pdu(10, 12, chr(0xFF), 2) 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() ################################################## # Connections ################################################## self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (self.blocks_message_debug_0, 'print_pdu')) self.msg_connect((self.blocks_random_pdu_0, 'pdus'), (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')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0))
def test_001_t(self): # set up fg phr = np.random.randint(0, 2, size=(12, )) data = np.array(np.random.randint(0, 256, size=(6 * 3, ))) data_bin = np.unpackbits(np.array(data, dtype=np.uint8)) self.src = blocks.vector_source_b(data, False, 1, []) self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 6, "packet_len") self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") self.pref = ieee802_15_4.phr_prefixer(phr) self.pdu2ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.snk = blocks.vector_sink_b(1) self.tb.connect(self.src, self.s2ts, self.ts2pdu) self.tb.msg_connect(self.ts2pdu, "pdus", self.pref, "in") self.tb.msg_connect(self.pref, "out", self.pdu2ts, "pdus") self.tb.connect(self.pdu2ts, self.snk) self.tb.start() time.sleep(1) self.tb.stop() # check data data_out = self.snk.data() # print "input:" # for i in data: # print i # print "output:" # for i in data_out: # print data_out expected_output = np.concatenate( (phr, data_bin[0:6 * 8], phr, data_bin[6 * 8:12 * 8], phr, data_bin[12 * 8:18 * 8])) self.assertFloatTuplesAlmostEqual(data_out, expected_output)
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")
def __init__(self, options=None): gr.hier_block2.__init__( self, 'ax5043_deframer', gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) options_block.__init__(self, options) self.message_port_register_hier_out('out') self.slicer = digital.binary_slicer_fb() # 4000 bits will leave enough room for the 200 byte packets self.deframer = sync_to_pdu( packlen=4000, sync=_syncword, threshold=4) self.deinterleave = deinterleave() self.viterbi = viterbi_decoder(5, [25, 23]) self.pdu2tag = blocks.pdu_to_tagged_stream(byte_t, 'packet_len') self.hdlc = hdlc_deframer(True, 10000, crc_check_func=crc_check) self.connect(self, self.slicer, self.deframer) self.msg_connect((self.deframer, 'out'), (self.deinterleave, 'in')) self.msg_connect((self.deinterleave, 'out'), (self.viterbi, 'in')) self.msg_connect((self.viterbi, 'out'), (self.pdu2tag, 'pdus')) self.connect(self.pdu2tag, self.hdlc) self.msg_connect((self.hdlc, 'out'), (self, 'out'))
def __init__(self, callsign='', host='localhost', latitude=0, longitude=0, norad=0, port='8001', recstart=''): gr.top_block.__init__(self, "KISS client telemetry submitter") ################################################## # Parameters ################################################## self.callsign = callsign self.host = host self.latitude = latitude self.longitude = longitude self.norad = norad self.port = port self.recstart = recstart ################################################## # Blocks ################################################## self.sids_submit_0 = sids.submit('http://tlm.pe0sat.nl/tlmdb/frame_db.php', norad, callsign, longitude, latitude, recstart) self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_CLIENT", host, port, 10000, False) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.sids_submit_0, 'in')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.kiss_kiss_to_pdu_0, 0))
def __init__(self, host='127.0.0.1', iq_port='9094', packet_port='9095', sample_filename='sample_filename.dat'): gr.top_block.__init__(self, "Hurdle 1 Solution Stub") ################################################## # Parameters ################################################## self.host = host self.iq_port = iq_port self.packet_port = packet_port self.sample_filename = sample_filename ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4e6 self.num_garbage = num_garbage = int(1e6 / 8) ################################################## # Blocks ################################################## self.blocks_throttle_1 = blocks.throttle(gr.sizeof_char * 1, samp_rate / 8.0, True) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_char, 1, 1000, 'packet_len') self.blocks_socket_pdu_0_0 = blocks.socket_pdu("TCP_CLIENT", host, packet_port, 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_CLIENT", host, iq_port, 10000, False) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, 'packet_len') self.blocks_head_0 = blocks.head(gr.sizeof_char * 1, num_garbage) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, sample_filename, False) self.blocks_file_sink_0.set_unbuffered(False) self.analog_random_source_x_0 = blocks.vector_source_b( map(int, numpy.random.randint(0, 255, 1000)), True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.blocks_socket_pdu_0_0, 'pdus')) self.connect((self.analog_random_source_x_0, 0), (self.blocks_throttle_1, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_throttle_1, 0), (self.blocks_head_0, 0))
def __init__(self, ip=None, port=None, options=None): gr.hier_block2.__init__(self, 'codec2_udp_sink', gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) options_block.__init__(self, options) self.message_port_register_hier_in('in') if ip is None: ip = self.options.codec2_ip if port is None: port = self.options.codec2_port self.pdu2tag = blocks.pdu_to_tagged_stream(byte_t, 'packet_len') payload_bytes = 7 # The UDP sink has been moved in GNU Radio 3.10 if gr.api_version() == '9': self.udp = udp_sink(gr.sizeof_char * 1, ip, port, payload_bytes, False) else: udp_header = 0 # no header # The new UDP sink requires at least 8 bytes of payload. # We use 14 bytes, which is 2 codec2 frames. payload_bytes = 14 self.udp = network.udp_sink(gr.sizeof_char, 1, ip, port, udp_header, payload_bytes, False) self.msg_connect((self, 'in'), (self.pdu2tag, 'pdus')) self.connect(self.pdu2tag, self.udp)
def __init__(self): gr.top_block.__init__(self, "Receive_airprobe_bladerf") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # Blocks ################################################## self.zeromq_sub_msg_source_0 = zeromq.sub_msg_source( "tcp://192.168.42.2:4729", 1) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream( blocks.complex_t, "packet_len") self.blocks_file_meta_sink_0 = blocks.file_meta_sink( gr.sizeof_gr_complex * 1, "/home/abhishek/tmp/Untitled Folder/data_bladeRF1/test", samp_rate, 1, blocks.GR_FILE_FLOAT, True, 48000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.zeromq_sub_msg_source_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.blocks_file_meta_sink_0, 0))
def setUp(self): self.tb = gr.top_block() ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32e3 self.preamble = preamble = get_random_bits(64 * 3) self.npreamble = len(self.preamble) # self.modulation = modulation = "QPSK" self.nbits = 16 * 3 self.bits = get_random_bits(self.nbits) self.tag_preamble = gr.tag_t() self.tag_preamble.key = pmt.intern("pkt") self.tag_preamble.value = pmt.from_long(self.npreamble) self.tag_preamble.offset = 0 self.tag_body = gr.tag_t() self.tag_body.key = pmt.intern("pkt") self.tag_body.value = pmt.from_long(self.nbits) ################################################## # Blocks ################################################## # self.modulator = modulator_classic(modulation) # self.demodulator = demodulator_neural(seed=0, hidden_layers=(64, ), bits_per_symbol=2, preamble=preamble) self.vector_source_preamble = blocks.vector_source_b( preamble, True, 1, [self.tag_preamble]) self.vector_source_body = blocks.vector_source_b( self.bits, True, 1, [self.tag_body]) self.tags_mux = blocks.tagged_stream_mux(gr.sizeof_char * 1, "pkt") self.strm_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "pkt") self.pdu_to_strm = blocks.pdu_to_tagged_stream(blocks.byte_t, "pkt") self.vector_sink = blocks.vector_sink_b()
def test_encoder_decoder(self): """Connects a PDU to KISS and KISS to PDU and sends PDUs through""" pdu2kiss = pdu_to_kiss(include_timestamp=True) kiss2pdu = kiss_to_pdu() pdu2tag = blocks.pdu_to_tagged_stream(byte_t) dbg = blocks.message_debug() self.tb.connect(pdu2tag, kiss2pdu) self.tb.msg_connect((pdu2kiss, 'out'), (pdu2tag, 'pdus')) self.tb.msg_connect((kiss2pdu, 'out'), (dbg, 'store')) test_size = 150 test_number_frames = 7 test_data = [ np.random.randint(0, 256, test_size, dtype='uint8') for _ in range(test_number_frames) ] for td in test_data: test_frame = pmt.cons(pmt.PMT_NIL, pmt.init_u8vector(test_size, td)) pdu2kiss.to_basic_block()._post(pmt.intern('in'), test_frame) pdu2kiss.to_basic_block()._post( pmt.intern('system'), pmt.cons(pmt.intern('done'), pmt.from_long(1))) self.tb.start() self.tb.wait() for j, td in enumerate(test_data): result_data = pmt.u8vector_elements(pmt.cdr(dbg.get_message(j))) np.testing.assert_equal( td, result_data, 'KISS to PDU output does not match expected frame')
def __init__(self): gr.hier_block2.__init__( self, "OFDM PHY", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature2(2, 2, gr.sizeof_gr_complex * 1, gr.sizeof_char)) # Message Port self.message_port_register_hier_out("from_mac") self.message_port_register_hier_in("to_mac") # Blocks self.tx_pdu = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_length") self.tx_path = ofdm_tx(scramble_bits=True) self.rx_path = ofdm_rx(scramble_bits=True) self.rx_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_length") # Connections self.connect(self.tx_pdu, self.tx_path, self) self.connect(self, self.rx_path, self.rx_pdu) self.connect((self.rx_path, 1), (self, 1)) # Message Connection self.msg_connect(self, "from_mac", self.tx_pdu, "pdus") self.msg_connect(self.rx_pdu, "pdus", self, "to_mac")
def test_001_t (self): # set up fg phr = np.random.randint(0,2,size=(12,)) data = np.array(np.random.randint(0,256, size=(6*3,))) data_bin = np.unpackbits(np.array(data,dtype=np.uint8)) self.src = blocks.vector_source_b(data, False, 1, []) self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 6, "packet_len") self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") self.pref = ieee802_15_4.phr_prefixer(phr) self.pdu2ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.snk = blocks.vector_sink_b(1) self.tb.connect(self.src, self.s2ts, self.ts2pdu) self.tb.msg_connect(self.ts2pdu, "pdus", self.pref, "in") self.tb.msg_connect(self.pref, "out", self.pdu2ts, "pdus") self.tb.connect(self.pdu2ts, self.snk) self.tb.start() time.sleep(1) self.tb.stop() # check data data_out = self.snk.data() # print "input:" # for i in data: # print i # print "output:" # for i in data_out: # print data_out expected_output = np.concatenate((phr,data_bin[0:6*8], phr, data_bin[6*8:12*8], phr, data_bin[12*8:18*8])) self.assertFloatTuplesAlmostEqual(data_out, expected_output)
def __init__(self): gr.top_block.__init__(self, "Quetzal-1 Receiver") ################################################## # Variables ################################################## self.symb_rate = symb_rate = 4800 self.samp_rate = samp_rate = 48000 self.samp_per_sym = samp_per_sym = int(samp_rate/symb_rate) self.log = log = 0 self.homedir = homedir = "" self.hhmmss = hhmmss = "" self.gain_mu = gain_mu = 0.175*3 self.filename_raw_beacon = filename_raw_beacon = "" self.filename_parsed_beacon = filename_parsed_beacon = "" self.filename_image_metadata = filename_image_metadata = "" self.filename_image = filename_image = "" self.do_once = do_once = 0 self.data_rate = data_rate = 4800 self.count = count = 0 self.center_freq = center_freq = 437.2e6 ################################################## # Blocks ################################################## self.zeromq_pub_sink_0 = zeromq.pub_sink(gr.sizeof_char, 1, 'tcp://127.0.0.1:1502', 100, False, -1) self.satellites_strip_ax25_header_0 = satellites.strip_ax25_header() self.satellites_nrzi_decode_0 = satellites.nrzi_decode() self.satellites_hdlc_deframer_0 = satellites.hdlc_deframer(check_fcs=True, max_length=10000) self.quetzal1_parse = quetzal1_parse.quetzal1_parse(filename_parsed_beacon='', filename_raw_beacon='') self.low_pass_filter_0_0 = filter.fir_filter_fff(1, firdes.low_pass( 1, 48000, 2400, 2000, firdes.WIN_HAMMING, 6.76)) self.digital_descrambler_bb_0 = digital.descrambler_bb(0x21, 0, 16) self.digital_clock_recovery_mm_xx_0_0 = digital.clock_recovery_mm_ff(10, 0.25*gain_mu*gain_mu, 0.5, gain_mu, 0.005) self.digital_binary_slicer_fb_0 = digital.binary_slicer_fb() self.blocks_wavfile_source_0 = blocks.wavfile_source('/home/dan/Documents/repos/gr-quetzal1/recordings/example_beacon_quetzal1.wav', False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_float*1, samp_rate,True) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((5, )) self.blocks_add_const_vxx_0 = blocks.add_const_vff((0, )) ################################################## # Connections ################################################## self.msg_connect((self.satellites_hdlc_deframer_0, 'out'), (self.satellites_strip_ax25_header_0, 'in')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.satellites_strip_ax25_header_0, 'out'), (self.quetzal1_parse, 'in')) self.connect((self.blocks_add_const_vxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.low_pass_filter_0_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.zeromq_pub_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_add_const_vxx_0, 0)) self.connect((self.blocks_wavfile_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.digital_binary_slicer_fb_0, 0), (self.satellites_nrzi_decode_0, 0)) self.connect((self.digital_clock_recovery_mm_xx_0_0, 0), (self.digital_binary_slicer_fb_0, 0)) self.connect((self.digital_descrambler_bb_0, 0), (self.satellites_hdlc_deframer_0, 0)) self.connect((self.low_pass_filter_0_0, 0), (self.digital_clock_recovery_mm_xx_0_0, 0)) self.connect((self.satellites_nrzi_decode_0, 0), (self.digital_descrambler_bb_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "IEEE802.15.4 OQPSK PHY", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) self.message_port_register_hier_in("txin") self.message_port_register_hier_out("rxout") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4000000 ################################################## # Blocks ################################################## self.single_pole_iir_filter_xx_0 = filter.single_pole_iir_filter_ff(0.00016, 1) self.ieee802_15_4_packet_sink_0 = ieee802_15_4.packet_sink(10) self.ieee802_15_4_access_code_prefixer_0 = ieee802_15_4.access_code_prefixer() self.foo_burst_tagger_0 = foo.burst_tagger(pmt.intern("pdu_length"), 128) 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.blocks_vector_source_x_0 = blocks.vector_source_c([0, sin(pi/4), 1, sin(3*pi/4)], True, 1, []) 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_multiply_xx_0 = blocks.multiply_vcc(1) 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.ieee802_15_4_access_code_prefixer_0, 'out'), (self.blocks_pdu_to_tagged_stream_0_0_0, 'pdus')) self.msg_connect((self.ieee802_15_4_packet_sink_0, 'out'), (self, 'rxout')) self.msg_connect((self, 'txin'), (self.ieee802_15_4_access_code_prefixer_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.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.foo_burst_tagger_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_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_vector_source_x_0, 0), (self.blocks_multiply_xx_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.foo_burst_tagger_0, 0), (self, 0)) self.connect((self, 0), (self.analog_quadrature_demod_cf_0, 0)) self.connect((self.single_pole_iir_filter_xx_0, 0), (self.blocks_sub_xx_0, 1))
def test_000(self): # Just run some data through and make sure it doesn't puke. src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) src = blocks.pdu_to_tagged_stream(blocks.byte_t) snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t) snk2 = blocks.vector_sink_b() snk = blocks.tag_debug(1, "test") snk.set_display(False) dbg = blocks.message_debug() # Test that the right number of ports exist. pi = snk3.message_ports_in() po = snk3.message_ports_out() # system port is defined automatically self.assertEqual(pmt.length(pi), 1) self.assertEqual(pmt.length(po), 1) self.tb.connect(src, snk) self.tb.connect(src, snk2) self.tb.connect(src, snk3) self.tb.msg_connect(snk3, "pdus", dbg, "store") # make our reference and message pmts port = pmt.intern("pdus") msg = pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(16, 0xFF)) # post the message src.to_basic_block()._post(port, msg) src.to_basic_block()._post( pmt.intern("system"), pmt.cons(pmt.intern("done"), pmt.from_long(1))) self.tb.start() self.tb.wait() # Get the vector of data from the vector sink result_data = snk2.data() # Get the vector of data from the message sink # Convert the message PMT as a pair into its vector result_msg = dbg.get_message(0) msg_vec = pmt.cdr(result_msg) # pmt.print(msg_vec) # Convert the PMT vector into a Python list msg_data = [] for i in range(16): msg_data.append(pmt.u8vector_ref(msg_vec, i)) actual_data = 16 * [ 0xFF, ] self.assertEqual(actual_data, list(result_data)) self.assertEqual(actual_data, msg_data)
def __init__(self): gr.top_block.__init__(self) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 4000000 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(1090000000, 0) self.uhd_usrp_sink_0.set_gain(33, 0) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length( gr.sizeof_gr_complex * 1, "packet_len", 2) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_char * 1, 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream( blocks.byte_t, "packet_len") self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1.25) self.AdsbEncoder_0 = adsbtx.AdsbEncoder(200) ################################################## # Connections ################################################## self.connect((self.blocks_char_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_repeat_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_repeat_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.AdsbEncoder_0, "pdus", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.AdsbEncoder_0, "pdus")
def test_000(self): # Just run some data through and make sure it doesn't puke. src_data = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10) src = blocks.pdu_to_tagged_stream(blocks.byte_t) snk3 = blocks.tagged_stream_to_pdu(blocks.byte_t) snk2 = blocks.vector_sink_b() snk = blocks.tag_debug(1, "test") snk.set_display(False) dbg = blocks.message_debug() # Test that the right number of ports exist. pi = snk3.message_ports_in() po = snk3.message_ports_out() self.assertEqual(pmt.length(pi), 0) self.assertEqual(pmt.length(po), 1) self.tb.connect(src, snk) self.tb.connect(src, snk2) self.tb.connect(src, snk3) self.tb.msg_connect(snk3, "pdus", dbg, "store") self.tb.start() # make our reference and message pmts port = pmt.intern("pdus") msg = pmt.cons( pmt.PMT_NIL, pmt.make_u8vector(16, 0xFF)) # post the message src.to_basic_block()._post(port, msg) # eww, what's that smell? while dbg.num_messages() < 1: time.sleep(0.1) self.tb.stop() self.tb.wait() # Get the vector of data from the vector sink result_data = snk2.data() # Get the vector of data from the message sink # Convert the message PMT as a pair into its vector result_msg = dbg.get_message(0) msg_vec = pmt.cdr(result_msg) #pmt.print(msg_vec) # Convert the PMT vector into a Python list msg_data = [] for i in xrange(16): msg_data.append(pmt.u8vector_ref(msg_vec, i)) actual_data = 16*[0xFF,] self.assertEqual(actual_data, list(result_data)) self.assertEqual(actual_data, msg_data)
def __init__(self): gr.top_block.__init__(self, "Kiss To Pdu File") Qt.QWidget.__init__(self) self.setWindowTitle("Kiss To Pdu File") 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", "kiss_to_pdu_file") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## 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) self.message_tools_message_file_sink_0 = message_tools.message_file_sink('/home/zleffke/github/vtgs/vcc_flowgraphs/v2.0/dev/hdlc_test_frame.pdu',False) self.message_tools_message_file_sink_0.set_unbuffered(False) self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True) self.kiss_hdlc_framer_0 = kiss.hdlc_framer(preamble_bytes=64, postamble_bytes=64) self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', '8000', 1024, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.message_tools_message_file_sink_0, 'print_pdu')) self.msg_connect((self.kiss_hdlc_framer_0, 'out'), (self.vcc_qt_hex_text_0, 'pdus')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.kiss_hdlc_framer_0, 'in')) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.kiss_kiss_to_pdu_0, 0))
def __init__(self, cfo_samps, corr_reps, body_size, cfar_thresh, samps_per_symb, beta_rrc, cfo_freqs): gr.hier_block2.__init__( self, "packet_handler", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature # Define blocks and connect them self.wrapper = EPW(cfo_samps=cfo_samps, cfo_freqs=cfo_freqs, corr_reps=corr_reps, samps_per_symb=samps_per_symb, beta_rrc=beta_rrc) self.unwrapper = EPU(cfo_samps=cfo_samps, cfo_freqs=cfo_freqs, corr_reps=corr_reps, samps_per_symb=samps_per_symb, beta_rrc=beta_rrc) self.detector = EPD(cfo_samps=cfo_samps, corr_reps=corr_reps, samps_per_symb=samps_per_symb, beta_rrc=beta_rrc, threshold=cfar_thresh, body_size=body_size) self.pdu2strm = blocks.pdu_to_tagged_stream(blocks.complex_t, "packet_len") self.set_min_output_buffer(8192) self.pdu2strm.set_min_output_buffer(8192) # TODO: Shape bursts with head and tail phasing samples and amplitude envelope # self.burst_shaper = digital.burst_shaper_cc((([])), 128, 128, True, "packet_len") # Create message ports self.port_wrap_in = pmt.intern("wrap_in") self.port_unwrap_out = pmt.intern("unwrap_out") self.primitive_message_port_register_hier_in(self.port_wrap_in) self.primitive_message_port_register_hier_out(self.port_unwrap_out) # Connect all ports # Inputs self.connect(self, self.detector) self.msg_connect(self, self.port_wrap_in, self.wrapper, pmt.intern("body")) # Outputs self.connect((self.pdu2strm, 0), (self, 0)) self.msg_connect(self.unwrapper, pmt.intern("body"), self, self.port_unwrap_out) # Internal self.msg_connect(self.wrapper, pmt.intern("frame"), self.pdu2strm, pmt.intern("pdus")) self.msg_connect(self.detector, pmt.intern("frame"), self.unwrapper, pmt.intern("frame"))
def __init__(self, syncword_threshold=None, options=None): gr.hier_block2.__init__(self, 'aausat4_deframer', gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) options_block.__init__(self, options) self.message_port_register_hier_out('out') if syncword_threshold is None: syncword_threshold = self.options.syncword_threshold self.deframer = sync_to_pdu_soft(packlen=1996 + 8, sync=_syncword, threshold=syncword_threshold) self.fsm = aausat4_remove_fsm() self.viterbi_short = fec.cc_decoder.make(1020, 7, 2, [79, -109], 0, -1, fec.CC_TERMINATED, False) self.viterbi_decoder_short = fec.async_decoder(self.viterbi_short, True, False, 1020 // 8) self.viterbi_long = fec.cc_decoder.make(1996, 7, 2, [79, -109], 0, -1, fec.CC_TERMINATED, False) self.viterbi_decoder_long = fec.async_decoder(self.viterbi_long, False, False, 1996 // 8) # Workaround for bug https://github.com/gnuradio/gnuradio/pull/2965 # We use packed output for Viterbi short decoder and then # we unpack the PDUs. self.pdu2tag = blocks.pdu_to_tagged_stream(byte_t, 'packet_len') self.unpack = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.taglength = blocks.tagged_stream_multiply_length( gr.sizeof_char * 1, 'packet_len', 8) self.tag2pdu = blocks.tagged_stream_to_pdu(byte_t, 'packet_len') self.scrambler = ccsds_descrambler() self.rs = decode_rs(False, 1) self.connect(self, self.deframer) self.msg_connect((self.deframer, 'out'), (self.fsm, 'in')) self.msg_connect((self.fsm, 'short'), (self.viterbi_decoder_short, 'in')) self.msg_connect((self.fsm, 'long'), (self.viterbi_decoder_long, 'in')) # Workaround self.msg_connect((self.viterbi_decoder_short, 'out'), (self.pdu2tag, 'pdus')) self.connect(self.pdu2tag, self.unpack, self.taglength, self.tag2pdu) self.msg_connect((self.tag2pdu, 'pdus'), (self.scrambler, 'in')) self.msg_connect((self.viterbi_decoder_long, 'out'), (self.scrambler, 'in')) self.msg_connect((self.scrambler, 'out'), (self.rs, 'in')) self.msg_connect((self.rs, 'out'), (self, 'out'))
def __init__(self, file, append=False, options=None): gr.hier_block2.__init__(self, "kiss_file_sink", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0)) self.message_port_register_hier_in('in') self.kiss = pdu_to_kiss(include_timestamp=True) self.pdu2tag = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.filesink = blocks.file_sink(gr.sizeof_char, file, append) self.connect(self.pdu2tag, self.filesink) self.msg_connect((self, 'in'), (self.kiss, 'in')) self.msg_connect((self.kiss, 'out'), (self.pdu2tag, 'pdus'))
def __init__(self, port): gr.top_block.__init__(self) socket_pdu = blocks.socket_pdu("TCP_SERVER", '0.0.0.0', port, MTU, True) input = blocks.pdu_to_tagged_stream(blocks.complex_t, 'packet_len') self.msg_connect((socket_pdu, 'pdus'), (input, 'pdus')) receiver = p25.c4fm_receiver_cf(48000 * 20) audio_sink = audio.sink(8000, '', True) self.connect(input, receiver, audio_sink)
def __init__(self): gr.top_block.__init__(self, "Kiss Monitor") Qt.QWidget.__init__(self) self.setWindowTitle("Kiss Monitor") 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", "kiss_monitor") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## 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) self.kiss_kiss_to_pdu_0 = kiss.kiss_to_pdu(True) self.blocks_socket_pdu_0_2 = blocks.socket_pdu("TCP_SERVER", '10.42.0.21', '8000', 1024, False) self.blocks_pdu_to_tagged_stream_1 = blocks.pdu_to_tagged_stream( blocks.byte_t, 'packet_len') ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_2, 'pdus'), (self.blocks_pdu_to_tagged_stream_1, 'pdus')) self.msg_connect((self.kiss_kiss_to_pdu_0, 'out'), (self.vcc_qt_hex_text_0, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_1, 0), (self.kiss_kiss_to_pdu_0, 0))
def __init__(self, min_tx_len): gr.top_block.__init__(self, "OFDMChatApp") # Variables self.samp_rate = samp_rate = 1e6 self.len_tag_key = len_tag_key = "packet_len" self.gain = gain = 60 self.fft_len = fft_len = 128 self.min_tx_len = min_tx_len self.pdu_port = pmt.intern("pdus") # Blocks self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(400e6, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None, ) self.fosdem_burst_marker_0 = fosdem.burst_marker(gr.sizeof_gr_complex, len_tag_key, 0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=True ) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, len_tag_key, 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.fosdem_burst_marker_0, 0)) self.connect((self.fosdem_burst_marker_0, 0), (self.uhd_usrp_sink_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 ################################################## # Blocks ################################################## self.ec_ax25_decoder_b_0 = ec.ax25_decoder_b(True, 0, "") self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52001", 10000, False) self.blocks_random_pdu_0 = blocks.random_pdu(256, 256, chr(0xFF), 1) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_packed_to_unpacked_xx_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 2000) self.ax25_ax25_encoder_0 = ax25.ax25_encoder("SPACE ", "EARTH ", 0, 0) ################################################## # Connections ################################################## self.msg_connect((self.ax25_ax25_encoder_0, 'pdu_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) 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.ax25_ax25_encoder_0, 'pdu_in')) self.msg_connect((self.ec_ax25_decoder_b_0, 'pdus'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.blocks_packed_to_unpacked_xx_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_packed_to_unpacked_xx_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.ec_ax25_decoder_b_0, 0))
def __init__(self): gr.top_block.__init__(self, "Test Grc") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # Blocks ################################################## self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(1e9, 0) self.uhd_usrp_source_0.set_gain(60, 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_clock_rate(26e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(1e9, 0) self.uhd_usrp_sink_0.set_gain(40, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.bursts_gen_0 = bursts_gen_0.bursts_gen() self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.complex_t, 'packet_len') self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex*1, int(4*samp_rate)) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, 'wy.cfile', False) self.blocks_file_sink_0.set_unbuffered(False) ################################################## # Connections ################################################## self.msg_connect((self.bursts_gen_0, 'bursts'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_head_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_head_0, 0))
def test_001(self): #Test the overflow buffer in pdu_to_tagged_stream src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] src = blocks.pdu_to_tagged_stream(blocks.float_t) snk = blocks.vector_sink_f() self.tb.connect(src, snk) port = pmt.intern("pdus") msg = pmt.cons( pmt.PMT_NIL, pmt.init_f32vector(10, src_data)) src.to_basic_block()._post(port, msg) self.tb.start() #ideally, would wait until we get ten samples time.sleep(0.2) self.tb.stop() self.assertEqual(src_data, list(snk.data()) )
def test_001(self): #Test the overflow buffer in pdu_to_tagged_stream src_data = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0] src = blocks.pdu_to_tagged_stream(blocks.float_t) snk = blocks.vector_sink_f() self.tb.connect(src, snk) port = pmt.intern("pdus") msg = pmt.cons( pmt.PMT_NIL, pmt.init_f32vector(10, src_data)) src.to_basic_block()._post(port, msg) src.to_basic_block()._post(pmt.intern("system"), pmt.cons(pmt.intern("done"), pmt.from_long(1))) self.tb.start() self.tb.wait() self.assertEqual(src_data, list(snk.data()) )
def __init__(self, fifo_file): gr.hier_block2.__init__(self, "fifo_async_sink", gr.io_signature(0,0,0), # Input signature gr.io_signature(0,0,0)) # Output signature self.message_port_register_hier_in("async_pdu") ################################################## # Blocks ################################################## self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, 'packet_len') self.mods_file_sink_nonblock_0 = mods.file_sink_nonblock(fifo_file) ################################################## # Connections ################################################## self.msg_connect((self,'async_pdu'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.mods_file_sink_nonblock_0, 0))
def test_004_t (self): # PDU size < fragmentation size, overlap # set up fg self.src = blocks.vector_source_b(range(255), False, 1, []) self.s2ts = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, 4, "packet_len") self.ts2pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") self.frag = ieee802_15_4.fragmentation(6) self.pdu2ts = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.snk = blocks.vector_sink_b(1) self.tb.connect(self.src, self.s2ts, self.ts2pdu) self.tb.msg_connect(self.ts2pdu, "pdus", self.frag, "in") self.tb.msg_connect(self.frag, "out", self.pdu2ts, "pdus") self.tb.connect(self.pdu2ts, self.snk) self.tb.start() time.sleep(1) self.tb.stop() # check data data = [i for i in self.snk.data()] print data self.assertTrue(data==range(252))
def __init__(self, destination_callsign="SPACE", destination_ssid=0, post_flag_quantity=16, post_sync_quantity=16, pre_flag_quantity=16, pre_sync_quantity=128, source_callsign="EARTH", source_ssid=0, sync_value=85): gr.hier_block2.__init__( self, "AX.25 Encoding Heir Block", gr.io_signature(0, 0, 0), gr.io_signature(1, 1, gr.sizeof_char*1), ) self.message_port_register_hier_in("pdus in") ################################################## # Parameters ################################################## self.destination_callsign = destination_callsign self.destination_ssid = destination_ssid self.post_flag_quantity = post_flag_quantity self.post_sync_quantity = post_sync_quantity self.pre_flag_quantity = pre_flag_quantity self.pre_sync_quantity = pre_sync_quantity self.source_callsign = source_callsign self.source_ssid = source_ssid self.sync_value = sync_value ################################################## # Blocks ################################################## self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.ax25_pdu_prepend_append_0_0 = ax25.pdu_prepend_append(pre_flag_quantity, post_flag_quantity, 0x7e) self.ax25_pdu_prepend_append_0 = ax25.pdu_prepend_append(pre_sync_quantity, post_sync_quantity, sync_value) self.ax25_ax25_encoder_0 = ax25.ax25_encoder(destination_callsign, source_callsign, destination_ssid, source_ssid) ################################################## # Connections ################################################## self.msg_connect((self.ax25_ax25_encoder_0, 'pdu_out'), (self.ax25_pdu_prepend_append_0_0, 'pdu_in')) self.msg_connect((self.ax25_pdu_prepend_append_0, 'pdu_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.ax25_pdu_prepend_append_0_0, 'pdu_out'), (self.ax25_pdu_prepend_append_0, 'pdu_in')) self.msg_connect((self, 'pdus in'), (self.ax25_ax25_encoder_0, 'pdu_in')) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self, 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.tnc_hdlc_framer_0 = tnc.hdlc_framer(preamble_length=50, postamble_length=7,verbose=False, use_scrambler=False) self.tnc_hdlc_deframer_0 = tnc.hdlc_deframer() self.tnc_ax25_framer_0 = tnc.ax25_framer(mycall="KI4MTT",destcall="KI4MTS",verbose=True) self.tnc_ax25_deframer_0 = tnc.ax25_deframer(mycall="KI4MTT",verbose=True) self.blocks_random_pdu_0 = blocks.random_pdu(50, 50) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000) self.blocks_message_debug_0 = blocks.message_debug() ################################################## # Connections ################################################## self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.tnc_hdlc_deframer_0, 0)) ################################################## # Asynch Message 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.tnc_ax25_framer_0, "in") self.msg_connect(self.tnc_ax25_deframer_0, "out", self.blocks_message_debug_0, "print_pdu") self.msg_connect(self.tnc_ax25_framer_0, "out", self.tnc_hdlc_framer_0, "in") self.msg_connect(self.tnc_hdlc_framer_0, "out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.tnc_hdlc_deframer_0, "out", self.tnc_ax25_deframer_0, "in")
def __init__(self): gr.top_block.__init__(self, "Wifi Loopback") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Loopback") try: self.setWindowIcon(Qt.QIcon.fromTheme("gnuradio-grc")) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_loopback") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.snr = snr = 36 self.samp_rate = samp_rate = 1e6 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.noise_var = noise_var = -150 self.interval = interval = 100 self.freq_offset = freq_offset = 0 self.encoding = encoding = 0 self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self._snr_range = Range(-15, 50, 1, 36, 200) self._snr_win = RangeWidget(self._snr_range, self.set_snr, "snr", "counter_slider") self.top_layout.addWidget(self._snr_win) self._noise_var_range = Range(-180, -40, 5, -150, 200) self._noise_var_win = RangeWidget(self._noise_var_range, self.set_noise_var, "noise_var", "counter_slider") self.top_layout.addWidget(self._noise_var_win) self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7] self._encoding_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", ] self._encoding_group_box = Qt.QGroupBox("encoding") self._encoding_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._encoding_button_group = variable_chooser_button_group() self._encoding_group_box.setLayout(self._encoding_box) for i, label in enumerate(self._encoding_labels): radio_button = Qt.QRadioButton(label) self._encoding_box.addWidget(radio_button) self._encoding_button_group.addButton(radio_button, i) self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod( self._encoding_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._encoding_options.index(i)) ) self._encoding_callback(self.encoding) self._encoding_button_group.buttonClicked[int].connect(lambda i: self.set_encoding(self._encoding_options[i])) self.top_layout.addWidget(self._encoding_group_box) self._chan_est_options = [0, 1] self._chan_est_labels = ["LMS", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod( self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i)) ) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect(lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self.wifi_phy_hier_0 = wifi_phy_hier(encoding=encoding, chan_est=chan_est) self.sync_long = ieee802_11.ofdm_sync_long(sync_length, False, False) self.qtgui_time_sink_x_1 = qtgui.time_sink_c( 2 ** 14, samp_rate, "", 1 # size # samp_rate # name # number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-1, 1) self.qtgui_time_sink_x_1.set_y_label("My own sycn short", "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.05, 0, 0, "ofdm_start") self.qtgui_time_sink_x_1.enable_autoscale(True) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 2 ** 15, samp_rate, "", 3 # size # samp_rate # name # number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-0.01, 0.4) 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_NORM, qtgui.TRIG_SLOPE_POS, 0.15, 2e-3, 2, "FISTOR") self.qtgui_time_sink_x_0.enable_autoscale(False) self.qtgui_time_sink_x_0.enable_grid(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["samples", "corr", "correlation_big", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(3): if len(labels[i]) == 0: self.qtgui_time_sink_x_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_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("nuber sync") 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, -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_layout.addWidget(self._qtgui_number_sink_0_win) self._pdu_length_range = Range(0, 1500, 1, 500, 200) self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider") self.top_layout.addWidget(self._pdu_length_win) self.marica = ofdm_80211.short_match_filter(160, 16) self._interval_range = Range(10, 10000, 1, 100, 200) self._interval_win = RangeWidget(self._interval_range, self.set_interval, "interval", "counter_slider") self.top_layout.addWidget(self._interval_win) self.ieee802_11_ofdm_parse_mac_0_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, False) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac( ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF]), ) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(False, False) self._freq_offset_range = Range(-0.10, 0.1, 0.0001, 0, 200) self._freq_offset_win = RangeWidget(self._freq_offset_range, self.set_freq_offset, "freq_offset", "slider") self.top_layout.addWidget(self._freq_offset_win) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.fft_vxx_0_1 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.carajito = ofdm_80211.ofdm_sync_short(0.05, 2, False, False) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate / 2, True) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex * 1, 64) self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_1_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_null_sink_0_1_0 = blocks.null_sink(gr.sizeof_float * 1) self.blocks_null_sink_0_0 = blocks.null_sink(gr.sizeof_gr_complex * 1) self.blocks_multiply_const_vxx_0_0_0 = blocks.multiply_const_vff((4e9 * 10 ** ((36 - snr) / 10.0),)) self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((9e9,)) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((10 ** ((snr + noise_var) / 20.0) + 1,)) self.blocks_message_strobe_1_0 = blocks.message_strobe( pmt.intern( "HOLAabcd123456aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1234" ), 1000, ) self.blocks_delay_0_1 = blocks.delay(gr.sizeof_gr_complex * 1, sync_length) self.blocks_complex_to_mag_squared_0_1_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_squared_0_1 = blocks.complex_to_mag_squared(1) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_1_0, "strobe"), (self.ieee802_11_ofdm_mac_0, "app in")) self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, "out"), (self.ieee802_11_ofdm_parse_mac_0_0, "in")) self.msg_connect((self.ieee802_11_ofdm_mac_0, "phy out"), (self.wifi_phy_hier_0, "mac_in")) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0_0, "fer"), (self.blocks_pdu_to_tagged_stream_0_0, "pdus")) self.msg_connect((self.wifi_phy_hier_0, "mac_out"), (self.ieee802_11_ofdm_parse_mac_0, "in")) self.connect((self.blocks_complex_to_mag_squared_0_1, 0), (self.blocks_multiply_const_vxx_0_0_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0_1_0, 0), (self.blocks_multiply_const_vxx_0_0, 0)) self.connect((self.blocks_delay_0_1, 0), (self.sync_long, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.marica, 0)) self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_multiply_const_vxx_0_0_0, 0), (self.qtgui_time_sink_x_0, 1)) self.connect((self.blocks_null_source_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0_1, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.carajito, 0), (self.blocks_delay_0_1, 0)) self.connect((self.carajito, 0), (self.blocks_null_sink_0_1_0_0, 0)) self.connect((self.carajito, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.carajito, 0), (self.sync_long, 0)) self.connect((self.fft_vxx_0_1, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.marica, 1), (self.blocks_complex_to_mag_squared_0_1, 0)) self.connect((self.marica, 0), (self.blocks_complex_to_mag_squared_0_1_0, 0)) self.connect((self.marica, 2), (self.blocks_null_sink_0_1_0, 0)) self.connect((self.marica, 1), (self.carajito, 1)) self.connect((self.marica, 3), (self.carajito, 2)) self.connect((self.marica, 0), (self.carajito, 0)) self.connect((self.marica, 3), (self.qtgui_time_sink_x_0, 2)) self.connect((self.sync_long, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
if self.callback is not None: self.callback(msg_str) else: print msg_str if meta is not None: print "[METADATA]: ", meta if __name__ == "__main__": import time # Create a flow graph tb = gr.top_block() # Create chat blocks chat_tx = message_pdu(None) chat_rx = message_pdu(None) pdu_to_tagged_stream = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") tagged_stream_to_pdu = blocks.tagged_stream_to_pdu(blocks.byte_t, "packet_len") # Connect them up tb.msg_connect(chat_tx, 'out', chat_rx, 'in') # Start flow graph tb.start() chat_str = "" print "======= Chat/Message Passing Tester. Please type a message (type /quit to exit) =========" try: while chat_str != "/quit": chat_str = raw_input('> ') chat_tx.post_message("freq.", chat_str) time.sleep(0.1) except KeyboardInterrupt: print "\n" except EOFError:
def __init__(self, sym_rate=256, samp_per_sym=256, nominal_uplink_freq=2041.95e6*0 + 2041.9479e6 + 1e6*0, lo_off=5e6 * 0, tx_gain=15*0 + 13.5*0, backoff=0.150*0 + (0.6+0.1)*0 + 1e-3, record_path='/media/balint/PATRIOT/ICE/TX/'): grc_wxgui.top_block_gui.__init__(self, title="Uplink") ################################################## # Parameters ################################################## self.sym_rate = sym_rate self.samp_per_sym = samp_per_sym self.nominal_uplink_freq = nominal_uplink_freq self.lo_off = lo_off self.tx_gain = tx_gain self.backoff = backoff self.record_path = record_path ################################################## # Variables ################################################## self.time_format = time_format = "%Y-%d-%m_%H-%M-%S" self.time_now = time_now = time.strftime(time_format) self.samp_rate = samp_rate = 250000 self.pre_resamp_rate = pre_resamp_rate = sym_rate * samp_per_sym self.f1 = f1 = 9000.0 self.f0 = f0 = 7500.0 self.resamp_rate = resamp_rate = float(samp_rate)/float(pre_resamp_rate) self.pm = pm = 1.2*0 + 1.0 self.nominal_uplink_freq_chooser = nominal_uplink_freq_chooser = nominal_uplink_freq self.manual_doppler = manual_doppler = 0 self.file_name = file_name = time_now + ".mcfile" self.doppler = doppler = 0 self.deviation = deviation = (f1 - f0) / 2.0 self.tx_gain_user = tx_gain_user = tx_gain self.subcarrier_freq = subcarrier_freq = f0 + deviation self.source = source = 'external' self.pm_txt = pm_txt = pm self.nominal_uplink_freq_user = nominal_uplink_freq_user = nominal_uplink_freq_chooser self.lo_off_user = lo_off_user = lo_off self.length_mul = length_mul = float(samp_per_sym) * resamp_rate self.invert = invert = 1 self.final_record_path = final_record_path = os.path.join(record_path, file_name) self.final_doppler = final_doppler = doppler + manual_doppler self.backoff_user = backoff_user = backoff ################################################## # Blocks ################################################## _tx_gain_user_sizer = wx.BoxSizer(wx.VERTICAL) self._tx_gain_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, label="TX Gain", converter=forms.float_converter(), proportion=0, ) self._tx_gain_user_slider = forms.slider( parent=self.GetWin(), sizer=_tx_gain_user_sizer, value=self.tx_gain_user, callback=self.set_tx_gain_user, minimum=0, maximum=32, num_steps=32, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_tx_gain_user_sizer) self._nominal_uplink_freq_user_text_box = forms.text_box( parent=self.GetWin(), value=self.nominal_uplink_freq_user, callback=self.set_nominal_uplink_freq_user, label="Nominal Uplink Freq", converter=forms.float_converter(), ) self.Add(self._nominal_uplink_freq_user_text_box) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "Output FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input FFT") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Input Phase/Mag") self.nb.AddPage(grc_wxgui.Panel(self.nb), "Mod Clk/Data") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Output Scope") self.nb.AddPage(grc_wxgui.Panel(self.nb), "PM Input") self.Add(self.nb) self._lo_off_user_text_box = forms.text_box( parent=self.GetWin(), value=self.lo_off_user, callback=self.set_lo_off_user, label="LO Offset", converter=forms.float_converter(), ) self.Add(self._lo_off_user_text_box) self._final_doppler_static_text = forms.static_text( parent=self.GetWin(), value=self.final_doppler, callback=self.set_final_doppler, label="Final Doppler", converter=forms.float_converter(), ) self.Add(self._final_doppler_static_text) self._doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.doppler, callback=self.set_doppler, label="Doppler Shift", converter=forms.float_converter(), ) self.Add(self._doppler_text_box) _backoff_user_sizer = wx.BoxSizer(wx.VERTICAL) self._backoff_user_text_box = forms.text_box( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, label="Backoff", converter=forms.float_converter(), proportion=0, ) self._backoff_user_slider = forms.slider( parent=self.GetWin(), sizer=_backoff_user_sizer, value=self.backoff_user, callback=self.set_backoff_user, minimum=0, maximum=1, num_steps=100, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_backoff_user_sizer) self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("", 52003), allow_none=True) self.xmlrpc_server_0.register_instance(self) threading.Thread(target=self.xmlrpc_server_0.serve_forever).start() self.wxgui_scopesink2_2 = scopesink2.scope_sink_f( self.nb.GetPage(5).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(5).Add(self.wxgui_scopesink2_2.win) self.wxgui_scopesink2_1 = scopesink2.scope_sink_c( self.nb.GetPage(4).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(4).Add(self.wxgui_scopesink2_1.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(0).GetWin(), baseband_freq=0, y_per_div=10, y_divs=10, ref_level=0, ref_scale=2.0, sample_rate=samp_rate, fft_size=256, fft_rate=10, average=False, avg_alpha=None, title="FFT Plot", peak_hold=False, fft_in=False, always_run=False, fft_out=False, ) self.nb.GetPage(0).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("serial=F4A7C3", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), "", True, ) self.uhd_usrp_sink_0.set_clock_source(source, 0) self.uhd_usrp_sink_0.set_time_source(source, 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(nominal_uplink_freq_user,lo_off_user), 0) self.uhd_usrp_sink_0.set_gain(tx_gain*0 + tx_gain_user, 0) self.uhd_usrp_sink_0.set_antenna('TX/RX', 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=int(samp_rate), decimation=int(pre_resamp_rate), taps=None, fractional_bw=None, ) self._pm_txt_static_text = forms.static_text( parent=self.GetWin(), value=self.pm_txt, callback=self.set_pm_txt, label="Phase Moduation Index", converter=forms.float_converter(), ) self.Add(self._pm_txt_static_text) self._nominal_uplink_freq_chooser_chooser = forms.drop_down( parent=self.GetWin(), value=self.nominal_uplink_freq_chooser, callback=self.set_nominal_uplink_freq_chooser, label="Nomial Uplink Frequency", choices=[2041.9479e6, 2090.66e6], labels=['B: 2041.9479', 'A: 2090.66'], ) self.Add(self._nominal_uplink_freq_chooser_chooser) self._manual_doppler_text_box = forms.text_box( parent=self.GetWin(), value=self.manual_doppler, callback=self.set_manual_doppler, label="Manual Doppler", converter=forms.float_converter(), ) self.Add(self._manual_doppler_text_box) self.mac_burst_tagger_0 = mac.burst_tagger('packet_len', length_mul, 256, 32*0 + 256, True, False) self.clock_and_data = scopesink2.scope_sink_c( self.nb.GetPage(3).GetWin(), title="Scope Plot", sample_rate=pre_resamp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(3).Add(self.clock_and_data.win) self.carrier = analog.sig_source_c(samp_rate, analog.GR_COS_WAVE, doppler*0 + final_doppler, 0*backoff + backoff_user, 0) self.blocks_vector_source_x_0 = blocks.vector_source_f(tuple([1] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [0] * (samp_per_sym/4) + [1] * (samp_per_sym/4)), True, 1, []) self.blocks_socket_pdu_0 = blocks.socket_pdu("TCP_SERVER", "", "52002", 10000, False) self.blocks_repeat_0 = blocks.repeat(gr.sizeof_float*1, samp_per_sym) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len", 1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_multiply_xx_1 = blocks.multiply_vcc(1) self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vff((2.0/3, )) self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vff((2, )) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((invert, )) self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.cons(pmt.to_pmt({'ignore': True}), pmt.init_u8vector(1, 1*[0])), 0) self.blocks_float_to_complex_2 = blocks.float_to_complex(1) self.blocks_float_to_complex_1 = blocks.float_to_complex(1) self.blocks_file_meta_sink_0 = blocks.file_meta_sink(gr.sizeof_gr_complex*1, final_record_path, samp_rate, 1, blocks.GR_FILE_FLOAT, True, 1000000, "", True) self.blocks_file_meta_sink_0.set_unbuffered(False) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.blocks_add_const_vxx_1_0 = blocks.add_const_vff((1.0/3, )) self.blocks_add_const_vxx_1 = blocks.add_const_vff((-1, )) self.binary_to_pdu0 = isee3.binary_to_pdu() self.analog_sig_source_x_0 = analog.sig_source_c(pre_resamp_rate, analog.GR_COS_WAVE, subcarrier_freq, 1/1.333, 0) self.analog_phase_modulator_fc_1 = analog.phase_modulator_fc(pm / (2.0*0 + 1)) self.analog_frequency_modulator_fc_0 = analog.frequency_modulator_fc(float(deviation) / float(pre_resamp_rate) * math.pi*2.0) ################################################## # Connections ################################################## self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_multiply_const_vxx_1, 0)) self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_const_vxx_1, 0)) self.connect((self.blocks_add_const_vxx_1, 0), (self.blocks_repeat_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.analog_frequency_modulator_fc_0, 0), (self.blocks_multiply_xx_0, 0)) self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_const_vxx_1_0, 0)) self.connect((self.analog_sig_source_x_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 0)) self.connect((self.blocks_float_to_complex_1, 0), (self.clock_and_data, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.carrier, 0), (self.blocks_multiply_xx_1, 1)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_1, 1)) self.connect((self.blocks_repeat_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.analog_frequency_modulator_fc_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_phase_modulator_fc_1, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.wxgui_scopesink2_2, 0)) self.connect((self.blocks_add_const_vxx_1_0, 0), (self.blocks_float_to_complex_2, 1)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_float_to_complex_1, 0)) self.connect((self.blocks_float_to_complex_2, 0), (self.blocks_multiply_xx_0, 2)) self.connect((self.mac_burst_tagger_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.mac_burst_tagger_0, 0)) self.connect((self.blocks_multiply_xx_1, 0), (self.wxgui_scopesink2_1, 0)) self.connect((self.analog_phase_modulator_fc_1, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_xx_1, 0)) self.connect((self.mac_burst_tagger_0, 0), (self.blocks_file_meta_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.binary_to_pdu0, "pdu_out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.blocks_socket_pdu_0, "pdus", self.binary_to_pdu0, "binary_in") self.msg_connect(self.blocks_message_strobe_0_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.uhd_usrp_sink_0, "ctl", self.blocks_message_strobe_0_0, "trigger")
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Rx Only Power") _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png" self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY)) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 20e6 self.lo_offset = lo_offset = 11e6 self.gain = gain = 20 self.freq = freq = 5.805e9 self.chan_est = chan_est = 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=["5 MHz", "10 MHz", "20 MHz"], style=wx.RA_HORIZONTAL, ) self.Add(self._samp_rate_chooser) self.nb = self.nb = wx.Notebook(self.GetWin(), style=wx.NB_TOP) self.nb.AddPage(grc_wxgui.Panel(self.nb), "constellation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "autocorrelation") self.nb.AddPage(grc_wxgui.Panel(self.nb), "FFT") self.Add(self.nb) 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) _gain_sizer = wx.BoxSizer(wx.VERTICAL) self._gain_text_box = forms.text_box( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, label='gain', converter=forms.int_converter(), proportion=0, ) self._gain_slider = forms.slider( parent=self.GetWin(), sizer=_gain_sizer, value=self.gain, callback=self.set_gain, minimum=0, maximum=100, num_steps=100, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_gain_sizer) 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._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_f( self.nb.GetPage(1).GetWin(), title="Scope Plot", sample_rate=samp_rate, v_scale=0, v_offset=0, t_scale=0, ac_couple=False, xy_mode=False, num_inputs=1, trig_mode=wxgui.TRIG_MODE_AUTO, y_axis_label="Counts", ) self.nb.GetPage(1).Add(self.wxgui_scopesink2_0.win) self.wxgui_scopesink1 = scopesink2.scope_sink_c( self.nb.GetPage(0).GetWin(), title="Scope Plot", sample_rate=12500, 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.nb.GetPage(0).Add(self.wxgui_scopesink1.win) self.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="%", minval=0, maxval=100, factor=1.0, decimal_places=2, ref_level=0, sample_rate=1, number_rate=15, average=True, avg_alpha=0.02, label="Frame Error Rate", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wxgui_fftsink2_0 = fftsink2.fft_sink_c( self.nb.GetPage(2).GetWin(), baseband_freq=580.5*10e6, y_per_div=10, y_divs=10, ref_level=gain, ref_scale=2.0, sample_rate=samp_rate, fft_size=64, fft_rate=15, average=True, avg_alpha=None, title="FFT Plot", peak_hold=False, ) self.nb.GetPage(2).Add(self.wxgui_fftsink2_0.win) self.uhd_usrp_source_0 = uhd.usrp_source( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_source_0.set_samp_rate(samp_rate) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_gain(gain, 0) self.ieee802_11_ofdm_sync_short_0 = ieee802_11.ofdm_sync_short(0.56, 2, False, False) self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, True, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(chan_est, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(True, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(True, True) self.ieee802_11_moving_average_xx_1 = ieee802_11.moving_average_ff(window_size + 16) self.ieee802_11_moving_average_xx_0 = ieee802_11.moving_average_cc(window_size) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.blocks_vector_to_stream_1 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 64) self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_gr_complex*1, 48) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") self.blocks_multiply_xx_0 = blocks.multiply_vcc(1) self.blocks_file_sink_1 = blocks.file_sink(gr.sizeof_gr_complex*1, "/home/furonics/GNURadio/25Feb2016DataTransfer.dat", False) self.blocks_file_sink_1.set_unbuffered(False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/furonics/GNURadio/11thFeb2016_AtHome.pcap", False) self.blocks_file_sink_0.set_unbuffered(True) self.blocks_divide_xx_0 = blocks.divide_ff(1) self.blocks_delay_0_0 = blocks.delay(gr.sizeof_gr_complex*1, 16) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) self.blocks_conjugate_cc_0 = blocks.conjugate_cc() self.blocks_complex_to_mag_squared_0 = blocks.complex_to_mag_squared(1) self.blocks_complex_to_mag_0 = blocks.complex_to_mag(1) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_complex_to_mag_0, 0), (self.blocks_divide_xx_0, 0)) self.connect((self.blocks_complex_to_mag_squared_0, 0), (self.ieee802_11_moving_average_xx_1, 0)) self.connect((self.blocks_conjugate_cc_0, 0), (self.blocks_multiply_xx_0, 1)) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_delay_0_0, 0), (self.blocks_conjugate_cc_0, 0)) self.connect((self.blocks_delay_0_0, 0), (self.ieee802_11_ofdm_sync_short_0, 0)) self.connect((self.blocks_divide_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 2)) self.connect((self.blocks_divide_xx_0, 0), (self.wxgui_scopesink2_0, 0)) self.connect((self.blocks_multiply_xx_0, 0), (self.ieee802_11_moving_average_xx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.blocks_vector_to_stream_0, 0), (self.wxgui_scopesink1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.blocks_file_sink_1, 0)) self.connect((self.blocks_vector_to_stream_1, 0), (self.wxgui_fftsink2_0, 0)) self.connect((self.fft_vxx_0, 0), (self.blocks_vector_to_stream_1, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.blocks_complex_to_mag_0, 0)) self.connect((self.ieee802_11_moving_average_xx_0, 0), (self.ieee802_11_ofdm_sync_short_0, 1)) self.connect((self.ieee802_11_moving_average_xx_1, 0), (self.blocks_divide_xx_0, 1)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.blocks_vector_to_stream_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.blocks_delay_0, 0)) self.connect((self.ieee802_11_ofdm_sync_short_0, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_complex_to_mag_squared_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_delay_0_0, 0)) self.connect((self.uhd_usrp_source_0, 0), (self.blocks_multiply_xx_0, 0))
def __init__(self): gr.top_block.__init__(self, "Ofdm Tx") Qt.QWidget.__init__(self) self.setWindowTitle("Ofdm Tx") 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", "ofdm_tx") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 self.packet_len = packet_len = 100 self.len_tag_key = len_tag_key = "packet_len" self.gain = gain = 60 self.fft_len = fft_len = 128 ################################################## # Blocks ################################################## self._gain_layout = Qt.QVBoxLayout() self._gain_tool_bar = Qt.QToolBar(self) self._gain_layout.addWidget(self._gain_tool_bar) self._gain_tool_bar.addWidget(Qt.QLabel("gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._gain_counter = qwt_counter_pyslot() self._gain_counter.setRange(0, 90, 1) self._gain_counter.setNumButtons(2) self._gain_counter.setValue(self.gain) self._gain_tool_bar.addWidget(self._gain_counter) self._gain_counter.valueChanged.connect(self.set_gain) self._gain_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._gain_slider.setRange(0, 90, 1) self._gain_slider.setValue(self.gain) self._gain_slider.setMinimumWidth(200) self._gain_slider.valueChanged.connect(self.set_gain) self._gain_layout.addWidget(self._gain_slider) self.top_layout.addLayout(self._gain_layout) self.uhd_usrp_sink_0 = uhd.usrp_sink( device_addr="", stream_args=uhd.stream_args( cpu_format="fc32", channels=range(1), ), ) self.uhd_usrp_sink_0.set_subdev_spec("A:A", 0) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(400e6, 0) self.uhd_usrp_sink_0.set_gain(gain, 0) self.rational_resampler_xxx_0 = filter.rational_resampler_ccc( interpolation=2, decimation=1, taps=None, fractional_bw=None, ) self.fosdem_burst_marker_0 = fosdem.burst_marker(gr.sizeof_gr_complex, len_tag_key, 0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=fft_len, cp_len=fft_len/4, packet_length_tag_key=len_tag_key, bps_header=1, bps_payload=2, rolloff=0, debug_log=False, scramble_bits=True ) self.blocks_tagged_stream_multiply_length_0 = blocks.tagged_stream_multiply_length(gr.sizeof_gr_complex*1, len_tag_key, 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.05, )) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(packet_len, 0xAA)), 1000) ################################################## # Connections ################################################## self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_tagged_stream_multiply_length_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.rational_resampler_xxx_0, 0)) self.connect((self.rational_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.blocks_tagged_stream_multiply_length_0, 0), (self.fosdem_burst_marker_0, 0)) self.connect((self.fosdem_burst_marker_0, 0), (self.uhd_usrp_sink_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.blocks_message_strobe_0, "strobe", self.blocks_pdu_to_tagged_stream_0, "pdus")
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 10e6 self.pdu_length = pdu_length = 500 self.lo_offset = lo_offset = 0 self.gain = gain = 0.75 self.freq = freq = 5890000000 self.encoding = encoding = [0,0,0,0,0] self.chan_est = chan_est = 0 ################################################## # Blocks ################################################## self.frequencyAdaptiveOFDM_mac_and_parse_0 = frequencyAdaptiveOFDM.mac_and_parse(([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), False, True, '/tmp/tx_packets.csv', '/tmp/rx_packets.csv') self._samp_rate_options = [5e6, 10e6, 20e6] self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate"+": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self._pdu_length_range = Range(0, 1500, 1, 500, 200) self._pdu_length_win = RangeWidget(self._pdu_length_range, self.set_pdu_length, "pdu_length", "counter_slider", int) self.top_layout.addWidget(self._pdu_length_win) self._lo_offset_options = (0, 6e6, 11e6, ) self._lo_offset_labels = (str(self._lo_offset_options[0]), str(self._lo_offset_options[1]), str(self._lo_offset_options[2]), ) self._lo_offset_tool_bar = Qt.QToolBar(self) self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset"+": ")) self._lo_offset_combo_box = Qt.QComboBox() self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box) for label in self._lo_offset_labels: self._lo_offset_combo_box.addItem(label) self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(self._lo_offset_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._lo_offset_options.index(i))) self._lo_offset_callback(self.lo_offset) self._lo_offset_combo_box.currentIndexChanged.connect( lambda i: self.set_lo_offset(self._lo_offset_options[i])) self.top_layout.addWidget(self._lo_offset_tool_bar) self._gain_range = Range(0, 1, 0.01, 0.75, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "counter_slider", float) self.top_layout.addWidget(self._gain_win) self._freq_options = [2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0, 5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0, 5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0, 5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0, 5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0, 5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0, 5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0, 5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0, 5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0, 5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0] self._freq_labels = [' 1 | 2412.0 | 11g', ' 2 | 2417.0 | 11g', ' 3 | 2422.0 | 11g', ' 4 | 2427.0 | 11g', ' 5 | 2432.0 | 11g', ' 6 | 2437.0 | 11g', ' 7 | 2442.0 | 11g', ' 8 | 2447.0 | 11g', ' 9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a', ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a', ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a', '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a', '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a', '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a', '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a', '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a', '142 | 5710.0 | 11a', '144 | 5720.0 | 11a', '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)', '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)', '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)', '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'] self._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("freq"+": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) def _encoding_probe(): while True: val = self.frequencyAdaptiveOFDM_mac_and_parse_0.get_encoding() try: self.set_encoding(val) except AttributeError: pass time.sleep(1.0 / (1000)) _encoding_thread = threading.Thread(target=_encoding_probe) _encoding_thread.daemon = True _encoding_thread.start() self._chan_est_options = 0, 1, 3, 2 self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"] self._chan_est_group_box = Qt.QGroupBox("chan_est") self._chan_est_box = Qt.QHBoxLayout() class variable_chooser_button_group(Qt.QButtonGroup): def __init__(self, parent=None): Qt.QButtonGroup.__init__(self, parent) @pyqtSlot(int) def updateButtonChecked(self, button_id): self.button(button_id).setChecked(True) self._chan_est_button_group = variable_chooser_button_group() self._chan_est_group_box.setLayout(self._chan_est_box) for i, label in enumerate(self._chan_est_labels): radio_button = Qt.QRadioButton(label) self._chan_est_box.addWidget(radio_button) self._chan_est_button_group.addButton(radio_button, i) self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(self._chan_est_button_group, "updateButtonChecked", Qt.Q_ARG("int", self._chan_est_options.index(i))) self._chan_est_callback(self.chan_est) self._chan_est_button_group.buttonClicked[int].connect( lambda i: self.set_chan_est(self._chan_est_options[i])) self.top_layout.addWidget(self._chan_est_group_box) self.wifi_freq_adap_phy_hier_0 = wifi_freq_adap_phy_hier( bandwidth=10e6, chan_est=0, encoding=encoding, frequency=5.89e9, sensitivity=0.56, ) 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_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_source_0.set_normalized_gain(gain, 0) self.uhd_usrp_source_0.set_antenna("TX/RX", 0) self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(('', "")), uhd.stream_args( cpu_format="fc32", channels=range(1), ), 'packet_len', ) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0) self.uhd_usrp_sink_0.set_normalized_gain(gain, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_f( 1024, #size 300000, #samp_rate "Data Received", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label('Amplitude', "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(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_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0, qtgui.NUM_GRAPH_NONE, 1 ) self.qtgui_number_sink_0.set_update_time(0.10) self.qtgui_number_sink_0.set_title("") labels = ['Error Rate', '', '', '', '', '', '', '', '', ''] units = ['Percent', '', '', '', '', '', '', '', '', ''] 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, 100) 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_const_sink_x_0 = qtgui.const_sink_c( 48*10, #size "", #name 4 #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 = ['RB1', 'RB2', 'RB3', 'RB4', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "yellow", "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(4): 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.frequencyAdaptiveOFDM_write_frame_data_0 = frequencyAdaptiveOFDM.write_frame_data('/tmp/snr.csv', '/tmp/encoding.csv', '/tmp/wifi_frame_delay.csv', True) self.frequencyAdaptiveOFDM_rb_const_demux_stream_0 = frequencyAdaptiveOFDM.rb_const_demux_stream('packet_len') 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.blocks_vector_source_x_0 = blocks.vector_source_b(range(100), True, 1, []) self.blocks_uchar_to_float_0 = blocks.uchar_to_float() self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, 'packet_len') self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_char, 1, pdu_length, 'packet_len') self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", '', '52001', 10000, False) 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 = blocks.pdu_to_tagged_stream(blocks.float_t, 'packet_len') self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, )) (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000) self.adaptiveOFDM_stream_spacer_0 = adaptiveOFDM.stream_spacer(blocks.byte_t, 500) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app in')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'app out'), (self.blocks_pdu_to_tagged_stream_0_1, 'pdus')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'frame data'), (self.frequencyAdaptiveOFDM_write_frame_data_0, 'frame data')) self.msg_connect((self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy out'), (self.wifi_freq_adap_phy_hier_0, 'mac_in')) self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'mac_out'), (self.frequencyAdaptiveOFDM_mac_and_parse_0, 'phy in')) self.msg_connect((self.wifi_freq_adap_phy_hier_0, 'carrier'), (self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 'symbols_in')) self.connect((self.adaptiveOFDM_stream_spacer_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0_1, 0), (self.blocks_uchar_to_float_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.adaptiveOFDM_stream_spacer_0, 0)) self.connect((self.blocks_uchar_to_float_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_vector_source_x_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 0), (self.qtgui_const_sink_x_0, 0)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 1), (self.qtgui_const_sink_x_0, 1)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 2), (self.qtgui_const_sink_x_0, 2)) self.connect((self.frequencyAdaptiveOFDM_rb_const_demux_stream_0, 3), (self.qtgui_const_sink_x_0, 3)) self.connect((self.uhd_usrp_source_0, 0), (self.wifi_freq_adap_phy_hier_0, 0)) self.connect((self.wifi_freq_adap_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 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_newv") 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(1255e6, 0) self.uhd_usrp_sink_0.set_gain(15, 0) self.uhd_usrp_sink_0.set_antenna("TX/RX", 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 = 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.dbconnect_packet_controller_0 = dbconnect.packet_controller(samp_rate/interp_factor, (10000,), 5, 10, 2, 20, 10, 5, 6643, 30000, (10,20,30), (0,1,2), True) self.dbconnect_cmd_pktgen_0 = dbconnect.cmd_pktgen("127.0.0.1", 5002, 64, 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.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.09, )) 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_packet_controller_0, 'in0')) self.msg_connect((self.dbconnect_cmd_pktgen_0, 'out0'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.dbconnect_packet_controller_0, 'gcmd'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.dbconnect_packet_controller_0, 'cmd'), (self.dbconnect_cmd_pktgen_0, 'cmd')) 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.dbconnect_packet_controller_0, 0), (self.rational_resampler_xxx_0_0, 0)) self.connect((self.dbconnect_packet_controller_0, 1), (self.rational_resampler_xxx_0_0_1, 0)) self.connect((self.dbconnect_packet_controller_0, 2), (self.rational_resampler_xxx_0_0_1_0, 0)) self.connect((self.dbconnect_packet_controller_0, 3), (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.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))
def __init__(self): gr.top_block.__init__(self, "OFDM Transceiver") self._lock = threading.RLock() ################################################## # Variables ################################################## self.sent_pkt = 0 self.rcv_pkt = 0 self.pilot_symbols = pilot_symbols = ((1, 1, 1, -1,),) self.pilot_carriers = pilot_carriers = ((-21, -7, 7, 21,),) self.payload_mod = payload_mod = digital.constellation_qpsk() self.packet_length_tag_key = packet_length_tag_key = "packet_len" self.occupied_carriers = occupied_carriers = (range(-26, -21) + range(-20, -7) + range(-6, 0) + range(1, 7) + range(8, 21) + range(22, 27),) self.length_tag_key = length_tag_key = "frame_len" self.header_mod = header_mod = digital.constellation_bpsk() self.fft_len = fft_len = 64 self.waterfall_min = waterfall_min = -80 self.waterfall_max = waterfall_max = -20 self.tx_gain = tx_gain = 0.03 self.sync_word2 = sync_word2 = [0j, 0j, 0j, 0j, 0j, 0j, (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1 +0j), (1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), 0j, (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (1+0j), (1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (1+0j), (-1+0j), (1+0j), (-1+0j), (-1+0j), (-1+0j), (-1+0j), 0j, 0j, 0j, 0j, 0j] 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.samp_rate = samp_rate = 20e6 self.payload_equalizer = payload_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, payload_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols, 1) self.header_formatter = header_formatter = digital.packet_header_ofdm(occupied_carriers, n_syms=1, len_tag_key=packet_length_tag_key, frame_len_tag_key=length_tag_key, bits_per_header_sym=header_mod.bits_per_symbol(), bits_per_payload_sym=payload_mod.bits_per_symbol(), scramble_header=False) self.header_equalizer = header_equalizer = digital.ofdm_equalizer_simpledfe(fft_len, header_mod.base(), occupied_carriers, pilot_carriers, pilot_symbols) self.center_freq = center_freq = 2.412e9 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=1" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(center_freq, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(1, 0) self.osmosdr_source_0.set_iq_balance_mode(1, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(10, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(samp_rate, 0) self.osmosdr_sink_0 = osmosdr.sink( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_sink_0.set_sample_rate(samp_rate) self.osmosdr_sink_0.set_center_freq(center_freq, 0) self.osmosdr_sink_0.set_freq_corr(10, 0) self.osmosdr_sink_0.set_gain(20, 0) self.osmosdr_sink_0.set_if_gain(20, 0) self.osmosdr_sink_0.set_bb_gain(0, 0) self.osmosdr_sink_0.set_antenna("", 0) self.osmosdr_sink_0.set_bandwidth(samp_rate, 0) self.digital_ofdm_tx_0 = digital.ofdm_tx( fft_len=64, cp_len=fft_len/4, packet_length_tag_key=packet_length_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=1, rolloff=0, debug_log=True, scramble_bits=False ) self.digital_ofdm_rx_0 = digital.ofdm_rx( fft_len=64, cp_len=fft_len/4, frame_length_tag_key='frame_'+packet_length_tag_key, packet_length_tag_key=packet_length_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=1, debug_log=False, scramble_bits=False ) self.dc_blocker_xx_0 = filter.dc_blocker_cc(1024, False) self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu(blocks.byte_t, packet_length_tag_key) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, packet_length_tag_key) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((tx_gain, )) self.blocks_message_debug_0 = blocks.message_debug() self.pdu_block = messaging.pdu_block(self) ################################################## # Connections ################################################## self.msg_connect((self.pdu_block, 'out_pdu'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.pdu_block, 'in_pdu')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.osmosdr_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_ofdm_tx_0, 0)) self.connect((self.dc_blocker_xx_0, 0), (self.digital_ofdm_rx_0, 0)) self.connect((self.digital_ofdm_rx_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.digital_ofdm_tx_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.dc_blocker_xx_0, 0))
def __init__(self, chan_est=1, encoding=0, freq_offset=0, interval=500, pdu_length=500, snr=10): gr.top_block.__init__(self, "Wifi Loopback") ################################################## # Parameters ################################################## self.chan_est = chan_est self.encoding = encoding self.freq_offset = freq_offset self.interval = interval self.pdu_length = pdu_length self.snr = snr ################################################## # Variables ################################################## self.out_buf_size = out_buf_size = 96000 ################################################## # Blocks ################################################## self.wifi_phy_hier_0 = wifi_phy_hier( encoding=encoding, chan_est=chan_est, ) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=.5**.5, frequency_offset=freq_offset, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1) self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, )) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), interval) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/sim.csv", False) self.blocks_file_sink_0.set_unbuffered(True) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in')) self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_null_sink_1, 0)) self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0)) self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 32000 self.interleave = interleave = 4 ################################################## # Blocks ################################################## self.qtgui_time_sink_x_1 = qtgui.time_sink_f( 800, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_1.set_update_time(0.10) self.qtgui_time_sink_x_1.set_y_axis(-130, 130) self.qtgui_time_sink_x_1.set_y_label("Amplitude", "") self.qtgui_time_sink_x_1.enable_tags(-1, True) self.qtgui_time_sink_x_1.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_1.enable_autoscale(False) self.qtgui_time_sink_x_1.enable_grid(False) self.qtgui_time_sink_x_1.enable_axis_labels(True) self.qtgui_time_sink_x_1.enable_control_panel(False) if not True: self.qtgui_time_sink_x_1.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_1.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_1.set_line_label(i, labels[i]) self.qtgui_time_sink_x_1.set_line_width(i, widths[i]) self.qtgui_time_sink_x_1.set_line_color(i, colors[i]) self.qtgui_time_sink_x_1.set_line_style(i, styles[i]) self.qtgui_time_sink_x_1.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_1.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_1_win = sip.wrapinstance(self.qtgui_time_sink_x_1.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_1_win) self.ccsds_rs_decode_pdu_0 = ccsds.rs_decode_pdu(interleave) self.ccsds_asm_deframer_pdu_0 = ccsds.asm_deframer_pdu(0, interleave, 1, 255) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_char*1, samp_rate,True) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_packed_to_unpacked_xx_0_0 = blocks.packed_to_unpacked_bb(1, gr.GR_MSB_FIRST) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test_Files/BAL_FEC_Test/frame.bit", False) self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/home/gs-laptop1/GroundStation/GroundStation/GNURadio/Test_Files/BAL_FEC_Test/frame_out.bit", False) self.blocks_file_sink_0.set_unbuffered(False) self.blocks_char_to_float_1 = blocks.char_to_float(1, 1) ################################################## # Connections ################################################## self.msg_connect((self.ccsds_asm_deframer_pdu_0, 'pdus'), (self.ccsds_rs_decode_pdu_0, 'pdu_in')) self.msg_connect((self.ccsds_rs_decode_pdu_0, 'pdu_out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_char_to_float_1, 0), (self.qtgui_time_sink_x_1, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_packed_to_unpacked_xx_0_0, 0), (self.ccsds_asm_deframer_pdu_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_file_sink_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_packed_to_unpacked_xx_0_0, 0))
def __init__(self): gr.top_block.__init__(self, "Top Block") Qt.QWidget.__init__(self) self.setWindowTitle("Top Block") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "top_block") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.samp_rate = samp_rate = 614400 self.rf_freq = rf_freq = 145e6 self.rf_bw = rf_bw = 100e3 ################################################## # Blocks ################################################## self.uhd_usrp_sink_0 = uhd.usrp_sink( ",".join(("", "")), uhd.stream_args( cpu_format="fc32", otw_format="sc12", channels=range(1), ), "packet_len", ) self.uhd_usrp_sink_0.set_clock_rate(30.72e6, uhd.ALL_MBOARDS) self.uhd_usrp_sink_0.set_samp_rate(samp_rate) self.uhd_usrp_sink_0.set_center_freq(rf_freq, 0) self.uhd_usrp_sink_0.set_gain(0, 0) self.uhd_usrp_sink_0.set_bandwidth(rf_bw, 0) self.qtgui_time_sink_x_0 = qtgui.time_sink_c( 1024, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0.set_update_time(0.10) self.qtgui_time_sink_x_0.set_y_axis(-1, 1) self.qtgui_time_sink_x_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0.enable_tags(-1, True) self.qtgui_time_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, 0.5, 0, 0, "") self.qtgui_time_sink_x_0.enable_autoscale(True) self.qtgui_time_sink_x_0.enable_grid(False) self.qtgui_time_sink_x_0.enable_axis_labels(True) self.qtgui_time_sink_x_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0.disable_legend() labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_win) self.blocks_random_pdu_0 = blocks.random_pdu(2000, 2000, chr(0xFF), 2) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 1000) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_char_to_float_0 = blocks.char_to_float(1, 1) self.analog_const_source_x_0 = analog.sig_source_f(0, analog.GR_CONST_WAVE, 0, 0, 0) ################################################## # 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.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.analog_const_source_x_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.blocks_char_to_float_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.qtgui_time_sink_x_0, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.uhd_usrp_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_char_to_float_0, 0))
def __init__(self): gr.top_block.__init__(self, "Wifi Rx Jun28") Qt.QWidget.__init__(self) self.setWindowTitle("Wifi Rx Jun28") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "wifi_rx_jun28") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Variables ################################################## self.window_size = window_size = 48 self.threshold = threshold = 1000 self.sync_length = sync_length = 320 self.samp_rate = samp_rate = 0.5e6 self.lo_offset = lo_offset = 0 self.gain = gain = 20 self.freq = freq = 943000000.0 self.decimation = decimation = 40 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## self._samp_rate_options = [0.5e6, 1e6, 5e6, 10e6, 20e6] self._samp_rate_labels = ["500 KHz", "1 MHz", "5 MHz", "10 MHz", "20 MHz"] self._samp_rate_tool_bar = Qt.QToolBar(self) self._samp_rate_tool_bar.addWidget(Qt.QLabel("Sample Rate"+": ")) self._samp_rate_combo_box = Qt.QComboBox() self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box) for label in self._samp_rate_labels: self._samp_rate_combo_box.addItem(label) self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(self._samp_rate_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._samp_rate_options.index(i))) self._samp_rate_callback(self.samp_rate) self._samp_rate_combo_box.currentIndexChanged.connect( lambda i: self.set_samp_rate(self._samp_rate_options[i])) self.top_layout.addWidget(self._samp_rate_tool_bar) self.qtgui_time_sink_x_2 = qtgui.time_sink_f( 32, #size 10, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_2.set_update_time(0.10) self.qtgui_time_sink_x_2.set_y_axis(-1, 110) self.qtgui_time_sink_x_2.set_y_label("Amplitude", "") self.qtgui_time_sink_x_2.enable_tags(-1, True) self.qtgui_time_sink_x_2.set_trigger_mode(qtgui.TRIG_MODE_FREE, qtgui.TRIG_SLOPE_POS, 0.0, 0, 0, "") self.qtgui_time_sink_x_2.enable_autoscale(False) self.qtgui_time_sink_x_2.enable_grid(True) self.qtgui_time_sink_x_2.enable_control_panel(False) if not True: self.qtgui_time_sink_x_2.disable_legend() labels = ["Packets Reveiced", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_2.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_2.set_line_label(i, labels[i]) self.qtgui_time_sink_x_2.set_line_width(i, widths[i]) self.qtgui_time_sink_x_2.set_line_color(i, colors[i]) self.qtgui_time_sink_x_2.set_line_style(i, styles[i]) self.qtgui_time_sink_x_2.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_2.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_2_win = sip.wrapinstance(self.qtgui_time_sink_x_2.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_2_win) self.qtgui_time_sink_x_0_0_0_0 = qtgui.time_sink_c( 2**17, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0_0.set_y_axis(-2, 2) self.qtgui_time_sink_x_0_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_TAG, qtgui.TRIG_SLOPE_POS, 0.02, 0.1, 0, "ofdm_start") self.qtgui_time_sink_x_0_0_0_0.enable_autoscale(False) self.qtgui_time_sink_x_0_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0_0.disable_legend() labels = ["samples", "corr", "correlation_big", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(2*1): if len(labels[i]) == 0: if(i % 2 == 0): self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, "Re{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, "Im{{Data {0}}}".format(i/2)) else: self.qtgui_time_sink_x_0_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_0_win) self.qtgui_time_sink_x_0_0_0 = qtgui.time_sink_f( 2**17, #size samp_rate, #samp_rate "", #name 1 #number of inputs ) self.qtgui_time_sink_x_0_0_0.set_update_time(0.10) self.qtgui_time_sink_x_0_0_0.set_y_axis(-0.1, 1000) self.qtgui_time_sink_x_0_0_0.set_y_label("Amplitude", "") self.qtgui_time_sink_x_0_0_0.enable_tags(-1, True) self.qtgui_time_sink_x_0_0_0.set_trigger_mode(qtgui.TRIG_MODE_NORM, qtgui.TRIG_SLOPE_POS, threshold, 5e-3, 0, "FISTOR") self.qtgui_time_sink_x_0_0_0.enable_autoscale(True) self.qtgui_time_sink_x_0_0_0.enable_grid(True) self.qtgui_time_sink_x_0_0_0.enable_control_panel(False) if not True: self.qtgui_time_sink_x_0_0_0.disable_legend() labels = ["correlation I", "correlation Q", "correlation_big", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "blue"] styles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] markers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_time_sink_x_0_0_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_time_sink_x_0_0_0.set_line_label(i, labels[i]) self.qtgui_time_sink_x_0_0_0.set_line_width(i, widths[i]) self.qtgui_time_sink_x_0_0_0.set_line_color(i, colors[i]) self.qtgui_time_sink_x_0_0_0.set_line_style(i, styles[i]) self.qtgui_time_sink_x_0_0_0.set_line_marker(i, markers[i]) self.qtgui_time_sink_x_0_0_0.set_line_alpha(i, alphas[i]) self._qtgui_time_sink_x_0_0_0_win = sip.wrapinstance(self.qtgui_time_sink_x_0_0_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_time_sink_x_0_0_0_win) self.qtgui_number_sink_0 = qtgui.number_sink( gr.sizeof_float, 0.99, qtgui.NUM_GRAPH_HORIZ, 1 ) self.qtgui_number_sink_0.set_update_time(0.0000010) self.qtgui_number_sink_0.set_title("Frame error Rata") 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, 100) 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( 8192, #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_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_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(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.ofdm_80211_short_MF_v2_0 = ofdm_80211.short_MF_v2(160, 16) self.ofdm_80211_ftc_0 = ofdm_80211.ftc() self.nutaq_rtdex_source_0 = nutaq.rtdex_source("nutaq_carrier_perseus_0",gr.sizeof_float,1,3) self.nutaq_rtdex_source_0.set_type(0) self.nutaq_rtdex_source_0.set_packet_size(8192) self.nutaq_rtdex_source_0.set_channels("2") self.nutaq_radio420_tx_0_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_0", 2, 2) self.nutaq_radio420_tx_0_0_0.set_default_enable(0) self.nutaq_radio420_tx_0_0_0.set_default_tx_freq(743e6) self.nutaq_radio420_tx_0_0_0.set_default_reference(0) self.nutaq_radio420_tx_0_0_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_tx_0_0_0.set_default_calibrate(1) self.nutaq_radio420_tx_0_0_0.set_default_band(0) self.nutaq_radio420_tx_0_0_0.set_default_update_rate(1) self.nutaq_radio420_tx_0_0_0.set_default_tx_vga1_gain(-10) self.nutaq_radio420_tx_0_0_0.set_default_tx_vga2_gain(15) self.nutaq_radio420_tx_0_0_0.set_default_tx_gain3(3) self.nutaq_radio420_tx_0_0_0.set_default_tx_lpf_bandwidth(6) self.nutaq_radio420_tx_0_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_tx_gain_ctrl(0) self.nutaq_radio420_tx_0_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_tx_0_0 = nutaq.radio420_tx("nutaq_carrier_perseus_0", 1, 0) self.nutaq_radio420_tx_0_0.set_default_enable(0) self.nutaq_radio420_tx_0_0.set_default_tx_freq(743e6) self.nutaq_radio420_tx_0_0.set_default_reference(0) self.nutaq_radio420_tx_0_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_tx_0_0.set_default_calibrate(1) self.nutaq_radio420_tx_0_0.set_default_band(0) self.nutaq_radio420_tx_0_0.set_default_update_rate(1) self.nutaq_radio420_tx_0_0.set_default_tx_vga1_gain(-10) self.nutaq_radio420_tx_0_0.set_default_tx_vga2_gain(15) self.nutaq_radio420_tx_0_0.set_default_tx_gain3(3) self.nutaq_radio420_tx_0_0.set_default_tx_lpf_bandwidth(6) self.nutaq_radio420_tx_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_tx_gain_ctrl(0) self.nutaq_radio420_tx_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_rx_0_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 2, 3) self.nutaq_radio420_rx_0_0.set_default_enable(1) self.nutaq_radio420_rx_0_0.set_default_rx_freq(943e6) self.nutaq_radio420_rx_0_0.set_default_reference(0) self.nutaq_radio420_rx_0_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_rx_0_0.set_default_calibrate(1) self.nutaq_radio420_rx_0_0.set_default_band(0) self.nutaq_radio420_rx_0_0.set_default_update_rate(1) self.nutaq_radio420_rx_0_0.set_default_rx_lna_gain(3) self.nutaq_radio420_rx_0_0.set_default_rx_vga1_gain(3) self.nutaq_radio420_rx_0_0.set_default_rx_gain2(0) self.nutaq_radio420_rx_0_0.set_default_rx_gain3(8) self.nutaq_radio420_rx_0_0.set_default_rx_rf_filter(2) self.nutaq_radio420_rx_0_0.set_default_rx_lpf_bandwidth(2) self.nutaq_radio420_rx_0_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_rf_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_rx_gain_ctrl(0) self.nutaq_radio420_rx_0_0.set_default_pll_cpld_ctrl(0) self.nutaq_radio420_rx_0 = nutaq.radio420_rx("nutaq_carrier_perseus_0", 1, 1) self.nutaq_radio420_rx_0.set_default_enable(0) self.nutaq_radio420_rx_0.set_default_rx_freq(943e6) self.nutaq_radio420_rx_0.set_default_reference(0) self.nutaq_radio420_rx_0.set_default_datarate(samp_rate*2*decimation) self.nutaq_radio420_rx_0.set_default_calibrate(1) self.nutaq_radio420_rx_0.set_default_band(0) self.nutaq_radio420_rx_0.set_default_update_rate(1) self.nutaq_radio420_rx_0.set_default_rx_lna_gain(2) self.nutaq_radio420_rx_0.set_default_rx_vga1_gain(1) self.nutaq_radio420_rx_0.set_default_rx_gain2(0) self.nutaq_radio420_rx_0.set_default_rx_gain3(3) self.nutaq_radio420_rx_0.set_default_rx_rf_filter(2) self.nutaq_radio420_rx_0.set_default_rx_lpf_bandwidth(2) self.nutaq_radio420_rx_0.set_default_ref_clk_ctrl(0) self.nutaq_radio420_rx_0.set_default_rf_ctrl(0) self.nutaq_radio420_rx_0.set_default_rx_gain_ctrl(0) self.nutaq_radio420_rx_0.set_default_pll_cpld_ctrl(0) self.nutaq_custom_register_0_2 = nutaq.custom_register("nutaq_carrier_perseus_0",4) self.nutaq_custom_register_0_2.set_index(0) self.nutaq_custom_register_0_2.set_default_value(int((4e6)/samp_rate/40*(2**32))) self.nutaq_custom_register_0_2.set_update_rate(1) self.nutaq_custom_register_0_1 = nutaq.custom_register("nutaq_carrier_perseus_0",4) self.nutaq_custom_register_0_1.set_index(2) self.nutaq_custom_register_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_1 = nutaq.custom_register("nutaq_carrier_perseus_0",5) self.nutaq_custom_register_0_0_1.set_index(3) self.nutaq_custom_register_0_0_1.set_default_value(7) self.nutaq_custom_register_0_0_1.set_update_rate(1) self.nutaq_custom_register_0_0_0 = nutaq.custom_register("nutaq_carrier_perseus_0",5) self.nutaq_custom_register_0_0_0.set_index(6) self.nutaq_custom_register_0_0_0.set_default_value(600) self.nutaq_custom_register_0_0_0.set_update_rate(1) self.nutaq_custom_register_0_0 = nutaq.custom_register("nutaq_carrier_perseus_0",5) self.nutaq_custom_register_0_0.set_index(4) self.nutaq_custom_register_0_0.set_update_rate(1) self.nutaq_custom_register_0 = nutaq.custom_register("nutaq_carrier_perseus_0",4) self.nutaq_custom_register_0.set_index(1) self.nutaq_custom_register_0.set_default_value(3) self.nutaq_custom_register_0.set_update_rate(1) self.nutaq_carrier_perseus_0 = nutaq.carrier(0,"nutaq_carrier_perseus_0", "192.168.0.101") self.ieee802_11_ofdm_sync_long_0 = ieee802_11.ofdm_sync_long(sync_length, False, False) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, False) self.ieee802_11_ofdm_equalize_symbols_0 = ieee802_11.ofdm_equalize_symbols(ieee802_11.LMS, False) self.ieee802_11_ofdm_decode_signal_0 = ieee802_11.ofdm_decode_signal(False, False) self.ieee802_11_ofdm_decode_mac_0 = ieee802_11.ofdm_decode_mac(False, False) self._gain_range = Range(0, 100, 1, 20, 200) self._gain_win = RangeWidget(self._gain_range, self.set_gain, "gain", "slider") self.top_layout.addWidget(self._gain_win) self._freq_options = [943000000.0, 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] self._freq_labels = [' 0 | 943.0 | ??', ' 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._freq_tool_bar = Qt.QToolBar(self) self._freq_tool_bar.addWidget(Qt.QLabel("Channel"+": ")) self._freq_combo_box = Qt.QComboBox() self._freq_tool_bar.addWidget(self._freq_combo_box) for label in self._freq_labels: self._freq_combo_box.addItem(label) self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(self._freq_combo_box, "setCurrentIndex", Qt.Q_ARG("int", self._freq_options.index(i))) self._freq_callback(self.freq) self._freq_combo_box.currentIndexChanged.connect( lambda i: self.set_freq(self._freq_options[i])) self.top_layout.addWidget(self._freq_tool_bar) self.fft_vxx_0 = fft.fft_vcc(64, True, (window.rectangular(64)), True, 1) self.carajito = ofdm_80211.ofdm_sync_short(threshold, 2, False, False) self.blocks_stream_to_vector_0 = blocks.stream_to_vector(gr.sizeof_gr_complex*1, 64) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") self.blocks_null_sink_0_1_0_0 = blocks.null_sink(gr.sizeof_float*1) self.blocks_delay_0 = blocks.delay(gr.sizeof_gr_complex*1, sync_length) ################################################## # Connections ################################################## self.msg_connect((self.ieee802_11_ofdm_decode_mac_0, 'out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.connect((self.blocks_delay_0, 0), (self.ieee802_11_ofdm_sync_long_0, 1)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_number_sink_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.qtgui_time_sink_x_2, 0)) self.connect((self.blocks_stream_to_vector_0, 0), (self.fft_vxx_0, 0)) self.connect((self.carajito, 0), (self.blocks_delay_0, 0)) self.connect((self.carajito, 0), (self.ieee802_11_ofdm_sync_long_0, 0)) self.connect((self.carajito, 0), (self.qtgui_time_sink_x_0_0_0_0, 0)) self.connect((self.fft_vxx_0, 0), (self.ieee802_11_ofdm_equalize_symbols_0, 0)) self.connect((self.ieee802_11_ofdm_decode_signal_0, 0), (self.ieee802_11_ofdm_decode_mac_0, 0)) self.connect((self.ieee802_11_ofdm_equalize_symbols_0, 0), (self.ieee802_11_ofdm_decode_signal_0, 0)) self.connect((self.ieee802_11_ofdm_sync_long_0, 0), (self.blocks_stream_to_vector_0, 0)) self.connect((self.nutaq_rtdex_source_0, 0), (self.ofdm_80211_ftc_0, 0)) self.connect((self.ofdm_80211_ftc_0, 0), (self.ofdm_80211_short_MF_v2_0, 0)) self.connect((self.ofdm_80211_ftc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 2), (self.blocks_null_sink_0_1_0_0, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 0), (self.carajito, 0)) self.connect((self.ofdm_80211_short_MF_v2_0, 1), (self.carajito, 1)) self.connect((self.ofdm_80211_short_MF_v2_0, 3), (self.carajito, 2)) self.connect((self.ofdm_80211_short_MF_v2_0, 3), (self.qtgui_time_sink_x_0_0_0, 0))
def __init__(self): grc_wxgui.top_block_gui.__init__(self, title="Wifi Loopback Ah") ################################################## # Variables ################################################## self.snr = snr = 20 self.pdu_length = pdu_length = 500 self.out_buf_size = out_buf_size = 96000 self.interval = interval = 100 self.encoding = encoding = 0 self.chan_est = chan_est = 1 ################################################## # Blocks ################################################## _snr_sizer = wx.BoxSizer(wx.VERTICAL) self._snr_text_box = forms.text_box( parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.set_snr, label='snr', converter=forms.float_converter(), proportion=0, ) self._snr_slider = forms.slider( parent=self.GetWin(), sizer=_snr_sizer, value=self.snr, callback=self.set_snr, minimum=-15, maximum=30, num_steps=1000, style=wx.SL_HORIZONTAL, cast=float, proportion=1, ) self.Add(_snr_sizer) _pdu_length_sizer = wx.BoxSizer(wx.VERTICAL) self._pdu_length_text_box = forms.text_box( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, label='pdu_length', converter=forms.int_converter(), proportion=0, ) self._pdu_length_slider = forms.slider( parent=self.GetWin(), sizer=_pdu_length_sizer, value=self.pdu_length, callback=self.set_pdu_length, minimum=0, maximum=1500, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_pdu_length_sizer) _interval_sizer = wx.BoxSizer(wx.VERTICAL) self._interval_text_box = forms.text_box( parent=self.GetWin(), sizer=_interval_sizer, value=self.interval, callback=self.set_interval, label="PDU Interval (ms)", converter=forms.int_converter(), proportion=0, ) self._interval_slider = forms.slider( parent=self.GetWin(), sizer=_interval_sizer, value=self.interval, callback=self.set_interval, minimum=10, maximum=1000, num_steps=1000, style=wx.SL_HORIZONTAL, cast=int, proportion=1, ) self.Add(_interval_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,8], labels=["BPSK 1/2", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4", "64QAM 5/6", "256QAM 3/4" ], style=wx.RA_HORIZONTAL, ) self.Add(self._encoding_chooser) self._chan_est_chooser = forms.radio_buttons( parent=self.GetWin(), value=self.chan_est, callback=self.set_chan_est, label='chan_est', choices=[0, 1], labels=["LMS", "Linear Comb"], style=wx.RA_HORIZONTAL, ) self.Add(self._chan_est_chooser) self.wxgui_scopesink2_0 = scopesink2.scope_sink_c( self.GetWin(), title="Scope Plot", sample_rate=12500, 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.wxgui_numbersink2_0 = numbersink2.number_sink_f( self.GetWin(), unit="%", minval=0, maxval=100, factor=1.0, decimal_places=2, ref_level=0, sample_rate=1, number_rate=15, average=True, avg_alpha=0.02, label="Frame Error Rate", peak_hold=False, show_gauge=True, ) self.Add(self.wxgui_numbersink2_0.win) self.wifi_phy_hier_ah_0 = wifi_phy_hier_ah( chan_est=chan_est, encoding=encoding, sensitivity=0.56, ) self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) (self.foo_packet_pad2_0).set_min_output_buffer(96000) self.channels_channel_model_0 = channels.channel_model( noise_voltage=1, frequency_offset=0, epsilon=1.0, taps=(1.0, ), noise_seed=0, block_tags=False ) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, )) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), interval) ################################################## # Connections ################################################## self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.ieee802_11_ofdm_mac_0, 'app in')) self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_ah_0, 'mac_in')) self.msg_connect((self.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.wifi_phy_hier_ah_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.wxgui_numbersink2_0, 0)) self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_ah_0, 0)) self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) self.connect((self.wifi_phy_hier_ah_0, 0), (self.foo_packet_pad2_0, 0)) self.connect((self.wifi_phy_hier_ah_0, 1), (self.wxgui_scopesink2_0, 0))
def __init__(self, rate=1e6, access_code_threshold=0, samps_per_sym=2, ampl=1): gr.hier_block2.__init__( self, "GFSK Modem", gr.io_signature(1, 1, gr.sizeof_gr_complex*1), gr.io_signature(1, 1, gr.sizeof_gr_complex*1), ) ################################################## # Parameters ################################################## self.rate = rate self.access_code_threshold = access_code_threshold self.samps_per_sym = samps_per_sym self.ampl = ampl ################################################## # Variables ################################################## self.samp_rate = samp_rate = rate ################################################## # Message Queues ################################################## mac_packet_deframer_0_msgq_out = mac_packet_to_pdu_0_msgq_in = gr.msg_queue(2) ################################################## # Blocks ################################################## self.pad_source_1 = None;self.message_port_register_hier_out("msg_in") self.pad_sink_0_0 = None;self.message_port_register_hier_in("msg_out") self.mac_packet_to_pdu_0 = mac.packet_to_pdu(msgq=mac_packet_to_pdu_0_msgq_in, dewhiten=True, output_invalid=False) self.mac_packet_framer_0 = mac.packet_framer( access_code="", whitener_offset=0, rotate_whitener_offset=0, whiten=True, preamble=''.join(['\x55']*((256*1)/8/samps_per_sym)), postamble=''.join(['\x00']*(16/8/samps_per_sym)*0), ) self.mac_packet_deframer_0 = mac.packet_deframer(msgq=mac_packet_deframer_0_msgq_out, access_code="", threshold=access_code_threshold) self.mac_burst_tagger_0 = mac.burst_tagger('length', samps_per_sym*8, 32*0+ 0, 16*0 + 16) self.digital_gfsk_mod_0 = digital.gfsk_mod( samples_per_symbol=samps_per_sym, sensitivity=1.0, bt=0.35, verbose=False, log=False, ) self.digital_gfsk_demod_0 = digital.gfsk_demod( samples_per_symbol=samps_per_sym, sensitivity=1.0, gain_mu=0.175, mu=0.5, omega_relative_limit=0.005, freq_error=0.0, verbose=False, log=False, ) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "length") ################################################## # Connections ################################################## self.connect((self.mac_burst_tagger_0, 0), (self, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.digital_gfsk_mod_0, 0)) self.connect((self, 0), (self.digital_gfsk_demod_0, 0)) self.connect((self.digital_gfsk_demod_0, 0), (self.mac_packet_deframer_0, 0)) self.connect((self.digital_gfsk_mod_0, 0), (self.mac_burst_tagger_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.mac_packet_framer_0, "out", self.blocks_pdu_to_tagged_stream_0, "pdus") self.msg_connect(self.mac_packet_to_pdu_0, "pdu", self, "msg_out") self.msg_connect(self, "msg_in", self.mac_packet_framer_0, "in")
def __init__(self): gr.top_block.__init__(self, "Top Block") ################################################## # Variables ################################################## self.rate = rate = 2 self.polys = polys = [109, 79] self.k = k = 7 self.samp_rate = samp_rate = 48000 self.enc_cc = enc_cc = fec.cc_encoder_make(8000, k, rate, (polys), 0, fec.CC_TERMINATED, False) self.dec_cc = dec_cc = fec.cc_decoder.make(8000, k, rate, (polys), 0, -1, fec.CC_TERMINATED, False) ################################################## # Blocks ################################################## self.splash_packet_encoder_0 = splash.packet_encoder( samples_per_symbol=8, bits_per_symbol=1, preamble="", access_code="", pad_for_usrp=False, payload_length=9 ) self.splash_packet_decoder_0 = splash.packet_decoder( access_code="", threshold=-1 ) self.splash_XCEIVER_0 = splash.XCEIVER() self.digital_map_bb_0 = digital.map_bb(([-1,1])) self.dflood_dflood_0 = dflood.dflood( 2, 0, 30, False, False, 5, 65, 2, 120, 50, 2, True, None ) self.blocks_tagged_stream_to_pdu_1 = blocks.tagged_stream_to_pdu(blocks.float_t, "packet_len") self.blocks_repack_bits_bb_0 = blocks.repack_bits_bb(8, 1, "packet_len", True, gr.GR_MSB_FIRST) self.blocks_random_pdu_0_0 = blocks.random_pdu(1, 5, chr(0xFF), 1) self.blocks_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.byte_t, "packet_len") self.blocks_message_strobe_2 = blocks.message_strobe(pmt.intern("TEST"), 10000) self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("TEST"), 10000) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_char_to_float_0_1 = blocks.char_to_float(1, 1) self.audio_source_0 = audio.source(48000, "", True) self.audio_sink_0 = audio.sink(48000, "", True) self.analog_probe_avg_mag_sqrd_x_0 = analog.probe_avg_mag_sqrd_c(-70, 1) self.Async_Ecnoder = fec.async_encoder(enc_cc, True, False, False, 1500) self.Async_Decoder = fec.async_decoder(dec_cc, True, False, 1500) ################################################## # Connections ################################################## self.msg_connect((self.Async_Decoder, 'out'), (self.dflood_dflood_0, 'from_radio')) self.msg_connect((self.Async_Ecnoder, 'out'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (self.blocks_random_pdu_0_0, 'generate')) self.msg_connect((self.blocks_message_strobe_2, 'strobe'), (self.dflood_dflood_0, 'ctrl_in')) self.msg_connect((self.blocks_random_pdu_0_0, 'pdus'), (self.dflood_dflood_0, 'from_app')) self.msg_connect((self.blocks_tagged_stream_to_pdu_1, 'pdus'), (self.Async_Decoder, 'in')) self.msg_connect((self.dflood_dflood_0, 'to_radio'), (self.Async_Ecnoder, 'in')) self.msg_connect((self.dflood_dflood_0, 'to_app'), (self.blocks_message_debug_0, 'print_pdu')) self.connect((self.audio_source_0, 0), (self.splash_XCEIVER_0, 0)) self.connect((self.blocks_char_to_float_0_1, 0), (self.blocks_tagged_stream_to_pdu_1, 0)) self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.splash_packet_encoder_0, 0)) self.connect((self.blocks_repack_bits_bb_0, 0), (self.digital_map_bb_0, 0)) self.connect((self.digital_map_bb_0, 0), (self.blocks_char_to_float_0_1, 0)) self.connect((self.splash_XCEIVER_0, 2), (self.analog_probe_avg_mag_sqrd_x_0, 0)) self.connect((self.splash_XCEIVER_0, 0), (self.audio_sink_0, 0)) self.connect((self.splash_XCEIVER_0, 1), (self.splash_packet_decoder_0, 0)) self.connect((self.splash_packet_decoder_0, 0), (self.blocks_repack_bits_bb_0, 0)) self.connect((self.splash_packet_encoder_0, 0), (self.splash_XCEIVER_0, 1))