discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] pmt.to_python behaves differently in console and


From: Tom McDermott
Subject: Re: [Discuss-gnuradio] pmt.to_python behaves differently in console and in gnuradio
Date: Mon, 1 Jan 2018 16:41:50 -0800

Nevermind.    Problem was in my code creating the np.array over on the send
side.  Sorry to waste the bandwidth.

-- Tom, N5EG





On Mon, Jan 1, 2018 at 1:23 PM, Tom McDermott <address@hidden> wrote:

Hello, Happy New Year !

I am trying to use message passing in gnuradio maint branch, 3.7.11.1
(python 2.7 based)

When just bringing up a command line window, starting python 2.7,
importing gnuradio, numpy and pmt,
the behavior I get (which agrees with the documentation):

n = np.array([1,2,3,4,5], dtype=uint8)
p = pmt.to_pmt(n)
r = pmt.to_python(p)

printing the types of a, p, and r yield the expected...

type(n) -->  <type 'numpy.ndarray'>
type(p) --> <class 'pmt.pmt_swig.swig_int_ptr'>
type(r) -->  <type 'numpy.ndarray'>



However when in gnuradio
create and pass the pmt via the message port,
I get a string type after converting to python:


    def handle_rxmsg(self, msg):
        dat = pmt.to_python(msg)  # dat is an np.array[9] of type np.uint8
        print "Type of msg: ", type(msg)
        print "Type of dat: ", type(dat)


This prints on the gnuradio console:

Type of msg:  <class 'pmt.pmt_swig.swig_int_ptr'>
Type of dat:  <type 'str'>


Does anyone know how do I get back a numpy array from pmt while
running under gnuradio?

Why does this work in a command line console, but not in gnuradio?


-- Tom, N5EG





reply via email to

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