openwebrx-clone/owrx/source/fifi_sdr.py
Jakob Ketterl e60c332c24 arm
2019-12-31 16:24:45 +01:00

38 lines
1.1 KiB
Python

from owrx.command import Option
from .direct import DirectSource
from subprocess import Popen
import logging
logger = logging.getLogger(__name__)
class FifiSdrSource(DirectSource):
def __init__(self, id, props):
super().__init__(id, props)
self.getCommandMapper().setBase("arecord").setMappings(
{"device": Option("-D"), "samp_rate": Option("-r")}
).setStatic("-f S16_LE -c2 -")
def getEventNames(self):
return super().getEventNames() + ["device"]
def getFormatConversion(self):
return ["csdr convert_s16_f", "csdr gain_ff 30"]
def sendRockProgFrequency(self, frequency):
process = Popen(["rockprog", "--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)