commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 16/25: Added controls for importing, export


From: git
Subject: [Commit-gnuradio] [gnuradio] 16/25: Added controls for importing, exporting, and sharing LOs
Date: Fri, 27 May 2016 19:14:59 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit 3b0ba5c956ea20e4f03a245b7bf181cca6a252a3
Author: Derek Kozel <address@hidden>
Date:   Wed Apr 20 16:17:15 2016 -0700

    Added controls for importing, exporting, and sharing LOs
---
 gr-uhd/grc/gen_uhd_usrp_blocks.py         | 92 ++++++++++++++++++++++++++++-
 gr-uhd/include/gnuradio/uhd/usrp_source.h | 77 ++++++++++++++++++++++++
 gr-uhd/lib/usrp_block_impl.h              |  8 +++
 gr-uhd/lib/usrp_sink_impl.cc              |  2 -
 gr-uhd/lib/usrp_source_impl.cc            | 98 +++++++++++++++++++++++++++++++
 gr-uhd/lib/usrp_source_impl.h             |  9 +++
 gr-uhd/swig/uhd_swig.i                    | 12 ++++
 7 files changed, 295 insertions(+), 3 deletions(-)

diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py 
b/gr-uhd/grc/gen_uhd_usrp_blocks.py
index fd2e777..e99de0d 100644
--- a/gr-uhd/grc/gen_uhd_usrp_blocks.py
+++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py
@@ -82,6 +82,12 @@ self.\$(id).set_antenna(\$ant$(n), $n)
 self.\$(id).set_bandwidth(\$bw$(n), $n)
        \#end if
 #if $sourk == 'source'
+       \#if \$lo_export$(n)() and not \$hide_lo_controls()
+self.\$(id).set_lo_export_enabled(\$lo_export$(n), uhd.ALL_LOS, $n)
+       \#end if
+    \#if \$lo_source$(n)() and not \$hide_lo_controls()
+self.\$(id).set_lo_source(\$lo_source$(n), uhd.ALL_LOS, $n)
+       \#end if
        \#if \$dc_offs_enb$(n)()
 self.\$(id).set_auto_dc_offset(\$dc_offs_enb$(n), $n)
        \#end if
@@ -101,6 +107,14 @@ self.\$(id).set_normalized_gain(\$gain$(n), $n)
 self.\$(id).set_gain(\$gain$(n), $n)
 \#end if
        </callback>
+       <callback>\#if not \$hide_lo_controls()
+set_lo_source(\$lo_source$(n), uhd.ALL_LOS, $n)
+\#end if
+       </callback>
+    <callback>\#if not \$hide_lo_controls()
+set_lo_export_enabled(\$lo_export$(n), uhd.ALL_LOS, $n)
+\#end if
+       </callback>
        <callback>set_antenna(\$ant$(n), $n)</callback>
        <callback>set_bandwidth(\$bw$(n), $n)</callback>
        #end for
