How to update the value of a variable by reading message in grc?

Hi all,

I’m working on a system with packet headers. I want to use the message
decoded by the Packet Header Parser to update a variable.

I knew the message can be stored in a message debug block, and be
retrieved
by using the “get_message” function. So I can define a get function to
read
the message in the flowgraph class, and call this get function in “main”
and
set this value to the variable I want to update. For example, I wrote a
get
function like this:

def get_type(self):

self.num_msg = self.msg_debug.num_messages()
self.msg = pmt.to_python(self.msg_debug.get_message(self.num_msg-1))
self.type = self.msg.get(‘type_tag’)
return self.type

and call this get function in “main”
type = tb.get_type()
tb.set_variable(type)

But as far as I know, the get function can only be called once in
“main”, so
the variable can only be updated once. Since we want to update the
variable
every time we decoded a message, I’m wondering is there a way in the grc
to
change a variable
by the message?

I actually have a idea in mind. Like the Header/Payload Demux block used
in
rx_ofdm, I can write a block that taking message as input, reading the
PMT
dictionary to get the value we want, and output the value. Then the
desired
variable can be updated by connecting the output of my designed block to
a
function probe.

But this function probe only probes the port in a certain frequency,
i.e. it
can not catch all the updates. So I’m wondering if there is a way to
update
a predefined variable through a block every time.

Any suggestions will be valued.

Thanks!
Best,
Zhe


View this message in context:
http://gnuradio.4.n7.nabble.com/How-to-update-the-value-of-a-variable-by-reading-message-in-grc-tp47932.html
Sent from the GnuRadio mailing list archive at Nabble.com.

On Sat, May 3, 2014 at 2:31 AM, Zhe F. [email protected] wrote:

function like this:
tb.set_variable(type)
dictionary to get the value we want, and output the value. Then the desired
Thanks!
Best,
Zhe

I think your best option is to create your own block for handling the
messages and not use the Message Debug block. As that block says, it’s
designed to help us debug message passing applications; it’s not meant
to
be actually used as part of a real application.

Tom

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