discuss-gnuradio
[Top][All Lists]
Advanced

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

[Discuss-gnuradio] Fwd: Write a source block in python


From: Thanasis Balafoutis
Subject: [Discuss-gnuradio] Fwd: Write a source block in python
Date: Thu, 22 Jan 2015 23:12:13 +0200

Hi

I wrote a simple source block that reads a string (as a parameter) and outputs the corresponding array of bytes.
Here is the code:

class myblock(gr.sync_block):

    def __init__(self, helloMsg):
        gr.sync_block.__init__(self,
            name="myblock",
            in_sig=None,
            out_sig=[numpy.byte])
        self.helloMsg = helloMsg

    def work(self, input_items, output_items):
        out = output_items[0]
       
        test = array.array('B',self.helloMsg)
        for j in range(len(test)):
           out[j] = test[j]
        return len(output_items[0][:len(test)])

In the output I repeatedly get the helloMsg. (it seems that the work() function is always running)
Is it possible to get in the output my helloMsg only one time (or a specific amount of times) and then stop the execution of the flowgraph?

Thank you in advance!
Thanasis


reply via email to

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