예제 #1
0
def main():
    sys.path.append(os.getcwd())
    from PHY import PhysicalLayer
    
    samples_per_symbol = 4
    samp_rate = 4e6
    tb = gr.top_block()

    modulator = blks2.gmsk_mod(samples_per_symbol=samples_per_symbol)
    demodulator = blks2.gmsk_demod(samples_per_symbol=samples_per_symbol)

    sys.stderr.write('Using bitrate %sbits/s\n' % eng_notation.num_to_str(samp_rate / samples_per_symbol / modulator.bits_per_symbol()))
    sys.stderr.flush()
    phy = PhysicalLayer.PhysicalLayer(modulator, demodulator, hint = 'addr=192.168.10.2', access_code = 'master')
    tb.connect(phy)
    
    phy.tune(1.8e9)
    phy.set_gain(45)
    phy.set_samp_rate(samp_rate)

    args = shlex.split('cvlc --sout "#transcode{vcodec=theora, vb=128}:std{access=file, mux=ogg, dst=-}" v4l2:///dev/video0')
    child = subprocess.Popen(args, stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr=None)
    print 'Started vlc with pid', child.pid

    def read_data_from_child():
        print "[DEBUG] reading from child's pipe"
        phy.send_pkt(child.stdout.read(512))
        return True

    tb.start()
    gobject.threads_init()
    gobject.idle_add(read_data_from_child)
    loop = gobject.MainLoop()
    loop.run()
예제 #2
0
def main():
    sys.path.append(os.getcwd())
    from PHY import PhysicalLayer
    
    samples_per_symbol = 4
    samp_rate = 4e6
    tb = gr.top_block()

    modulator = blks2.gmsk_mod(samples_per_symbol=samples_per_symbol)
    demodulator = blks2.gmsk_demod(samples_per_symbol=samples_per_symbol)

    sys.stderr.write('Using bitrate %sbits/s\n' % eng_notation.num_to_str(samp_rate / samples_per_symbol / modulator.bits_per_symbol()))
    sys.stderr.flush()
    phy = PhysicalLayer.PhysicalLayer(modulator, demodulator, hint = 'addr=192.168.10.3', access_code = 'slave')

    tb.connect(phy)
    
    phy.tune(1.8e9)
    phy.set_gain(45)
    phy.set_samp_rate(samp_rate)

    child = subprocess.Popen(['cvlc', '-'], stdout = subprocess.PIPE, stdin = subprocess.PIPE, stderr=None)
    #print 'Started vlc with pid', child.pid

    def write_to_child_pipe(ok, data):
        print "[DEBUG] writing to VLC's pipe"
        if(ok):
            child.stdin.write(data)

    phy.set_rx_callback(write_to_child_pipe)
    tb.start()
    gobject.threads_init()
    loop = gobject.MainLoop()
    loop.run()
예제 #3
0
def main():
    sys.path.append(os.getcwd())
    from MAC import MacLayer
    from PHY import PhysicalLayer
    import LLC.SlidingWindow

    samples_per_symbol = 2
    samp_rate = 4e6

    tb = gr.top_block()

    modulator = blks2.gmsk_mod(samples_per_symbol=samples_per_symbol)
    demodulator = blks2.gmsk_demod(samples_per_symbol=samples_per_symbol)

    sys.stderr.write('Using bitrate %sbits/s\n' % eng_notation.num_to_str(
        samp_rate / samples_per_symbol / modulator.bits_per_symbol()))
    sys.stderr.flush()
    phy = PhysicalLayer.PhysicalLayer(modulator,
                                      demodulator,
                                      hint='addr=192.168.10.3',
                                      access_code='slave')
    #phy = PhysicalLayer.PhysicalLayer(modulator, demodulator, hint = 'type=usrp1', access_code = 'slave')
    mac = MacLayer.SimpleMacLayer(phy, addr=True)
    llc = LLC.SlidingWindowDataLinkLayer(mac, wr=1500, wt=4000)

    def cleanup():
        tb.stop()
        sys.exit(0)

    tb.connect(phy)

    phy.tune(1.8e9)
    phy.set_gain(45)
    phy.set_samp_rate(samp_rate)

    #dbus stuff
    DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    service = bus.get_object('org.gnuradio.grotarapi',
                             '/org/gnuradio/grotarapi/controller/slave')
    iface = dbus.Interface(service,
                           dbus_interface='org.gnuradio.grotarapi.guts')

    def send_data(data):
        sys.stderr.write('[Slave Child] trying to send data %s\n' % data)
        sys.stderr.flush()
        llc.send_pkt(str(data))

    iface.connect_to_signal("send_data", send_data)
    llc.set_rx_callback(iface.rx_callback_binary)
    tb.start()
    gobject.threads_init()
    loop = gobject.MainLoop()
    loop.run()
