Пример #1
0
def main():
    gr.enable_realtime_scheduling()
    tb = gr.top_block ()
    src = gr.file_source(gr.sizeof_gr_complex, "transmit-data.dat", True)
    parser = OptionParser(option_class=eng_option, conflict_handler="resolve")
    (options, args) = parser.parse_args ()
    d = {'verbose': True, 'discontinuous': False, 'samples_per_symbol': 2, 'usrpx': None, 'interp': INTERP, 'fusb_block_size': 0, 'megabytes': 1.0, 'rx_freq': 2.475e9, 'size': 1500, 'show_tx_gain_range': False, 'log': False, 'tx_subdev_spec': None, 'fusb_nblocks': 0, 'lo_offset': None, 'tx_gain': TXGAIN, 'which': 0, 'modulation': 'gmsk', 'excess_bw': 0.34999999999999998, 'bt': 0.34999999999999998, 'interface': 'eth0', 'freq': None, 'bitrate': 100000.0, 'from_file': None, 'tx_freq': 2475000000.0, 'mac_addr': '', 'tx_amplitude': 0.1, 'gray_code': True}
    for i, j in d.items():
        setattr(options, i, j)

    u = usrp_options.create_usrp_sink(options)
    dac_rate = u.dac_rate()
    if options.verbose:
        print 'USRP Sink:', u
    (_bitrate, _samples_per_symbol, _interp) = \
                    pick_tx_bitrate(options.bitrate, 2, \
                                    options.samples_per_symbol, options.interp, dac_rate, \
                                    u.get_interp_rates())

    u.set_interp(_interp)
    u.set_auto_tr(True)

    if not u.set_center_freq(options.tx_freq):
        print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(options.tx_freq))
        raise ValueError, eng_notation.num_to_str(options.tx_freq)
    
    m = gr.multiply_const_cc(CONSTANT)
    tb.connect(src, m, u)


    tb.run()
Пример #2
0
    def _setup_usrp_sink(self, options):
        """
        Creates a USRP sink, determines the settings for best bitrate,
        and attaches to the transmitter's subdevice.
        """
        self.u = usrp_options.create_usrp_sink(options)
        dac_rate = self.u.dac_rate()
        self.rs_rate = options.bitrate    # Store requested bit rate
            
        (self._bitrate, self._samples_per_symbol, self._interp) = \
                        pick_tx_bitrate(options.bitrate, self._modulator_class.bits_per_symbol(),
                                        options.samples_per_symbol, options.interp,
                                        dac_rate, self.u.get_interp_rates())

        options.interp = self._interp
        options.samples_per_symbol = self._samples_per_symbol
        options.bitrate = self._bitrate

        if options.verbose:
            print 'USRP Sink:', self.u
            print "Interpolation Rate: ", self._interp
        
        self.u.set_interp(self._interp)
        self.u.set_auto_tr(True)

        if not self.u.set_center_freq(options.tx_freq):
            print "Failed to set Rx frequency to %s" % (eng_notation.num_to_str(options.tx_freq))
            raise ValueError, eng_notation.num_to_str(options.tx_freq)
Пример #3
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 = usrp.sink_c(fusb_block_size=self._fusb_block_size,fusb_nblocks=self._fusb_nblocks)
        dac_rate = self.u.dac_rate();

        # derive values of bitrate, samples_per_symbol, and interp from desired info
        (self._bitrate, self._samples_per_symbol, self._interp) = \
            pick_tx_bitrate(self._bitrate, self._modulator_class.bits_per_symbol(),
                            self._samples_per_symbol, self._interp, dac_rate)
        
        self.u.set_interp_rate(self._interp)

        # determine the daughterboard subdevice we're using
        if self._tx_subdev_spec is None:
            self._tx_subdev_spec = usrp.pick_tx_subdevice(self.u)
        self.u.set_mux(usrp.determine_tx_mux_value(self.u, self._tx_subdev_spec))
        self.subdev = usrp.selected_subdev(self.u, self._tx_subdev_spec)