|
From: | Thanasis Balafoutis |
Subject: | Re: [Discuss-gnuradio] Fwd: Write a source block in python |
Date: | Fri, 23 Jan 2015 00:53:46 +0200 |
I think having the work fn return "-1" will cause the flowgraph to exit, so you could potentially have a "self.count = 1" in __init__ and then when you've output >= self.count, have work return -1
-Doug
Douglas Anderson | InternDOC/NTIA/ITS-T | 325 Broadway St., Boulder, CO 80305 | P: 303 497 3582
From: discuss-gnuradio-bounces+danderson=address@hidden [discuss-gnuradio-bounces+danderson=address@hidden] on behalf of Thanasis Balafoutis [address@hidden]
Sent: Thursday, January 22, 2015 2:12 PM
To: address@hidden
Subject: [Discuss-gnuradio] Fwd: Write a source block in python
ThanasisThank you in advance!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?In the output I repeatedly get the helloMsg. (it seems that the work() function is always running)Here is the code:HiI wrote a simple source block that reads a string (as a parameter) and outputs the corresponding array of bytes.
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)])
[Prev in Thread] | Current Thread | [Next in Thread] |