mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-15 12:51:49 -05:00
Device user arguments: use it in SoapySDR
This commit is contained in:
parent
ea1b3e90b4
commit
8ce43225ae
@ -15,6 +15,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
#include "devicesoapysdr.h"
|
#include "devicesoapysdr.h"
|
||||||
|
|
||||||
DeviceSoapySDR::DeviceSoapySDR()
|
DeviceSoapySDR::DeviceSoapySDR()
|
||||||
@ -31,10 +32,10 @@ DeviceSoapySDR& DeviceSoapySDR::instance()
|
|||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoapySDR::Device *DeviceSoapySDR::openSoapySDR(uint32_t sequence)
|
SoapySDR::Device *DeviceSoapySDR::openSoapySDR(uint32_t sequence, const QString& hardwareUserArguments)
|
||||||
{
|
{
|
||||||
instance();
|
instance();
|
||||||
return openopenSoapySDRFromSequence(sequence);
|
return openopenSoapySDRFromSequence(sequence, hardwareUserArguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceSoapySDR::closeSoapySdr(SoapySDR::Device *device)
|
void DeviceSoapySDR::closeSoapySdr(SoapySDR::Device *device)
|
||||||
@ -42,7 +43,7 @@ void DeviceSoapySDR::closeSoapySdr(SoapySDR::Device *device)
|
|||||||
SoapySDR::Device::unmake(device);
|
SoapySDR::Device::unmake(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
SoapySDR::Device *DeviceSoapySDR::openopenSoapySDRFromSequence(uint32_t sequence)
|
SoapySDR::Device *DeviceSoapySDR::openopenSoapySDRFromSequence(uint32_t sequence, const QString& hardwareUserArguments)
|
||||||
{
|
{
|
||||||
if (sequence > m_scanner.getNbDevices())
|
if (sequence > m_scanner.getNbDevices())
|
||||||
{
|
{
|
||||||
@ -57,10 +58,30 @@ SoapySDR::Device *DeviceSoapySDR::openopenSoapySDRFromSequence(uint32_t sequence
|
|||||||
SoapySDR::Kwargs kwargs;
|
SoapySDR::Kwargs kwargs;
|
||||||
kwargs["driver"] = deviceEnum.m_driverName.toStdString();
|
kwargs["driver"] = deviceEnum.m_driverName.toStdString();
|
||||||
|
|
||||||
if (deviceEnum.m_idKey.size() > 0) {
|
if (hardwareUserArguments.size() > 0)
|
||||||
|
{
|
||||||
|
QStringList kvArgs = hardwareUserArguments.split(',');
|
||||||
|
|
||||||
|
for (int i = 0; i < kvArgs.size(); i++)
|
||||||
|
{
|
||||||
|
QStringList kv = kvArgs.at(i).split('=');
|
||||||
|
|
||||||
|
if (kv.size() > 1) {
|
||||||
|
kwargs[kv.at(0).toStdString()] = kv.at(1).toStdString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (deviceEnum.m_idKey.size() > 0)
|
||||||
|
{
|
||||||
kwargs[deviceEnum.m_idKey.toStdString()] = deviceEnum.m_idValue.toStdString();
|
kwargs[deviceEnum.m_idKey.toStdString()] = deviceEnum.m_idValue.toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SoapySDR::Kwargs::const_iterator it = kwargs.begin();
|
||||||
|
|
||||||
|
for (; it != kwargs.end(); ++it) {
|
||||||
|
qDebug("DeviceSoapySDR::openopenSoapySDRFromSequence: %s=%s", it->first.c_str(), it->second.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
SoapySDR::Device *device = SoapySDR::Device::make(kwargs);
|
SoapySDR::Device *device = SoapySDR::Device::make(kwargs);
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ class DEVICES_API DeviceSoapySDR
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static DeviceSoapySDR& instance();
|
static DeviceSoapySDR& instance();
|
||||||
SoapySDR::Device *openSoapySDR(uint32_t sequence);
|
SoapySDR::Device *openSoapySDR(uint32_t sequence, const QString& hardwareUserArguments);
|
||||||
void closeSoapySdr(SoapySDR::Device *device);
|
void closeSoapySdr(SoapySDR::Device *device);
|
||||||
|
|
||||||
uint32_t getNbDevices() const { return m_scanner.getNbDevices(); }
|
uint32_t getNbDevices() const { return m_scanner.getNbDevices(); }
|
||||||
@ -43,7 +43,7 @@ protected:
|
|||||||
~DeviceSoapySDR();
|
~DeviceSoapySDR();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SoapySDR::Device *openopenSoapySDRFromSequence(uint32_t sequence);
|
SoapySDR::Device *openopenSoapySDRFromSequence(uint32_t sequence, const QString& hardwareUserArguments);
|
||||||
DeviceSoapySDRScan m_scanner;
|
DeviceSoapySDRScan m_scanner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ bool SoapySDROutput::openDevice()
|
|||||||
{
|
{
|
||||||
qDebug("SoapySDROutput::openDevice: open device here");
|
qDebug("SoapySDROutput::openDevice: open device here");
|
||||||
DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
|
DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
|
||||||
m_deviceShared.m_device = deviceSoapySDR.openSoapySDR(m_deviceAPI->getSamplingDeviceSequence());
|
m_deviceShared.m_device = deviceSoapySDR.openSoapySDR(m_deviceAPI->getSamplingDeviceSequence(), m_deviceAPI->getHardwareUserArguments());
|
||||||
|
|
||||||
if (!m_deviceShared.m_device)
|
if (!m_deviceShared.m_device)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ bool SoapySDRInput::openDevice()
|
|||||||
{
|
{
|
||||||
qDebug("SoapySDRInput::openDevice: open device here");
|
qDebug("SoapySDRInput::openDevice: open device here");
|
||||||
DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
|
DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
|
||||||
m_deviceShared.m_device = deviceSoapySDR.openSoapySDR(m_deviceAPI->getSamplingDeviceSequence());
|
m_deviceShared.m_device = deviceSoapySDR.openSoapySDR(m_deviceAPI->getSamplingDeviceSequence(), m_deviceAPI->getHardwareUserArguments());
|
||||||
|
|
||||||
if (!m_deviceShared.m_device)
|
if (!m_deviceShared.m_device)
|
||||||
{
|
{
|
||||||
|
@ -288,8 +288,11 @@ void MainCore::addSinkDevice()
|
|||||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||||
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
|
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
|
||||||
|
|
||||||
// delete previous plugin instance
|
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
||||||
//m_deviceSets.back()->m_deviceSinkAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput()
|
|
||||||
|
if (userArgs.size() > 0) {
|
||||||
|
m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceSampleSink *sink = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
|
DeviceSampleSink *sink = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
|
||||||
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
|
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
|
||||||
@ -330,6 +333,12 @@ void MainCore::addSourceDevice()
|
|||||||
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
||||||
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex));
|
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex));
|
||||||
|
|
||||||
|
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
||||||
|
|
||||||
|
if (userArgs.size() > 0) {
|
||||||
|
m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceSampleSource *source = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
|
DeviceSampleSource *source = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
|
||||||
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
|
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
|
||||||
m_deviceSets.back()->m_deviceAPI->setSampleSource(source);
|
m_deviceSets.back()->m_deviceAPI->setSampleSource(source);
|
||||||
|
Loading…
Reference in New Issue
Block a user