Hi Marcus. Thanks for your message.
How can I take just the real number of that pair? do you have a reference page of the command? I was reading a lot yesterday and my search wasn't well. I understood that I need to send the pair. Is it possible to send just the real number? Again, thanks a lot for your time. Best regards, Cristian On Jun 27, 2017 3:48 AM, "Marcus Müller" <marcus.muel...@ettus.com> wrote: You're explicitly sending a pair (pmt::cons), not a real or integer number! On 27.06.2017 04:57, Cristian Rodríguez wrote: 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. [image: Imágenes integradas 3] - 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))); - When i start the flowgraph, the block put in the output a PMT message, after that, as it is linked with the input, the message go to the input port. When it is recevied, the function set_msg is launched, but the type of the number in the PMT is not recognized as double. *Here is my problem, I don't understand why it is happening, because the PMT that I put in the output is build from a double, then it is supposed, the one that i received is too a double. What do you think?* [image: Imágenes integradas 2] Thanks in advance. Best regards, Cristian 2017-06-26 12:45 GMT-05:00 Marcus Müller <marcus.muel...@ettus.com>: > Hi Cristian, > > you need to subscribe a *handler* to the message port. See: > > https://wiki.gnuradio.org/index.php/Guided_Tutorial_Programm > ing_Topics#5.3.2_Adding_Message_Passing_to_the_Code > > 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::pmt_t out_threshold) > > 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, > > 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 > <https://gnuradio.org/doc/doxygen/namespacepmt.html#ab4b70d9293452eb74dd07c670e6811fa> > in_threshold,pmt::pmt_t > <https://gnuradio.org/doc/doxygen/namespacepmt.html#ab4b70d9293452eb74dd07c670e6811fa> > target); > d_threshold= pmt::to_double > <https://gnuradio.org/doc/doxygen/namespacepmt.html#a0f58166fe9f449249f5de7dc7b3ab754> > (target); > > And, I think i can write it as follows: > > msg=pmt::from_double > <https://gnuradio.org/doc/doxygen/namespacepmt.html#ad20c287c509e8470d03d1c8e97fea12d> > (d_threshold); > message_port_pub(pmt::pmt_t > <https://gnuradio.org/doc/doxygen/namespacepmt.html#ab4b70d9293452eb74dd07c670e6811fa> > out_threshold,pmt::pmt_t > <https://gnuradio.org/doc/doxygen/namespacepmt.html#ab4b70d9293452eb74dd07c670e6811fa> > 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 > listDiscuss-gnuradio@gnu.orghttps://lists.gnu.org/mailman/listinfo/discuss-gnuradio > > > > _______________________________________________ > Discuss-gnuradio mailing list > Discuss-gnuradio@gnu.org > https://lists.gnu.org/mailman/listinfo/discuss-gnuradio > >
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio