update a variable in GNU Radio over the network

2019-09-18 13:41发布

问题:

I am using GNU Radio to stream RF data out using a UDP sink. The data is streamed to a controlling program. As part of this process I am frequency shifting (with a multiply block), filtering and down sampling.

I would like to change the values of frequency shift at run time.

Is there a way for me to have values from a UDP source saved directly to a variable? The only solution I can think of now is to forever generate a sine wave and then pipe that into GNU Radio, and then multiply my signal with that. But that seems like a huge waste of resources. I would like to be able to send a single packet, have that value "latch" into a GNU Radio variable, and then use that variable in my blocks.

回答1:

There's multiple approaches for that:

  1. If you want to stick with the GNU Radio Companion "variable" concept, you can use the XMLRPC blocks. Usage is pretty straightforward, and the GNU Radio GRC example (often found under /usr/share/gnuradio/examples/grc cover that.
  2. If you want to write a little code for yourself, you could write a python hier block that really just contains a signal source, but also has a message port, with a message port handler that modifies the frequency of the signal source. That way, you could also the ZeroMQ blocks, which are pretty awesome :)
  3. Hypothetically, you could of course also implement the hier block from 2., but instead of giving it a message port and a message handler, make it asynchronously react to network messages coming from the outside, to change the settings of the signal source. Caveat here is that python multithreading is a bit tricky, and you'd be basically re-implementing the XMLRPC blocks from 1.