|
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 |
Does anyone know how do I get back a numpy array from pmt whiletype(r) --> <type 'numpy.ndarray'>type(p) --> <class 'pmt.pmt_swig.swig_int_ptr'>type(n) --> <type 'numpy.ndarray'>p = pmt.to_pmt(n)n = np.array([1,2,3,4,5], dtype=uint8)I am trying to use message passing in gnuradio maint branch, 3.7.11.1Hello, Happy New Year !(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):r = pmt.to_python(p)printing the types of a, p, and r yield the expected...However when in gnuradiocreate 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'>running under gnuradio?Why does this work in a command line console, but not in gnuradio?-- Tom, N5EG
[Prev in Thread] | Current Thread | [Next in Thread] |