From 5a57648eeccebe0c2dd5ac8288ad96d5e80318cc Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Fri, 10 Jan 2020 20:50:56 +0100 Subject: [PATCH] add direct sampling option, ref #37 --- owrx/command.py | 11 ++++++++--- owrx/source/rtl_sdr_soapy.py | 7 +++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/owrx/command.py b/owrx/command.py index 21d60d1..9cf0327 100644 --- a/owrx/command.py +++ b/owrx/command.py @@ -54,13 +54,18 @@ class Flag(CommandMapping): class Option(CommandMapping): def __init__(self, option): self.option = option + self.spacer = " " def map(self, value): if value is not None: if isinstance(value, str) and " " in value: - template = '{0} "{1}"' + template = '{option}{spacer}"{value}"' else: - template = "{0} {1}" - return template.format(self.option, value) + template = "{option}{spacer}{value}" + return template.format(option=self.option, spacer=self.spacer, value=value) else: return "" + + def setSpacer(self, spacer): + self.spacer = spacer + return self diff --git a/owrx/source/rtl_sdr_soapy.py b/owrx/source/rtl_sdr_soapy.py index 2606683..24fe9f4 100644 --- a/owrx/source/rtl_sdr_soapy.py +++ b/owrx/source/rtl_sdr_soapy.py @@ -1,6 +1,13 @@ from .soapy import SoapyConnectorSource +from owrx.command import Option class RtlSdrSoapySource(SoapyConnectorSource): + def getCommandMapper(self): + return super().getCommandMapper().setMappings({"direct_sampling": Option("-t direct_samp").setSpacer("=")}) + def getDriver(self): return "rtlsdr" + + def getEventNames(self): + return super().getEventNames() + ["direct_sampling"]