discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Issue with the Message API in Python


From: CEL
Subject: Re: [Discuss-gnuradio] Issue with the Message API in Python
Date: Sun, 26 May 2019 18:06:36 +0000

Hey,

got nothing to do with patience – I like what I'm doing, and that
especially includes conversing with you :)

So, yeah, most of the ways you interact with GNU Radio from Python is
to make Python-wrapped C++ code do what you want. For many things, that
wrapping is relatively thin (e.g. when you set a property of a GNU
Radio block written in C++, all that happens is some type conversions
and the call to the underlying C++ method of the block class), for some
there's a bit more magic involved:

In the case of writing your own block, GNU Radio's Python API tries to
be as close to what the C++ blocks do, logically. So, you can inherent
from the gr.block class and override (nearly) all the things a C++
block could override, too, be it the work() function, or be it the
housekeeping start().

So, yes, if you want to know what something does, the C++ documentation
is generally a good place to look.

That being said, things aren't perfect in GNU Radio land when it comes
to documentation. But Marc has an exciting project underway – he, we,
are generating a "block-wise" documentation that differs in its scope
from the C++ API documentation: It documents each block, including
explanations, usage guidance, and a neat integration into the GNU Radio
companion.

To me, that's big news, because obviously, I want GNU Radio to run on
every computer that belongs to someone who thinks that live processing
of signals is a good thing.

Best regards,
Marcus

On Sun, 2019-05-26 at 14:45 +0200, Sebastian Sahlin wrote:
> Hi again,
> 
> Thanks for the info and for being patient Marcus. I suppose as a
> general rule you need to be able to interpret C++ documentation if
> you're going the Python route in GR?
> 
> Regards
> 
> Den fre 24 maj 2019 kl 17:50 skrev Müller, Marcus (CEL) <
> address@hidden>:
> > Oh, I nearly forgot you asked for documentation:
> > 
> > 
> > https://www.gnuradio.org/doc/doxygen/classgr_1_1block.html#a7f58745d1374b30a7b866406dc97850f
> > 
> > Best regards,
> > Marcus
> > On Fri, 2019-05-24 at 15:53 +0200, Sebastian Sahlin wrote:
> > > Okay, this appears to work:
> > > 
> > > def start(self):
> > > threading.Thread(target=self.send_message('Hello World')).start()
> > > return true
> > > 
> > > However I am unsure why the return value is necessary (figured it
> > out through an error message). Is there somewhere in the
> > documentation you can point me to find more info about this?
> > > 
> > > Regards
> > > 
> > > 
> > > Den fre 24 maj 2019 kl 14:45 skrev Sebastian Sahlin <
> > address@hidden>:
> > > > Hi Marcus,
> > > > 
> > > > Aha! I saw hints of this in the documentation but couldn't
> > fully connect the dots. 
> > > > 
> > > > Would this be the start() function of top_block, or the block
> > in question? How would the syntax look like then?
> > > > 
> > > > Regards
> > > > 
> > > > Den tors 23 maj 2019 kl 18:32 skrev Müller, Marcus (CEL) <
> > address@hidden>:
> > > > > Hi Sebastian,
> > > > > 
> > > > > classic one!
> > > > > 
> > > > > You send the messages in the block's constructor in an
> > endless loop.
> > > > > 
> > > > > So, that constructor never finishes.
> > > > > 
> > > > > Thus, the block never can get message-connected. Thus, your
> > messages
> > > > > disappear.
> > > > > 
> > > > > You can't publish message in a constructor. Spawn off a
> > thread in the
> > > > > `start()` method to do that.
> > > > > 
> > > > > Best regards,
> > > > > Marcus
> > > > > 
> > > > > On Thu, 2019-05-23 at 17:42 +0200, Sebastian Sahlin wrote:
> > > > > > Hi,
> > > > > > 
> > > > > > For learning purposes I'm trying to replicate the
> > functionality of the Message Strobe block in Python, however I'm
> > stumped by what should be a very basic function. I'm simply
> > attempting to publish a message every x seconds:
> > > > > > 
> > > > > > def __init__(self, period):
> > > > > >         gr.basic_block.__init__(self,
> > > > > >             name="msg_strobe",
> > > > > >             in_sig=None,
> > > > > >             out_sig=None)
> > > > > > 
> > > > > >       
> >  self.message_port_register_out(pmt.intern('msg_out'))
> > > > > > 
> > > > > >         while(True):
> > > > > >             self.send_message('Hello World')
> > > > > >             time.sleep(period)
> > > > > > 
> > > > > >     def send_message(self, string):
> > > > > >         self.message_port_pub(pmt.intern('msg_out'),
> > pmt.intern(string))
> > > > > > 
> > > > > > However there is no message published to the Message Debug
> > block.  
> > > > > > 
> > > > > > _______________________________________________
> > > > > > Discuss-gnuradio mailing list
> > > > > > address@hidden
> > > > > > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
> 
> _______________________________________________
> Discuss-gnuradio mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/discuss-gnuradio

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]