예제 #4
0
def main():
    sys.path.append(os.getcwd())
    gobject.threads_init()
    loop = gobject.MainLoop()
    from MAC import MacLayer
    from PHY import PhysicalLayer
    import LLC.SlidingWindow

    
    samples_per_symbol = 2
    samp_rate = 4e6

    tb = gr.top_block()

    modulator = blks2.gmsk_mod(samples_per_symbol=samples_per_symbol)
    demodulator = blks2.gmsk_demod(samples_per_symbol=samples_per_symbol)

    sys.stderr.write('Using bitrate %sbits/s\n' % eng_notation.num_to_str(samp_rate / samples_per_symbol / modulator.bits_per_symbol()))
    sys.stderr.flush()
    phy = PhysicalLayer.PhysicalLayer(modulator, demodulator, hint = 'addr=192.168.10.2', access_code = 'master')
    #phy = PhysicalLayer.PhysicalLayer(modulator, demodulator, hint = 'type=usrp1', access_code = 'slave')
    mac = MacLayer.SimpleMacLayer(phy, addr = False)
    llc = LLC.SlidingWindowDataLinkLayer(mac, wr = 1500, wt = 4000)

    tb.connect(phy)
    
    phy.tune(1.8e9)
    phy.set_gain(45)
    phy.set_samp_rate(samp_rate)

    #dbus stuff
    DBusGMainLoop(set_as_default = True)
    bus = dbus.SessionBus()
    service = bus.get_object('org.gnuradio.grotarapi',
                             '/org/gnuradio/grotarapi/controller/master')
    iface = dbus.Interface(service, dbus_interface = 'org.gnuradio.grotarapi.guts')

    def send_data(data):
        #sys.stderr.write('[Master Child] trying to send data %s\n' % data)
        #sys.stderr.flush()
        llc.send_pkt(str(data))

    def rx_callback(data):
        sys.stderr.write('[Master Child] received %s\n' % data)
        iface.rx_callback_binary(data)
    iface.connect_to_signal("send_data", send_data)
    llc.set_rx_callback(rx_callback)
    tb.start()
    loop.run()
예제 #5
0
    def __init__(self, inputfile, callback, options):
        gr.top_block.__init__(self)

        # settings for the demodulator: /usr/local/lib/python2.5/site-packages/gnuradio/blks2impl/gmsk.py
        # settings for the demodulator: /usr/local/lib/python2.5/site-packages/gnuradio/blks2impl/pkt.py

        if options.dsp:
            self.src = audio.source(options.dsp_sample_rate, "", True)
        else:
            self.src = gr.wavfile_source( inputfile, False )

        self.iq_to_c = gr.float_to_complex()
        if options.dsp and options.wait:
            samples = options.dsp_sample_rate * options.wait
            self._head0 = gr.head(gr.sizeof_float, samples)
            self._head1 = gr.head(gr.sizeof_float, samples)
            self.connect( (self.src, 0), self._head0, (self.iq_to_c, 0) )
            self.connect( (self.src, 1), self._head1, (self.iq_to_c, 1) )
            if verbose: print "installed %d second head filter on dsp (%d samples at %d sps)" % (options.wait, samples, options.dsp_sample_rate)
        else:
            self.connect( (self.src, 0), (self.iq_to_c, 0) )
            self.connect( (self.src, 1), (self.iq_to_c, 1) )

        self.demodulator = blks2.gmsk_demod(samples_per_symbol=options.samples_per_symbol)
        self.pkt_queue   = blks2.demod_pkts( demodulator=self.demodulator, callback=callback, threshold=options.threshold )

        if options.carrier_frequency == 0:
            self.mixer = self.iq_to_c
        else:
            self.carrier  = gr.sig_source_c( options.carrier_sample_rate, gr.GR_SIN_WAVE, - options.carrier_frequency, 1.0 )
            self.mixer    = gr.multiply_vcc(1)
            self.connect(self.iq_to_c, (self.mixer, 0) )
            self.connect(self.carrier, (self.mixer, 1) )

        self.amp = gr.multiply_const_cc(1); self.amp.set_k(options.amp_amplitude)
        self.connect(self.mixer, self.amp, self.pkt_queue)

        if options.debug_wavs:
            from myblks import debugwav
            self._dpass = debugwav("rx_passband", options)
            self._dbase = debugwav("rx_baseband", options)
            self.connect(self.iq_to_c, self._dpass)
            self.connect(self.mixer,   self._dbase)

        if options.debug_files:
            self._dpassf = gr.file_sink(gr.sizeof_gr_complex*1, "debug_rx_passband.d_c")
            self._dbasef = gr.file_sink(gr.sizeof_gr_complex*1, "debug_rx_baseband.d_c")
            self.connect(self.iq_to_c, self._dpassf)
            self.connect(self.mixer,   self._dbasef)
