discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] USRP control thread in GR block - how do I pass a


From: Andy Walls
Subject: Re: [Discuss-gnuradio] USRP control thread in GR block - how do I pass a USRP sptr?
Date: Thu, 04 Feb 2016 10:19:59 -0500

On Thu, 2016-02-04 at 08:32 -0500, address@hidden
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





reply via email to

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