aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Map/epy_block_1.py
blob: d30c2eb76ed38c57bf918e77f167deb9d967ba82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Embedded Python Blocks:

Each time this file is saved, GRC will instantiate the first class it finds
to get ports and parameters of your block. The arguments to __init__  will
be the parameters. All of them are required to have default values!
"""

import numpy as np
from gnuradio import gr

np.set_printoptions(formatter={'int':hex})

class blk(gr.sync_block):
    def __init__(self):
        gr.sync_block.__init__(
            self,
            name='Printer',
            in_sig=[np.byte],
            out_sig=[]
        )

    def work(self, input_items, output_items):
        inp = np.array(input_items[0], dtype=np.uint8)
        print(f"Decoded {len(inp)} samples:\n{inp}")

        return len(inp)