How to make a message source and message strobe blocks in GNURadio

Question:

I have to make a message source block in GNURadio. I have to use Windows 10 and I don’t know how to install and use gr-modtool on it, so I’m trying to make the block using the Embedded Python Block.

The message block shall behave in a manner similar to the Message Strobe, which periodically sends a message to output port. The only difference is that my message is not an input parameter but is a variable that needs to be periodically calculated. I’m trying to understand how to do it but I didn’t find much information about.

So, this block has no input ports and only one message output port, then the first portion of code should be

class msg_block(gr.sync_block):
   def __init__(self):
       gr.sync_block.__init__(
           self,
           name="msg_block",
           in_sig=None,
           out_sig=None)

       self.message_port_register_out(pmt.intern('msg_out'))

The first issue is that I couldn’t realize even a simple message source. Because if in_sig and out_sig are None, the work method "does not work" then, if I insert the line

self.message_port_pub(pmt.intern('msg_out'), pmt.intern('hello world'))

inside it, it does not really put the message on the msg_out port. In fact, if I run a gnuradio app with my block and a Message debug, nothing is printed. I think I didn’t understand how the method message_port_pub() works because I tried few solution, but none of these worked.

As second step, of course, it would be the introducing of the time loop. I think to use a threading.Timer.

I looked everywhere the message strobe code but did not find it.
Could someone help me to understand how to make both the message source and a message strobe block?

Thanks.

Asked By: Wincio

||

Answers:

I looked everywhere the message strobe code but did not find it.

You can find the message strobe’s source code here

As second step, of course, it would be the introducing of the time loop. I think to use a threading.Timer.

Yes, to implement this you need to start a thread or use some sort of Timer.

Answered By: Vasil Velichkov