Hi Cristian, a blob is not a string.
You MUST NOT const char *aux = reinterpret_cast<const char *>(pmt::blob_data(blob)); pmt::pmt_t snrf2 = pmt::intern(std::string(aux)); ever. Blob data is *not* zero-terminated and it's absolutely legal to contain the zero byte. While a std::string might actually contain zero bytes, there's nothing guaranteeing that for the pmt string type. Also: it doesn't really make sense to try and convert something that is not a string to a string type. So, if your Tx App takes arbitrary data, it shouldn't be consuming PMT strings (which actually come with quite a performance hit, by the way, if used to transport info), and if it actually only accepts strings, then you can't just put arbitrary binary data through it. Best regards, Marcus On 06/30/2017 06:13 PM, Cristian Rodríguez wrote: > > Hi all. > > I'm trying to convert a variable from BLOB to String. > > I'm trying to do this. > > Imágenes integradas 1 > > Before, the next block was instead of WiFi App. > > Imágenes integradas 2 > Message strobe sends a PMT message of STRING type (without car and > cdr, just message_port_pub(pmt::mp("strobe"), pmt.intern("12345678")); > ), then I need to send from the port Message out a PMT message of > STRING type. > > But I receive the message in a BLOB type. I was trying all types of > methods, but I can't convert from BLOB to String If I send BLOB it > doesn't work. > > The message comes in the cdr of the PMT, so i tried with different > versions of this code > > pmt::pmt_t blob(pmt::cdr(msg)); > const char *aux = reinterpret_cast<const char > *>(pmt::blob_data(blob)); > > pmt::pmt_t snrf2 = pmt::intern(std::string(aux)); > std::cout << "Es blob " <<std::string(aux)<< std::endl; > message_port_pub(pmt::mp("message out"), snrf2); > > There, i try to convert it to a char and later from char to String, > but it doesn't work. > > What do you think i can do? What i need is to take de data in BLOB > format, convert it to String, save it in a PMT message and send it. > > Thanks a lot for your time to read. > > Best regards, > > Cristian > > > > _______________________________________________ > 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