0

I'm trying to implement a GNURadio source block in Python, which has to produce a vector of a fixed size at each call of the [general_] work function.

As a first toy-example I tried to output just a vector of constant values which should change at each call of the [general_] work function.

import numpy
import sys
from gnuradio import gr

class my_source_vf(gr.sync_block):
    """
    docstring for block 
    """
    def __init__(self, v_size):
        self.v_size = v_size
        self.mult = 1
        self.buff = numpy.ones(v_size)
        gr.sync_block.__init__(self,
            name="my_source_vf",
            in_sig=None,
            #out_sig=[numpy.float32])
            out_sig=[(numpy.float32, self.v_size)])


    def work(self, input_items, output_items):
        # <+signal processing here+>
        print len(output_items)

        out = output_items[0]
        out[0][:] = self.buff*self.mult
        self.mult = self.mult+1

        return self.v_size

However, when I connect it to QT GUI Vector sink block I just see oscillations between 0 and 1, which let me think [general_] work function is called just once.

Frank
  • 3
  • 1

1 Answers1

0

You mustn't return v_size – that's the length of one item, but you should return the number of items you've produced this call.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94