Hello,
I tried to build my first custom block.
Very easy. It just generates one tune msg every 5 seconds.
I followed steps of writing an OOT block in python:
http://gnuradio.org/redmine/projects/gnuradio/wiki/OutOfTreeModules#Tutorial-3-Writing-a-signal-processing-block-in-Python% gr_modtool super_msg_generator
super_msg_generator % gr_modtool add -t sync -l python generador
Inside python/generador.py my code:
#!/usr/bin/env python
import numpy
from gnuradio import gr
import time
class generador(gr.sync_block):
def __init__(self):
gr.sync_block.__init__(self,
name="generador"
#,in_sig=[],
#,out_sig=[]
)
self.message_port_register_out(pmt.intern("ppm"))
def work(self):
while True:
time.sleep(5)
self.message_port_pub(pmt.intern("ppm"), pmt.to_pmt("freq", float(915e6)))
time.sleep(5)
self.message_port_pub(pmt.intern("ppm"), pmt.to_pmt("freq", float(918e6)))
How can I check a block with no inputs and no outputs?
After that I created a build folder in gnuradio/gr-super_msg_generator
cmake ../
make
sudo make install
sudo ldconfig
I thought that was everyhting.
However when trying to setup a python flowgraph the code cannot import the new block.
tune_msg.py::
#!/usr/bin/env python
from gnuradio import blocks
from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import uhd
from gnuradio import super_msg_generator
.....
output when executing: $ python tune_msg.py
linux; GNU C++ version 4.7.2; Boost_104900; UHD_003.008.001-42-g8c87a524
Traceback (most recent call last):
File "tune_msg.py", line 12, in <module>
from gnuradio import super_msg_generator
ImportError: cannot import name super_msg_generator
There is something missing but I do not figure it out. Any help please?
Regards,