From a9b99fa0ffd777616427f54c24674ddc58237278 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 17 Nov 2019 20:52:16 +0100 Subject: [PATCH] introduce connector source for sdrplay --- owrx/feature.py | 3 ++- owrx/source.py | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/owrx/feature.py b/owrx/feature.py index f18aef9..985a2cd 100644 --- a/owrx/feature.py +++ b/owrx/feature.py @@ -20,8 +20,9 @@ class FeatureDetector(object): features = { "core": ["csdr", "nmux", "nc"], "rtl_sdr": ["rtl_sdr"], - "rtl_sdr_socket": ["owrx_connector"], + "rtl_sdr_connector": ["owrx_connector"], "sdrplay": ["rx_tools"], + "sdrplay_connector": ["owrx_connector"], "hackrf": ["hackrf_transfer"], "airspy": ["airspy_rx"], "digital_voice_digiham": ["digiham", "sox"], diff --git a/owrx/source.py b/owrx/source.py index 3e6f48c..73aa960 100644 --- a/owrx/source.py +++ b/owrx/source.py @@ -199,9 +199,7 @@ class SdrSource(object): props = self.rtlProps cmd = self.getCommand().format( - **props.collect( - "samp_rate", "center_freq", "ppm", "rf_gain", "lna_gain", "rf_amp", "antenna", "if_gain" - ).__dict__() + **props.collect(*self.getEventNames()).__dict__() ) format_conversion = self.getFormatConversion() @@ -439,15 +437,12 @@ class Resampler(SdrSource): pass -class RtlSdrSocketSource(SdrSource): +class ConnectorSource(SdrSource): def __init__(self, id, props, port): super().__init__(id, props, port) self.controlSocket = None self.controlPort = getAvailablePort() - def getEventNames(self): - return ["samp_rate", "center_freq", "ppm", "rf_gain"] - def wireEvents(self): def reconfigure(prop, value): if self.monitor is None: @@ -468,9 +463,6 @@ class RtlSdrSocketSource(SdrSource): self.controlSocket.close() self.controlSocket = None - def getCommand(self): - return "rtl_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + " -s {samp_rate} -f {center_freq} -g {rf_gain} -P {ppm}" - def getFormatConversion(self): return None @@ -478,6 +470,22 @@ class RtlSdrSocketSource(SdrSource): return False +class RtlSdrConnectorSource(ConnectorSource): + def getEventNames(self): + return ["samp_rate", "center_freq", "ppm", "rf_gain"] + + def getCommand(self): + return "rtl_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + " -s {samp_rate} -f {center_freq} -g {rf_gain} -P {ppm}" + + +class SdrplayConnectorSource(ConnectorSource): + def getEventNames(self): + return ["samp_rate", "center_freq", "ppm", "rf_gain", "antenna", "device"] + + def getCommand(self): + return "soapy_connector -p {port} -c {controlPort}".format(port=self.port, controlPort=self.controlPort) + " -s {samp_rate} -f {center_freq} -g \"{rf_gain}\" -P {ppm} -a \"{antenna}\" -d \"{device}\"" + + class RtlSdrSource(SdrSource): def getCommand(self): return "rtl_sdr -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -"