Added ability to supply device arguments as parameter to applications.
Change adressing #140 enhancement request.
It is possible to select rtl-sdr dongle:
-with device index through commanline parameter: `--args="rtl=1"` (where 1 is the device index). Caution: device index is not unique identifier and it changes on each connection of the dongle.
-with devices serial number, the commandline option in this case has following form: `--args="rtl=00000001"` (where 00000001 is the serial number).
NOTE: You can set the serial number with use of:
```sh
rtl_eeprom -s <serial_number>
```
diff --git a/apps/grgsm_livemon b/apps/grgsm_livemon
index 9c5e8a9..7bf4ee3 100755
--- a/apps/grgsm_livemon
+++ b/apps/grgsm_livemon
@@ -35,7 +35,7 @@
class grgsm_livemon(gr.top_block, Qt.QWidget):
- def __init__(self, fc=939.4e6, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3):
+ def __init__(self, fc=939.4e6, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3, args=""):
gr.top_block.__init__(self, "Gr-gsm Livemon")
Qt.QWidget.__init__(self)
self.setWindowTitle("Gr-gsm Livemon")
@@ -86,7 +86,7 @@
self._fc_slider_range = Range(925e6, 1990e6, 2e5, fc, 100)
self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, "Frequency", "counter_slider", float)
self.top_layout.addWidget(self._fc_slider_win)
- self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" )
+ self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + args )
self.rtlsdr_source_0.set_sample_rate(samp_rate)
self.rtlsdr_source_0.set_center_freq(fc_slider-shiftoff, 0)
self.rtlsdr_source_0.set_freq_corr(ppm_slider, 0)
@@ -260,13 +260,16 @@
help="Set samp_rate [default=%default]")
parser.add_option("-o", "--shiftoff", dest="shiftoff", type="eng_float", default=eng_notation.num_to_str(400e3),
help="Set shiftoff [default=%default]")
+ parser.add_option("", "--args", dest="args", type="string", default="",
+ help="Set device arguments [default=%default]")
+
(options, args) = parser.parse_args()
# from distutils.version import StrictVersion
# if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"):
# Qt.QApplication.setGraphicsSystem(gr.prefs().get_string('qtgui','style','raster'))
Qt.QApplication.setGraphicsSystem(gr.prefs().get_string('qtgui','style','raster'))
qapp = Qt.QApplication(sys.argv)
- tb = grgsm_livemon(fc=options.fc, gain=options.gain, ppm=options.ppm, samp_rate=options.samp_rate, shiftoff=options.shiftoff)
+ tb = grgsm_livemon(fc=options.fc, gain=options.gain, ppm=options.ppm, samp_rate=options.samp_rate, shiftoff=options.shiftoff, args=options.args)
tb.start()
tb.show()