Python block, itemsize mismatch

Hi,

I get the following error connecting ‘OFDM Serializer’ (GNU Radio block
with complex output), to my own Python block ‘blsd_dec_bfb’ (with
complex input)

“ValueError: itemsize mismatch: ofdm_serializer_vcc0:0 using 8,
blsd_dec_bfb0:0 using 16”

This is the code in the beginning of my block

“class blsd_dec_bfb(gr.basic_block):
“””
docstring for block blsd_dec_bfb
“”"
def init(self, num_packets=1, K=50, K2=20, kA1=4, NA1=8,
num_carriers=64):
gr.basic_block.init(self,
name=“blsd_dec_bfb”,
in_sig=[numpy.complex],
out_sig=[numpy.uint8,numpy.uint8,numpy.uint8])"

the xml is

"…
in
complex

bA1 byte bA2 byte b2 byte ..."

The colours match in the GRC, and it lets me run it (i.e. no complaints
about type mismatch before run-time).

I hope it is just a silly mistake. Can anyone help?

Regards,

David


NOTE: The information in this email and any attachments may be
confidential and/or legally privileged. This message may be read, copied
and used only by the intended recipient. If you are not the intended
recipient, please destroy this message, delete any copies held on your
system and notify the sender immediately.

Toshiba Research Europe Limited, registered in England and Wales
(2519556). Registered Office 208 Cambridge Science Park, Milton Road,
Cambridge CB4 0GZ, England. Web: www.toshiba.eu/research/trl

On 03/10/2014 06:57 PM, David Halls wrote:

“class blsd_dec_bfb(gr.basic_block):
“””
docstring for block blsd_dec_bfb
“”"
def init(self, num_packets=1, K=50, K2=20, kA1=4, NA1=8,
num_carriers=64):
gr.basic_block.init(self,
name=“blsd_dec_bfb”,
in_sig=[numpy.complex],
out_sig=[numpy.uint8,numpy.uint8,numpy.uint8])"

I think you need to do numpy.complex64 – not 100%, can you please tell
us if this worked.

M

On Tue, Mar 11, 2014 at 5:29 AM, Martin B.
[email protected]wrote:

This is the code in the beginning of my block
out_sig=[numpy.uint8,numpy.uint8,numpy.uint8])"

I think you need to do numpy.complex64 – not 100%, can you please tell
us if this worked.

M

The colours match in the GRC, and it lets me run it (i.e. no complaints
about type mismatch before run-time).

The “float” and “gr_complex” data type in c++ usually match with
“numpy.float32” and “numpy.complex64” in python.
The “int” in c++ matches “numpy.int32” in python.
So far I haven’t encountered any exception.

c++ python

On 03/11/2014 02:06 AM, David Halls wrote:

You’re a genius! It works.

Interestingly for a float it requires numpy.float32 or a similar error
occurs.

Yes, in GNU Radio we consistently use 32-bit floats. A complex value
consists of two of these, hence the 64 bits.

Note that this is just for buffers. A lot of blocks use double
internally (i.e. 64-bit float, or 128-bit complex) for accuracy reason.
However, for signals, it’s just a waste of bandwidth (most of time, SNR
will trump quantization noise anyway).

M

You’re a genius! It works.

Interestingly for a float it requires numpy.float32 or a similar error
occurs.

D


From: discuss-gnuradio-bounces+david.halls=removed_email_address@domain.invalid
[discuss-gnuradio-bounces+david.halls=removed_email_address@domain.invalid] on
behalf of Martin B. [[email protected]]
Sent: 10 March 2014 21:29
To: [email protected]
Subject: Re: [Discuss-gnuradio] Python block, itemsize mismatch

On 03/10/2014 06:57 PM, David Halls wrote:

“class blsd_dec_bfb(gr.basic_block):
“””
docstring for block blsd_dec_bfb
“”"
def init(self, num_packets=1, K=50, K2=20, kA1=4, NA1=8,
num_carriers=64):
gr.basic_block.init(self,
name=“blsd_dec_bfb”,
in_sig=[numpy.complex],
out_sig=[numpy.uint8,numpy.uint8,numpy.uint8])"

I think you need to do numpy.complex64 – not 100%, can you please tell
us if this worked.

M

about type mismatch before run-time). confidential and/or legally privileged. This message may be read, copied ------------------------------------------------------------------------

Discuss-gnuradio mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnuradio


NOTE: The information in this email and any attachments may be
confidential and/or legally privileged. This message may be read, copied
and used only by the intended recipient. If you are not the intended
recipient, please destroy this message, delete any copies held on your
system and notify the sender immediately.

Toshiba Research Europe Limited, registered in England and Wales
(2519556). Registered Office 208 Cambridge Science Park, Milton Road,
Cambridge CB4 0GZ, England. Web: www.toshiba.eu/research/trl