"Variable" bit rate output block

I’d like to write a block that has a variable output rate for a given
fixed input rate.

What I have in mind is something like gr.simple_squelch_cc, but instead
of outputting zeros when the average power is below the threshold,
doesn’t output anything at all.

The How to Write A Block document says “Adroit use of forecast and
consume allows variable rate blocks to be built…”

Are there any examples to study? Perhaps a pseudo code explanation of
what to do?

Thanks,

-Johnathan

Johnathan C. wrote:

What I have in mind is something like gr.simple_squelch_cc, but instead
of outputting zeros when the average power is below the threshold,
doesn’t output anything at all.

After further reading, it seems like the strategy here would be to have
the general_work() method the block:

  1. Only copy data from input to output when the power threshold is met.

  2. When the power threshold is not met, skip over the input items but
    don’t advance the output index.

  3. Call consume() for the entire input buffer.

  4. Return from general_work() with the actual number of items copied,
    which will always be equal or less than the input buffer size.

Would this work?

-Johnathan, AE6HO

On Tue, Jun 06, 2006 at 10:10:40PM -0700, Johnathan C. wrote:

  1. When the power threshold is not met, skip over the input items but
    don’t advance the output index.

  2. Call consume() for the entire input buffer.

  3. Return from general_work() with the actual number of items copied,
    which will always be equal or less than the input buffer size.

Would this work?

In general, yes.

Eric

Johnathan C. wrote:

What I have in mind is something like gr.simple_squelch_cc, but instead
of outputting zeros when the average power is below the threshold,
doesn’t output anything at all.

A patch to gr.simple_squelch_cc, implementing this functionality, has
been sent to the patch-gnuradio mailing list.

-Johnathan, AE6HO