From 55559086ac9b2845733c6e9743087ba30e75b1ba Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Thu, 8 Aug 2013 22:15:24 -0700 Subject: [PATCH] Small Osmosdr fixes. Still unsatisfactory w/HackRF Jawbreaker. DC block unhelpful. --- apps/modes_gui | 17 ++++++++++------- python/radio.py | 10 +++++----- python/rx_path.py | 5 +++-- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/apps/modes_gui b/apps/modes_gui index e03f38d..01f9a28 100755 --- a/apps/modes_gui +++ b/apps/modes_gui @@ -59,7 +59,8 @@ class mainwindow(QtGui.QMainWindow): if defaults["pmf"] is not None: self.ui.check_pmf.setChecked(bool(defaults["pmf"])) if defaults["samplerate"] is not None: - self.ui.combo_rate.setCurrentIndex(self.rates.index(int(defaults["samplerate"]))) + if defaults["samplerate"] in self.rates: + self.ui.combo_rate.setCurrentIndex(self.rates.index(int(defaults["samplerate"]))) self.ui.prog_rssi.setMinimum(0) self.ui.prog_rssi.setMaximum(40) @@ -140,6 +141,7 @@ class mainwindow(QtGui.QMainWindow): #hook up parameter-changed signals so we can change gain, rate, etc. while running self.ui.combo_rate.currentIndexChanged['QString'].connect(self.update_sample_rate) self.ui.line_gain.editingFinished.connect(self.update_gain) + self.ui.combo_source.currentIndexChanged['QString'].connect(self.populate_source_options) #hook up live data text box update signal self.live_data_changed_signal.connect(self.on_append_live_data) @@ -228,7 +230,7 @@ class mainwindow(QtGui.QMainWindow): elif sourceid == "Osmocom": try: import osmosdr - self.src = osmosdr.source_c("") + self.src = osmosdr.source("") self.rates = [rate.start() for rate in self.src.get_sample_rates() if (rate.start() % 2.e6) == 0] self.antennas = ["RX"] self.src = None @@ -258,11 +260,12 @@ class mainwindow(QtGui.QMainWindow): self.ui.combo_ant.addItems(self.antennas) #set up recommended sample rate - recommended_rate = min(x for x in self.rates if x >= 4e6 and - max(self.rates) % x == 0) - if recommended_rate >= 8.e6: - self.ui.check_pmf.setChecked(True) - self.ui.combo_rate.setCurrentIndex(self.rates.index(recommended_rate)) + if len(self.rates) > 1: + recommended_rate = min(x for x in self.rates if x >= 4e6 and + max(self.rates) % x == 0) + if recommended_rate >= 8.e6: + self.ui.check_pmf.setChecked(True) + self.ui.combo_rate.setCurrentIndex(self.rates.index(recommended_rate)) ################ action handlers #################### def on_combo_source_currentIndexChanged(self, index): diff --git a/python/radio.py b/python/radio.py index d0d5f66..d8a77e1 100644 --- a/python/radio.py +++ b/python/radio.py @@ -102,7 +102,7 @@ class modes_radio (gr.top_block, pubsub): #RX path args group.add_option("-r", "--rate", type="eng_float", default=4e6, help="set sample rate [default=%default]") - group.add_option("-T", "--threshold", type="eng_float", default=5.0, + group.add_option("-T", "--threshold", type="eng_float", default=7.0, help="set pulse detection threshold above noise in dB [default=%default]") group.add_option("-p","--pmf", action="store_true", default=False, help="Use pulse matched filtering [default=%default]") @@ -119,7 +119,6 @@ class modes_radio (gr.top_block, pubsub): if self.live_source(): self._u.set_gain(gain) print "Gain is %f" % self.get_gain() - return self.get_gain() def set_rate(self, rate): @@ -131,7 +130,7 @@ class modes_radio (gr.top_block, pubsub): def get_freq(self, freq): return self._u.get_center_freq(freq, 0) if self.live_source() else 1090e6 - + def get_gain(self): return self._u.get_gain() if self.live_source() else 0 @@ -176,7 +175,7 @@ class modes_radio (gr.top_block, pubsub): #osmocom doesn't have gain bucket distribution like UHD does elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker import osmosdr - self._u = osmosdr.source_c(options.args) + self._u = osmosdr.source(options.args) # self._u.set_sample_rate(3.2e6) #fixed for RTL dongles self._u.set_sample_rate(options.rate) if not self._u.set_center_freq(options.freq): @@ -188,7 +187,7 @@ class modes_radio (gr.top_block, pubsub): ###DO NOT COMMIT self._u.set_gain(14, "RF", 0) self._u.set_gain(40, "IF", 0) - #self._u.set_gain(14, "BB", 0) + self._u.set_gain(6, "BB", 0) ###DO NOT COMMIT # self._u.set_gain(options.gain) print "Gain is %i" % self._u.get_gain() @@ -214,3 +213,4 @@ class modes_radio (gr.top_block, pubsub): def close(self): self._sender.close() + self._u = None diff --git a/python/rx_path.py b/python/rx_path.py index e778d04..e148f4e 100644 --- a/python/rx_path.py +++ b/python/rx_path.py @@ -19,7 +19,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr, blocks +from gnuradio import gr, blocks, filter import air_modes_swig class rx_path(gr.hier_block2): @@ -36,6 +36,7 @@ class rx_path(gr.hier_block2): # Convert incoming I/Q baseband to amplitude self._demod = blocks.complex_to_mag_squared() +# self._dcblock = filter.dc_blocker_ff(128, False) self._bb = self._demod # Pulse matched filter for 0.5us pulses @@ -54,7 +55,7 @@ class rx_path(gr.hier_block2): self._slicer = air_modes_swig.slicer(self._queue) # Wire up the flowgraph - self.connect(self, self._demod) + self.connect(self, self._demod)#, self._dcblock) self.connect(self._bb, (self._sync, 0)) self.connect(self._bb, self._avg, (self._sync, 1)) self.connect(self._sync, self._slicer)