Insert messages in queues?

If I’m using a block that has a message port output, is there a way to
put
those messages into a message queue? For instance:

self.message_queue = gr.msg_queue()
self.msg_connect((self.gsm_control_channels_decoder, ‘msgs’),
(???message_queue???, 0))

I have used gr.msg_queue() with blocks.message_sink() but that only
accepts
items such as complex, float, etc. I need to take the messages
generated by
any old block and parse them outside the flowgraph.

From what I have read, I thought all blocks that handle messages have
queues, so shouldn’t I be able to pop them directly out of that block?
I
guess I’m confused. Are there two type of message passing; an old one
that
uses queues, and a new one that uses PMT?

Thanks,
Lou


View this message in context:
http://gnuradio.4.n7.nabble.com/Insert-messages-in-queues-tp53272.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On 11.04.2015 20:38, madengr wrote:

From what I have read, I thought all blocks that handle messages have
queues, so shouldn’t I be able to pop them directly out of that block? I
guess I’m confused. Are there two type of message passing; an old one that
uses queues, and a new one that uses PMT?

Hey Louis,

Yes, there are two ways, and they’re completely different. The old
message queues will be deprecated soon, so anything with gr.msg_queue()
in there will, at one point in the future, stop working.

Look at the Python output of some of the message examples we provide,
also check out this manual page:
http://gnuradio.org/doc/doxygen/page_msg_passing.html

M

Thanks Martin. Looking at the gr-blocks/examples/msg_passing, the
tutorial
link, and qa_msg, I only find examples of posting messages. Those make
sense, but is there an equivalent to _post method that pulls messages?

http://gnuradio.org/doc/doxygen/classgr_1_1basic__block.html#a8501714cb14c1a08b4ff55761600f3a5

From the above docs, I see the delete_head_blocking, which is maybe what
I
want. If I have a tagged stream to PDU like below, how do I pull the
message?

sink=blocks.tagged_stream_to_pdu(blocks.float_t, “packet_len”)
sink.to_basic_block.???

Lou

Martin B.-2 wrote

M


Discuss-gnuradio mailing list

[email protected]

https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


View this message in context:
http://gnuradio.4.n7.nabble.com/Insert-messages-in-queues-tp53272p53277.html
Sent from the GnuRadio mailing list archive at Nabble.com.

Martin,

Yes, pop them outside the block, but also outside of the flow graph.
Exactly reverse of the last example “Posting from External Sources”
here:

http://gnuradio.org/doc/doxygen/page_msg_passing.html

“The last feature of the message passing architecture to discuss here is
how
it can be used to take in messages from an external source. We can call
a
block’s gr::basic_block::_post method directly and pass it a message. So
any
block with an input message port can receive messages from the outside
in
this way.”

I want to take any block with an output message port and _pull that
message
to the outside (of the flow so I can process it in Python).

Presently, with the old queued messaging system, I can use
blocks.message_sink() to take an item into a message queue I can access
outside the flow. Since this will be deprecated, I’d want to use
blocks.tagged_stream_to_pdu() to generate a message, but don’t see a way
to
get those messages stored into a FIFO (queue) and access them outside
the
flow.

As you suggest, maybe the solution is to develop a block, with an input
message port, that performs the callback and stores those messages in a
FIFO. From browsing the documentation, it looks like the message_debug
block will store up messages (I haven’t attempted to read those
messages),
but I’d be worried about overflows. I guess the ideal was to do it
without
developing or modifying any blocks.

Though looking at line 278 of usrp_spectrum_sense.py, when the message
queues are deprecated, what would you do to get the data out of the
flow? I
assume blocks.bin_statistics_f() would have to be re-written to have a
message port output, but then how do you get that message out of the
flow?

https://github.com/gnuradio/gnuradio/blob/master/gr-uhd/examples/python/usrp_spectrum_sense.py#L278

Thanks,
Lou

Martin B.-2 wrote

Cheers,
M


View this message in context:
http://gnuradio.4.n7.nabble.com/Insert-messages-in-queues-tp53272p53279.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On 12.04.2015 15:22, madengr wrote:

sink=blocks.tagged_stream_to_pdu(blocks.float_t, “packet_len”)
sink.to_basic_block.???

So you want pop messages from outside the block, right? Is the original
block written in C++?

delete_head_block() should work, but this seems unusual. Typically, we
have two mechanisms of handling messages: Dedicated message handler
callbacks, or we pop the queue ourselves in work() using delete_head().

If you’re popping messages outside of the block, the block itself would
never see or use those messages – which is why I’m surprised. You might
be better of writing a mini-Python-block that handles the messages.

Cheers,
M

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