add direct sampling option, ref #37

This commit is contained in:
Jakob Ketterl 2020-01-10 20:50:56 +01:00
parent b7538dcdd0
commit 5a57648eec
2 changed files with 15 additions and 3 deletions

View File

@ -54,13 +54,18 @@ class Flag(CommandMapping):
class Option(CommandMapping): class Option(CommandMapping):
def __init__(self, option): def __init__(self, option):
self.option = option self.option = option
self.spacer = " "
def map(self, value): def map(self, value):
if value is not None: if value is not None:
if isinstance(value, str) and " " in value: if isinstance(value, str) and " " in value:
template = '{0} "{1}"' template = '{option}{spacer}"{value}"'
else: else:
template = "{0} {1}" template = "{option}{spacer}{value}"
return template.format(self.option, value) return template.format(option=self.option, spacer=self.spacer, value=value)
else: else:
return "" return ""
def setSpacer(self, spacer):
self.spacer = spacer
return self

View File

@ -1,6 +1,13 @@
from .soapy import SoapyConnectorSource from .soapy import SoapyConnectorSource
from owrx.command import Option
class RtlSdrSoapySource(SoapyConnectorSource): class RtlSdrSoapySource(SoapyConnectorSource):
def getCommandMapper(self):
return super().getCommandMapper().setMappings({"direct_sampling": Option("-t direct_samp").setSpacer("=")})
def getDriver(self): def getDriver(self):
return "rtlsdr" return "rtlsdr"
def getEventNames(self):
return super().getEventNames() + ["direct_sampling"]