import json import pathlib import gnuradio.gr import numpy class MessageGeneratorBlock(gnuradio.gr.basic_block): def __init__(self): gnuradio.gr.basic_block.__init__( self, name="Message Generator", in_sig=None, out_sig=[numpy.uint8] ) # __file__ is not available self._messages = json.loads( pathlib.Path().resolve().parent.joinpath("messages.json").read_text() ) def general_work(self, input_items, output_items) -> int: # pylint: disable=unused-argument message = self._messages["ON0"] + [0] * 128 if len(output_items[0]) < len(message): print("output buffer too short", len(output_items[0])) output_items[0][:] = 0 return len(output_items[0]) output_items[0][: len(message)] = message return len(message)