예제 #6
0
def main():
    signal.signal(signal.SIGCHLD, signal.SIG_IGN)
    sys.path.append(os.getcwd())
    from PHY import PhysicalLayer

    samples_per_symbol = 4
    samp_rate = 4e6
    tb = gr.top_block()

    modulator = blks2.gmsk_mod(samples_per_symbol=samples_per_symbol)
    demodulator = blks2.gmsk_demod(samples_per_symbol=samples_per_symbol)

    sys.stderr.write('Using bitrate %sbits/s\n' % eng_notation.num_to_str(
        samp_rate / samples_per_symbol / modulator.bits_per_symbol()))
    sys.stderr.flush()
    phy = PhysicalLayer.PhysicalLayer(modulator,
                                      demodulator,
                                      hint='addr=192.168.10.2',
                                      access_code='master')
    tb.connect(phy)

    phy.tune(1.8e9)
    phy.set_gain(45)
    phy.set_samp_rate(samp_rate)

    args = shlex.split(
        'cvlc --sout "#transcode{acodec=vorbis, ab=48}:std{access=file, mux=ogg, dst=-}" seek.mp3'
    )
    child = subprocess.Popen(args,
                             stdout=subprocess.PIPE,
                             stdin=subprocess.PIPE,
                             stderr=None)

    #print 'Started vlc with pid', child.pid

    def read_data_from_child():
        print "[DEBUG] reading from child's pipe"
        phy.send_pkt(child.stdout.read(512))
        return True

    tb.start()
    gobject.threads_init()
    gobject.idle_add(read_data_from_child)
    loop = gobject.MainLoop()
    loop.run()
예제 #7
0
def main():
    sys.path.append(os.getcwd())
    from PHY import PhysicalLayer

    samples_per_symbol = 4
    samp_rate = 4e6
    tb = gr.top_block()

    modulator = blks2.gmsk_mod(samples_per_symbol=samples_per_symbol)
    demodulator = blks2.gmsk_demod(samples_per_symbol=samples_per_symbol)

    sys.stderr.write('Using bitrate %sbits/s\n' % eng_notation.num_to_str(
        samp_rate / samples_per_symbol / modulator.bits_per_symbol()))
    sys.stderr.flush()
    phy = PhysicalLayer.PhysicalLayer(modulator,
                                      demodulator,
                                      hint='addr=192.168.10.3',
                                      access_code='slave')

    tb.connect(phy)

    phy.tune(1.8e9)
    phy.set_gain(45)
    phy.set_samp_rate(samp_rate)

    child = subprocess.Popen(['cvlc', '-'],
                             stdout=subprocess.PIPE,
                             stdin=subprocess.PIPE,
                             stderr=None)

    #print 'Started vlc with pid', child.pid

    def write_to_child_pipe(ok, data):
        print "[DEBUG] writing to VLC's pipe"
        if (ok):
            child.stdin.write(data)

    phy.set_rx_callback(write_to_child_pipe)
    tb.start()
    gobject.threads_init()
    loop = gobject.MainLoop()
    loop.run()
예제 #8
0
	def __init__(self):
		gr.top_block.__init__(self, "Simple TX/RX Path")

		##################################################
		# Blocks
		##################################################
		self.blks2_gmsk_demod_0 = blks2.gmsk_demod(
			samples_per_symbol=2,
			gain_mu=0.175,
			mu=0.5,
			omega_relative_limit=0.005,
			freq_error=0.0,
			verbose=False,
			log=False,
		)
		self.blks2_gmsk_mod_0 = blks2.gmsk_mod(
			samples_per_symbol=2,
			bt=0.35,
			verbose=False,
			log=False,
		)
		self.blks2_packet_decoder_0 = grc_blks2.packet_demod_b(grc_blks2.packet_decoder(
				access_code="",
				threshold=-1,
				callback=lambda ok, payload: self.blks2_packet_decoder_0.recv_pkt(ok, payload),
			),
		)
		self.blks2_packet_encoder_0 = grc_blks2.packet_mod_b(grc_blks2.packet_encoder(
				samples_per_symbol=1,
				bits_per_symbol=1,
				access_code="",
				pad_for_usrp=True,
			),
			payload_length=0,
		)
		self.blks2_tcp_sink_0 = grc_blks2.tcp_sink(
			itemsize=gr.sizeof_char*1,
			addr="127.0.0.1",
			port=9001,
			server=True,
		)
		self.blks2_tcp_source_0 = grc_blks2.tcp_source(
			itemsize=gr.sizeof_char*1,
			addr="127.0.0.1",
			port=9000,
			server=True,
		)
		self.gr_channel_model_0 = gr.channel_model(
			noise_voltage=0.0,
			frequency_offset=0.0,
			epsilon=1.0,
			taps=(1.0 + 1.0j, ),
			noise_seed=42,
		)

		##################################################
		# Connections
		##################################################
		self.connect((self.blks2_tcp_source_0, 0), (self.blks2_packet_encoder_0, 0))
		self.connect((self.blks2_packet_encoder_0, 0), (self.blks2_gmsk_mod_0, 0))
		self.connect((self.blks2_gmsk_mod_0, 0), (self.gr_channel_model_0, 0))
		self.connect((self.gr_channel_model_0, 0), (self.blks2_gmsk_demod_0, 0))
		self.connect((self.blks2_gmsk_demod_0, 0), (self.blks2_packet_decoder_0, 0))
		self.connect((self.blks2_packet_decoder_0, 0), (self.blks2_tcp_sink_0, 0))