pass antenna parameter only if set

This commit is contained in:
Jakob Ketterl 2019-05-19 13:36:05 +02:00
parent eb758685a1
commit 92abef7172

View File

@ -92,9 +92,13 @@ class SdrSource(object):
self.process = None self.process = None
self.modificationLock = threading.Lock() self.modificationLock = threading.Lock()
# override these in subclasses as necessary # override this in subclasses
self.command = None def getCommand(self):
self.format_conversion = None pass
# override this in subclasses, if necessary
def getFormatConversion(self):
return None
def activateProfile(self, id = None): def activateProfile(self, id = None):
profiles = self.props["profiles"] profiles = self.props["profiles"]
@ -127,12 +131,13 @@ class SdrSource(object):
props = self.rtlProps props = self.rtlProps
start_sdr_command = self.command.format( start_sdr_command = self.getCommand().format(
**props.collect("samp_rate", "center_freq", "ppm", "rf_gain", "lna_gain", "rf_amp", "antenna").__dict__() **props.collect("samp_rate", "center_freq", "ppm", "rf_gain", "lna_gain", "rf_amp", "antenna").__dict__()
) )
if self.format_conversion is not None: format_conversion = self.getFormatConversion()
start_sdr_command += " | " + self.format_conversion if format_conversion is not None:
start_sdr_command += " | " + format_conversion
nmux_bufcnt = nmux_bufsize = 0 nmux_bufcnt = nmux_bufsize = 0
while nmux_bufsize < props["samp_rate"]/4: nmux_bufsize += 4096 while nmux_bufsize < props["samp_rate"]/4: nmux_bufsize += 4096
@ -224,22 +229,26 @@ class SdrSource(object):
class RtlSdrSource(SdrSource): class RtlSdrSource(SdrSource):
def __init__(self, props, port): def getCommand(self):
super().__init__(props, port) return "rtl_sdr -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -"
self.command = "rtl_sdr -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -"
self.format_conversion = "csdr convert_u8_f" def getFormatConversion(self):
return "csdr convert_u8_f"
class HackrfSource(SdrSource): class HackrfSource(SdrSource):
def __init__(self, props, port): def getCommand(self):
super().__init__(props, port) return "hackrf_transfer -s {samp_rate} -f {center_freq} -g {rf_gain} -l{lna_gain} -a{rf_amp} -r-"
self.command = "hackrf_transfer -s {samp_rate} -f {center_freq} -g {rf_gain} -l{lna_gain} -a{rf_amp} -r-"
self.format_conversion = "csdr convert_s8_f" def getFormatConversion(self):
return "csdr convert_s8_f"
class SdrplaySource(SdrSource): class SdrplaySource(SdrSource):
def __init__(self, props, port): def getCommand(self):
super().__init__(props, port) command = "rx_sdr -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain}"
self.command = "rx_sdr -F CF32 -s {samp_rate} -f {center_freq} -p {ppm} -g {rf_gain} -a \"{antenna}\" -" if self.rtlProps["antenna"] is not None:
self.format_conversion = None command += " -a \"{antenna}\""
command += " -"
return command
def sleepOnRestart(self): def sleepOnRestart(self):
time.sleep(1) time.sleep(1)