|
From: | Tom Rondeau |
Subject: | Re: [Discuss-gnuradio] How to update the value of a variable by reading message in grc? |
Date: | Sun, 11 May 2014 10:22:14 -0400 |
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
[Prev in Thread] | Current Thread | [Next in Thread] |