aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2016-09-14 11:12:29 -0600
committerSylvain Munaut <tnt@246tNt.com>2016-09-14 11:12:29 -0600
commit5b5ee37ce8090667431e780aad3b3bd1c3b34bbd (patch)
tree3c7d5db26ab038a781ba56a8ab830874c97c0eb6
parentb8bf70a333b6b8fe1052b642939d6c161db95a57 (diff)
rx_lband fix
-rwxr-xr-xutils/gmr1_rx_lband.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/utils/gmr1_rx_lband.py b/utils/gmr1_rx_lband.py
index e6a1f0b..38a3619 100755
--- a/utils/gmr1_rx_lband.py
+++ b/utils/gmr1_rx_lband.py
@@ -14,6 +14,7 @@ if sys.platform.startswith('linux'):
import argparse
import math
+import sys
from distutils.version import StrictVersion
try:
@@ -260,9 +261,14 @@ class top_block(gr.top_block):
self.source = osmosdr.source(args=args)
self.source.set_sample_rate(samp_rate)
self.source.set_center_freq(center_freq, 0)
- self.source.set_gain(gain, 0)
self.source.set_freq_corr(corr, 0)
+ if type(gain) in (float, int):
+ self.source.set_gain(gain, 0)
+ elif type(gain) == list:
+ for g in gain:
+ self.source.set_gain(g[1], g[0], 0)
+
if bw:
self.source.set_bandwidth(bw)
@@ -288,9 +294,9 @@ class top_block(gr.top_block):
# Outputs
if len(arfcns) > 10:
- self._init_direct(arfcns)
- else:
self._init_pfb(arfcns)
+ else:
+ self._init_direct(arfcns)
def _init_direct(self, arfcns):
# Find config for all branches
@@ -328,8 +334,7 @@ class top_block(gr.top_block):
new_center_freq = self._arfcn_to_freq(arfcn_center)
if abs(new_center_freq - self.center_freq) > 200:
- # FIXME: Check this
- rotation = 2 * math.pi * (self.center_freq - new_center_freq) / self.samp_rate
+ rotation = - 2 * math.pi * (self.center_freq - new_center_freq) / self.samp_rate
else:
rotation = 0
@@ -461,8 +466,9 @@ if __name__ == '__main__':
"-g", "--gain",
dest="gain",
metavar="GAIN",
- default=20.0,
- type=float,
+ type=str,
+ default=[],
+ action="append",
help="Set gain to the osmosdr source"
)
parser.add_argument(
@@ -504,6 +510,18 @@ if __name__ == '__main__':
)
args = parser.parse_args()
+ # Pre-process gain
+ try:
+ if (len(args.gain) == 1) and (':' not in args.gain[0]):
+ gain = float(args.gain[0])
+ elif len(args.gain) > 0:
+ gain = [ ( g.split(':')[0], float(g.split(':')[1]) ) for g in args.gain ]
+ else:
+ gain = None
+ except:
+ print "Invalid gain settings"
+ sys.exit(-1)
+
# Check if UI is enabled
if not args.ui:
UI = False
@@ -524,7 +542,7 @@ if __name__ == '__main__':
samp_rate = args.samp_rate,
center_freq = args.center_freq,
args = args.args,
- gain = args.gain,
+ gain = gain,
corr = args.corr,
bw = args.bw,
arfcns = args.arfcns,