Exemple #1
0
def detect_usrp2():
	interface = 'eth0'
	args = ['find_usrps', '-e', interface]
	p = subprocess.Popen(args=args,
			stdout=subprocess.PIPE,
			stderr=subprocess.STDOUT,
			shell=False,
			universal_newlines=True)
	msg = p.stdout.read()
	usrp2_macs = sorted(map(lambda l: l.split()[0], filter(lambda l: l.count(':') >= 5, msg.strip().splitlines())))
	if(len(usrp2_macs)==0):
		print "\033[1;31mno USRP2's found\033[1;m"
		return -1
	for usrp2_mac in usrp2_macs:
		print "\033[1;31mUSRP2 found, mac address:", usrp2_mac, "\033[1;m"
		u2 = usrp2.source_32fc(interface, usrp2_mac)
		db = u2.daughterboard_id()
		if(db!=-1):
			db_name = [k for k, v in usrp_dbid.__dict__.iteritems() if v == db][0]
			print "\033[1;33mRX daughterboard:", db_name, "(dbid: 0x%04X)" % (db,), "\033[1;m"
			print "freq range: (", u2.freq_min()/1e6, "MHz, ", u2.freq_max()/1e6, "MHz )"
		u2 = usrp2.sink_32fc(interface, usrp2_mac)
		db = u2.daughterboard_id()
		if(db!=-1):
			db_name = [k for k, v in usrp_dbid.__dict__.iteritems() if v == db][0]
			print "\033[1;33mTX daughterboard:", db_name, "(dbid: 0x%04X)" % (db,), "\033[1;m"
			print "freq range: (", u2.freq_min()/1e6, "MHz, ", u2.freq_max()/1e6, "MHz )"
    def __init__(self, options):
        gr.top_block.__init__(self)

        self.u = usrp2.sink_32fc(options.interface, options.mac_addr)
        self.samples_per_symbol = 2
        self.chan_num = options.channel
        self.data_rate = int(self.u.dac_rate() / self.samples_per_symbol / options.interp_rate)

        self.u.set_center_freq(ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num])
        self.u.set_interp(options.interp_rate)
        if not options.gain:
            g = self.u.gain_range()
            options.gain = float(g[0] + g[1]) / 2

        self.u.set_gain(options.gain)

        print "cordic_freq = %s" % (eng_notation.num_to_str(ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num]))
        print "data_rate = ", eng_notation.num_to_str(self.data_rate)
        print "samples_per_symbol = ", self.samples_per_symbol
        print "usrp_interp = ", options.interp_rate

        # self.u.set_pga(0, options.gain)
        # self.u.set_pga(1, options.gain)

        # transmitter
        self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(
            self, spb=self.samples_per_symbol, msgq_limit=2
        )
        self.gain = gr.multiply_const_cc(1)

        self.connect(self.packet_transmitter, self.gain, self.u)
Exemple #3
0
 def set_usrp2(self, interface, mac_addr):
     self._u = usrp2.sink_32fc(interface, mac_addr)
     self._dac_rate = self._u.dac_rate()
     if self._verbose:
         print "Network interface:", interface
         print "Network address:", self._u.mac_addr()
         print "Daughterboard ID:", hex(self._u.daughterboard_id())
Exemple #4
0
	def __init__(self, options):
                gr.top_block.__init__(self)
		
		self.file_source = gr.file_source(gr.sizeof_gr_complex*1, "matlabframe.dat", options.repeat)
		self.usrp2_sink = usrp2.sink_32fc(options.interface, options.mac_addr)
		self.usrp2_sink.set_interp(options.interp)
		self.usrp2_sink.set_center_freq(options.freq)
		self.usrp2_sink.set_gain(options.gain)
		self.connect((self.file_source, 0), (self.usrp2_sink, 0))
    def _setup_usrp_sink(self):
        """
        Creates a USRP sink, determines the settings for best bitrate,
        and attaches to the transmitter's subdevice.
        """
        self.u = usrp2.sink_32fc(self._interface, self._mac_addr)
        self.u.set_interp(self._interp)
	self.u.set_gain(self._gain)
	self.set_freq(self._tx_freq)
Exemple #6
0
def sink(options):
  from gnuradio import usrp2
  u = usrp2.sink_32fc (ifc=options.ifc, mac=expand(options.mac))
  u.set_interp(options.interp)
  ok = u.set_center_freq(options.freq)
  if not ok:
    raise ValueError("Failed to set Tx frequency to %s" % (eng_notation.num_to_str(options.freq),))
  if options.gain is None:
    options.gain = u.gain_max() # default gain is MAX (actually, it doesn't seem to matter)
  u.set_gain(options.gain) # (self.u.gain_range()[1])
  return u
Exemple #7
0
	def __init__(self):
		grc_wxgui.top_block_gui.__init__(self, title="Top Block")

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

		##################################################
		# Blocks
		##################################################
		self.usrp2_sink_xxxx_0 = usrp2.sink_32fc()
		self.usrp2_sink_xxxx_0.set_interp(16)
		self.usrp2_sink_xxxx_0.set_center_freq(900e6)
		self.usrp2_sink_xxxx_0.set_gain(0)
		self.usrp2_sink_xxxx_0.config_mimo(usrp2.MC_WE_DONT_LOCK)
		self.gr_noise_source_x_0 = gr.noise_source_c(gr.GR_GAUSSIAN, 1, 42)

		##################################################
		# Connections
		##################################################
		self.connect((self.gr_noise_source_x_0, 0), (self.usrp2_sink_xxxx_0, 0))
Exemple #8
0
    def _setup_usrp2(self): self._u = usrp2.sink_32fc(self._interface, self._mac_addr)

    def _setup_uhd(self): 
 def _setup_usrp2(self):
     self._u = usrp2.sink_32fc(self._interface, self._mac_addr)
Exemple #10
0
 def _setup_usrp2(self):
     from gnuradio import usrp2
     self._u = usrp2.sink_32fc(self._interface, self._mac_addr)
Exemple #11
0
    def _setup_usrp2(self): self._u = usrp2.sink_32fc(self._interface, self._mac_addr)

    def _setup_dummy(self): self._u = gr.null_sink(gr.sizeof_gr_complex)