aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Witkowski <pete@deepwavedigital.com>2019-04-15 15:03:56 -0600
committerMartin Braun <martin.braun@ettus.com>2019-05-17 21:15:46 -0700
commit4e4f44c726556496c420bceb87ccafe6843916f7 (patch)
tree9efa4a511e6ecaea19c1700d8dbaad24b076473f
parentblocks: add byte option to add_const_v in GRC (diff)
downloadgnuradio-4e4f44c726556496c420bceb87ccafe6843916f7.tar.xz
gnuradio-4e4f44c726556496c420bceb87ccafe6843916f7.zip
uhd: Add set_rx_agc() API call and GRC bindings
This adds the set_rx_agc() call from UHD to the USRP source.
-rw-r--r--gr-uhd/grc/gen_uhd_usrp_blocks.py40
-rw-r--r--gr-uhd/include/gnuradio/uhd/usrp_source.h9
-rw-r--r--gr-uhd/lib/usrp_source_impl.cc11
-rw-r--r--gr-uhd/lib/usrp_source_impl.h1
4 files changed, 61 insertions, 0 deletions
diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py
index 3139a5e6b..db83b4203 100644
--- a/gr-uhd/grc/gen_uhd_usrp_blocks.py
+++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py
@@ -170,11 +170,26 @@ templates:
% for n in range(max_nchan):
${'%'} if context.get('nchan')() > ${n}:
self.${'$'}{id}.set_center_freq(${'$'}{${'center_freq' + str(n)}}, ${n})
+ % if sourk == 'source':
+ ${'%'} if context.get('rx_agc${n}')() == 'Enabled':
+ self.${'$'}{id}.set_rx_agc(True, ${n})
+ ${'%'} elif context.get('rx_agc${n}')() == 'Disabled':
+ self.${'$'}{id}.set_rx_agc(False, ${n})
+ ${'%'} endif
+ ${'%'} if context.get('rx_agc${n}')() != 'Enabled':
${'%'} if bool(eval(context.get('norm_gain' + '${n}')())):
self.${'$'}{id}.set_normalized_gain(${'$'}{${'gain' + str(n)}}, ${n})
${'%'} else:
self.${'$'}{id}.set_gain(${'$'}{${'gain' + str(n)}}, ${n})
${'%'} endif
+ ${'%'} endif
+ % else:
+ ${'%'} if bool(eval(context.get('norm_gain' + '${n}')())):
+ self.${'$'}{id}.set_normalized_gain(${'$'}{${'gain' + str(n)}}, ${n})
+ ${'%'} else:
+ self.${'$'}{id}.set_gain(${'$'}{${'gain' + str(n)}}, ${n})
+ ${'%'} endif
+ % endif
${'%'} if context.get('ant${n}')():
self.${'$'}{id}.set_antenna(${'$'}{${'ant' + str(n)}}, ${n})
${'%'} endif
@@ -202,7 +217,14 @@ templates:
- set_samp_rate(${'$'}{samp_rate})
% for n in range(max_nchan):
- set_center_freq(${'$'}{${'center_freq' + str(n)}}, ${n})
+ % if sourk == 'source':
+ - ${'$'}{'set_rx_agc(True, ${n})' if context.get('rx_agc${n}')() == 'Enabled' else ''}
+ - ${'$'}{'set_rx_agc(False, ${n})' if context.get('rx_agc${n}')() == 'Disabled' else ''}
+ - ${'$'}{'set_gain(${'$'}{${'gain' + str(n)}}, ${n})' if not bool(eval(context.get('norm_gain${n}')())) and context.get('rx_agc${n}')() != 'Enabled' else ''}
+ - ${'$'}{'set_normalized_gain(${'$'}{${'gain' + str(n)}}, ${n})' if bool(eval(context.get('norm_gain${n}')())) and context.get('rx_agc${n}')() != 'Enabled' else ''}
+ % else:
- self.${'$'}{id}.set_${'$'}{'normalized_' if bool(eval(context.get('norm_gain${n}')())) else ''}gain(${'$'}{${'gain' + str(n)}}, ${n})
+ % endif
- ${'$'}{'set_lo_source(' + lo_source${n} + ', uhd.ALL_LOS, ${n})' if show_lo_controls else ''}
- ${'$'}{'set_lo_export_enabled(' + lo_export${n} + ', uhd.ALL_LOS, ${n})' if show_lo_controls else ''}
- set_antenna(${'$'}{${'ant' + str(n)}}, ${n})
@@ -296,12 +318,26 @@ PARAMS_TMPL = """
dtype: real
default: '0'
hide: ${'$'}{ 'none' if (nchan > ${n}) else 'all' }
+% if sourk == 'source':
+- id: rx_agc${n}
+ label: 'Ch${n}: AGC'
+ category: RF Options
+ dtype: string
+ default: 'Default'
+ options: ['Default', 'Disabled', 'Enabled']
+ option_labels: [Default, Disabled, Enabled]
+ hide: ${'$'}{ 'none' if (nchan > ${n}) else 'all' }
+% endif
- id: gain${n}
label: 'Ch${n}: Gain Value'
category: RF Options
dtype: float
default: '0'
+% if sourk == 'source':
+ hide: ${'$'}{ 'none' if nchan > ${n} and rx_agc${n} != 'Enabled' else 'all' }
+% else:
hide: ${'$'}{ 'none' if nchan > ${n} else 'all' }
+% endif
- id: norm_gain${n}
label: 'Ch${n}: Gain Type'
category: RF Options
@@ -309,7 +345,11 @@ PARAMS_TMPL = """
default: 'False'
options: ['False', 'True']
option_labels: [Absolute (dB), Normalized]
+% if sourk == 'source':
+ hide: ${'$'}{ 'all' if nchan <= ${n} or rx_agc${n} == 'Enabled' else ('none' if bool(eval('norm_gain' + str(${n}))) else 'part')}
+% else:
hide: ${'$'}{ 'all' if nchan <= ${n} else ('none' if bool(eval('norm_gain' + str(${n}))) else 'part')}
+% endif
- id: ant${n}
label: 'Ch${n}: Antenna'
category: RF Options
diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h b/gr-uhd/include/gnuradio/uhd/usrp_source.h
index 60413e35d..f3ecdeb79 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_source.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h
@@ -253,6 +253,15 @@ namespace gr {
size_t chan = 0) = 0;
/*!
+ * Enable/disable the RX AGC module.
+ * If AGC is turned on, all manual gain settings are ignored.
+ *
+ * \param enable true to enable the AGC
+ * \param chan the channel index 0 to N-1
+ */
+ virtual void set_rx_agc(const bool enable, size_t chan = 0) = 0;
+
+ /*!
* Convenience function for finite data acquisition.
* This is not to be used with the scheduler; rather,
* one can request samples from the USRP in python.
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index 0a7dd0050..83ec74fa8 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -159,6 +159,17 @@ namespace gr {
return _dev->set_rx_gain(gain, name, chan);
}
+ void
+ usrp_source_impl::set_rx_agc(const bool enable, size_t chan)
+ {
+#if UHD_VERSION >= 30803
+ chan = _stream_args.channels[chan];
+ return _dev->set_rx_agc(enable, chan);
+#else
+ throw std::runtime_error("not implemented in this version");
+#endif
+ }
+
void usrp_source_impl::set_normalized_gain(double norm_gain, size_t chan)
{
#ifdef UHD_USRP_MULTI_USRP_NORMALIZED_GAIN
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
index 6a592aa88..bd5865893 100644
--- a/gr-uhd/lib/usrp_source_impl.h
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -83,6 +83,7 @@ namespace gr {
size_t chan);
void set_gain(double gain, size_t chan);
void set_gain(double gain, const std::string &name, size_t chan);
+ void set_rx_agc(const bool enable, size_t chan);
void set_normalized_gain(double gain, size_t chan);
void set_antenna(const std::string &ant, size_t chan);
void set_bandwidth(double bandwidth, size_t chan);