[Top][All Lists]

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

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

From: Tom McDermott
Subject: [Discuss-gnuradio] pmt.to_python behaves differently in console and in gnuradio
Date: Mon, 1 Jan 2018 13:23:28 -0800

Hello, Happy New Year !

I am trying to use message passing in gnuradio maint branch,
(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]