I tried to implement a python block which generates tuning commands
every 5
seconds.
Python block: 0 inputs, 0 outputs, 1 out_msg port which must be
declared in the constructor.
I used gr_modtool. I got some trouble that I think can be easily solved.
New python block:
#!/usr/bin/env python
import numpy
from gnuradio import gr
import time
class generador_NN(SOMETHING_1):
def init(self):
SOMETHING_1.init(SOMETHING_2)
self.message_port_register_out(pmt.intern(“ppm”))
def general_work(self):
while True:
time.sleep(5)
self.message_port_pub(pmt.intern("ppm"), pmt.to_pmt("freq",
SOMETHING_1: gr.sync_block, gr.basic_block, gr.noblock ¿?
When using gr_mod tool, which kind of block must specify? If I use sync
or
basic it complaints there are missing input/outputs. On the other hand
if I
write noblock there is no message_port_register_out method available.
How can I solve that?
SOMETHING_2: Depends which kind of block is the parent. Since there is
no
input/output it must be empty (self). Correct?
class newblock(gr.basic_block):
“”"
What the block does.
“”"
def init(self, args):
gr.basic_block.init(self,
name=“newblock”,
in_sig=[], # No streaming ports!
out_sig=[])
# Register the message port
self.message_port_register_out(pmt.intern(‘portname’))
You should take a look at our Guided Tutorials. The above code comes
straight from one of the example blocks we create in there that I made
more
generic here.
SOMETHING_1: gr.sync_block, gr.basic_block, gr.noblock ?
When using gr_mod tool, which kind of block must specify? If I use sync
or basic it complaints there are missing input/outputs. On the other
hand if I write noblock there is no message_port_register_out method
available.
How can I solve that?
Maybe a hier block is the right choice. modtool can do those, so follow
its lead as closely as possible. It will have zero in- and outputs, but
registers message ports.
See qa_hier_block2_message_connections.py for an example.
Cheers,
Martin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.