[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r10929 - gnuradio/branches/developers/jblum/digital
From: |
jblum |
Subject: |
[Commit-gnuradio] r10929 - gnuradio/branches/developers/jblum/digital |
Date: |
Mon, 27 Apr 2009 19:27:50 -0600 (MDT) |
Author: jblum
Date: 2009-04-27 19:27:49 -0600 (Mon, 27 Apr 2009)
New Revision: 10929
Added:
gnuradio/branches/developers/jblum/digital/usrp_options.py
Modified:
gnuradio/branches/developers/jblum/digital/generic_usrp.py
gnuradio/branches/developers/jblum/digital/receive_path.py
gnuradio/branches/developers/jblum/digital/transmit_path.py
Log:
Separated generic usrp into generic usrp classes and usrp options.
Usrp options can be a standard way to add options to a python options parser,
and a standard way to create generic usrp objects from these options.
Generic usrp can ge a standard way to have usrp objects that represent usrp or
usrp2.
Modified: gnuradio/branches/developers/jblum/digital/generic_usrp.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/generic_usrp.py 2009-04-27
23:20:45 UTC (rev 10928)
+++ gnuradio/branches/developers/jblum/digital/generic_usrp.py 2009-04-28
01:27:49 UTC (rev 10929)
@@ -29,30 +29,18 @@
########################################################################
class _generic_usrp_base(object):
- @staticmethod
- def add_options(normal, expert):
- """
- Add options to manually choose between usrp or usrp2.
- Add options for usb. Add options common to source and sink.
- @param parser: instance of OptionParser
- """
- if normal.has_option("usrpx"): return
- #pick usrp or usrp2
- normal.add_option("-u", "--usrpx", type="string", default=None,
- help="specify which usrp model: 1 for USRP, 2 for
USRP2 [default=auto]")
- #fast usb options
- expert.add_option("-B", "--fusb-block-size", type="int", default=0,
- help="specify fast usb block size
[default=%default]")
- expert.add_option("-N", "--fusb-nblocks", type="int", default=0,
- help="specify number of fast usb blocks
[default=%default]")
+ def __init__(self, which=0, subdev_spec=None, interface="", mac_addr="",
fusb_block_size=0, fusb_nblocks=0, usrpx=None):
+ self._gain = 0
+ self._usrpx = usrpx
#usrp options
- normal.add_option("-w", "--which", type="int", default=0,
- help="select USRP board [default=%default]")
+ self._which = which
+ self._subdev_spec = subdev_spec
#usrp2 options
- normal.add_option("-e", "--interface", type="string", default="eth0",
- help="Use specified Ethernet interface
[default=%default]")
- normal.add_option("-m", "--mac-addr", type="string", default="",
- help="Use USRP2 at specified MAC address
[default=None]")
+ self._interface = interface
+ self._mac_addr = mac_addr
+ #fusb options
+ self._fusb_block_size = fusb_block_size
+ self._fusb_nblocks = fusb_nblocks
def __str__(self):
if self._type == USRP_TYPE: return self._subdev.side_and_name()
@@ -74,7 +62,7 @@
def set_center_freq(self, target_freq):
if self._type == USRP_TYPE:
- return bool(self._u.tune(self._dc, self._subdev, target_freq))
+ return bool(self._u.tune(self._dxc, self._subdev, target_freq))
elif self._type == USRP2_TYPE:
return self._u.set_center_freq(target_freq)
@@ -92,30 +80,15 @@
Provide generic access methods so the API looks the same for both.
"""
- @staticmethod
- def add_options(normal, expert):
- normal.add_option("-R", "--rx-subdev-spec", type="subdev",
default=None,
- help="select USRP Rx side A or B")
- _generic_usrp_base.add_options(normal, expert)
-
- def __init__(self, options):
+ def __init__(self, **kwargs):
+ _generic_usrp_base.__init__(self, **kwargs)
gr.hier_block2.__init__(self, "generic_usrp_source",
gr.io_signature(0, 0, 0), # Input signature
gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature
-
- #usrp options
- self._which = options.which
- self._rx_subdev_spec = options.rx_subdev_spec
- self._fusb_block_size = options.fusb_block_size
- self._fusb_nblocks = options.fusb_nblocks
- #usrp2 options
- self._interface = options.interface
- self._mac_addr = options.mac_addr
-
#pick usrp or usrp2
- if options.usrpx == '1' or self._rx_subdev_spec:
+ if self._usrpx == '1' or self._subdev_spec:
self._setup_usrp_source()
- elif options.usrpx == '2' or self._mac_addr:
+ elif self._usrpx == '2' or self._mac_addr:
self._setup_usrp2_source()
else: #automatic
try: self._setup_usrp2_source()
@@ -139,13 +112,13 @@
fusb_block_size=self._fusb_block_size,
fusb_nblocks=self._fusb_nblocks)
# determine the daughterboard subdevice we're using
- if self._rx_subdev_spec is None:
- self._rx_subdev_spec = usrp.pick_rx_subdevice(self._u)
- self._subdev = usrp.selected_subdev(self._u, self._rx_subdev_spec)
- self._u.set_mux(usrp.determine_rx_mux_value(self._u,
self._rx_subdev_spec))
+ if self._subdev_spec is None:
+ self._subdev_spec = usrp.pick_rx_subdevice(self._u)
+ self._subdev = usrp.selected_subdev(self._u, self._subdev_spec)
+ self._u.set_mux(usrp.determine_rx_mux_value(self._u,
self._subdev_spec))
self._subdev.set_auto_tr(True)
self._type = USRP_TYPE
- self._dc = 0
+ self._dxc = 0
def _setup_usrp2_source(self):
self._u = usrp2.source_32fc(self._interface, self._mac_addr)
@@ -161,30 +134,16 @@
Provide generic access methods so the API looks the same for both.
"""
- @staticmethod
- def add_options(normal, expert):
- normal.add_option("-T", "--tx-subdev-spec", type="subdev",
default=None,
- help="select USRP Tx side A or B")
- _generic_usrp_base.add_options(normal, expert)
-
- def __init__(self, options):
+ def __init__(self, **kwargs):
+ _generic_usrp_base.__init__(self, **kwargs)
gr.hier_block2.__init__(self, "generic_usrp_sink",
gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature
gr.io_signature(0, 0, 0)) # Output signature
- #usrp options
- self._which = options.which
- self._tx_subdev_spec = options.tx_subdev_spec
- self._fusb_block_size = options.fusb_block_size
- self._fusb_nblocks = options.fusb_nblocks
- #usrp2 options
- self._interface = options.interface
- self._mac_addr = options.mac_addr
-
#pick usrp or usrp2
- if options.usrpx == '1' or self._tx_subdev_spec:
+ if self._usrpx == '1' or self._subdev_spec:
self._setup_usrp_source()
- elif options.usrpx == '2' or self._mac_addr:
+ elif self._usrpx == '2' or self._mac_addr:
self._setup_usrp2_source()
else: #automatic
try: self._setup_usrp2_source()
@@ -212,13 +171,13 @@
fusb_block_size=self._fusb_block_size,
fusb_nblocks=self._fusb_nblocks)
# 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._subdev = usrp.selected_subdev(self._u, self._tx_subdev_spec)
- self._u.set_mux(usrp.determine_tx_mux_value(self._u,
self._tx_subdev_spec))
+ if self._subdev_spec is None:
+ self._subdev_spec = usrp.pick_tx_subdevice(self._u)
+ self._subdev = usrp.selected_subdev(self._u, self._subdev_spec)
+ self._u.set_mux(usrp.determine_tx_mux_value(self._u,
self._subdev_spec))
self._subdev.set_auto_tr(True)
self._type = USRP_TYPE
- self._dc = self._subdev.which()
+ self._dxc = self._subdev.which()
def _setup_usrp2_source(self):
self._u = usrp2.sink_32fc(self._interface, self._mac_addr)
Modified: gnuradio/branches/developers/jblum/digital/receive_path.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/receive_path.py 2009-04-27
23:20:45 UTC (rev 10928)
+++ gnuradio/branches/developers/jblum/digital/receive_path.py 2009-04-28
01:27:49 UTC (rev 10929)
@@ -28,7 +28,7 @@
# from current dir
from pick_bitrate import pick_rx_bitrate
-import generic_usrp
+import usrp_options
# /////////////////////////////////////////////////////////////////////////////
# receive path
@@ -119,7 +119,7 @@
def _setup_usrp_source(self, options):
- self.u = generic_usrp.generic_usrp_source_c(options)
+ self.u = usrp_options.create_usrp_source(options)
adc_rate = self.u.adc_rate()
# derive values of bitrate, samples_per_symbol, and decim from desired
info
@@ -189,18 +189,12 @@
if not normal.has_option("--bitrate"):
normal.add_option("-r", "--bitrate", type="eng_float",
default=None,
help="specify bitrate. samples-per-symbol and
interp/decim will be derived.")
- generic_usrp.generic_usrp_source_c.add_options(normal, expert)
+ usrp_options.add_rx_options(normal, expert)
normal.add_option("-v", "--verbose", action="store_true",
default=False)
expert.add_option("-S", "--samples-per-symbol", type="int",
default=None,
help="set samples/symbol [default=%default]")
expert.add_option("", "--rx-freq", type="eng_float", default=None,
help="set Rx frequency to FREQ [default=%default]",
metavar="FREQ")
- normal.add_option("--rx-gain", type="eng_float", default=None,
metavar="GAIN",
- help="set receiver gain in dB [default=midpoint].
See also --show-rx-gain-range")
- normal.add_option("--show-rx-gain-range", action="store_true",
default=False,
- help="print min and max Rx gain available on
selected daughterboard")
- expert.add_option("-d", "--decim", type="intx", default=None,
- help="set fpga decimation rate to DECIM
[default=%default]")
expert.add_option("", "--log", action="store_true", default=False,
help="Log all parts of flow graph to files (CAUTION:
lots of data)")
expert.add_option("", "--log-rx-power", action="store_true",
default=False,
Modified: gnuradio/branches/developers/jblum/digital/transmit_path.py
===================================================================
--- gnuradio/branches/developers/jblum/digital/transmit_path.py 2009-04-27
23:20:45 UTC (rev 10928)
+++ gnuradio/branches/developers/jblum/digital/transmit_path.py 2009-04-28
01:27:49 UTC (rev 10929)
@@ -28,7 +28,7 @@
# from current dir
from pick_bitrate import pick_tx_bitrate
-import generic_usrp
+import usrp_options
# /////////////////////////////////////////////////////////////////////////////
# transmit path
@@ -107,7 +107,7 @@
Creates a USRP sink, determines the settings for best bitrate,
and attaches to the transmitter's subdevice.
"""
- self.u = generic_usrp.generic_usrp_sink_c(options)
+ self.u = usrp_options.create_usrp_sink(options)
dac_rate = self.u.dac_rate();
# derive values of bitrate, samples_per_symbol, and interp from
desired info
@@ -171,7 +171,7 @@
if not normal.has_option('--bitrate'):
normal.add_option("-r", "--bitrate", type="eng_float",
default=None,
help="specify bitrate. samples-per-symbol and
interp/decim will be derived.")
- generic_usrp.generic_usrp_sink_c.add_options(normal, expert)
+ usrp_options.add_tx_options(normal, expert)
normal.add_option("--tx-amplitude", type="eng_float", default=None,
metavar="AMPL",
help="set transmitter digital amplitude
[default=midpoint]. See also --show-tx-ampl-range")
normal.add_option("--show-tx-ampl-range", action="store_true",
default=False,
@@ -181,8 +181,6 @@
help="set samples/symbol [default=%default]")
expert.add_option("", "--tx-freq", type="eng_float", default=None,
help="set transmit frequency to FREQ
[default=%default]", metavar="FREQ")
- expert.add_option("-i", "--interp", type="intx", default=None,
- help="set fpga interpolation rate to INTERP
[default=%default]")
expert.add_option("", "--log", action="store_true", default=False,
help="Log all parts of flow graph to file (CAUTION:
lots of data)")
expert.add_option("","--use-whitener-offset", action="store_true",
default=False,
Copied: gnuradio/branches/developers/jblum/digital/usrp_options.py (from rev
10905, gnuradio/branches/developers/jblum/digital/generic_usrp.py)
===================================================================
--- gnuradio/branches/developers/jblum/digital/usrp_options.py
(rev 0)
+++ gnuradio/branches/developers/jblum/digital/usrp_options.py 2009-04-28
01:27:49 UTC (rev 10929)
@@ -0,0 +1,103 @@
+#
+# Copyright 2009 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Radio is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+#
+
+import generic_usrp
+
+def _add_options(parser, expert):
+ """
+ Add options to manually choose between usrp or usrp2.
+ Add options for usb. Add options common to source and sink.
+ @param parser: instance of OptionParser
+ """
+ #pick usrp or usrp2
+ parser.add_option("-u", "--usrpx", type="string", default=None,
+ help="specify which usrp model: 1 for USRP, 2 for USRP2
[default=auto]")
+ #fast usb options
+ expert.add_option("-B", "--fusb-block-size", type="int", default=0,
+ help="specify fast usb block size [default=%default]")
+ expert.add_option("-N", "--fusb-nblocks", type="int", default=0,
+ help="specify number of fast usb blocks
[default=%default]")
+ #usrp options
+ parser.add_option("-w", "--which", type="int", default=0,
+ help="select USRP board [default=%default]")
+ #usrp2 options
+ parser.add_option("-e", "--interface", type="string", default="eth0",
+ help="Use USRP2 at specified Ethernet interface
[default=%default]")
+ parser.add_option("-m", "--mac-addr", type="string", default="",
+ help="Use USRP2 at specified MAC address [default=None]")
+
+def add_rx_options(parser, expert=None):
+ """
+ Add receive specific usrp options.
+ @param parser: instance of OptionParser
+ """
+ parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None,
+ help="select USRP Rx side A or B")
+ parser.add_option("--rx-gain", type="eng_float", default=None,
metavar="GAIN",
+ help="set receiver gain in dB [default=midpoint]. See
also --show-rx-gain-range")
+ parser.add_option("--show-rx-gain-range", action="store_true",
default=False,
+ help="print min and max Rx gain available on selected
daughterboard")
+ parser.add_option("-d", "--decim", type="intx", default=None,
+ help="set fpga decimation rate to DECIM
[default=%default]")
+ _add_options(parser, expert)
+
+def create_usrp_source(options):
+ u = generic_usrp.generic_usrp_source_c(
+ usrpx=options.usrpx,
+ which=options.which,
+ subdev_spec=options.rx_subdev_spec,
+ interface=options.interface,
+ mac_addr=options.mac_addr,
+ fusb_block_size=options.fusb_block_size,
+ fusb_nblocks=options.fusb_nblocks,
+ )
+ if options.show_rx_gain_range:
+ print "Rx Gain Range: minimum = %g, maximum = %g, step size =
%g"%tuple(u.gain_range())
+ return u
+
+def add_tx_options(parser, expert=None):
+ """
+ Add transmit specific usrp options.
+ @param parser: instance of OptionParser
+ """
+ parser.add_option("-T", "--tx-subdev-spec", type="subdev", default=None,
+ help="select USRP Rx side A or B")
+ parser.add_option("--tx-gain", type="eng_float", default=None,
metavar="GAIN",
+ help="set transmitter gain in dB [default=midpoint].
See also --show-tx-gain-range")
+ parser.add_option("--show-tx-gain-range", action="store_true",
default=False,
+ help="print min and max Tx gain available on selected
daughterboard")
+ parser.add_option("-i", "--interp", type="intx", default=None,
+ help="set fpga interpolation rate to INTERP
[default=%default]")
+ _add_options(parser, expert)
+
+def create_usrp_sink(options):
+ u = generic_usrp.generic_usrp_sink_c(
+ usrpx=options.usrpx,
+ which=options.which,
+ subdev_spec=options.tx_subdev_spec,
+ interface=options.interface,
+ mac_addr=options.mac_addr,
+ fusb_block_size=options.fusb_block_size,
+ fusb_nblocks=options.fusb_nblocks,
+ )
+ if options.show_tx_gain_range:
+ print "Tx Gain Range: minimum = %g, maximum = %g, step size =
%g"%tuple(u.gain_range())
+ return u
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r10929 - gnuradio/branches/developers/jblum/digital,
jblum <=