Hopefully fix broken RTL support.
This commit is contained in:
parent
b3021720d6
commit
df35c92fe2
@ -33,6 +33,7 @@ import zmq
|
|||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import fractions
|
||||||
|
|
||||||
class modes_radio (gr.top_block, pubsub):
|
class modes_radio (gr.top_block, pubsub):
|
||||||
def __init__(self, options, context):
|
def __init__(self, options, context):
|
||||||
@ -44,6 +45,8 @@ class modes_radio (gr.top_block, pubsub):
|
|||||||
|
|
||||||
self._resample = None
|
self._resample = None
|
||||||
self._setup_source(options)
|
self._setup_source(options)
|
||||||
|
if self._resample is not None:
|
||||||
|
self._rate = 4.0e6 #fixed rate we resample to in RTL case
|
||||||
|
|
||||||
self._rx_path = air_modes.rx_path(self._rate, options.threshold,
|
self._rx_path = air_modes.rx_path(self._rate, options.threshold,
|
||||||
self._queue, options.pmf, options.dcblock)
|
self._queue, options.pmf, options.dcblock)
|
||||||
@ -81,7 +84,7 @@ class modes_radio (gr.top_block, pubsub):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def add_radio_options(parser):
|
def add_radio_options(parser):
|
||||||
group = OptionGroup(parser, "Receiver setup options")
|
group = OptionGroup(parser, "Receiver setup options")
|
||||||
|
|
||||||
#Choose source
|
#Choose source
|
||||||
group.add_option("-s","--source", type="string", default="uhd",
|
group.add_option("-s","--source", type="string", default="uhd",
|
||||||
help="Choose source: uhd, osmocom, <filename>, or <ip:port> [default=%default]")
|
help="Choose source: uhd, osmocom, <filename>, or <ip:port> [default=%default]")
|
||||||
@ -172,13 +175,14 @@ class modes_radio (gr.top_block, pubsub):
|
|||||||
self._u.set_gain(options.gain)
|
self._u.set_gain(options.gain)
|
||||||
print "Gain is %i" % self._u.get_gain()
|
print "Gain is %i" % self._u.get_gain()
|
||||||
|
|
||||||
#TODO: detect if you're using an RTLSDR or Jawbreaker
|
|
||||||
#and set up accordingly.
|
|
||||||
elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker
|
elif options.source == "osmocom": #RTLSDR dongle or HackRF Jawbreaker
|
||||||
import osmosdr
|
import osmosdr
|
||||||
self._u = osmosdr.source(options.args)
|
self._u = osmosdr.source(options.args)
|
||||||
# self._u.set_sample_rate(3.2e6) #fixed for RTL dongles
|
rates = self._u.get_sample_rates()
|
||||||
|
|
||||||
self._u.set_sample_rate(options.rate)
|
self._u.set_sample_rate(options.rate)
|
||||||
|
actual_rate = int(self._u.get_sample_rate())
|
||||||
|
|
||||||
if not self._u.set_center_freq(options.freq):
|
if not self._u.set_center_freq(options.freq):
|
||||||
print "Failed to set initial frequency"
|
print "Failed to set initial frequency"
|
||||||
|
|
||||||
@ -188,9 +192,14 @@ class modes_radio (gr.top_block, pubsub):
|
|||||||
self._u.set_gain(options.gain)
|
self._u.set_gain(options.gain)
|
||||||
print "Gain is %i" % self._u.get_gain()
|
print "Gain is %i" % self._u.get_gain()
|
||||||
|
|
||||||
#Note: this should only come into play if using an RTLSDR.
|
if actual_rate < 4.0e6:
|
||||||
# lpfiltcoeffs = gr.firdes.low_pass(1, 5*3.2e6, 1.6e6, 300e3)
|
gcd = fractions.gcd(4.0e6, actual_rate)
|
||||||
# self._resample = filter.rational_resampler_ccf(interpolation=5, decimation=4, taps=lpfiltcoeffs)
|
interp = 4.0e6 / gcd
|
||||||
|
decim = actual_rate / gcd
|
||||||
|
lpfiltcoeffs = filter.firdes.low_pass(1, interp*actual_rate, 1.6e6, 300e3)
|
||||||
|
self._resample = filter.rational_resampler_ccf(interpolation=interp,
|
||||||
|
decimation=decim,
|
||||||
|
taps=lpfiltcoeffs)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
#semantically detect whether it's ip.ip.ip.ip:port or filename
|
#semantically detect whether it's ip.ip.ip.ip:port or filename
|
||||||
@ -205,7 +214,7 @@ class modes_radio (gr.top_block, pubsub):
|
|||||||
self._u = blocks.file_source(gr.sizeof_gr_complex, options.source)
|
self._u = blocks.file_source(gr.sizeof_gr_complex, options.source)
|
||||||
print "Using file source %s" % options.source
|
print "Using file source %s" % options.source
|
||||||
|
|
||||||
print "Rate is %i" % (options.rate,)
|
print "Rate is %i" % actual_rate
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
self._sender.close()
|
self._sender.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user