From 6f1177772404a04d86dd7ffe5b713778978235c4 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Sun, 21 Sep 2014 19:03:16 -0700 Subject: [PATCH] Fix rate setting for devices with <4Msps rates (RTL). --- python/radio.py | 19 +++++++++++++++++-- python/rx_path.py | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/python/radio.py b/python/radio.py index 0842d10..0268b33 100644 --- a/python/radio.py +++ b/python/radio.py @@ -27,6 +27,7 @@ from gnuradio import gr, gru, eng_notation, filter, blocks from gnuradio.filter import optfir from gnuradio.eng_option import eng_option from gnuradio.gr.pubsub import pubsub +from gnuradio.filter import pfb from optparse import OptionParser, OptionGroup import air_modes import zmq @@ -45,9 +46,16 @@ class modes_radio (gr.top_block, pubsub): self._resample = None self._setup_source(options) - self._rx_path = air_modes.rx_path(self._rate, options.threshold, + if self._rate < 4e6: + self._resample = pfb.arb_resampler_ccf(4.e6/self._rate) + self._rx_rate = 4e6 + else: + self._rx_rate = self._rate + + self._rx_path = air_modes.rx_path(self._rx_rate, options.threshold, self._queue, options.pmf, options.dcblock) + #now subscribe to set various options via pubsub self.subscribe("freq", self.set_freq) self.subscribe("gain", self.set_gain) @@ -125,7 +133,14 @@ class modes_radio (gr.top_block, pubsub): return self.get_gain() def set_rate(self, rate): - self._rx_path.set_rate(rate) + if(rate < 4e6 and self._rate > 4e6): + raise NotImplementedError("Lowering rate <4e6Msps not currently supported.") + if(rate < 4e6): + self._resample.set_rate(4e6/rate) + self._rx_rate = 4e6 + else: + self._rx_rate = rate + self._rx_path.set_rate(self._rx_rate) return self._u.set_rate(rate) if self.live_source() else 0 def set_threshold(self, threshold): diff --git a/python/rx_path.py b/python/rx_path.py index 36350c2..f948b97 100644 --- a/python/rx_path.py +++ b/python/rx_path.py @@ -37,7 +37,7 @@ class rx_path(gr.hier_block2): # Convert incoming I/Q baseband to amplitude self._demod = blocks.complex_to_mag_squared() if use_dcblock: - self._dcblock = filter.dc_blocker_cc(100*self._spc,True) + self._dcblock = filter.dc_blocker_cc(100*self._spc,False) self.connect(self, self._dcblock, self._demod) else: self.connect(self, self._demod)