root / gnuradio-examples / python / digital / usrp_options.py @ bc105a1e
History | View | Annotate | Download (4.5 kB)
| 1 | #
|
|---|---|
| 2 | # Copyright 2009 Free Software Foundation, Inc.
|
| 3 | #
|
| 4 | # This file is part of GNU Radio
|
| 5 | #
|
| 6 | # GNU Radio is free software; you can redistribute it and/or modify
|
| 7 | # it under the terms of the GNU General Public License as published by
|
| 8 | # the Free Software Foundation; either version 3, or (at your option)
|
| 9 | # any later version.
|
| 10 | #
|
| 11 | # GNU Radio is distributed in the hope that it will be useful,
|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 14 | # GNU General Public License for more details.
|
| 15 | #
|
| 16 | # You should have received a copy of the GNU General Public License
|
| 17 | # along with GNU Radio; see the file COPYING. If not, write to
|
| 18 | # the Free Software Foundation, Inc., 51 Franklin Street,
|
| 19 | # Boston, MA 02110-1301, USA.
|
| 20 | #
|
| 21 | |
| 22 | import generic_usrp |
| 23 | |
| 24 | def _add_options(parser, expert): |
| 25 | """
|
| 26 | Add options to manually choose between usrp or usrp2.
|
| 27 | Add options for usb. Add options common to source and sink.
|
| 28 | @param parser: instance of OptionParser
|
| 29 | """ |
| 30 | #pick usrp or usrp2
|
| 31 | parser.add_option("-u", "--usrpx", type="string", default=None, |
| 32 | help="specify which usrp model: 1 for USRP, 2 for USRP2 [default=auto]")
|
| 33 | #fast usb options
|
| 34 | expert.add_option("-B", "--fusb-block-size", type="int", default=0, |
| 35 | help="specify fast usb block size [default=%default]")
|
| 36 | expert.add_option("-N", "--fusb-nblocks", type="int", default=0, |
| 37 | help="specify number of fast usb blocks [default=%default]")
|
| 38 | #usrp options
|
| 39 | parser.add_option("-w", "--which", type="int", default=0, |
| 40 | help="select USRP board [default=%default]")
|
| 41 | #usrp2 options
|
| 42 | parser.add_option("-e", "--interface", type="string", default="eth0", |
| 43 | help="Use USRP2 at specified Ethernet interface [default=%default]")
|
| 44 | parser.add_option("-m", "--mac-addr", type="string", default="", |
| 45 | help="Use USRP2 at specified MAC address [default=None]")
|
| 46 | |
| 47 | def add_rx_options(parser, expert=None): |
| 48 | """
|
| 49 | Add receive specific usrp options.
|
| 50 | @param parser: instance of OptionParser
|
| 51 | """ |
| 52 | parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, |
| 53 | help="select USRP Rx side A or B")
|
| 54 | parser.add_option("--rx-gain", type="eng_float", default=None, metavar="GAIN", |
| 55 | help="set receiver gain in dB [default=midpoint]. See also --show-rx-gain-range")
|
| 56 | parser.add_option("--show-rx-gain-range", action="store_true", default=False, |
| 57 | help="print min and max Rx gain available on selected daughterboard")
|
| 58 | parser.add_option("-d", "--decim", type="intx", default=None, |
| 59 | help="set fpga decimation rate to DECIM [default=%default]")
|
| 60 | _add_options(parser, expert) |
| 61 | |
| 62 | def create_usrp_source(options): |
| 63 | u = generic_usrp.generic_usrp_source_c( |
| 64 | usrpx=options.usrpx, |
| 65 | which=options.which, |
| 66 | subdev_spec=options.rx_subdev_spec, |
| 67 | interface=options.interface, |
| 68 | mac_addr=options.mac_addr, |
| 69 | fusb_block_size=options.fusb_block_size, |
| 70 | fusb_nblocks=options.fusb_nblocks, |
| 71 | ) |
| 72 | if options.show_rx_gain_range:
|
| 73 | print "Rx Gain Range: minimum = %g, maximum = %g, step size = %g"%tuple(u.gain_range()) |
| 74 | return u
|
| 75 | |
| 76 | def add_tx_options(parser, expert=None): |
| 77 | """
|
| 78 | Add transmit specific usrp options.
|
| 79 | @param parser: instance of OptionParser
|
| 80 | """ |
| 81 | parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None, |
| 82 | help="select USRP Rx side A or B")
|
| 83 | parser.add_option("--tx-gain", type="eng_float", default=None, metavar="GAIN", |
| 84 | help="set transmitter gain in dB [default=midpoint]. See also --show-tx-gain-range")
|
| 85 | parser.add_option("--show-tx-gain-range", action="store_true", default=False, |
| 86 | help="print min and max Tx gain available on selected daughterboard")
|
| 87 | parser.add_option("-i", "--interp", type="intx", default=None, |
| 88 | help="set fpga interpolation rate to INTERP [default=%default]")
|
| 89 | _add_options(parser, expert) |
| 90 | |
| 91 | def create_usrp_sink(options): |
| 92 | u = generic_usrp.generic_usrp_sink_c( |
| 93 | usrpx=options.usrpx, |
| 94 | which=options.which, |
| 95 | subdev_spec=options.tx_subdev_spec, |
| 96 | interface=options.interface, |
| 97 | mac_addr=options.mac_addr, |
| 98 | fusb_block_size=options.fusb_block_size, |
| 99 | fusb_nblocks=options.fusb_nblocks, |
| 100 | ) |
| 101 | if options.show_tx_gain_range:
|
| 102 | print "Tx Gain Range: minimum = %g, maximum = %g, step size = %g"%tuple(u.gain_range()) |
| 103 | return u
|