I'm trying to create a simple source block in gnuradio. I've used gr_modtool to create the bare bones module and block, but whenever I try to run the tests, it quickly eats up all my memory and my computer starts lagging. Even worse, the tests fail with "thread[thread-per-block[1]: ]: std::bad_alloc"
Here's my block (called csv):
import numpy
from gnuradio import gr
class csv(gr.sync_block):
"""
docstring for block csv
"""
def __init__(self, filename):
gr.sync_block.__init__(self, name="csv",
in_sig=None,
out_sig=[numpy.float32])
def work(self, input_items, output_items):
out = output_items[0]
out[:] = 0
return len(output_items[0])
And here's the code I'm using to test:
from gnuradio import gr, gr_unittest
from gnuradio import blocks
from csv import csv
import time
class qa_csv (gr_unittest.TestCase):
def setUp (self):
self.tb = gr.top_block ()
def tearDown (self):
self.tb = None
def test_001_t (self):
expected = [0.0]
# set up fg
c = csv(None)
sink = blocks.vector_sink_f()
self.tb.connect(c, sink)
self.tb.run()
# check data
results = sink.data()
self.assertFloatTuplesAlmostEqual(expected, results)
if __name__ == '__main__':
gr_unittest.run(qa_csv, "qa_csv.xml")
Can anyone help me figure out where I'm going wrong or point me in the right direction?