예제 #1
0
파일: bot1_rx.py 프로젝트: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        if(options.rx_freq is not None):
	    symbol_rate = 500000
	    self.source = uhd_receiver(options.args, symbol_rate,
				       2,
				       options.rx_freq, 30,
				       #options.spec, "RX2",
				       options.spec, "TX/RX",
				       1) #options.verbose)
	    options.samples_per_symbol = self.source._sps

        elif(options.from_file is not None):
            sys.stderr.write(("Reading samples from '%s'.\n\n" % (options.from_file)))
            self.source = gr.file_source(gr.sizeof_gr_complex, options.from_file)
        else:
            sys.stderr.write("No source defined, pulling samples from null source.\n\n")
            self.source = gr.null_source(gr.sizeof_gr_complex)

        # Set up receive path
	# Correlator block
        self.correlator = correlator_cc.correlator_cc()

	# Despreader block
	self.despreader = spreader.despreader_cb()
  
        # RS Decoder block
	self.decoder = rscoding_bb.decode_bb()

        # CRC RX Block
        self.crcrx = crc.crcrx()

	# Packetizer receiver
	self.packetrx = packetizer.packet_sink()

	# Print block
	self.printer = print_bb.print_bb()

	# NULL sink block
        self.nullsink = gr.null_sink(1)
 
        # RRC filter
        #nfilts = 32 
        #ntaps = nfilts * 11 * int(options.samples_per_symbol)
        #self.rrc_taps = gr.firdes.root_raised_cosine(
            #1.0, # gain
            #1000000, # sampling rate based on 32 fliters in resampler
            #symbol_rate,    # symbol rate
            #1.0,    # excess bandwidth or roll-off factor
            #ntaps)
        #self.rrc_filter = gr.pfb_arb_resampler_ccf(options.samples_per_symbol, 
        #                                           self.rrc_taps)


        # Design filter to get actual channel we want
        sw_decim = 1
        chan_coeffs = gr.firdes.low_pass (1.0,                  # gain
                                          #sw_decim * self.samples_per_symbol(), # sampling rate
                                          #1000000, # sampling rate
                                          2,
                                          #self._chbw_factor,    # midpoint of trans. band
                                          1,    # midpoint of trans. band
                                          0.5,                  # width of trans. band
                                          gr.firdes.WIN_HANN)   # filter type
        self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)


	# Connect the blocks
        #self.connect(self.source, self.correlator)
        #self.connect(self.source, self.rrc_filter)
        #self.connect(self.rrc_filter, self.correlator)

        # connect block input to channel filter
	self.connect(self.source, self.channel_filter)
        self.connect(self.channel_filter, self.correlator)


        #self.connect(self.source, self.correlator)
        self.connect(self.correlator, self.despreader)
        self.connect(self.despreader, self.decoder)
        self.connect(self.decoder, self.crcrx)
        #self.connect(self.decoder, self.printer)
        #self.connect(self.printer, self.crcrx)
        #self.connect(self.despreader, self.printer)
        #self.connect(self.printer, self.nullsink)
        #self.connect(self.printer, self.filesink)
        #self.connect(self.crcrx, self.filesink)
        self.connect(self.crcrx, self.packetrx) 
