#!/usr/bin/env python # -*- coding: utf-8 -*- # # Author: Piotr Krysik #Program presenting potential problem caused by message passing done #from Python. The program should exit after sending the message - however this doesn't happen. from gnuradio import gr import pmt class test_msg_source(gr.basic_block): def __init__(self): gr.basic_block.__init__(self, name="test_msg_source", in_sig=[], out_sig=[]) self.message_port_register_out(pmt.intern("msgs")) def send_msg(self): msg_ppm = pmt.from_double(0.0) self.message_port_pub(pmt.intern("msgs"), msg_ppm) class test_msg_sink(gr.basic_block): def __init__(self): gr.basic_block.__init__(self, name="test_msg_sink", in_sig=[], out_sig=[]) self.message_port_register_in(pmt.intern("msgs")) self.set_msg_handler(pmt.intern("msgs"), self.process_msg) def process_msg(self, msg): print "Received message:", msg class test_flowgraph(gr.top_block): def __init__(self): gr.top_block.__init__(self, "test_flograph") self.msg_source = test_msg_source() self.msg_sink = test_msg_sink() self.msg_connect((self.msg_source, 'msgs'), (self.msg_sink, 'msgs')) def trigger_message_transmission(self): self.msg_source.send_msg() if __name__ == '__main__': tb = test_flowgraph() tb.start() tb.trigger_message_transmission() tb.wait()