Hi.
Thanks a lot for your time to read.
I read the two links that you shared to me, Marcus. Thanks a
lot for your help. But i still have a problem.
I've implemented as follows:
- I create, the output, input and the handler:
message_port_register_out(pmt::mp("out_threshold"));
message_port_register_in(pmt::mp("in_threshold"));
set_msg_handler(pmt::mp("in_threshold"),
boost::bind(&sync_short_impl::set_msg, this, _1));
- I create, the next function to handle the inputs
void set_msg(pmt::pmt_t msg) { d_msg= msg;
dout << "Nueva lectura : " << d_msg
<< " ninput: " << std::endl;
if (pmt::is_integer(d_msg)) {
d_threshold = (double) pmt::to_long(d_msg);
} else if (pmt::is_real(d_msg)) {
d_threshold = pmt::to_double(d_msg);
} else {
// We really expected an integer or a double here, so we
don't know what to do
throw std::runtime_error("expected an integer!");
}
}
- In the block i linked the input and the output, just to
check that the function set_msg(), works.
- I compile the c++ codes, etc... all that is necessary.
- I write the output as follows (that's working, i checked
that with a message debug):
message_port_pub(pmt::mp("out_threshold"),
pmt::cons(pmt::PMT_NIL, pmt::from_double(d_threshold)));