fifisdr fixes
This commit is contained in:
		@@ -249,10 +249,13 @@ class SdrSource(ABC):
 | 
			
		||||
    def getPort(self):
 | 
			
		||||
        return self.port
 | 
			
		||||
 | 
			
		||||
    def _getTcpSourceFormat(self):
 | 
			
		||||
        return Format.COMPLEX_FLOAT
 | 
			
		||||
 | 
			
		||||
    def _getTcpSource(self):
 | 
			
		||||
        with self.modificationLock:
 | 
			
		||||
            if self.tcpSource is None:
 | 
			
		||||
                self.tcpSource = TcpSource(self.port, Format.COMPLEX_FLOAT)
 | 
			
		||||
                self.tcpSource = TcpSource(self.port, self._getTcpSourceFormat())
 | 
			
		||||
        return self.tcpSource
 | 
			
		||||
 | 
			
		||||
    def getBuffer(self):
 | 
			
		||||
 
 | 
			
		||||
@@ -11,6 +11,10 @@ logger = logging.getLogger(__name__)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class DirectSource(SdrSource, metaclass=ABCMeta):
 | 
			
		||||
    def __init__(self, id, props):
 | 
			
		||||
        self._conversion = None
 | 
			
		||||
        super().__init__(id, props)
 | 
			
		||||
 | 
			
		||||
    def onPropertyChange(self, changes):
 | 
			
		||||
        logger.debug("restarting sdr source due to property changes: {0}".format(changes))
 | 
			
		||||
        self.stop()
 | 
			
		||||
@@ -48,6 +52,10 @@ class DirectSource(SdrSource, metaclass=ABCMeta):
 | 
			
		||||
    def getFormatConversion(self) -> Optional[Chain]:
 | 
			
		||||
        return None
 | 
			
		||||
 | 
			
		||||
    def _getTcpSourceFormat(self):
 | 
			
		||||
        conversion = self.getFormatConversion()
 | 
			
		||||
        return Format.COMPLEX_FLOAT if conversion is None else conversion.getInputFormat()
 | 
			
		||||
 | 
			
		||||
    # override this in subclasses, if necessary
 | 
			
		||||
    def sleepOnRestart(self):
 | 
			
		||||
        pass
 | 
			
		||||
@@ -57,12 +65,12 @@ class DirectSource(SdrSource, metaclass=ABCMeta):
 | 
			
		||||
            source = self._getTcpSource()
 | 
			
		||||
            buffer = Buffer(source.getOutputFormat())
 | 
			
		||||
            source.setWriter(buffer)
 | 
			
		||||
            conversion = self.getFormatConversion()
 | 
			
		||||
            if conversion is not None:
 | 
			
		||||
                conversion.setReader(buffer.getReader())
 | 
			
		||||
            self._conversion = self.getFormatConversion()
 | 
			
		||||
            if self._conversion is not None:
 | 
			
		||||
                self._conversion.setReader(buffer.getReader())
 | 
			
		||||
                # this one must be COMPLEX_FLOAT
 | 
			
		||||
                buffer = Buffer(Format.COMPLEX_FLOAT)
 | 
			
		||||
                conversion.setWriter(buffer)
 | 
			
		||||
                self._conversion.setWriter(buffer)
 | 
			
		||||
            self.buffer = buffer
 | 
			
		||||
        return self.buffer
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,8 @@ from subprocess import Popen
 | 
			
		||||
from csdr.chain import Chain
 | 
			
		||||
from pycsdr.modules import Convert, Gain
 | 
			
		||||
from pycsdr.types import Format
 | 
			
		||||
from typing import List
 | 
			
		||||
from owrx.form.input import Input, TextInput
 | 
			
		||||
 | 
			
		||||
import logging
 | 
			
		||||
 | 
			
		||||
@@ -49,3 +51,15 @@ class FifiSdrDeviceDescription(DirectSourceDeviceDescription):
 | 
			
		||||
    def supportsPpm(self):
 | 
			
		||||
        # not currently mapped, and it's unclear how this should be sent to the device
 | 
			
		||||
        return False
 | 
			
		||||
 | 
			
		||||
    def getInputs(self) -> List[Input]:
 | 
			
		||||
        return super().getInputs() + [
 | 
			
		||||
            TextInput(
 | 
			
		||||
                "device",
 | 
			
		||||
                "Device identifier",
 | 
			
		||||
                infotext="Alsa audio device identifier",
 | 
			
		||||
            ),
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
    def getDeviceOptionalKeys(self):
 | 
			
		||||
        return super().getDeviceOptionalKeys() + ["device"]
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user