[Top][All Lists]

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

the out_items of python block?

From: ????????
Subject: the out_items of python block?
Date: Wed, 23 Jun 2021 11:32:38 +0800

I am now learning to use embedded python blocks, and I want to make the simplest output source. The flowchart is in the attachment ??and Below is my code:

import numpy as np
from gnuradio import gr
from gnuradio.gr.runtime_swig import random
class blk(gr.sync_block):  # other base classes are basic_block, decim_block, interp_block
    """Embedded Python Block example - a simple multiply const"""
    def __init__(self):  # only default arguments here
        """arguments to this function show up as parameters in GRC"""
            name='random limit source',   # will show up in GRC
            in_sig = None,
            out_sig = [np.float32]
        # if an attribute with the same name as a parameter is found,
        # a callback is registered (properties work, too).
    def work(self, input_items, output_items):
        """example: multiply with constant"""
        for i in range(10) :
            output_items[0][i] = 0.5
        return len(output_items[0])

when I run my flow graph, the effect looks different from what the program shows. According to the program, it should output 10 "test" characters, but in fact there are more than 10 "test" characters. I want to know why is that?
Is it because I didn't assign values to items after out_items[0][10], which caused the program to keep running in a loop?
If so, how can I prevent it from looping like this?
In addition, I would like to know how the abscissa of the time domain diagram is determined with respect to the duration of each point?


Attachment: test_source.pdf
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]