You know, maybe this is opening up a can of worms, but you *can* do this. A
lot of blocks don't accept messages; messages aren't exactly first-class
(in the sense that every block accepts them) in Gnuradio. All blocks have
getters/setters to change parameters, but only a comparative few have
message slots, even though their functionality usually overlaps.

I'm currently doing this (callbacks) to interface Gpredict to a GRC
flowgraph to provide Doppler correction. A Python block takes a callback to
tb.set_<varname>() as a parameter, and sets the Doppler correction
frequency as needed using the rotator block, which does not accept
messages. It's easy, convenient, and didn't require modifying anything. The
process has made me think a bit about messages in GR.

I'm sure anyone who's spent time looking at performance in GR is cringing
right now, but a more generic way of doing this would be for GRC blocks to
register slots (for message sinks) and signals (for message sources).
Within GRC, message slots could be automatically generated for every
callback defined in the .yml. It wouldn't require any changes to any
blocks, which seems like a win to me, rather than changing every block in
GR to add message inputs for all setters.

Nick, waiting for the chorus of "BURN THE WITCH"

On Wed, Mar 25, 2020 at 8:14 AM Steffen Kiel <steffenk...@outlook.dk> wrote:

> Hello Marcus,
> alright, i will look into this whole "message" thing instead then.
>
>  thanks for your quick reply.
>
> BR,
> Steffen
>
>
> ------------------------------
> *Fra:* Müller, Marcus (CEL)
> *Sendt:* Onsdag 25 Marts 2020 16:05
> *Til:* steffenk...@outlook.dk; discuss-gnuradio@gnu.org
> *Emne:* Re: Change Variable value from an python block or module?
>
> Yes, but no!
>
> So, GRC Variables are really a GRC concept, and you'd need to break
> multiple layers of encapsulation from within a Python block just to
> alter them. Really, that's possible with a simple callback function,
> but please don't.
>
> Instead, the appropriate way of dealing with this would be giving the
> signal source a message port, on which it accepts new values via
> message.
>
> Then, from your Python or C++ block, just send a message.
>
> Best regards,
> Marcus
>
> On Wed, 2020-03-25 at 14:57 +0000, Steffen Kiel wrote:
> > Hello!
> >
> > I have a signal source whose frequency input is referenced to a variable.
> > Is it possible to access this variables value and set it from a python
> block or python module?
> >
> > BR,
> > Steffen
>

Reply via email to