예제 #2
0
파일: tx.py 프로젝트: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        # Input Data File
        TX_input_file = "TX_Input_Data"
        _TX_input_file = "TX_Input_Data"
        # TX_input_file = "Ding_Dong2.wma"
        # _TX_input_file = 'Ding_Dong2.wma'
        TX_source_data = gr.file_source(gr.sizeof_char, TX_input_file)
        TX_Input_filesize = os.stat(_TX_input_file).st_size

        # RX_output_file = "RX_output_test_file"
        # _RX_output_file = 'RX_output_test_file'

        # RX_file_sink = gr.file_sink(gr.sizeof_char, RX_output_file)
        # RX_output_filesize = os.stat(_RX_output_file).st_size

        # Source block
        # frame = ((+1+0j),(+1+0j),(+1+0j),(+1+0j),(+1+0j),(+1+0j),(+1+0j),(+1+0j),(+1+0j),(+1+0j))

        zeros10 = (0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        zeros20 = zeros10 + zeros10
        zeros40 = zeros20 + zeros20

        frame_pad223 = zeros40 + zeros40 + zeros40 + zeros40 + zeros40 + zeros20 + (0x0, 0x0, 0x0)
        frame_pad219 = (
            zeros40 + zeros40 + zeros40 + zeros40 + zeros40 + zeros10 + (0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        )
        frame_pad215 = zeros40 + zeros40 + zeros40 + zeros40 + zeros40 + zeros10 + (0x0, 0x0, 0x0, 0x0, 0x0)
        frame_pad183 = zeros40 + zeros40 + zeros40 + zeros40 + zeros20 + (0x0, 0x0, 0x0)
        frame_pad179 = zeros40 + zeros40 + zeros40 + zeros40 + zeros10 + (0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)

        data12 = (0xD, 0xE, 0xA, 0xD, 0xB, 0xE, 0xE, 0xF, 0xD, 0x0, 0x0, 0xD)
        data40 = data12 + data12 + data12 + (0xD, 0xE, 0xA, 0xD)
        data10 = (0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9)

        data223 = data40 + data40 + data40 + data40 + data40 + data10 + data10 + (0xA, 0xB, 0xC)
        data219 = data40 + data40 + data40 + data40 + data40 + data10 + (0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8)
        data183 = data40 + data40 + data40 + data40 + data10 + data10 + (0x0, 0x1, 0x2)

        # src = frame_pad + data + data + data + data + frame_pad
        # src = frame_pad + frame_pad + data + data + data + data + data + data + data + data + data + data+ data + frame_pad + frame_pad

        # src = frame_pad215+data219+frame_pad219

        # 10 frames
        # src = frame_pad215+frame_pad219+data219+data219+data219+data219+data219+data219+frame_pad219+frame_pad219

        # 20 frames
        # src = frame_pad215+frame_pad219+data219+data219+data219+data219+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+frame_pad219+frame_pad219

        # 8 frames
        # src = frame_pad215+frame_pad219+data219+data219+data219+data219+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+data219+data219
        # src = src+frame_pad219+frame_pad219
        # 50 frames

        # 8 frames
        src = frame_pad179 + frame_pad183 + data183 + data183 + data183 + data183 + data183 + data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        # src = src+data183+data183
        src = src + frame_pad183 + frame_pad183
        # 50 frames

        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src

        # print len(src)
        # print len(data)

        # data = data + data + data + data

        # data = data + data + data + data + data + data + data + data + data + data + data + data + data + data
        # data = (0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf, 0xd, 0x0)
        # self.source = gr.vector_source_b(src)
        # self.source = gr.vector_source_b(frame_pad)

        # CRC TX block
        # self.crctx = crc.crctx()

        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src

        # print len(src)
        # print len(data)

        # data = data + data + data + data

        # data = data + data + data + data + data + data + data + data + data + data + data + data + data + data
        # data = (0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf, 0xd, 0x0)
        # self.source = gr.vector_source_b(src)
        # self.source = gr.vector_source_b(frame_pad)

        # CRC TX block
        # self.crctx = crc.crctx()
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src
        # src = src + src

        # print len(src)
        # print len(data)

        # data = data + data + data + data

        # data = data + data + data + data + data + data + data + data + data + data + data + data + data + data
        # data = (0xd, 0xe, 0xa, 0xd, 0xb, 0xe, 0xe, 0xf, 0xd, 0x0)
        # self.source = gr.vector_source_b(src)
        # self.source = gr.vector_source_b(frame_pad)

        # CRC TX block
        self.crctx = crc.crctx(TX_Input_filesize)

        # RS encoding
        self.encoder = rscoding_bb.encode_bb()

        # Spreader
        self.spreader = spreader.spreader_bc()

        # Preamble insert block
        self.inserter = correlator_cc.preamble_insert_cc()

        # Printer block
        self.printer = print_bb.print_bb()

        # Sink block
        symbol_rate = 500000  # Work-around to get the modulation's bits_per_symbol
        self.sink = uhd_transmitter(options.args, symbol_rate, 2, options.tx_freq, 30, options.spec, "TX/RX", 1)
        # options.verbose)
        options.samples_per_symbol = self.sink._sps

        ntaps = 11 * int(options.samples_per_symbol)
        self.rrc_taps = gr.firdes.root_raised_cosine(1.0, 1000000, symbol_rate, 1.0, ntaps)
        self.rrc_filter = gr.interp_fir_filter_ccf(1, self.rrc_taps)

        # Connect the blocks
        # self.connect(self.source, self.inserter)
        # self.connect(self.inserter, self.sink)
        # self.connect(self.source, self.spreader)
        self.connect(TX_source_data, self.crctx)
        # self.connect(self.crctx, self.printer)
        # self.connect(self.printer, self.encoder)
        self.connect(self.crctx, self.encoder)
        self.connect(self.encoder, self.spreader)
        # self.connect(self.source, self.spreader)
        self.connect(self.spreader, self.inserter)
        # self.connect(self.inserter, self.rrc_filter)
        # self.connect(self.rrc_filter, self.sink)
        self.connect(self.inserter, self.sink)
예제 #3
0
파일: rx.py 프로젝트: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        # Source block
        symbol_rate = 500000
        self.source = uhd_receiver(options.args, symbol_rate,
                                   2,
                                   options.rx_freq, 30,
                                   #options.spec, "RX2",
                                   options.spec, "TX/RX",
                                   1) #options.verbose)
        options.samples_per_symbol = self.source._sps


        RX_output_file = "RX_output_test_file"
	_RX_output_file = 'RX_output_test_file'
        #RX_output_file = "Ding_Dong2.wma"
	#_RX_output_file = 'Ding_Dong2.wma'


        RX_file_sink = gr.file_sink(gr.sizeof_char, RX_output_file)
	RX_output_filesize = os.stat(_RX_output_file).st_size
  
        #print RX_output_filesize



        self.filesink = gr.file_sink(1, "output_file")


	# Correlator block
        self.correlator = correlator_cc.correlator_cc()

	# Despreader block
	self.despreader = spreader.despreader_cb()
  
        # RS Decoder block
	self.decoder = rscoding_bb.decode_bb()

        # CRC RX Block
        self.crcrx = crc.crcrx()

	# Print block
	self.printer = print_bb.print_bb()

	# NULL sink block
        self.nullsink = gr.null_sink(1)
 
        # RRC filter
        #nfilts = 32 
        #ntaps = nfilts * 11 * int(options.samples_per_symbol)
        #self.rrc_taps = gr.firdes.root_raised_cosine(
            #1.0, # gain
            #1000000, # sampling rate based on 32 fliters in resampler
            #symbol_rate,    # symbol rate
            #1.0,    # excess bandwidth or roll-off factor
            #ntaps)
        #self.rrc_filter = gr.pfb_arb_resampler_ccf(options.samples_per_symbol, 
        #                                           self.rrc_taps)


        # Design filter to get actual channel we want
        sw_decim = 1
        chan_coeffs = gr.firdes.low_pass (1.0,                  # gain
                                          #sw_decim * self.samples_per_symbol(), # sampling rate
                                          #1000000, # sampling rate
                                          2,
                                          #self._chbw_factor,    # midpoint of trans. band
                                          1,    # midpoint of trans. band
                                          0.5,                  # width of trans. band
                                          gr.firdes.WIN_HANN)   # filter type
        self.channel_filter = gr.fft_filter_ccc(sw_decim, chan_coeffs)


	# Connect the blocks
        #self.connect(self.source, self.correlator)
        #self.connect(self.source, self.rrc_filter)
        #self.connect(self.rrc_filter, self.correlator)

        # connect block input to channel filter
	self.connect(self.source, self.channel_filter)
        self.connect(self.channel_filter, self.correlator)


        #self.connect(self.source, self.correlator)
        self.connect(self.correlator, self.despreader)
        self.connect(self.despreader, self.decoder)
        self.connect(self.decoder, self.crcrx)
        #self.connect(self.decoder, self.printer)
        #self.connect(self.printer, self.crcrx)
        #self.connect(self.despreader, self.printer)
        #self.connect(self.printer, self.nullsink)
        #self.connect(self.printer, self.filesink)
        #self.connect(self.crcrx, self.filesink)
        self.connect(self.crcrx, RX_file_sink)
예제 #4
0
파일: bot1_tx.py 프로젝트: randyp1248/darpa
    def __init__(self, options):
        gr.top_block.__init__(self)

        if(options.tx_freq is not None):
            symbol_rate = 500000
	    self.sink = uhd_transmitter(options.args, symbol_rate,
					2,
					options.tx_freq, 30,
					options.spec, "TX/RX",
					1)
	    options.samples_per_symbol = self.sink._sps
        elif(options.to_file is not None):
            sys.stderr.write(("Saving samples to '%s'.\n\n" % (options.to_file)))
            self.sink = gr.file_sink(gr.sizeof_gr_complex, options.to_file)
        else:
            sys.stderr.write("No sink defined, dumping samples to null sink.\n\n")
            self.sink = gr.null_sink(gr.sizeof_gr_complex)

        # Packetizer
	self.packettx = packetizer.packet_source()

        # CRC TX block
        self.crctx = crc.crctx(0)

        # RS encoding
        self.encoder = rscoding_bb.encode_bb()

        # Spreader
        self.spreader = spreader.spreader_bc()

	# Preamble insert block
        self.inserter = correlator_cc.preamble_insert_cc()

        # Printer block
        self.printer = print_bb.print_bb()

        ntaps = 11 * int(options.samples_per_symbol)
        self.rrc_taps = gr.firdes.root_raised_cosine( 
                      1.0,
                      1000000,
                      symbol_rate,
                      1.0,
                      ntaps)
        self.rrc_filter = gr.interp_fir_filter_ccf(1, self.rrc_taps)


	# Connect the blocks
        #self.connect(self.source, self.inserter)
        #self.connect(self.inserter, self.sink)
        #self.connect(self.source, self.spreader)
        #self.connect(TX_source_data, self.crctx)
        self.connect(self.packettx, self.crctx)
        #self.connect(self.crctx, self.printer)
        #self.connect(self.printer, self.encoder)
        self.connect(self.crctx, self.encoder)
        self.connect(self.encoder, self.spreader)
        #self.connect(self.source, self.spreader)
        self.connect(self.spreader, self.inserter)
        #self.connect(self.inserter, self.rrc_filter)
        #self.connect(self.rrc_filter, self.sink)
        self.connect(self.inserter, self.sink)