From 406d06fef2ace46f57640b68d5464d52de2234cd Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Tue, 31 Dec 2019 16:20:36 +0100 Subject: [PATCH] add rockprog interface --- owrx/source/__init__.py | 14 ++++++++++++++ owrx/source/fifi_sdr.py | 23 ++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/owrx/source/__init__.py b/owrx/source/__init__.py index 7b26444..0fb6c91 100644 --- a/owrx/source/__init__.py +++ b/owrx/source/__init__.py @@ -125,6 +125,11 @@ class SdrSource(ABC): if self.monitor: return + try: + self.preStart() + except Exception: + logger.exception("Exception during preStart()") + cmd = self.getCommand() cmd = [c for c in cmd if c is not None] @@ -176,7 +181,16 @@ class SdrSource(ABC): self.setState(SdrSource.STATE_FAILED if self.failed else SdrSource.STATE_RUNNING) + def preStart(self): + """ + override this method in subclasses if there's anything to be done before starting up the actual SDR + """ + pass + def postStart(self): + """ + override this method in subclasses if there's things to do after the actual SDR has started up + """ pass def isAvailable(self): diff --git a/owrx/source/fifi_sdr.py b/owrx/source/fifi_sdr.py index 64517a9..99548b4 100644 --- a/owrx/source/fifi_sdr.py +++ b/owrx/source/fifi_sdr.py @@ -1,5 +1,10 @@ from owrx.command import Option from .direct import DirectSource +from subprocess import Popen + +import logging + +logger = logging.getLogger(__name__) class FifiSdrSource(DirectSource): @@ -13,4 +18,20 @@ class FifiSdrSource(DirectSource): return super().getEventNames() + ["device"] def getFormatConversion(self): - return ["csdr convert_s16_f", "csdr gain_ff 30"] \ No newline at end of file + return ["csdr convert_s16_f", "csdr gain_ff 30"] + + def sendRockProgFrequency(self, frequency): + process = Popen(["echo", "--vco", "-w", "--", "freq={}".format(frequency / 1E6)]) + process.communicate() + rc = process.wait() + if rc != 0: + logger.warning("rockprog failed to set frequency; rc=%i", rc) + + def preStart(self): + values = self.getCommandValues() + self.sendRockProgFrequency(values["tuner_freq"]) + + def onPropertyChange(self, name, value): + if name != "center_freq": + return + self.sendRockProgFrequency(value)