Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- Embedded Python Block:
- 27.01.22
- """
- import numpy
- from gnuradio import gr
- class general_test(gr.basic_block):
- # Ordinary init function, with two variables and one input/output
- def __init__(self, buffer_len=512, out_items= 128):
- gr.basic_block.__init__(self,
- name="general_test",
- in_sig=[numpy.complex64],
- out_sig=[numpy.complex64])
- self.buffer_len = buffer_len
- self.out_items = out_items
- def general_work(self, input_items, output_items):
- # Firstly check, if input_items has a sufficient amount of items
- # and if output is large enough to hold an amount of items equal to out_items
- if len(input_items[0]) >= self.buffer_len and (len(output_items[0])) >= self.out_items:
- # Only output a fraction of input, say the first self.out_items, on output port[0]
- output_items[0][:self.out_items] = input_items[0][:self.out_items]
- # Then consume exactly self.buffer_len items
- self.consume_each(self.buffer_len)
- # return the length, that we want to return of output_items[0]
- return self.out_items
- else:
- # if we do not have enough input_items, tell the scheduler that we produced nothing
- return 0
Advertisement
Add Comment
Please, Sign In to add comment