2019-12-27 23:26:45 +00:00
|
|
|
from owrx.command import Option
|
|
|
|
from .direct import DirectSource
|
2019-12-31 15:20:36 +00:00
|
|
|
from subprocess import Popen
|
|
|
|
|
|
|
|
import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
2019-12-21 19:58:28 +00:00
|
|
|
|
|
|
|
|
2019-12-27 23:26:45 +00:00
|
|
|
class FifiSdrSource(DirectSource):
|
2019-12-31 18:14:05 +00:00
|
|
|
def getCommandMapper(self):
|
|
|
|
return super().getCommandMapper().setBase("arecord").setMappings(
|
2019-12-28 00:24:07 +00:00
|
|
|
{"device": Option("-D"), "samp_rate": Option("-r")}
|
2020-03-26 08:45:41 +00:00
|
|
|
).setStatic("-t raw -f S16_LE -c2 -")
|
2019-12-27 23:26:45 +00:00
|
|
|
|
|
|
|
def getEventNames(self):
|
2019-12-28 00:24:07 +00:00
|
|
|
return super().getEventNames() + ["device"]
|
2019-12-21 19:58:28 +00:00
|
|
|
|
|
|
|
def getFormatConversion(self):
|
2020-06-07 20:53:31 +00:00
|
|
|
return ["csdr convert_s16_f", "csdr gain_ff 5"]
|
2019-12-31 15:20:36 +00:00
|
|
|
|
|
|
|
def sendRockProgFrequency(self, frequency):
|
2020-06-07 20:53:31 +00:00
|
|
|
process = Popen(["rockprog", "--vco", "-w", "--freq={}".format(frequency / 1E6)])
|
2019-12-31 15:20:36 +00:00
|
|
|
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)
|