Empty work functions

The implementation of the uhd_control_port block in gnuradio-extras has
an empty work function because it doesn’t actually process any samples.
I believe gnuradio-extras uses the gnuradio advanced scheduler (GRAS),
so apparently GRAS doesn’t mind blocks that don’t have any connections
in a flowgraph or do any work. Does the standard gnuradio scheduler also
support this? I just want to know for reference if the gnuradio
scheduler will keep or ignore a block with no connections, or empty
io_signatures, or no code body in the work function.

What I want to do is change power using timed commands independent of
the data path in the flowgraphs. I can do this one of two ways:

  1. Make a block with a message queue and some logic to handle timing (to
    play nice with the timed commands implementation, which has a limited
    FIFO size and only a 10 second timeout window).
  2. Launch a separate thread in Python that does the same thing as 1) but
    isn’t a block. I assume this will be a lot easier.

–sean

Hi Sean,

yes, the scheduler “supports” this; I’m using this whenever I just need
someone to receive messages.
So basically you do 1), which is quite easy because your “block” looks
like

from pmt.pmt_to_python import pmt_to_python as pmt2py
[…]
class messageReceiver(gr.sync_block):
message_port_identifier = pmt.intern(“msg_in”)

 def __init__(self, ref_to_uhd_sink):
     gr.sync_block.__init__(self, name="foo", in_sig=[], out_sig=[])
     self._uhd = _ref_to_uhd_sink

self.message_port_register_in(self.message_port_identifier)
self.set_msg_handler(self.message_port_identifier,
self.handle_msg)

 def handle_msg(self, msg):
     print "got message", pmt2py(msg)
     self._uhd->set_command_time[...]

Happy Hacking,
Marcus

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs