use automatic ports unless explicitly configured

This commit is contained in:
Jakob Ketterl
2019-12-31 15:24:11 +01:00
parent 42789ed561
commit 70347d1ef9
10 changed files with 21 additions and 37 deletions

View File

@ -1,6 +1,5 @@
from owrx.config import PropertyManager
from owrx.feature import FeatureDetector, UnknownFeatureException
import sys
import logging
@ -12,18 +11,6 @@ class SdrService(object):
sources = {}
lastPort = None
@staticmethod
def getNextPort():
pm = PropertyManager.getSharedInstance()
(start, end) = pm["iq_port_range"]
if SdrService.lastPort is None:
SdrService.lastPort = start
else:
SdrService.lastPort += 1
if SdrService.lastPort > end:
raise IndexError("no more available ports to start more sdrs")
return SdrService.lastPort
@staticmethod
def loadProps():
if SdrService.sdrProps is None:
@ -90,5 +77,5 @@ class SdrService(object):
className = "".join(x for x in sdrType.title() if x.isalnum()) + "Source"
module = __import__("owrx.source.{0}".format(sdrType), fromlist=[className])
cls = getattr(module, className)
SdrService.sources[id] = cls(id, props, SdrService.getNextPort())
SdrService.sources[id] = cls(id, props)
return {key: s for key, s in SdrService.sources.items() if not s.isFailed()}