def configure_cc2420(self):
        self.disconnect_all()
        gain = 0
        cordic_freq = 2415000000
        self.normal_gain = 8000

        dac_rate = self.u.dac_rate()
        self._data_rate = 2000000
        self._spb = 2
        self._interp = int(128e6 / self._spb / self._data_rate)
        self.fs = 128e6 / self._interp

        self.u.set_interp_rate(self._interp)

        # determine the daughterboard subdevice we're using
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, (0, 0)))
        self.subdev = usrp.selected_subdev(self.u, (0, 0))
        print "Using TX d'board %s" % (self.subdev.side_and_name(), )

        self.u.tune(self.subdev._which, self.subdev, cordic_freq)
        self.u.set_pga(0, gain)
        self.u.set_pga(1, gain)

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

        self.connect(self.packet_transmitter, self.gain, self.u)

        #self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'rx_test.dat')
        #self.connect(self.gain, self.filesink)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)  # enable Auto Transmit/Receive switching
    def configure_cc2420(self):
        self.disconnect_all()
        gain = 0
        cordic_freq = 2415000000
        self.normal_gain = 8000

        dac_rate = self.u.dac_rate();
        self._data_rate = 2000000
        self._spb = 2
        self._interp = int(128e6 / self._spb / self._data_rate)
        self.fs = 128e6 / self._interp

        self.u.set_interp_rate(self._interp)

        # determine the daughterboard subdevice we're using
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, (0, 0)))
        self.subdev = usrp.selected_subdev(self.u, (0, 0))
        print "Using TX d'board %s" % (self.subdev.side_and_name(),)

        self.u.tune(self.subdev._which, self.subdev, cordic_freq)
        self.u.set_pga(0, gain)
        self.u.set_pga(1, gain)

        # transmitter
        self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self._spb, msgq_limit=2)
        self.gain = gr.multiply_const_cc (self.normal_gain)
        
        self.connect(self.packet_transmitter, self.gain, self.u)

        #self.filesink = gr.file_sink(gr.sizeof_gr_complex, 'rx_test.dat')
        #self.connect(self.gain, self.filesink)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)                      # enable Auto Transmit/Receive switching
    def __init__(self, options):
        gr.top_block.__init__(self)

        if options.outfile is not None:
            u = gr.file_sink(gr.sizeof_gr_complex, options.outfile)
        elif (options.tx_freq is not None) or (options.channel is not None):
            if options.channel is not None:
                self.chan_num = options.channel
                options.tx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[
                    self.chan_num]

            u = uhd_transmitter(options.tx_args, options.bandwidth,
                                options.tx_freq, options.tx_gain, options.spec,
                                options.antenna, options.verbose,
                                options.external)
        else:
            raise SystemExit(
                "--tx-freq, --channel or --outfile must be specified\n")

        self.samples_per_symbol = 2

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

        self.u = u
        self.connect(self.packet_transmitter, self.amp, self.u)

        self.connect(self.amp,
                     gr.file_sink(gr.sizeof_gr_complex, 'cc2420-tx-diag.dat'))
Exemple #4
0
    def __init__(self, options):
        gr.flow_graph.__init__(self)
        self.normal_gain = 8000

        self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate()
        self._data_rate = 2000000
        self._spb = 2
        self._interp = int(128e6 / self._spb / self._data_rate)
        self.fs = 128e6 / self._interp

        self.u.set_interp_rate(self._interp)

        # determine the daughterboard subdevice we're using
        if options.tx_subdev_spec is None:
            options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(
            usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec)
        print "Using TX d'board %s" % (self.subdev.side_and_name(), )

        self.u.tune(self.subdev._which, self.subdev, options.cordic_freq_tx)
        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._spb, msgq_limit=2)
        self.gain = gr.multiply_const_cc(self.normal_gain)

        self.connect(self.packet_transmitter, self.gain, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)  # enable Auto Transmit/Receive switching
