discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Problem to handle message port in thread


From: André Gomes
Subject: Re: [Discuss-gnuradio] Problem to handle message port in thread
Date: Sun, 12 Nov 2017 21:36:13 -0200

Hi Michael, 

Thanks for you support but I'm still getting the same error. :/ 

1) Yes, I'm already doing that.
2) I did that. See figure bellow. Unfortunately, the error persists as you can see bellow. 

Figure 1: start() method.

Figure 2: error

I have not found such examples you mentioned for part two. Only few poor/ not crystal clear references about how to do this. Would you have any other suggestions? 

Kind regards,​


On 12 November 2017 at 18:17, Michael Dickens <address@hidden> wrote:
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, 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]