openwebrx-clone/owrx/source/fifi_sdr.py

45 lines
1.3 KiB
Python
Raw Permalink Normal View History

2019-12-27 23:26:45 +00:00
from owrx.command import Option
2021-02-20 17:09:24 +00:00
from owrx.source.direct import DirectSource, DirectSourceDeviceDescription
2019-12-31 15:20:36 +00:00
from subprocess import Popen
import logging
logger = logging.getLogger(__name__)
2019-12-27 23:26:45 +00:00
class FifiSdrSource(DirectSource):
2019-12-31 18:14:05 +00:00
def getCommandMapper(self):
2021-01-20 16:01:46 +00:00
return (
super()
.getCommandMapper()
.setBase("arecord")
.setMappings({"device": Option("-D"), "samp_rate": Option("-r")})
.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"]
def getFormatConversion(self):
2021-07-06 19:42:29 +00:00
return ["csdr++ convert -i s16 -o float", "csdr++ gain 5"]
2019-12-31 15:20:36 +00:00
def sendRockProgFrequency(self, frequency):
2021-01-20 16:01:46 +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"])
2020-12-30 16:18:46 +00:00
def onPropertyChange(self, changes):
if "center_freq" in changes:
self.sendRockProgFrequency(changes["center_freq"])
2021-02-20 17:09:24 +00:00
class FifiSdrDeviceDescription(DirectSourceDeviceDescription):
def getName(self):
return "FiFi SDR"