Exemple #5
0
    def __init__(self):
        gr.top_block.__init__(self)
        self.normal_gain = 8000

        self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate()
        self._data_rate = 2000000
        self._spb = 2
        self._interp = int(128e6 / self._spb / self._data_rate)
        self.fs = 128e6 / self._interp

        self.u.set_interp_rate(self._interp)

        self.picksubdev = pick_subdevice(self.u)
        #self.u.set_mux(usrp.determine_rx_mux_value(self.u, self.picksubdev))
        self.subdev = usrp.selected_subdev(self.u, pick_subdevice(self.u))
        print "Using TX d'board %s" % (self.subdev.side_and_name())

        #self.u.tune(0, self.subdev, 2475000000)
        #self.u.tune(0, self.subdev, 2480000000)
        self.u.tune(0, self.subdev, 2425000000)
        self.u.set_pga(0, 0)
        self.u.set_pga(1, 0)

        # transmitter
        self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(
            self, spb=self._spb, msgq_limit=2)

        self.gain = gr.multiply_const_cc(self.normal_gain)

        self.connect(self.packet_transmitter, self.gain, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)  # enable Auto Transmit/Receive switching
    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)
    def __init__(self, options):
        gr.top_block.__init__(self)

        if options.outfile is not None:
          u = gr.file_sink(gr.sizeof_gr_complex, options.outfile)
        elif (options.tx_freq is not None) or (options.channel is not None):
          if options.channel is not None:
            self.chan_num = options.channel
            options.tx_freq = ieee802_15_4_pkt.chan_802_15_4.chan_map[self.chan_num]

          u = uhd_transmitter(options.tx_args,
                              options.bandwidth,
                              options.tx_freq, options.tx_gain,
                              options.spec, options.antenna,
                              options.verbose, options.external)
        else:
          raise SystemExit("--tx-freq, --channel or --outfile must be specified\n")

        self.samples_per_symbol = 2

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

        self.u = u
        self.connect(self.packet_transmitter, self.amp, self.u)

        self.connect(self.amp, gr.file_sink(gr.sizeof_gr_complex, 'cc2420-tx-diag.dat'))
    def __init__(self):
        gr.top_block.__init__(self)
        self.normal_gain = 8000

        self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate()
        self._data_rate = 2000000
        self._spb = 2
        self._interp = int(128e6 / self._spb / self._data_rate)
        self.fs = 128e6 / self._interp

        self.u.set_interp_rate(self._interp)

        self.picksubdev = pick_subdevice(self.u)
        #self.u.set_mux(usrp.determine_rx_mux_value(self.u, self.picksubdev))
        self.subdev = usrp.selected_subdev(self.u, pick_subdevice(self.u))
        print "Using TX d'board %s" % (self.subdev.side_and_name())

        #self.u.tune(0, self.subdev, 2475000000)
        #self.u.tune(0, self.subdev, 2480000000)
        self.u.tune(0, self.subdev, 2425000000)
        self.u.set_pga(0, 0)
        self.u.set_pga(1, 0)

        # transmitter
        self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self._spb, msgq_limit=2)

        self.gain = gr.multiply_const_cc (self.normal_gain)

        self.connect(self.packet_transmitter, self.gain, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)                      # enable Auto Transmit/Receive switching
    def __init__(self, options):
        gr.flow_graph.__init__(self)
        self.normal_gain = 8000

        self.u = usrp.sink_c()
        dac_rate = self.u.dac_rate();
        self._data_rate = 2000000
        self._spb = 2
        self._interp = int(128e6 / self._spb / self._data_rate)
        self.fs = 128e6 / self._interp

        self.u.set_interp_rate(self._interp)

        # determine the daughterboard subdevice we're using
        if options.tx_subdev_spec is None:
            options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec)
        print "Using TX d'board %s" % (self.subdev.side_and_name(),)

        self.u.tune(self.subdev._which, self.subdev, options.cordic_freq_tx)
        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._spb, msgq_limit=2)
        self.gain = gr.multiply_const_cc (self.normal_gain)
        
        self.connect(self.packet_transmitter, self.gain, self.u)

        self.set_gain(self.subdev.gain_range()[1])  # set max Tx gain
        self.set_auto_tr(True)                      # enable Auto Transmit/Receive switching
    def __init__(self, rx_callback, SNR):
        """
        @param options Optparse option field for command line arguments.
        @param rx_callback Callback function for the event when a packet is received.
        """
        gr.flow_graph.__init__(self)

        self.samples_per_symbol = 2
	self.data_rate = 2000000
        payload_size = 128             # bytes

	self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(self, spb=self.samples_per_symbol, msgq_limit=2)

        # add some noise
	print " Setting SNR to ", SNR
        add = gr.add_cc()
        noise = gr.noise_source_c(gr.GR_GAUSSIAN, pow(10.0,-SNR/20.0))

        self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(self,
                                                                callback=rx_callback,
                                                                sps=self.samples_per_symbol,
                                                                symbol_rate=self.data_rate,
                                                                threshold=-1)

        self.connect (self.packet_transmitter, (add,0))
        self.connect (noise, (add,1))
        self.connect(add,  self.packet_receiver)
    def __init__(self, rx_callback, SNR):
        """
        @param options Optparse option field for command line arguments.
        @param rx_callback Callback function for the event when a packet is received.
        """
        gr.flow_graph.__init__(self)

        self.samples_per_symbol = 2
        self.data_rate = 2000000
        payload_size = 128  # bytes

        self.packet_transmitter = ieee802_15_4_pkt.ieee802_15_4_mod_pkts(
            self, spb=self.samples_per_symbol, msgq_limit=2)

        # add some noise
        print " Setting SNR to ", SNR
        add = gr.add_cc()
        noise = gr.noise_source_c(gr.GR_GAUSSIAN, pow(10.0, -SNR / 20.0))

        self.packet_receiver = ieee802_15_4_pkt.ieee802_15_4_demod_pkts(
            self,
            callback=rx_callback,
            sps=self.samples_per_symbol,
            symbol_rate=self.data_rate,
            threshold=-1)

        self.connect(self.packet_transmitter, (add, 0))
        self.connect(noise, (add, 1))
        self.connect(add, self.packet_receiver)
Exemple #12
0
    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)
    def __init__(self, options): 
        gr.top_block.__init__(self) 
        self.normal_gain = 8000

        samp_rate=1e6
        self.u = uhd.usrp_sink(
            device_addr="serial=4d9de875",
            stream_args=uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        
        self.u.set_subdev_spec("A:0", 0)
        self.u.set_samp_rate(samp_rate)
        self.u.set_center_freq(options.cordic_freq, 0)
        self.u.set_gain(options.gain, 0)
        
        #self.u = usrp.sink_c()
        #dac_rate = self.u.dac_rate();
        self._data_rate = 2000000
        self._spb = 2
        self._interp = int(128e6 / self._spb / self._data_rate)
        self.fs = 128e6 / self._interp

        #self.u.set_interp_rate(self._interp)

        # determine the daughterboard subdevice we're using
        #if options.tx_subdev_spec is None:
        #    options.tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
        #self.u.set_mux(usrp.determine_tx_mux_value(self.u, options.tx_subdev_spec))
        #self.subdev = usrp.selected_subdev(self.u, options.tx_subdev_spec)
        #print "Using TX d'board %s" % (self.subdev.side_and_name(),)

        #self.u.tune(0, self.subdev, options.cordic_freq)
        #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._spb, msgq_limit=2) 
        self.gain = gr.multiply_const_cc (self.normal_gain)
        
        self.connect(self.packet_transmitter, self.gain, self.u)