Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test coverage for pretuning and fix support for pretuning with no… #878

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 17 additions & 21 deletions gamutrf/grscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ def __init__(
self.wavelearner = wavelearner
self.iqtlabs = iqtlabs
self.samp_rate = samp_rate
self.retune_pre_fft = None
self.retune_pre_fft = blocks.stream_to_vector(
gr.sizeof_gr_complex, fft_batch_size * nfft
)

##################################################
# Blocks
Expand Down Expand Up @@ -305,26 +307,8 @@ def get_offload_fft_block(
tuning_ranges,
pretune,
):
if pretune:
self.retune_pre_fft = self.iqtlabs.retune_pre_fft(
nfft,
fft_batch_size,
"rx_freq",
int(freq_start),
int(freq_end),
tune_step_hz,
tune_step_fft,
skip_tune_step,
tuning_ranges,
)
stream_to_vector = self.retune_pre_fft
else:
stream_to_vector = blocks.stream_to_vector(
gr.sizeof_gr_complex, fft_batch_size * nfft
)

offload_blocks = [
stream_to_vector,
self.retune_pre_fft,
blocks.multiply_const_vff(
[val for val in self.get_window(nfft) for _ in range(2)]
* fft_batch_size
Expand All @@ -351,6 +335,18 @@ def get_fft_blocks(
tuning_ranges,
pretune,
):
if pretune:
self.retune_pre_fft = self.iqtlabs.retune_pre_fft(
nfft,
fft_batch_size,
"rx_freq",
int(freq_start),
int(freq_end),
tune_step_hz,
tune_step_fft,
skip_tune_step,
tuning_ranges,
)
fft_blocks = []
if dc_block_len:
fft_blocks.append(grfilter.dc_blocker_cc(dc_block_len, dc_block_long))
Expand Down Expand Up @@ -380,7 +376,7 @@ def get_fft_blocks(
else:
fft_blocks.extend(
[
blocks.stream_to_vector(gr.sizeof_gr_complex, nfft),
self.retune_pre_fft,
fft.fft_vcc(nfft, True, self.get_window(nfft), True, 1),
]
)
Expand Down
17 changes: 8 additions & 9 deletions tests/test_grscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_get_source_smoke(self):
for sdr in ("ettus", "bladerf"):
self.assertRaises(RuntimeError, get_source, sdr, 1e3, 10)

def run_grscan_smoke(self, wavelearner, write_samples):
def run_grscan_smoke(self, pretune, wavelearner, write_samples):
with tempfile.TemporaryDirectory() as tempdir:
tb = grscan(
sdr="tuneable_test_source",
Expand All @@ -106,9 +106,11 @@ def run_grscan_smoke(self, wavelearner, write_samples):
wavelearner=wavelearner,
rotate_secs=900,
db_clamp_floor=-1e6,
pretune=pretune,
fft_batch_size=1,
)
tb.start()
time.sleep(10)
time.sleep(3)
tb.stop()
tb.wait()
del tb
Expand All @@ -118,13 +120,10 @@ def run_grscan_smoke(self, wavelearner, write_samples):
self.assertTrue([x for x in glob.glob(f"{tempdir}/*/*sigmf-meta")])

def test_grscan_smoke(self):
for wavelearner, write_samples in (
(None, 0),
(None, 1),
(FakeWaveLearner(), 0),
(FakeWaveLearner(), 1),
):
self.run_grscan_smoke(wavelearner, write_samples)
for pretune in (True, False):
for wavelearner in (FakeWaveLearner(), None):
for write_samples in (0, 1):
self.run_grscan_smoke(pretune, wavelearner, write_samples)


if __name__ == "__main__": # pragma: no cover
Expand Down
Loading