discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] PMT blobs in Python


From: Marcus Müller
Subject: Re: [Discuss-gnuradio] PMT blobs in Python
Date: Sun, 04 Aug 2013 12:08:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

I can't really test this right now,
but you could insert
  %include <cdata.i>
into your project's swig file[1]; this should generate a python method
   cdata(ptr, length)
that you can feed your blob_data() to. I'm not quite sure that WILL
work as is, maybe you will need a C(++) wrapper that simply returns
an array of known type (that is, int* instead of void*) that you can
yourself wrap into a SWIG array_class (like in the linked document).

Greetings
Marcus

[1] http://www.swig.org/Doc1.3/Library.html#Library_nn7
On 08/04/2013 04:37 AM, Peter Horvath wrote:
Hi,

can I convert a blob created by my C++ code (unsigned chars) to a Python
list or NumPy array?

pmt.blob_data() returns a 'SwigPyObject' with which I can't do anything.
Passing it to a NumPy array constructor doesn't seem to do the job.

The blobs are in a tuple:
pmt::pmt_t b1 = pmt::make_blob(a, a_length);
pmt::pmt_t b2 = pmt::make_blob(b, b_length);
return pmt::make_tuple(b1, b2);

And I try to check the contents of b1 in QA code like this:
res = my_test_function()
b1 = pmt.blob_data(pmt.tuple_ref(res, 0))
b1_len = pmt.blob_length(pmt.tuple_ref(res, 0))

Thanks,
Peter

_______________________________________________
Discuss-gnuradio mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


reply via email to

[Prev in Thread] Current Thread [Next in Thread]