Hi All:

I am sorry to bother the list with such newbie questions, but I am climbing the 
gnuradio and C++ learning curve.  Hope you don’t mind!

I am working on a new OOT block that is similar to the Repeat block, but allows 
for a variable interpolation rate.  I followed the Guided Tutorials (thanks 
Marcus et al) and the new block, which I called “repeat_dynamic” appears to be 
working, sort of…  What I notice is that a simple flowgraph to testing purposes 
grinds to a halt.  I noticed this while debugging my <callback> function that 
resets the appropriate interpolation variable, called d_interp.

Here is my flowgraph, with the properties of the new block shown.  Note that 
“Interpolation is set to variable ‘z’, which is controlled through a Chooser:




Here are my callback and work() functions.  work() is essentially copied from 
the standard Repeat block.  I have added some debug print statements to the 
console to try to figure out what is going on:
    void
    repeat_dynamic_impl::set_interp(int interp)
    {
      d_interp = interp;
      gr::sync_interpolator::set_interpolation(d_interp);
      std::cout << "set_interp: d_interp now equals " << d_interp << "\n";
    }

    int
    repeat_dynamic_impl::work(int noutput_items,
                          gr_vector_const_void_star &input_items,
                          gr_vector_void_star &output_items)
    {
        const char *in = (const char *) input_items[0];
        char *out = (char *) output_items[0];

        // Do <+signal processing+>
        std::cout << "work: noutput_items = " << noutput_items << "\n";
        std::cout << "work: d_interp = " << d_interp << "\n\n";
        for (int i = 0; i < noutput_items/d_interp; i++) {
          for (int j = 0; j < d_interp; j++) {
            memcpy(out, in, d_itemsize);
            out += d_itemsize;
          }
          in += d_itemsize;
        }

        // Tell runtime system how many output items we produced.
        return noutput_items;
    }
My callback function gets triggered correctly when I change the value of 
variable ‘z’ through the flowgraph Chooser.  I see console messages “d_interp 
now equals X”.  So far so good.

The problem is that the input 0 of the Time Sink doesn’t change to reflect the 
new value of d_interp.  I added two more debug print statements to work() to 
see what’s going on.  I know this may not be advisable given assumed 
complexities in the scheduler, but I wanted to do something to try to solve my 
own problem.  The entire flowgraph appears to work for awhile, but 
noutput_items moves towards 0 and the whole process grinds to a halt.

I tried reducing the sampling rate to 1000, and then I CAN see changes in the 
Time Sink and the in0 trace getting updated as I click various alternate ‘z’ 
values in the Chooser, but soon the debug messages from work() cease and 
everything seems to grind to a halt with a low value (~10) for noutput_items.

The graph is still running, however, as subsequent clicks in the Chooser, 
changing ‘z’, still result in a console message showing that d_interp has 
indeed been updated.  I just never see another update from the two std::cout 
statements in work().

As it works at low sample rates for awhile (max a few seconds), I think that 
the basic functionality is okay.  I am missing a C++ or gnuradio nuance of some 
type.

So, I am guessing that I am doing something wrong possibly in the way I call 
sync_interpolator::set_interpolation(d_interp) in my callback function.

Newbie deficiencies are evident and I am turing to the list for some 
suggestions.

I am using Ubuntu 14.04 and the latest gnuradio, built through the 
build-bnuradio script.

Thanks in advance,

Kevin













Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

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

Reply via email to