@@ -524,6 +538,62 @@ PARAMS_TMPL = """  <param>
        </param>
 #if $sourk == 'source'
        <param>
+               <name>Ch$(n): LO Source</name>
+               <key>lo_source$(n)</key>
+               <value>internal</value>
+               <type>string</type>
+               <hide>
+                       \#if not \$nchan() > $n
+                               all
+                       \#elif \$hide_lo_controls()
+                               all
+                       \#else
+                               none
+                       \#end if
+               </hide>
+               <option>
+                       <name>Internal</name>
+                       <key>internal</key>
+               </option>
+               <option>
+                       <name>External</name>
+                       <key>external</key>
+               </option>
+               <option>
+                       <name>Companion</name>
+                       <key>companion</key>
+               </option>
+               <tab>RF Options</tab>
+       </param>
+#end if
+#if $sourk == 'source'
+       <param>
+               <name>Ch$(n): LO Export</name>
+               <key>lo_export$(n)</key>
+               <value>False</value>
+               <type>bool</type>
+               <hide>
+                       \#if not \$nchan() > $n
+                               all
+                       \#elif \$hide_lo_controls()
+                               all
+                       \#else
+                               none
+                       \#end if
+               </hide>
+               <option>
+                       <name>True</name>
+                       <key>True</key>
+               </option>
+               <option>
+                       <name>False</name>
+                       <key>False</key>
+               </option>
+               <tab>RF Options</tab>
+       </param>
+#end if
+#if $sourk == 'source'
+       <param>
                <name>Ch$(n): Enable DC Offset Correction</name>
                <key>dc_offs_enb$(n)</key>
                <value>""</value>
@@ -573,6 +643,25 @@ SHOW_CMD_PORT_PARAM = """
        </param>
 """
 
+SHOW_LO_CONTROLS_PARAM = """
+       <param>
+               <name>Show LO Controls</name>
+               <key>hide_lo_controls</key>
+               <value>True</value>
+               <type>bool</type>
+               <hide>part</hide>
+               <option>
+                       <name>Yes</name>
+                       <key>False</key>
+               </option>
+               <option>
+                       <name>No</name>
+                       <key>True</key>
+               </option>
+               <tab>Advanced</tab>
+       </param>
+"""
+
 TSBTAG_PARAM = """     <param>
                <name>TSB tag name</name>
                <key>len_tag_name</key>
@@ -605,7 +694,8 @@ if __name__ == '__main__':
                else: raise Exception, 'is %s a source or sink?'%file
 
                params = ''.join([parse_tmpl(PARAMS_TMPL, n=n, sourk=sourk) for 
n in range(max_num_channels)])
-                params += SHOW_CMD_PORT_PARAM
+               params += SHOW_CMD_PORT_PARAM
+               params += SHOW_LO_CONTROLS_PARAM
                if sourk == 'sink':
                        params += TSBTAG_PARAM
                        lentag_arg = TSBTAG_ARG
