|Subject:||Re: [Discuss-gnuradio] PMT blobs in Python|
|Date:||Sun, 04 Aug 2013 15:29:57 +0200|
|User-agent:||Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7|
On second thought: Does using pmt.make_vector solve your problem?
p = pmt::make_u8vector(length, fill);
(do stuff like pmt::u8vector_set(p, index, value), or even unsigned char* p_vec = pmt::u8vector_writable_elements(p,length). The later can summon hell if you use the same PMT object in multiple places.)
Note, however, that this will inherently copy each individual uchar to a python (long) int.
If you really want the raw bytes, you can always get really dependent on PMT structure (which is basically fine, as long as you know that PMT won't change during the lifetime of your application), and use
in python, as this will give you a string.
Thinking about that, there is yet another option, that suddendly blob's into mind.
in C++ , generate a std::string, and assign your char data to it:
std::string looks_like_it_s_text_but_is_data s();
s.assign(reinterpret_cast<const char*>(mydata), length);
pmt::pmt_t p = pmt::intern(s);
In python, you can use pmt.to_string(p) to get back the string, in case you want to use
it for a buffer.
PLEASE, be aware that this is NOT a good idea for high data volume or high throughput;
string_to_symbol hashes the string, and saves the hash as well as the pmt_t in a table.
On 08/04/2013 12:08 PM, Marcus Müller wrote:
|[Prev in Thread]||Current Thread||[Next in Thread]|