Exemple #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()
Exemple #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()
Exemple #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()
Exemple #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()
    def __init__(self, outputfile, options):
        gr.top_block.__init__(self)

        if options.dsp:
            self.dst = audio.sink( options.dsp_sample_rate )
        else:
            self.dst = gr.wavfile_sink(outputfile, 2, options.wav_sample_rate, 16)

        self.c_to_iq = gr.complex_to_float()
        self.connect( (self.c_to_iq, 0), (self.dst, 0))
        self.connect( (self.c_to_iq, 1), (self.dst, 1))

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

        self.modulator = blks2.gmsk_mod(samples_per_symbol=options.samples_per_symbol)
        self.pkt_queue = blks2.mod_pkts( modulator=self.modulator )

        if options.carrier_frequency == 0:
            self.mixer = self.pkt_queue
        else:
            self.mixer   = gr.multiply_vcc(1)
            self.carrier = gr.sig_source_c( options.carrier_sample_rate, gr.GR_SIN_WAVE, options.carrier_frequency, 1.0 )
            self.lowpass = gr.fir_filter_ccf(1, firdes.low_pass(1, 48000, 48000/(2*options.samples_per_symbol)+500, 500, firdes.WIN_HAMMING, 6.76))
            self.connect(self.pkt_queue, self.lowpass, (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.c_to_iq)

        if options.debug_wavs:
            from myblks import debugwav
            self._dpassw = debugwav("tx_passband", options)
            self._dprefw = debugwav("tx_prefband", options)
            self._dbasew = debugwav("tx_baseband", options)
            self.connect(self.amp, self._dpassw)
            self.connect(self.lowpass, self._dbasew)
            self.connect(self.pkt_queue, self._dprefw)

        if options.debug_files:
            self._dpassf = gr.file_sink(gr.sizeof_gr_complex*1, "debug_tx_passband.d_c")
            self._dpreff = gr.file_sink(gr.sizeof_gr_complex*1, "debug_tx_prefband.d_c")
            self._dbasef = gr.file_sink(gr.sizeof_gr_complex*1, "debug_tx_baseband.d_c")
            self.connect(self.amp, self._dpassf)
            self.connect(self.pkt_queue, self._dpreff)
            self.connect(self.lowpass, self._dbasef)
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()
Exemple #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()
Exemple #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))