2019-05-13 17:19:15 +00:00
|
|
|
import subprocess
|
|
|
|
from functools import reduce
|
2020-09-20 17:30:18 +00:00
|
|
|
from operator import and_
|
2019-06-15 11:29:59 +00:00
|
|
|
import re
|
|
|
|
from distutils.version import LooseVersion
|
2019-07-05 20:31:46 +00:00
|
|
|
import inspect
|
2021-02-11 18:31:44 +00:00
|
|
|
from owrx.config.core import CoreConfig
|
2021-05-31 18:41:37 +00:00
|
|
|
from owrx.config import Config
|
2019-11-14 21:13:02 +00:00
|
|
|
import shlex
|
2020-09-20 10:41:11 +00:00
|
|
|
import os
|
2020-10-10 20:08:35 +00:00
|
|
|
from datetime import datetime, timedelta
|
2019-05-12 13:56:18 +00:00
|
|
|
|
|
|
|
import logging
|
2019-07-21 17:40:28 +00:00
|
|
|
|
2019-05-12 13:56:18 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
class UnknownFeatureException(Exception):
|
|
|
|
pass
|
|
|
|
|
2019-07-05 20:31:46 +00:00
|
|
|
|
2020-10-10 20:08:35 +00:00
|
|
|
class FeatureCache(object):
|
|
|
|
sharedInstance = None
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def getSharedInstance():
|
|
|
|
if FeatureCache.sharedInstance is None:
|
|
|
|
FeatureCache.sharedInstance = FeatureCache()
|
|
|
|
return FeatureCache.sharedInstance
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
self.cache = {}
|
|
|
|
self.cachetime = timedelta(hours=2)
|
|
|
|
|
|
|
|
def has(self, feature):
|
|
|
|
if feature not in self.cache:
|
|
|
|
return False
|
|
|
|
now = datetime.now()
|
|
|
|
if self.cache[feature]["valid_to"] < now:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
def get(self, feature):
|
|
|
|
return self.cache[feature]["value"]
|
|
|
|
|
|
|
|
def set(self, feature, value):
|
|
|
|
valid_to = datetime.now() + self.cachetime
|
|
|
|
self.cache[feature] = {"value": value, "valid_to": valid_to}
|
|
|
|
|
|
|
|
|
2019-05-12 13:56:18 +00:00
|
|
|
class FeatureDetector(object):
|
|
|
|
features = {
|
2019-12-21 18:24:14 +00:00
|
|
|
# core features; we won't start without these
|
2019-07-21 17:40:28 +00:00
|
|
|
"core": ["csdr", "nmux", "nc"],
|
2019-12-21 18:24:14 +00:00
|
|
|
# different types of sdrs and their requirements
|
|
|
|
"rtl_sdr": ["rtl_connector"],
|
2020-01-10 19:43:28 +00:00
|
|
|
"rtl_sdr_soapy": ["soapy_connector", "soapy_rtl_sdr"],
|
2020-08-16 19:49:52 +00:00
|
|
|
"rtl_tcp": ["rtl_tcp_connector"],
|
2019-12-27 10:37:12 +00:00
|
|
|
"sdrplay": ["soapy_connector", "soapy_sdrplay"],
|
2020-05-30 20:58:31 +00:00
|
|
|
"hackrf": ["soapy_connector", "soapy_hackrf"],
|
2020-03-15 16:24:36 +00:00
|
|
|
"perseussdr": ["perseustest"],
|
2019-12-27 10:37:12 +00:00
|
|
|
"airspy": ["soapy_connector", "soapy_airspy"],
|
|
|
|
"airspyhf": ["soapy_connector", "soapy_airspyhf"],
|
2020-01-10 18:54:53 +00:00
|
|
|
"lime_sdr": ["soapy_connector", "soapy_lime_sdr"],
|
2020-05-14 19:40:28 +00:00
|
|
|
"fifi_sdr": ["alsa", "rockprog"],
|
2020-01-15 21:44:11 +00:00
|
|
|
"pluto_sdr": ["soapy_connector", "soapy_pluto_sdr"],
|
2020-02-09 12:59:37 +00:00
|
|
|
"soapy_remote": ["soapy_connector", "soapy_remote"],
|
2020-04-10 14:33:04 +00:00
|
|
|
"uhd": ["soapy_connector", "soapy_uhd"],
|
2020-05-09 22:03:14 +00:00
|
|
|
"radioberry": ["soapy_connector", "soapy_radioberry"],
|
2020-07-09 13:39:33 +00:00
|
|
|
"fcdpp": ["soapy_connector", "soapy_fcdpp"],
|
2020-11-27 17:49:33 +00:00
|
|
|
"sddc": ["sddc_connector"],
|
2020-11-02 12:11:54 +00:00
|
|
|
"hpsdr": ["hpsdr_connector"],
|
2021-02-03 02:21:09 +00:00
|
|
|
"runds": ["runds_connector"],
|
2019-12-21 18:24:14 +00:00
|
|
|
# optional features and their requirements
|
2021-05-31 18:41:37 +00:00
|
|
|
"digital_voice_digiham": ["digiham", "sox", "codecserver_ambe"],
|
2020-07-27 22:28:20 +00:00
|
|
|
"digital_voice_freedv": ["freedv_rx", "sox"],
|
2021-04-19 23:07:06 +00:00
|
|
|
"digital_voice_m17": ["m17_demod", "sox", "digiham"],
|
2019-07-21 17:40:28 +00:00
|
|
|
"wsjt-x": ["wsjtx", "sox"],
|
2021-01-09 18:19:53 +00:00
|
|
|
"wsjt-x-2-3": ["wsjtx_2_3", "sox"],
|
2021-02-03 18:33:02 +00:00
|
|
|
"wsjt-x-2-4": ["wsjtx_2_4", "sox"],
|
2019-12-01 14:42:50 +00:00
|
|
|
"packet": ["direwolf", "sox"],
|
2020-01-06 21:08:17 +00:00
|
|
|
"pocsag": ["digiham", "sox"],
|
2020-04-12 11:10:23 +00:00
|
|
|
"js8call": ["js8", "sox"],
|
2020-09-04 18:27:12 +00:00
|
|
|
"drm": ["dream", "sox"],
|
2019-05-12 13:56:18 +00:00
|
|
|
}
|
|
|
|
|
2019-05-13 17:19:15 +00:00
|
|
|
def feature_availability(self):
|
|
|
|
return {name: self.is_available(name) for name in FeatureDetector.features}
|
|
|
|
|
2019-07-05 17:30:24 +00:00
|
|
|
def feature_report(self):
|
2019-07-05 20:31:46 +00:00
|
|
|
def requirement_details(name):
|
|
|
|
available = self.has_requirement(name)
|
|
|
|
return {
|
|
|
|
"available": available,
|
|
|
|
# as of now, features are always enabled as soon as they are available. this may change in the future.
|
|
|
|
"enabled": available,
|
2019-07-21 17:40:28 +00:00
|
|
|
"description": self.get_requirement_description(name),
|
2019-07-05 20:31:46 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 17:30:24 +00:00
|
|
|
def feature_details(name):
|
2019-07-05 20:31:46 +00:00
|
|
|
return {
|
|
|
|
"available": self.is_available(name),
|
2019-07-21 17:40:28 +00:00
|
|
|
"requirements": {name: requirement_details(name) for name in self.get_requirements(name)},
|
2019-07-05 20:31:46 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 17:30:24 +00:00
|
|
|
return {name: feature_details(name) for name in FeatureDetector.features}
|
|
|
|
|
2019-05-12 13:56:18 +00:00
|
|
|
def is_available(self, feature):
|
2020-10-10 21:00:05 +00:00
|
|
|
return self.has_requirements(self.get_requirements(feature))
|
2019-05-12 13:56:18 +00:00
|
|
|
|
|
|
|
def get_requirements(self, feature):
|
|
|
|
try:
|
|
|
|
return FeatureDetector.features[feature]
|
|
|
|
except KeyError:
|
2019-07-21 17:40:28 +00:00
|
|
|
raise UnknownFeatureException('Feature "{0}" is not known.'.format(feature))
|
2019-05-12 13:56:18 +00:00
|
|
|
|
|
|
|
def has_requirements(self, requirements):
|
|
|
|
passed = True
|
|
|
|
for requirement in requirements:
|
2019-07-05 20:31:46 +00:00
|
|
|
passed = passed and self.has_requirement(requirement)
|
2019-05-12 13:56:18 +00:00
|
|
|
return passed
|
|
|
|
|
2019-07-05 20:31:46 +00:00
|
|
|
def _get_requirement_method(self, requirement):
|
|
|
|
methodname = "has_" + requirement
|
|
|
|
if hasattr(self, methodname) and callable(getattr(self, methodname)):
|
|
|
|
return getattr(self, methodname)
|
|
|
|
return None
|
|
|
|
|
|
|
|
def has_requirement(self, requirement):
|
2020-10-10 21:00:05 +00:00
|
|
|
cache = FeatureCache.getSharedInstance()
|
|
|
|
if cache.has(requirement):
|
|
|
|
return cache.get(requirement)
|
|
|
|
|
2019-07-05 20:31:46 +00:00
|
|
|
method = self._get_requirement_method(requirement)
|
2020-10-10 21:00:05 +00:00
|
|
|
result = False
|
2019-07-05 20:31:46 +00:00
|
|
|
if method is not None:
|
2020-10-10 21:00:05 +00:00
|
|
|
result = method()
|
2019-07-05 20:31:46 +00:00
|
|
|
else:
|
|
|
|
logger.error("detection of requirement {0} not implement. please fix in code!".format(requirement))
|
2020-10-10 21:00:05 +00:00
|
|
|
|
|
|
|
cache.set(requirement, result)
|
|
|
|
return result
|
2019-07-05 20:31:46 +00:00
|
|
|
|
|
|
|
def get_requirement_description(self, requirement):
|
|
|
|
return inspect.getdoc(self._get_requirement_method(requirement))
|
|
|
|
|
2020-09-20 10:41:11 +00:00
|
|
|
def command_is_runnable(self, command, expected_result=None):
|
2021-02-06 20:55:47 +00:00
|
|
|
tmp_dir = CoreConfig().get_temporary_directory()
|
2019-11-14 21:13:02 +00:00
|
|
|
cmd = shlex.split(command)
|
2020-09-20 10:41:11 +00:00
|
|
|
env = os.environ.copy()
|
|
|
|
# prevent X11 programs from opening windows if called from a GUI shell
|
|
|
|
env.pop("DISPLAY", None)
|
2019-11-14 21:13:02 +00:00
|
|
|
try:
|
2021-01-20 16:01:46 +00:00
|
|
|
process = subprocess.Popen(
|
|
|
|
cmd,
|
|
|
|
stdin=subprocess.DEVNULL,
|
|
|
|
stdout=subprocess.DEVNULL,
|
|
|
|
stderr=subprocess.DEVNULL,
|
|
|
|
cwd=tmp_dir,
|
|
|
|
env=env,
|
|
|
|
)
|
2020-09-20 10:41:11 +00:00
|
|
|
rc = process.wait()
|
|
|
|
if expected_result is None:
|
|
|
|
return rc != 32512
|
|
|
|
else:
|
|
|
|
return rc == expected_result
|
2019-11-14 21:13:02 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
return False
|
2019-05-13 17:19:15 +00:00
|
|
|
|
2019-05-12 13:56:18 +00:00
|
|
|
def has_csdr(self):
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
|
|
|
OpenWebRX uses the demodulator and pipeline tools provided by the csdr project. Please check out [the project
|
2020-03-29 16:33:14 +00:00
|
|
|
page on github](https://github.com/jketterl/csdr) for further details and installation instructions.
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
2020-08-26 22:08:50 +00:00
|
|
|
required_version = LooseVersion("0.17.0")
|
2020-08-26 18:07:58 +00:00
|
|
|
|
|
|
|
csdr_version_regex = re.compile("^csdr version (.*)$")
|
|
|
|
|
|
|
|
try:
|
|
|
|
process = subprocess.Popen(["csdr", "version"], stderr=subprocess.PIPE)
|
|
|
|
matches = csdr_version_regex.match(process.stderr.readline().decode())
|
|
|
|
if matches is None:
|
|
|
|
return False
|
|
|
|
version = LooseVersion(matches.group(1))
|
|
|
|
process.wait(1)
|
|
|
|
return version >= required_version
|
|
|
|
except FileNotFoundError:
|
|
|
|
return False
|
2019-05-12 13:56:18 +00:00
|
|
|
|
|
|
|
def has_nmux(self):
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
|
|
|
Nmux is another tool provided by the csdr project. It is used for internal multiplexing of the IQ data streams.
|
|
|
|
If you're missing nmux even though you have csdr installed, please update your csdr version.
|
|
|
|
"""
|
2019-05-13 17:19:15 +00:00
|
|
|
return self.command_is_runnable("nmux --help")
|
2019-05-12 13:56:18 +00:00
|
|
|
|
2019-06-04 22:08:56 +00:00
|
|
|
def has_nc(self):
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
|
|
|
Nc is the client used to connect to the nmux multiplexer. It is provided by either the BSD netcat (recommended
|
|
|
|
for better performance) or GNU netcat packages. Please check your distribution package manager for options.
|
|
|
|
"""
|
2019-07-21 17:40:28 +00:00
|
|
|
return self.command_is_runnable("nc --help")
|
2019-06-04 22:08:56 +00:00
|
|
|
|
2020-03-15 16:24:36 +00:00
|
|
|
def has_perseustest(self):
|
|
|
|
"""
|
|
|
|
To use a Microtelecom Perseus HF receiver, compile and
|
|
|
|
install the libperseus-sdr:
|
|
|
|
```
|
|
|
|
sudo apt install libusb-1.0-0-dev
|
|
|
|
cd /tmp
|
2020-03-15 23:13:51 +00:00
|
|
|
wget https://github.com/Microtelecom/libperseus-sdr/releases/download/v0.8.2/libperseus_sdr-0.8.2.tar.gz
|
|
|
|
tar -zxvf libperseus_sdr-0.8.2.tar.gz
|
|
|
|
cd libperseus_sdr-0.8.2/
|
2020-03-15 16:24:36 +00:00
|
|
|
./configure
|
|
|
|
make
|
|
|
|
sudo make install
|
|
|
|
sudo ldconfig
|
|
|
|
perseustest
|
|
|
|
```
|
|
|
|
"""
|
2020-03-15 23:13:51 +00:00
|
|
|
return self.command_is_runnable("perseustest -h")
|
2020-03-15 16:24:36 +00:00
|
|
|
|
2019-05-13 17:19:15 +00:00
|
|
|
def has_digiham(self):
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
|
|
|
To use digital voice modes, the digiham package is required. You can find the package and installation
|
|
|
|
instructions [here](https://github.com/jketterl/digiham).
|
|
|
|
|
|
|
|
Please note: there is close interaction between digiham and openwebrx, so older versions will probably not work.
|
|
|
|
If you have an older verison of digiham installed, please update it along with openwebrx.
|
2020-01-09 18:26:41 +00:00
|
|
|
As of now, we require version 0.3 of digiham.
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
2021-06-08 21:06:25 +00:00
|
|
|
required_version = LooseVersion("0.5")
|
2019-06-15 11:29:59 +00:00
|
|
|
|
2021-05-27 22:02:20 +00:00
|
|
|
digiham_version_regex = re.compile("^(.*) version (.*)$")
|
2019-07-21 17:40:28 +00:00
|
|
|
|
2019-06-15 11:29:59 +00:00
|
|
|
def check_digiham_version(command):
|
2019-05-13 17:19:15 +00:00
|
|
|
try:
|
2019-06-15 11:29:59 +00:00
|
|
|
process = subprocess.Popen([command, "--version"], stdout=subprocess.PIPE)
|
2019-11-11 17:07:14 +00:00
|
|
|
matches = digiham_version_regex.match(process.stdout.readline().decode())
|
|
|
|
if matches is None:
|
|
|
|
return False
|
2021-05-27 22:02:20 +00:00
|
|
|
version = LooseVersion(matches.group(2))
|
2019-06-15 11:29:59 +00:00
|
|
|
process.wait(1)
|
2021-05-27 22:02:20 +00:00
|
|
|
return matches.group(1) in [command, "digiham"] and version >= required_version
|
2019-05-13 17:19:15 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
return False
|
2019-07-21 17:40:28 +00:00
|
|
|
|
2019-07-13 21:16:25 +00:00
|
|
|
return reduce(
|
|
|
|
and_,
|
|
|
|
map(
|
|
|
|
check_digiham_version,
|
2019-07-21 17:40:28 +00:00
|
|
|
[
|
|
|
|
"rrc_filter",
|
|
|
|
"ysf_decoder",
|
|
|
|
"dmr_decoder",
|
|
|
|
"mbe_synthesizer",
|
|
|
|
"gfsk_demodulator",
|
|
|
|
"digitalvoice_filter",
|
2020-01-06 21:08:17 +00:00
|
|
|
"fsk_demodulator",
|
|
|
|
"pocsag_decoder",
|
2021-06-08 21:01:49 +00:00
|
|
|
"dstar_decoder",
|
2019-07-21 17:40:28 +00:00
|
|
|
],
|
2019-07-13 21:16:25 +00:00
|
|
|
),
|
2019-07-21 17:40:28 +00:00
|
|
|
True,
|
2019-07-13 21:16:25 +00:00
|
|
|
)
|
2019-05-13 17:19:15 +00:00
|
|
|
|
2021-05-17 21:57:37 +00:00
|
|
|
def _check_connector(self, command, required_version):
|
|
|
|
owrx_connector_version_regex = re.compile("^{} version (.*)$".format(re.escape(command)))
|
2019-11-21 14:31:37 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
process = subprocess.Popen([command, "--version"], stdout=subprocess.PIPE)
|
|
|
|
matches = owrx_connector_version_regex.match(process.stdout.readline().decode())
|
|
|
|
if matches is None:
|
|
|
|
return False
|
|
|
|
version = LooseVersion(matches.group(1))
|
|
|
|
process.wait(1)
|
|
|
|
return version >= required_version
|
|
|
|
except FileNotFoundError:
|
|
|
|
return False
|
|
|
|
|
2021-05-17 21:57:37 +00:00
|
|
|
def _check_owrx_connector(self, command):
|
|
|
|
return self._check_connector(command, LooseVersion("0.4"))
|
|
|
|
|
2019-11-21 14:31:37 +00:00
|
|
|
def has_rtl_connector(self):
|
2019-11-11 17:07:14 +00:00
|
|
|
"""
|
|
|
|
The owrx_connector package offers direct interfacing between your hardware and openwebrx. It allows quicker
|
|
|
|
frequency switching, uses less CPU and can even provide more stability in some cases.
|
|
|
|
|
2019-12-27 10:37:12 +00:00
|
|
|
You can get it [here](https://github.com/jketterl/owrx_connector).
|
2019-11-11 17:07:14 +00:00
|
|
|
"""
|
2021-05-17 21:57:37 +00:00
|
|
|
return self._check_owrx_connector("rtl_connector")
|
2019-11-11 17:07:14 +00:00
|
|
|
|
2020-08-16 19:49:52 +00:00
|
|
|
def has_rtl_tcp_connector(self):
|
|
|
|
"""
|
|
|
|
The owrx_connector package offers direct interfacing between your hardware and openwebrx. It allows quicker
|
|
|
|
frequency switching, uses less CPU and can even provide more stability in some cases.
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/jketterl/owrx_connector).
|
|
|
|
"""
|
2021-05-17 21:57:37 +00:00
|
|
|
return self._check_owrx_connector("rtl_tcp_connector")
|
2020-08-16 19:49:52 +00:00
|
|
|
|
2019-11-21 14:31:37 +00:00
|
|
|
def has_soapy_connector(self):
|
|
|
|
"""
|
|
|
|
The owrx_connector package offers direct interfacing between your hardware and openwebrx. It allows quicker
|
|
|
|
frequency switching, uses less CPU and can even provide more stability in some cases.
|
2019-11-11 17:07:14 +00:00
|
|
|
|
2019-12-27 10:37:12 +00:00
|
|
|
You can get it [here](https://github.com/jketterl/owrx_connector).
|
2019-11-21 14:31:37 +00:00
|
|
|
"""
|
2021-05-17 21:57:37 +00:00
|
|
|
return self._check_owrx_connector("soapy_connector")
|
2019-11-11 17:07:14 +00:00
|
|
|
|
2019-12-27 10:37:12 +00:00
|
|
|
def _has_soapy_driver(self, driver):
|
2019-12-30 15:38:16 +00:00
|
|
|
try:
|
|
|
|
process = subprocess.Popen(["SoapySDRUtil", "--info"], stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
|
2020-04-11 22:53:58 +00:00
|
|
|
factory_regex = re.compile("^Available factories\\.\\.\\. ?(.*)$")
|
2019-12-28 00:24:07 +00:00
|
|
|
|
2020-04-10 14:33:04 +00:00
|
|
|
drivers = []
|
|
|
|
for line in process.stdout:
|
|
|
|
matches = factory_regex.match(line.decode())
|
|
|
|
if matches:
|
2020-04-22 16:28:45 +00:00
|
|
|
drivers = [s.strip() for s in matches.group(1).split(", ")]
|
2019-12-28 00:24:07 +00:00
|
|
|
|
2020-04-10 14:33:04 +00:00
|
|
|
return driver in drivers
|
2019-12-30 15:38:16 +00:00
|
|
|
except FileNotFoundError:
|
|
|
|
return False
|
2019-12-27 10:37:12 +00:00
|
|
|
|
2020-01-10 22:31:51 +00:00
|
|
|
def has_soapy_rtl_sdr(self):
|
2020-01-10 19:43:28 +00:00
|
|
|
"""
|
|
|
|
The SoapySDR module for rtl-sdr devices can be used as an alternative to the rtl_connector. It provides
|
|
|
|
additional support for the direct sampling mod.
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/pothosware/SoapyRTLSDR/wiki).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("rtlsdr")
|
|
|
|
|
2020-01-10 22:31:51 +00:00
|
|
|
def has_soapy_sdrplay(self):
|
2019-12-27 10:37:12 +00:00
|
|
|
"""
|
|
|
|
The SoapySDR module for sdrplay devices is required for interfacing with SDRPlay devices (RSP1*, RSP2*, RSPDuo)
|
|
|
|
|
2020-05-24 12:43:25 +00:00
|
|
|
You can get it [here](https://github.com/SDRplay/SoapySDRPlay).
|
2019-12-27 10:37:12 +00:00
|
|
|
"""
|
2020-04-10 14:33:04 +00:00
|
|
|
return self._has_soapy_driver("sdrplay")
|
2019-12-27 10:37:12 +00:00
|
|
|
|
|
|
|
def has_soapy_airspy(self):
|
|
|
|
"""
|
|
|
|
The SoapySDR module for airspy devices is required for interfacing with Airspy devices (Airspy R2, Airspy Mini).
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/pothosware/SoapyAirspy/wiki).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("airspy")
|
|
|
|
|
|
|
|
def has_soapy_airspyhf(self):
|
|
|
|
"""
|
|
|
|
The SoapySDR module for airspyhf devices is required for interfacing with Airspy HF devices (Airspy HF+,
|
|
|
|
Airspy HF discovery).
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/pothosware/SoapyAirspyHF/wiki).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("airspyhf")
|
|
|
|
|
2020-01-10 18:54:53 +00:00
|
|
|
def has_soapy_lime_sdr(self):
|
|
|
|
"""
|
|
|
|
The Lime Suite installs - amongst others - a Soapy driver for the LimeSDR device series.
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/myriadrf/LimeSuite).
|
|
|
|
"""
|
2020-04-10 14:33:04 +00:00
|
|
|
return self._has_soapy_driver("lime")
|
2020-01-10 18:54:53 +00:00
|
|
|
|
2020-01-15 21:44:11 +00:00
|
|
|
def has_soapy_pluto_sdr(self):
|
|
|
|
"""
|
|
|
|
The SoapySDR module for PlutoSDR devices is required for interfacing with PlutoSDR devices.
|
|
|
|
|
2021-07-15 10:53:48 +00:00
|
|
|
You can get it [here](https://github.com/pothosware/SoapyPlutoSDR).
|
2020-01-15 21:44:11 +00:00
|
|
|
"""
|
2020-04-10 14:33:04 +00:00
|
|
|
return self._has_soapy_driver("plutosdr")
|
2020-01-15 21:44:11 +00:00
|
|
|
|
2020-02-09 12:59:37 +00:00
|
|
|
def has_soapy_remote(self):
|
|
|
|
"""
|
|
|
|
The SoapyRemote allows the usage of remote SDR devices using the SoapySDRServer.
|
|
|
|
|
|
|
|
You can get the code and find additional information [here](https://github.com/pothosware/SoapyRemote/wiki).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("remote")
|
|
|
|
|
2020-04-10 14:33:04 +00:00
|
|
|
def has_soapy_uhd(self):
|
|
|
|
"""
|
|
|
|
The SoapyUHD module allows using UHD / USRP devices with SoapySDR.
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/pothosware/SoapyUHD/wiki).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("uhd")
|
|
|
|
|
2020-05-09 22:03:14 +00:00
|
|
|
def has_soapy_radioberry(self):
|
|
|
|
"""
|
|
|
|
The Radioberry is a SDR hat for the Raspberry Pi.
|
|
|
|
|
|
|
|
You can find more information, along with its SoapySDR module [here](https://github.com/pa3gsb/Radioberry-2.x).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("radioberry")
|
|
|
|
|
2020-05-30 20:58:31 +00:00
|
|
|
def has_soapy_hackrf(self):
|
|
|
|
"""
|
|
|
|
The SoapyHackRF allows HackRF to be used with SoapySDR.
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/pothosware/SoapyHackRF/wiki).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("hackrf")
|
|
|
|
|
2020-07-09 13:39:33 +00:00
|
|
|
def has_soapy_fcdpp(self):
|
|
|
|
"""
|
|
|
|
The SoapyFCDPP module allows the use of the Funcube Dongle Pro+.
|
|
|
|
|
|
|
|
You can get it [here](https://github.com/pothosware/SoapyFCDPP).
|
|
|
|
"""
|
|
|
|
return self._has_soapy_driver("fcdpp")
|
|
|
|
|
2020-11-23 00:00:25 +00:00
|
|
|
def has_m17_demod(self):
|
2020-12-08 15:59:49 +00:00
|
|
|
"""
|
|
|
|
The `m17-demod` tool is used to demodulate M17 digital voice signals.
|
|
|
|
|
|
|
|
You can find more information [here](https://github.com/mobilinkd/m17-cxx-demod)
|
|
|
|
"""
|
2020-11-23 00:00:25 +00:00
|
|
|
return self.command_is_runnable("m17-demod")
|
|
|
|
|
2019-05-13 17:19:15 +00:00
|
|
|
def has_sox(self):
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
|
|
|
The sox audio library is used to convert between the typical 8 kHz audio sampling rate used by digital modes and
|
|
|
|
the audio sampling rate requested by the client.
|
|
|
|
|
|
|
|
It is available for most distributions through the respective package manager.
|
|
|
|
"""
|
2019-06-07 13:11:04 +00:00
|
|
|
return self.command_is_runnable("sox")
|
|
|
|
|
|
|
|
def has_direwolf(self):
|
2019-12-27 10:37:12 +00:00
|
|
|
"""
|
|
|
|
OpenWebRX uses the [direwolf](https://github.com/wb2osz/direwolf) software modem to decode Packet Radio and
|
|
|
|
report data back to APRS-IS. Direwolf is available from the package manager on many distributions, or you can
|
|
|
|
compile it from source.
|
|
|
|
"""
|
2019-06-22 16:20:01 +00:00
|
|
|
return self.command_is_runnable("direwolf --help")
|
|
|
|
|
2019-06-07 13:44:11 +00:00
|
|
|
def has_airspy_rx(self):
|
2019-07-05 20:31:46 +00:00
|
|
|
"""
|
|
|
|
In order to use an Airspy Receiver, you need to install the airspy_rx receiver software.
|
|
|
|
"""
|
2019-11-15 18:36:07 +00:00
|
|
|
return self.command_is_runnable("airspy_rx --help")
|
2019-07-08 18:16:29 +00:00
|
|
|
|
|
|
|
def has_wsjtx(self):
|
|
|
|
"""
|
|
|
|
To decode FT8 and other digimodes, you need to install the WSJT-X software suite. Please check the
|
|
|
|
[WSJT-X homepage](https://physics.princeton.edu/pulsar/k1jt/wsjtx.html) for ready-made packages or instructions
|
|
|
|
on how to build from source.
|
|
|
|
"""
|
2019-07-21 17:40:28 +00:00
|
|
|
return reduce(and_, map(self.command_is_runnable, ["jt9", "wsprd"]), True)
|
2019-12-19 20:37:19 +00:00
|
|
|
|
2021-01-09 18:19:53 +00:00
|
|
|
def _has_wsjtx_version(self, required_version):
|
|
|
|
wsjt_version_regex = re.compile("^WSJT-X (.*)$")
|
|
|
|
|
|
|
|
try:
|
|
|
|
process = subprocess.Popen(["wsjtx_app_version", "--version"], stdout=subprocess.PIPE)
|
|
|
|
matches = wsjt_version_regex.match(process.stdout.readline().decode())
|
|
|
|
if matches is None:
|
|
|
|
return False
|
|
|
|
version = LooseVersion(matches.group(1))
|
|
|
|
process.wait(1)
|
|
|
|
return version >= required_version
|
|
|
|
except FileNotFoundError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
def has_wsjtx_2_3(self):
|
|
|
|
"""
|
|
|
|
Newer digital modes (e.g. FST4, FST4) require WSJT-X in at least version 2.3.
|
|
|
|
"""
|
|
|
|
return self.has_wsjtx() and self._has_wsjtx_version(LooseVersion("2.3"))
|
|
|
|
|
2021-02-03 18:33:02 +00:00
|
|
|
def has_wsjtx_2_4(self):
|
|
|
|
"""
|
|
|
|
WSJT-X version 2.4 introduced the Q65 mode.
|
|
|
|
"""
|
|
|
|
return self.has_wsjtx() and self._has_wsjtx_version(LooseVersion("2.4"))
|
|
|
|
|
2020-04-12 11:10:23 +00:00
|
|
|
def has_js8(self):
|
|
|
|
"""
|
|
|
|
To decode JS8, you will need to install [JS8Call](http://js8call.com/)
|
2020-05-03 10:09:36 +00:00
|
|
|
|
|
|
|
Please note that the `js8` command line decoder is not made available on $PATH by some JS8Call package builds.
|
|
|
|
You will need to manually make it available by either linking it to `/usr/bin` or by adding its location to
|
|
|
|
$PATH.
|
2020-04-12 11:10:23 +00:00
|
|
|
"""
|
|
|
|
return self.command_is_runnable("js8")
|
|
|
|
|
2019-12-19 20:37:19 +00:00
|
|
|
def has_alsa(self):
|
|
|
|
"""
|
|
|
|
Some SDR receivers are identifying themselves as a soundcard. In order to read their data, OpenWebRX relies
|
|
|
|
on the Alsa library. It is available as a package for most Linux distributions.
|
|
|
|
"""
|
|
|
|
return self.command_is_runnable("arecord --help")
|
2020-05-14 19:40:28 +00:00
|
|
|
|
|
|
|
def has_rockprog(self):
|
|
|
|
"""
|
|
|
|
The "rockprog" executable is required to send commands to your FiFiSDR. It needs to be installed separately.
|
|
|
|
|
|
|
|
You can find instructions and downloads [here](https://o28.sischa.net/fifisdr/trac/wiki/De%3Arockprog).
|
|
|
|
"""
|
|
|
|
return self.command_is_runnable("rockprog")
|
2020-07-27 22:28:20 +00:00
|
|
|
|
|
|
|
def has_freedv_rx(self):
|
2020-08-07 20:58:24 +00:00
|
|
|
"""
|
|
|
|
The "freedv\_rx" executable is required to demodulate FreeDV digital transmissions. It comes together with the
|
|
|
|
codec2 library, but it's only a supplemental part and not installed by default or contained in its packages.
|
|
|
|
To install it, you will need to compile codec2 from source and manually install freedv\_rx.
|
|
|
|
|
2020-10-16 17:52:51 +00:00
|
|
|
Detailed installation instructions are available on the
|
|
|
|
[OpenWebRX wiki](https://github.com/jketterl/openwebrx/wiki/FreeDV-demodulator-notes).
|
2020-08-07 20:58:24 +00:00
|
|
|
"""
|
2020-07-27 22:28:20 +00:00
|
|
|
return self.command_is_runnable("freedv_rx")
|
2020-09-04 16:09:02 +00:00
|
|
|
|
|
|
|
def has_dream(self):
|
2020-09-04 18:27:12 +00:00
|
|
|
"""
|
2020-10-16 17:52:51 +00:00
|
|
|
In order to be able to decode DRM broadcasts, OpenWebRX needs the "dream" DRM decoder.
|
2020-09-20 10:41:11 +00:00
|
|
|
|
2020-09-04 18:27:12 +00:00
|
|
|
The version supplied by most distributions will not work properly on the command line, so compiling from source
|
2020-10-16 17:52:51 +00:00
|
|
|
with a custom set of commands is recommended. Detailed installation instructions are available on the
|
|
|
|
[OpenWebRX wiki](https://github.com/jketterl/openwebrx/wiki/DRM-demodulator-notes).
|
2020-09-04 18:27:12 +00:00
|
|
|
"""
|
2020-09-20 10:41:11 +00:00
|
|
|
return self.command_is_runnable("dream --help", 0)
|
2020-11-02 12:11:54 +00:00
|
|
|
|
2020-11-27 17:39:10 +00:00
|
|
|
def has_sddc_connector(self):
|
2020-11-27 17:49:33 +00:00
|
|
|
"""
|
|
|
|
The sddc_connector allows connectivity with SDR devices powered by libsddc, e.g. RX666, RX888, HF103.
|
|
|
|
|
|
|
|
You can find more information [here](https://github.com/jketterl/sddc_connector).
|
|
|
|
"""
|
2021-05-17 21:57:37 +00:00
|
|
|
return self._check_connector("sddc_connector", LooseVersion("0.1"))
|
2020-11-12 22:45:39 +00:00
|
|
|
|
2020-11-02 12:11:54 +00:00
|
|
|
def has_hpsdr_connector(self):
|
|
|
|
"""
|
|
|
|
In order to use the HPSDR connector, you will need to install [hpsdrconnector]
|
|
|
|
(https://github.com/jancona/hpsdrconnector).
|
|
|
|
"""
|
|
|
|
return self.command_is_runnable("hpsdrconnector -h")
|
2020-11-29 23:34:44 +00:00
|
|
|
|
2021-02-03 02:21:09 +00:00
|
|
|
def has_runds_connector(self):
|
2020-11-29 23:34:44 +00:00
|
|
|
"""
|
2021-02-03 02:21:09 +00:00
|
|
|
To use radios supporting R&S radios via EB200 or Ammos, you need to install the runds_connector.
|
2020-11-29 23:34:44 +00:00
|
|
|
|
2021-02-03 02:21:09 +00:00
|
|
|
You can find more information [here](https://github.com/jketterl/runds_connector).
|
2020-11-29 23:34:44 +00:00
|
|
|
"""
|
2021-05-17 21:57:37 +00:00
|
|
|
return self._check_connector("runds_connector", LooseVersion("0.2"))
|
2021-05-31 18:41:37 +00:00
|
|
|
|
|
|
|
def has_codecserver_ambe(self):
|
|
|
|
tmp_dir = CoreConfig().get_temporary_directory()
|
|
|
|
cmd = ["mbe_synthesizer", "--test"]
|
|
|
|
config = Config.get()
|
|
|
|
if "digital_voice_codecserver" in config:
|
|
|
|
cmd += ["--server", config["digital_voice_codecserver"]]
|
|
|
|
try:
|
|
|
|
process = subprocess.Popen(
|
|
|
|
cmd,
|
|
|
|
stdin=subprocess.DEVNULL,
|
|
|
|
stdout=subprocess.DEVNULL,
|
|
|
|
stderr=subprocess.DEVNULL,
|
|
|
|
cwd=tmp_dir,
|
|
|
|
)
|
|
|
|
return process.wait() == 0
|
|
|
|
except FileNotFoundError:
|
|
|
|
return False
|