|
From: | Tom Rondeau |
Subject: | Re: [Discuss-gnuradio] message ports |
Date: | Sat, 27 Feb 2016 09:48:29 -0800 |
I'm having a problem with message ports. I am trying to have a separate
thread within within the block periodically post messages.
The block is defined as:
<block>
<name>GenAudio</name>
<key>acars_GenAudio_x</key>
<category>acars</category>
<import>import acars</import>
<make>acars.GenAudio($rate,$rounding,$fake)</make>
<callback>set_rate($rate)</callback>
<callback>set_rounding($rounding)</callback>
<callback>set_fake($fake)</callback>
...
<sink>
<name>in</name>
<type>message</type>
<optional>1</optional>
</sink>
<source>
<name>out</name>
<type>complex</type>
</source>
Within the constructor of my block is the code:
d_port_id = pmt::mp( "in" );
message_port_register_in( d_port_id );
set_msg_handler( d_port_id,
boost::bind( &GenAudio_impl::_msgh, this, _1 ));
...
d_faker = std::thread([this](){ this->_thread_faker();});
The goal is other blocks may be connected to this block's input message
port to encode messages but for testing the periodic thread sends
messages to itself.
Within the periodic thread is the code:
void
GenAudio_impl::_thread_faker( void ) {
...
pmt::pmt_t target = pmt::PMT_NIL;
message_port_sub( d_port_id, target );
message_port_pub( d_port_id, m );
message_port_unsub( d_port_id, target );
...
The problem is the run time is throwing an exception with the message:
what(): Port does not exist: "in" on block: ()
I dumped the block's message ports and there is one named "in" so I
don't understand the error message. Is my code snippet NOT how messages
work?
[Prev in Thread] | Current Thread | [Next in Thread] |