2021-02-20 17:09:24 +00:00
|
|
|
from owrx.source.direct import DirectSource, DirectSourceDeviceDescription
|
2021-02-24 22:54:46 +00:00
|
|
|
from owrx.command import Option, Flag
|
2021-04-29 13:17:21 +00:00
|
|
|
from owrx.form.input import Input, DropdownEnum, DropdownInput, CheckboxInput
|
2021-02-24 22:54:46 +00:00
|
|
|
from typing import List
|
2020-03-15 16:24:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
#
|
2020-03-15 23:13:51 +00:00
|
|
|
# In order to interface Perseus hardware, we resolve to use the
|
|
|
|
# perseustest utility that comes with libperseus-sdr support package.
|
|
|
|
# Below the base options used are shown:
|
|
|
|
#
|
|
|
|
# -p output I/Q samples as 32 bits floating point
|
|
|
|
# -d -1 suppress debug messages
|
|
|
|
# -a don't test attenuators on startup
|
|
|
|
# -t 0 runs indefinitely
|
|
|
|
# -o - output samples on stdout
|
|
|
|
#
|
|
|
|
# As we are already returning I/Q samples as pairs of 32 bits
|
|
|
|
# floating points (option -p),no need for further conversions,
|
|
|
|
# so the method getFormatConversion(self) is not implemented at all.
|
2020-03-15 16:24:36 +00:00
|
|
|
|
2021-01-20 16:01:46 +00:00
|
|
|
|
2020-03-15 16:24:36 +00:00
|
|
|
class PerseussdrSource(DirectSource):
|
|
|
|
def getCommandMapper(self):
|
2021-01-20 16:01:46 +00:00
|
|
|
return (
|
|
|
|
super()
|
|
|
|
.getCommandMapper()
|
|
|
|
.setBase("perseustest -p -d -1 -a -t 0 -o - ")
|
|
|
|
.setMappings(
|
|
|
|
{
|
|
|
|
"samp_rate": Option("-s"),
|
|
|
|
"tuner_freq": Option("-f"),
|
|
|
|
"attenuator": Option("-u"),
|
2021-02-24 22:54:46 +00:00
|
|
|
"adc_preamp": Flag("-m"),
|
|
|
|
"adc_dither": Flag("-x"),
|
|
|
|
"wideband": Flag("-w"),
|
2021-01-20 16:01:46 +00:00
|
|
|
}
|
|
|
|
)
|
2020-03-15 23:13:51 +00:00
|
|
|
)
|
2021-02-20 17:09:24 +00:00
|
|
|
|
|
|
|
|
2021-02-24 22:54:46 +00:00
|
|
|
class AttenuatorOptions(DropdownEnum):
|
|
|
|
ATTENUATOR_0 = 0
|
|
|
|
ATTENUATOR_10 = -10
|
|
|
|
ATTENUATOR_20 = -20
|
|
|
|
ATTENUATOR_30 = -30
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return "{value} dB".format(value=self.value)
|
|
|
|
|
|
|
|
|
2021-02-20 17:09:24 +00:00
|
|
|
class PerseussdrDeviceDescription(DirectSourceDeviceDescription):
|
2021-04-17 15:42:08 +00:00
|
|
|
def getName(self):
|
|
|
|
return "Perseus SDR"
|
|
|
|
|
2021-02-24 22:54:46 +00:00
|
|
|
def getInputs(self) -> List[Input]:
|
|
|
|
return super().getInputs() + [
|
|
|
|
DropdownInput("attenuator", "Attenuator", options=AttenuatorOptions),
|
|
|
|
CheckboxInput("adc_preamp", "Activate ADC preamp"),
|
|
|
|
CheckboxInput("adc_dither", "Enable ADC dithering"),
|
|
|
|
CheckboxInput("wideband", "Disable analog filters"),
|
|
|
|
]
|
|
|
|
|
2021-03-24 22:17:50 +00:00
|
|
|
def getDeviceOptionalKeys(self):
|
2021-02-24 22:54:46 +00:00
|
|
|
# no rf_gain
|
2021-03-24 22:17:50 +00:00
|
|
|
return [key for key in super().getDeviceOptionalKeys() if key != "rf_gain"] + [
|
2021-02-24 22:54:46 +00:00
|
|
|
"attenuator",
|
|
|
|
"adc_preamp",
|
|
|
|
"adc_dither",
|
|
|
|
"wideband",
|
|
|
|
]
|
|
|
|
|
|
|
|
def getProfileOptionalKeys(self):
|
|
|
|
return [key for key in super().getProfileOptionalKeys() if key != "rf_gain"] + [
|
|
|
|
"attenuator",
|
|
|
|
"adc_preamp",
|
|
|
|
"adc_dither",
|
|
|
|
"wideband",
|
|
|
|
]
|