diff --git a/gr-uhd/include/gnuradio/uhd/usrp_source.h 
b/gr-uhd/include/gnuradio/uhd/usrp_source.h
index 19201c0..a0022b3 100644
--- a/gr-uhd/include/gnuradio/uhd/usrp_source.h
+++ b/gr-uhd/include/gnuradio/uhd/usrp_source.h
@@ -140,6 +140,83 @@ namespace gr {
        */
       virtual ::uhd::dict<std::string, std::string> get_usrp_info(size_t chan 
= 0) = 0;
 
+
+      /*!
+       * Get a list of possible LO stage names
+       * \param chan the channel index 0 to N-1
+       * \return a vector of strings for possible LO names
+       */
+      virtual std::vector<std::string> get_lo_names(size_t chan = 0) = 0;
+
+      /*!
+       * Set the LO source for the usrp device.
+       * For usrps that support selectable LOs, this function
+       * allows switching between them.
+       * Typical options for source: internal, external.
+       * \param src a string representing the LO source
+       * \param name the name of the LO stage to update
+       * \param chan the channel index 0 to N-1
+       */
+      virtual void set_lo_source(const std::string &src, const std::string 
&name, size_t chan = 0) = 0;
+
+      /*!
+       * Get the currently set LO source.
+       * \param name the name of the LO stage to query
+       * \param chan the channel index 0 to N-1
+       * \return the configured LO source
+       */
+      virtual const std::string get_lo_source(const std::string &name, size_t 
chan = 0) = 0;
+
+      /*!
+       * Get a list of possible LO sources.
+       * \param name the name of the LO stage to query
+       * \param chan the channel index 0 to N-1
+       * \return a vector of strings for possible settings
+       */
+      virtual std::vector<std::string> get_lo_sources(const std::string &name, 
size_t chan = 0) = 0;
+
+      /*!
+       * Set whether the LO used by the usrp device is exported
+       * For usrps that support exportable LOs, this function
+       * configures if the LO used by chan is exported or not.
+       * \param enabled if true then export the LO
+       * \param name the name of the LO stage to update
+       * \param chan the channel index 0 to N-1 for the source channel
+       */
+      virtual void set_lo_export_enabled(bool enabled, const std::string 
&name, size_t chan = 0) = 0;
+
+      /*!
+       * Returns true if the currently selected LO is being exported.
+       * \param name the name of the LO stage to query
+       * \param chan the channel index 0 to N-1
+       */
+      virtual bool get_lo_export_enabled(const std::string &name, size_t chan 
= 0) = 0;
+
+      /*!
+       * Set the RX LO frequency (Advanced).
+       * \param freq the frequency to set the LO to
+       * \param name the name of the LO stage to update
+       * \param chan the channel index 0 to N-1
+       * \return a coerced LO frequency
+       */
+      virtual double set_lo_freq(double freq, const std::string &name, size_t 
chan = 0) = 0;
+
+      /*!
+       * Get the current RX LO frequency (Advanced).
+       * \param name the name of the LO stage to query
+       * \param chan the channel index 0 to N-1
+       * \return the configured LO frequency
+       */
+      virtual double get_lo_freq(const std::string &name, size_t chan = 0) = 0;
+
+      /*!
+       * Get the LO frequency range of the RX LO.
+       * \param name the name of the LO stage to query
+       * \param chan the channel index 0 to N-1
+       * \return a frequency range object
+       */
+      virtual ::uhd::freq_range_t get_lo_freq_range(const std::string &name, 
size_t chan = 0) = 0;
+
       /*!
        * Enable/disable the automatic DC offset correction.
        * The automatic correction subtracts out the long-run average.
diff --git a/gr-uhd/lib/usrp_block_impl.h b/gr-uhd/lib/usrp_block_impl.h
index cb07fb3..a1bbf97 100644
--- a/gr-uhd/lib/usrp_block_impl.h
+++ b/gr-uhd/lib/usrp_block_impl.h
@@ -40,6 +40,14 @@
 namespace gr {
   namespace uhd {
 
+      static const size_t ALL_MBOARDS = ::uhd::usrp::multi_usrp::ALL_MBOARDS;
+      static const size_t ALL_CHANS = ::uhd::usrp::multi_usrp::ALL_CHANS;
+      static const std::string ALL_GAINS = ::uhd::usrp::multi_usrp::ALL_GAINS;
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+      static const std::string ALL_LOS = ::uhd::usrp::multi_usrp::ALL_LOS;
+#else
+      static const std::string ALL_LOS;
+#endif
     class usrp_block_impl : virtual public usrp_block
     {
      public:
diff --git a/gr-uhd/lib/usrp_sink_impl.cc b/gr-uhd/lib/usrp_sink_impl.cc
index 666f09c..8b3412b 100644
--- a/gr-uhd/lib/usrp_sink_impl.cc
+++ b/gr-uhd/lib/usrp_sink_impl.cc
@@ -29,8 +29,6 @@
 namespace gr {
   namespace uhd {
 
-    static const size_t ALL_CHANS = ::uhd::usrp::multi_usrp::ALL_CHANS;
-
     usrp_sink::sptr
     usrp_sink::make(const ::uhd::device_addr_t &device_addr,
                    const ::uhd::io_type_t &io_type,
diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index 0a09ed3..f0450a6 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -281,6 +281,104 @@ namespace gr {
         return _dev->get_rx_bandwidth_range(chan);
     }
 
+    std::vector<std::string>
+    usrp_source_impl::get_lo_names(size_t chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->get_rx_lo_names(chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    const std::string
+    usrp_source_impl::get_lo_source(const std::string &name, size_t chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->get_rx_lo_source(name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    std::vector<std::string>
+    usrp_source_impl::get_lo_sources(const std::string &name, size_t chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->get_rx_lo_sources(name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    void
+    usrp_source_impl::set_lo_source(const std::string &src, const std::string 
&name, size_t chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->set_rx_lo_source(src, name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    bool
+    usrp_source_impl::get_lo_export_enabled(const std::string &name, size_t 
chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->get_rx_lo_export_enabled(name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    void
+    usrp_source_impl::set_lo_export_enabled(bool enabled, const std::string 
&name, size_t chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->set_rx_lo_export_enabled(enabled, name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    ::uhd::freq_range_t
+    usrp_source_impl::get_lo_freq_range(const std::string &name, size_t chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->get_rx_lo_freq_range(name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    double
+    usrp_source_impl::get_lo_freq(const std::string &name, size_t chan)
+    {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->get_rx_lo_freq(name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
+    double
+    usrp_source_impl::set_lo_freq(double freq, const std::string &name, size_t 
chan) {
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+        chan = _stream_args.channels[chan];
+        return _dev->set_rx_lo_freq(freq, name, chan);
+#else
+        throw std::runtime_error("not implemented in this version");
+#endif
+    }
+
     void
     usrp_source_impl::set_auto_dc_offset(const bool enable, size_t chan)
     {
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
index 78a8341..f6225a7 100644
--- a/gr-uhd/lib/usrp_source_impl.h
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -77,6 +77,12 @@ namespace gr {
       ::uhd::sensor_value_t get_sensor(const std::string &name, size_t chan);
       std::vector<std::string> get_sensor_names(size_t chan);
       ::uhd::usrp::dboard_iface::sptr get_dboard_iface(size_t chan);
+      std::vector<std::string> get_lo_names(size_t chan);
+      const std::string get_lo_source(const std::string &name, size_t chan);
+      std::vector<std::string> get_lo_sources(const std::string &name, size_t 
chan);
+      bool get_lo_export_enabled(const std::string &name, size_t chan);
+      double get_lo_freq(const std::string &name, size_t chan);
+      ::uhd::freq_range_t get_lo_freq_range(const std::string &name, size_t 
chan);
 
       // Set Commands
       void set_subdev_spec(const std::string &spec, size_t mboard);
@@ -96,6 +102,9 @@ namespace gr {
       void set_iq_balance(const std::complex<double> &correction, size_t chan);
       void set_stream_args(const ::uhd::stream_args_t &stream_args);
       void set_start_time(const ::uhd::time_spec_t &time);
+      void set_lo_source(const std::string &src, const std::string &name = 
ALL_LOS, size_t chan = 0);
+      void set_lo_export_enabled(bool enabled, const std::string &name = 
ALL_LOS, size_t chan = 0);
+      double set_lo_freq(double freq, const std::string &name, size_t chan);
 
       void issue_stream_cmd(const ::uhd::stream_cmd_t &cmd);
       void flush(void);
diff --git a/gr-uhd/swig/uhd_swig.i b/gr-uhd/swig/uhd_swig.i
index 108f544..b82d0fd 100644
--- a/gr-uhd/swig/uhd_swig.i
+++ b/gr-uhd/swig/uhd_swig.i
@@ -155,8 +155,20 @@ static uhd::device_addrs_t find_devices_raw(const 
uhd::device_addr_t &dev_addr =
 ////////////////////////////////////////////////////////////////////////
 %{
 static const size_t ALL_MBOARDS = uhd::usrp::multi_usrp::ALL_MBOARDS;
+static const size_t ALL_CHANS = uhd::usrp::multi_usrp::ALL_CHANS;
+static const std::string ALL_GAINS = uhd::usrp::multi_usrp::ALL_GAINS;
+
+#ifdef UHD_USRP_MULTI_USRP_LO_CONFIG_API
+static const std::string ALL_LOS = uhd::usrp::multi_usrp::ALL_LOS;
+#else
+static const std::string ALL_LOS;
+#endif
 %}
+
 static const size_t ALL_MBOARDS;
+static const size_t ALL_CHANS;
+static const std::string ALL_GAINS;
+static const std::string ALL_LOS;
 
 %{
 #include <uhd/version.hpp>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]