Hi André - I think you're looking for 2 steps: 1) In the block constructor, declare the message port, e.g.: {{{ message_port_register_out (pmt::mp ("frame request")); }}} You're probably already doing this.
2) Add the thread creation to the ::start method, so that the thread is not trying to do something before the output message port is actually active. Make sure to use gr::thread::thread and boost::bind such that the thread is running in the same class namespace as the rest of the block, to get access to its variables and methods. The GR codebase provides examples of how to do this 2-part thread creation approach. Hope this helps! - MLD On Sun, Nov 12, 2017, at 03:01 PM, André Gomes wrote: > I'm getting an error while trying to use an output message port with a > thread. The thread is responsible for executing function > *check_buff()*. It seems to return the error bellow because the > message port inside the function was not initialized yet. Firstly, the > thread was started at the constructor. According to this link[1], > starting at the constructor is the root of the problem and one should > start the thread in the start function of the block (bool start()). So > I did but I'm still getting the same error. The port still does not > exist when the thread starts.> How do I guarantee the existence of the port > before starting > the thread?> > *Figure 1: *Error > Inline images 2 > > *Figure 2: *Function used by thread. > Inline images 1 Links: 1. https://lists.gnu.org/archive/html/discuss-gnuradio/2016-02/msg00388.html
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio