|
From: | Cristian Rodríguez |
Subject: | Re: [Discuss-gnuradio] Read and Write a PMT input/output GNURadio C++ |
Date: | Mon, 26 Jun 2017 21:57:31 -0500 |
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));
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!");
}
}
message_port_pub(pmt::mp("out_threshold"), pmt::cons(pmt::PMT_NIL, pmt::from_double(d_threshold)));
Thanks in advance.
Best regards,
Cristian
Hi Cristian,
you need to subscribe a handler to the message port. See:
It's absolutely up to you what kind of PMT you're publishing over a message port, but it's canonical to have a PMT dict that maps
pmt::mp("propertyname") -> pmt::
whateversuitsyourproperty. As an example, see what the gr-uhd blocks accept [1]
Best regards,
Marcus
[1] https://gnuradio.org/doc/
doxygen/page_uhd.html#uhd_ command_syntax
On 06/26/2017 07:35 PM, Cristian Rodríguez wrote:
Hi all,
I'm not sure about how to read and write PMT ports from and to local variables. I'm going to expose what i'm doing, and if someone can help me i would be very greatful.
I've created an input and an output of PMT type.
message_port_register_in(pmt::pmt_t in_threshold)
message_port_register_out(pmt:Now i want to read the port, and save the data in a local variable, do operations with that variable, and later write it in the output,:pmt_t out_threshold)
I create the variables,
double d_threshold;
pmt::pmt_t target;
I read it, I don't know how to do it. But I suppose:
message_port_sub(pmt::pmt_t in_threshold,pmt::pmt_t target);d_threshold= pmt::to_double(target);
And, I think i can write it as follows:
message_port_pub(pmt::pmt_t out_threshold,pmt::pmt_t msg);
What do you think, i've seen several examples, and they do this, message_port_pub(pmt::mp("symbols"), pmt::cons(pmt::make_dict(), pmt::init_c32vector(48, symbols)));
But I don't understand why it is necessary to use pmt::make_dict().
Thanks in advance.
Best regards,
Cristian
_______________________________________________ Discuss-gnuradio mailing list address@hidden https://lists.gnu.org/mailman/ listinfo/discuss-gnuradio
_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio
[Prev in Thread] | Current Thread | [Next in Thread] |