Im trying to create a program in GNU Radio that will store data from a signal into a Filesink. However, by doing that, most of the data in the filesink will consist of noise. My goal is to only store the main signal and a little bit of the noise before and after that same signal.
To accomplish that im trying to build a buffer, using the 'embedded python block', that will only store the main signal and, as mentioned above, a little bit of the noise before and after that signal (the size of the stored noise is determined by the size of the buffer).
For that i created this GNU Radio program GNU Radio Program where at the end i connected a filesink to the squelch block and a filesink to the buffer block so that i could compare both of the filesinks using a spectrum analyzer.
(Note: Im emitting a signal using a transmitter and an arduino. The arduino was programmed to send an "Hello World" message every second. I then use an SDR-Pluto to capture that signal/message).
The main problem is that after i run the program, the squelch filesink will only have 64KB, regardless of how long i leave the program running. On the other hand, the buffer filesink will store data, as time passes, however, when i inspect the buffer filesink on a spectrum analyzer, the spectrum is empty.
If anyone could help me understand what the problem is i would be extremely grateful. Here is my buffer code:
import numpy as np
from gnuradio import gr
class blk(gr.basic_block): # other base classes are basic_block, decim_block, interp_block
def __init__(self, buffer_size_param=10000.0): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.basic_block.__init__(
self,
name='Embedded Python Block (Buffer)', # will show up in GRC
in_sig=[np.complex64, np.complex64],
out_sig=[np.complex64]
)
self.buffer = []
self.buffer_size_param = buffer_size_param
self.counter = self.buffer_size_param
def general_work(self, input_items, output_items):
squelch = input_items[0]
throttle = input_items[1]
for i in range(len(squelch)):
if (squelch [i] == 0):
self.counter = self.counter + 1
if (self.counter <= buffer_size_param):
output_items.append(throttle[i])
else:
self.buffer.append(throttle [i])
if len (self.buffer) > buffer_size_param:
self.buffer.pop (0)
else:
output_items = output_items + self.buffer
output_items.append(throttle[i])
self.buffer = []
self.counter = 0
return len(output_items)