Device user arguments: use it in SoapySDR

pull/375/head
f4exb 2019-06-14 01:14:27 +02:00
rodzic ea1b3e90b4
commit 8ce43225ae
5 zmienionych plików z 40 dodań i 10 usunięć

Wyświetl plik

@ -15,6 +15,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QStringList>
#include "devicesoapysdr.h"
DeviceSoapySDR::DeviceSoapySDR()
@ -31,10 +32,10 @@ DeviceSoapySDR& DeviceSoapySDR::instance()
return inst;
}
SoapySDR::Device *DeviceSoapySDR::openSoapySDR(uint32_t sequence)
SoapySDR::Device *DeviceSoapySDR::openSoapySDR(uint32_t sequence, const QString& hardwareUserArguments)
{
instance();
return openopenSoapySDRFromSequence(sequence);
return openopenSoapySDRFromSequence(sequence, hardwareUserArguments);
}
void DeviceSoapySDR::closeSoapySdr(SoapySDR::Device *device)
@ -42,7 +43,7 @@ void DeviceSoapySDR::closeSoapySdr(SoapySDR::Device *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())
{
@ -57,10 +58,30 @@ SoapySDR::Device *DeviceSoapySDR::openopenSoapySDRFromSequence(uint32_t sequence
SoapySDR::Kwargs kwargs;
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();
}
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);
return device;
}

Wyświetl plik

@ -28,7 +28,7 @@ class DEVICES_API DeviceSoapySDR
{
public:
static DeviceSoapySDR& instance();
SoapySDR::Device *openSoapySDR(uint32_t sequence);
SoapySDR::Device *openSoapySDR(uint32_t sequence, const QString& hardwareUserArguments);
void closeSoapySdr(SoapySDR::Device *device);
uint32_t getNbDevices() const { return m_scanner.getNbDevices(); }
@ -43,7 +43,7 @@ protected:
~DeviceSoapySDR();
private:
SoapySDR::Device *openopenSoapySDRFromSequence(uint32_t sequence);
SoapySDR::Device *openopenSoapySDRFromSequence(uint32_t sequence, const QString& hardwareUserArguments);
DeviceSoapySDRScan m_scanner;
};

Wyświetl plik

@ -131,7 +131,7 @@ bool SoapySDROutput::openDevice()
{
qDebug("SoapySDROutput::openDevice: open device here");
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)
{

Wyświetl plik

@ -149,7 +149,7 @@ bool SoapySDRInput::openDevice()
{
qDebug("SoapySDRInput::openDevice: open device here");
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)
{

Wyświetl plik

@ -288,8 +288,11 @@ void MainCore::addSinkDevice()
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
// delete previous plugin instance
//m_deviceSets.back()->m_deviceSinkAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput()
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
if (userArgs.size() > 0) {
m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
}
DeviceSampleSink *sink = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
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->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(
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
m_deviceSets.back()->m_deviceAPI->setSampleSource(source);