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: Josh Blum
Subject: Re: [Discuss-gnuradio] PMT blobs in Python
Date: Mon, 05 Aug 2013 04:39:54 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7


On 08/04/2013 06:08 AM, Marcus Müller wrote:
> 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).
> 

I dont know if this made it into PMT, buts its definitely in gr core for
the block gateway. Basically the snippet gives you a numpy array given a
ptr and length. Once its in numpy, you can shape it however, no copies
involved, do math on it, etc...

Here it is for the blob extensions in the old grextras:
https://github.com/guruofquality/grextras/blob/grextras_v3.6/python/extras_pmt.py#L32

Using a similar one in PMC to handle various numeric arrays:
https://github.com/guruofquality/PMC/blob/master/python/PMC/PMCNumericArray.i#L87

And again for the smart buffer type:
https://github.com/guruofquality/gras/blob/master/include/gras/sbuffer.i#L26

go numpy!

-josh



reply via email to

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