On Thu, 2016-02-04 at 08:32 -0500, discuss-gnuradio-requ...@gnu.org
wrote:

> In case anyone is interested, I got this to work with code similar to
> the following. Note that ?usrp_alias? must be fetched from an already
> constructed usrp_sink object, for instance using ?self.usrp.alias()?
> in a Python-based flowgraph.

Sean,

Ah, interesting.

I wrote a "uhd_nmea" block for combined USRP and host clock discipline a
few years ago, and ended up using libuhd directly.  I didn't have to
worry about which block got instantiated first and could just use GRC
without editing the generated Python script.  I did have to take care
that it was the only block performing uhd control of device settings:
http://files.ettus.com/manual/page_general.html#general_threading_safety

Here's the relevant code on how I used libuhd directly in the OOT block.
The ::uhd::device_addr_t type is the same type of argument the usrp_sink
and usrp_source blocks use as input:

include/my-oot/uhd_nmea.h:

    class MY_OOT_API uhd_nmea : virtual public gr::block
    {
     public:
     static sptr make(const ::uhd::device_addr_t &uhd_device_addr,
                      ...);
    }


lib/uhd_nmea_impl.h:

#include <uhd/usrp/multi_usrp.hpp>

    class uhd_nmea_impl : public uhd_nmea
    {
     private:
      void open_uhd_device(const ::uhd::device_addr_t &uhd_device_addr);

      ::uhd::usrp::multi_usrp::sptr    d_uhd_dev;
    ...
    };


lib/uhd_nmea_impl.cc:

    uhd_nmea_impl::uhd_nmea_impl(const ::uhd::device_addr_t &uhd_device_addr,
                                 ...)
      : gr::block("uhd_nmea",
              gr::io_signature::make(0, 0, 0),
              gr::io_signature::make(0, 0, 0)),
        ....
    {
        open_uhd_device(uhd_device_addr);
        ....
    }

    void uhd_nmea_impl::open_uhd_device(const ::uhd::device_addr_t 
&uhd_device_addr)
    {
        d_uhd_dev = ::uhd::usrp::multi_usrp::make(uhd_device_addr);

        // 10 MHz reference clock from GPSDO, disable output on rear connector
        d_uhd_dev->set_clock_source("gpsdo", 0);
        d_uhd_dev->set_clock_source_out(false, 0);

        // PPS from GPSDO, enable output on rear connector
        d_uhd_dev->set_time_source("gpsdo", 0);
        d_uhd_dev->set_time_source_out(true, 0);
    }
    

-Andy



_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Reply via email to