[Top][All Lists]

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

The head block doesn't terminate the flowgraph execution with connection

From: Marcin Puchlik
Subject: The head block doesn't terminate the flowgraph execution with connection with modulator
Date: Fri, 13 Aug 2021 13:28:44 +0200

I encountered a problem when blocks.head() object doesn't terminate flowgraph execution when I used digital.generic_mod() object inside the same flowgraph. The problem was also described here: https://dsp.stackexchange.com/questions/75371/gnu-radio-head-block-doesnt-finish-simulation?noredirect=1#comment160051_75371. Is there any reason that those blocks are not compatible with themselves? I encountered the same issue while writing the code from the scratch:

from gnuradio import gr
from gnuradio import blocks
from gnuradio import analog
from gnuradio import digital
import numpy as np
import matplotlib.pyplot as plt

class transmitter_base(gr.hier_block2):
    def __init__(self, samples_count):
        # constructor my class
        # call constructor for parent class
        gr.hier_block2.__init__(self, name="transmitter_base", input_signature=gr.io_signature(0,0,0), output_signature=gr.io_signature(1,1,gr.sizeof_gr_complex))
        # Create random bits generator for modulator input - output of the random generator should by unsigned char
        self.bits_generator = analog.random_uniform_source_b(0, 256, np.random.randint(low = -2_147_483_647, high = 2_147_483_647)) # return and int from range [0, 256)
        self.limiter = blocks.head(gr.sizeof_gr_complex, samples_count)
        # self.connect(self.src, self.head, self) Note: connect in derived class
class bpsk_transmitter(transmitter_base):
    def __init__(self,samples_count, sps, alpha):
        transmitter_base.__init__(self, samples_count)
        # Here declare blocks that based on bit sequence generate BPSK waveform
        # self.mod = digital.generic_mod()
        self.mod = digital.generic_mod(digital.constellation_bpsk(), False, sps, False, alpha, True, False, False)
        self.connect(self.bits_generator,self.mod, self.limiter, self)
def main():
    my_bpsk_modulator = bpsk_transmitter(1000, 8, 0.35)
    sink = blocks.vector_sink_c()
    tb = gr.top_block()
    tb.connect(my_bpsk_modulator, sink)
    raw_output_vector = np.array(sink.data(), dtype=np.complex64)
if  __name__ == '__main__':

Kind regards,

Marcin Puchlik

reply via email to

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