diff --git a/gamutrf/grscan.py b/gamutrf/grscan.py index 49a6e4d8..bf8cd97c 100644 --- a/gamutrf/grscan.py +++ b/gamutrf/grscan.py @@ -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 @@ -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 @@ -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)) @@ -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), ] ) diff --git a/tests/test_grscan.py b/tests/test_grscan.py index 2a180db8..a102dccd 100644 --- a/tests/test_grscan.py +++ b/tests/test_grscan.py @@ -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", @@ -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 @@ -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