# Consuming block of data in python block

**URL:** <https://www.ruby-forum.com/t/consuming-block-of-data-in-python-block/225763>\
**Category:** GNU Radio\
**Created:** [January 29, 2013, 2:41am UTC](https://www.ruby-forum.com/t/consuming-block-of-data-in-python-block/225763 "2013-01-29T02:41:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSkonishi\_takurou\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@SSkonishi\_takurou\_S](https://www.ruby-forum.com/u/SSkonishi_takurou_S)\
**Post date:** [January 29, 2013, 2:41am UTC](https://www.ruby-forum.com/t/consuming-block-of-data-in-python-block/225763/1 "2013-01-29T02:41:52Z")

</div>

Hi list,

I’m trying to implement my first GNURadio block in python.

I followed the how\_to\_square\_ff tutorial.

In that block, each input generates an output. Now what I want is to  
change  
this behavior so that the how\_to\_square\_ff receives a block of data (512  
for  
example) and output only a single value (I know it is strange, but is  
only  
for learning purpose).

How I declare this in my block ?  
Now the declaration is as follow:

```
gr.sync_block. __init__ (
    self,
    name = "my_block",
    in_sig = [numpy.float32], # Input signature: 1 float at a time 

```

(want  
512)  
out\_sig = [numpy.float32], # Output signature: 1 float at a time  
)

Thanks

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/Consuming-block-of-data-in-python-block-tp39244.html](http://gnuradio.4.n7.nabble.com/Consuming-block-of-data-in-python-block-tp39244.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![maiconkist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@maiconkist](https://www.ruby-forum.com/u/maiconkist)\
**Post date:** [January 29, 2013, 9:04am UTC](https://www.ruby-forum.com/t/consuming-block-of-data-in-python-block/225763/2 "2013-01-29T09:04:30Z")

</div>

On Tue, Jan 29, 2013 at 02:00:15PM +0800, Sreeraj Rajendran wrote:

> ```
> out_sig=[numpy.float32])
> 
> ```
> 
> Also go through fixed/arbitrary ratio blocks in [2] for implementing blocks  
> with different rate.

$ gr\_modtool -t decimator -l python BLOCKNAME

will take you there.

M

–  
Karlsruhe Institute of Technology (KIT)  
Communications Engineering Lab (CEL)

Dipl.-Ing. Martin B.  
Research Associate

Kaiserstraße 12  
Building 05.01  
76131 Karlsruhe

Phone: +49 721 608-43790  
Fax: +49 721 608-46071  
www.cel.kit.edu

KIT – University of the State of Baden-Württemberg and  
National Laboratory of the Helmholtz Association

---

<div class="post-metadata">

**Author:** ![maiconkist](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7bcc69/32.png) [@maiconkist](https://www.ruby-forum.com/u/maiconkist)\
**Post date:** [January 29, 2013, 7:01am UTC](https://www.ruby-forum.com/t/consuming-block-of-data-in-python-block/225763/3 "2013-01-29T07:01:15Z")

</div>

As Josh explained in [1] input can be anything that you can represent as  
a numpy data type.

Try using something like

gr.block. **init** (self, name=“my block”,

in\_sig=[numpy.dtype((numpy.float32,2))],

out\_sig=[numpy.float32])

Also go through fixed/arbitrary ratio blocks in [2] for implementing  
blocks with different rate.

[1][Vector inputs/outputs with GRExtras block interface - GNU Radio - Ruby-Forum](http://www.ruby-forum.com/topic/4407846)  
[2][Blocks Coding Guide · guruofquality/grextras Wiki · GitHub](https://github.com/guruofquality/grextras/wiki/Blocks-Coding-Guide)

-Sreeraj

* * *

From: maiconkist [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: removed\_email\_address@domain.invalid  
Sent: Tuesday, 29 January 2013 7:10 AM  
Subject: [Discuss-gnuradio] Consuming block of data in python block

Hi list,

I’m trying to implement my first GNURadio block in python.

I followed the how\_to\_square\_ff tutorial.

In that block, each input generates an output. Now what I want is to  
change  
this behavior so that the how\_to\_square\_ff receives a block of data (512  
for  
example) and output only a single value (I know it is strange, but is  
only  
for learning purpose).

How I declare this in my block ?  
Now the declaration is as follow:

gr.sync\_block. **init** (  
self,  
name = “my\_block”,  
in\_sig = [numpy.float32], # Input signature: 1 float at a time (want  
512)  
out\_sig = [numpy.float32], # Output signature: 1 float at a time  
)

Thanks

–  
View this message in context:  
[http://gnuradio.4.n7.nabble.com/Consuming-block-of-data-in-python-block-tp39244.html](http://gnuradio.4.n7.nabble.com/Consuming-block-of-data-in-python-block-tp39244.html)  
Sent from the GnuRadio mailing list archive at [Nabble.com](http://Nabble.com).
