I am attempting to send a message from an OOT module to a gr-display module. This task is part of a large project with a complicated flowgraph. Therefore I am going to provide only the pertinent part of the code. I hope this is sufficient to understand my problem with some explanation.
The ft8_rxtx OOT module is connected to the gr-display module in the flowgraph.
The code is as follows:
from gnuradio import gr
import pmt
class ft8_rxtx(gr.basic_block):
"""
docstring for block ft8_rxtx
"""
def __init__(self, ptt_button, band_selector):
gr.basic_block.__init__(self,
name="ft8_rxtx",
in_sig=[],
out_sig=[])
self.ptt_button = ptt_button
self.band_selector = band_selector
self.portName = "text_out"
self.message_port_register_out(pmt.intern(self.portName))
def set_FT8(self, FT8_button):
if FT8_button == 1:
self.send_msg("Help")
PMT_msg = pmt.to_pmt("Help")
self.message_port_pub(pmt.intern(self.portName), PMT_msg)
main()
else:
quit()
def send_msg(self, msg):
PMT_msg = pmt.to_pmt(msg)
self.message_port_pub(pmt.intern(self.portName), PMT_msg)
def main():
gen_msg = ft8_rxtx(0,1)
gen_msg.send_msg("MAIN")
In main() I am calling send_msg as evidenced by the use of a print statement in the method which correctly displays MAIN. However, the message_port_pub() does not send the message to the gr-display.
If set_FT8 is called, the self.send_msg(“Help”) executes properly and the self.message_port_pub() executes properly. Both send the message “Help” to the gr-display.
Thus, the message passing works when calling send_msg from a class method but does not work when called from main(). Why not? What am I leaving out?
Jim
1
This isn’t valid Python; you need to make send_msg
a method of your class, not a free-standing function.
1