SoapySDR support: create output plugin with enumeration

This commit is contained in:
f4exb 2018-10-29 18:27:58 +01:00
parent 0e9a0f4f6d
commit 8f2ec099f3
14 changed files with 576 additions and 8 deletions

View File

@ -28,6 +28,11 @@ if(CM256CC_FOUND)
add_subdirectory(sdrdaemonsink)
endif(CM256CC_FOUND)
find_package(SoapySDR)
if(LIBUSB_FOUND AND SOAPYSDR_FOUND)
add_subdirectory(soapysdroutput)
endif()
if (BUILD_DEBIAN)
add_subdirectory(bladerf1output)
add_subdirectory(bladerf2output)
@ -35,6 +40,7 @@ if (BUILD_DEBIAN)
add_subdirectory(limesdroutput)
add_subdirectory(plutosdroutput)
add_subdirectory(sdrdaemonsink)
add_subdirectory(soapysdroutput)
endif (BUILD_DEBIAN)
add_subdirectory(filesink)

View File

@ -13,7 +13,7 @@ set(bladerf2output_SOURCES
set(bladerf2output_HEADERS
bladerf2outputgui.h
bladerf2output.h
bladerf1soutputplugin.h
bladerf2outputplugin.h
bladerf2outputsettings.h
bladerf2outputthread.h
)

View File

@ -46,8 +46,8 @@ public:
void resetToDefaults();
virtual qint64 getCenterFrequency() const;
virtual void setCenterFrequency(qint64 centerFrequency);
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual bool handleMessage(const Message& message);

View File

@ -22,7 +22,7 @@
class PluginAPI;
#define BLADERF2OUTPUT_DEVICE_TYPE_ID "sdrangel.samplesource.bladerf2output"
#define BLADERF2OUTPUT_DEVICE_TYPE_ID "sdrangel.samplesink.bladerf2output"
class BladeRF2OutputPlugin : public QObject, public PluginInterface {
Q_OBJECT

View File

@ -0,0 +1,78 @@
project(soapysdroutput)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(soapysdroutput_SOURCES
soapysdroutputgui.cpp
soapysdroutput.cpp
soapysdroutputplugin.cpp
# soapysdroutputsettings.cpp
# soapysdroutputthread.cpp
)
set(soapysdroutput_HEADERS
soapysdroutputgui.h
soapysdroutput.h
soapysdroutputplugin.h
# soapysdroutputsettings.h
# soapysdroutputthread.h
)
set(soapysdroutput_FORMS
# soapysdroutputgui.ui
)
if (BUILD_DEBIAN)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices
${SOAPYSDRSRC}/include
${SOAPYSDRSRC}/src
)
else (BUILD_DEBIAN)
include_directories(
.
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_SOURCE_DIR}/devices
${SOAPYSDR_INCLUDE_DIR}
)
endif (BUILD_DEBIAN)
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
qt5_wrap_ui(soapysdroutput_FORMS_HEADERS ${soapysdroutput_FORMS})
add_library(outputsoapysdr SHARED
${soapysdroutput_SOURCES}
${soapysdroutput_HEADERS_MOC}
${soapysdroutput_FORMS_HEADERS}
)
if (BUILD_DEBIAN)
target_link_libraries(outputsoapysdr
${QT_LIBRARIES}
bladerf
sdrbase
sdrgui
swagger
soapysdrdevice
)
else (BUILD_DEBIAN)
target_link_libraries(outputsoapysdr
${QT_LIBRARIES}
${SOAPYSDR_LIBRARY}
sdrbase
sdrgui
swagger
soapysdrdevice
)
endif (BUILD_DEBIAN)
target_link_libraries(outputsoapysdr Qt5::Core Qt5::Widgets)
install(TARGETS outputsoapysdr DESTINATION lib/plugins/samplesink)

View File

@ -0,0 +1,84 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "util/simpleserializer.h"
#include "soapysdroutput.h"
SoapySDROutput::SoapySDROutput(DeviceSinkAPI *deviceAPI __attribute__((unused))) :
m_deviceDescription("SoapySDROutput")
{
}
SoapySDROutput::~SoapySDROutput()
{
}
void SoapySDROutput::destroy()
{
delete this;
}
void SoapySDROutput::init()
{
}
bool SoapySDROutput::start()
{
return false;
}
void SoapySDROutput::stop()
{
}
QByteArray SoapySDROutput::serialize() const
{
SimpleSerializer s(1);
return s.final();
}
bool SoapySDROutput::deserialize(const QByteArray& data __attribute__((unused)))
{
return false;
}
const QString& SoapySDROutput::getDeviceDescription() const
{
return m_deviceDescription;
}
int SoapySDROutput::getSampleRate() const
{
return 0;
}
quint64 SoapySDROutput::getCenterFrequency() const
{
return 0;
}
void SoapySDROutput::setCenterFrequency(qint64 centerFrequency __attribute__((unused)))
{
}
bool SoapySDROutput::handleMessage(const Message& message __attribute__((unused)))
{
return false;
}

View File

@ -0,0 +1,52 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUT_H_
#define PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUT_H_
#include <QString>
#include "dsp/devicesamplesink.h"
class DeviceSinkAPI;
class SoapySDROutput : public DeviceSampleSink {
public:
SoapySDROutput(DeviceSinkAPI *deviceAPI);
virtual ~SoapySDROutput();
virtual void destroy();
virtual void init();
virtual bool start();
virtual void stop();
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const;
virtual void setCenterFrequency(qint64 centerFrequency);
virtual bool handleMessage(const Message& message);
private:
QString m_deviceDescription;
};
#endif /* PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUT_H_ */

View File

@ -0,0 +1,89 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "device/devicesinkapi.h"
#include "device/deviceuiset.h"
#include "util/simpleserializer.h"
#include "soapysdroutputgui.h"
SoapySDROutputGui::SoapySDROutputGui(DeviceUISet *deviceUISet, QWidget* parent) :
QWidget(parent),
ui(0),
m_deviceUISet(deviceUISet),
m_forceSettings(true),
m_doApplySettings(true),
m_sampleSink(0),
m_sampleRate(0),
m_lastEngineState(DSPDeviceSinkEngine::StNotStarted)
{
}
SoapySDROutputGui::~SoapySDROutputGui()
{
}
void SoapySDROutputGui::destroy()
{
delete this;
}
void SoapySDROutputGui::setName(const QString& name)
{
setObjectName(name);
}
QString SoapySDROutputGui::getName() const
{
return objectName();
}
void SoapySDROutputGui::resetToDefaults()
{
}
qint64 SoapySDROutputGui::getCenterFrequency() const
{
return 0;
}
void SoapySDROutputGui::setCenterFrequency(qint64 centerFrequency __attribute__((unused)))
{
}
QByteArray SoapySDROutputGui::serialize() const
{
SimpleSerializer s(1);
return s.final();
}
bool SoapySDROutputGui::deserialize(const QByteArray& data __attribute__((unused)))
{
return false;
}
bool SoapySDROutputGui::handleMessage(const Message& message __attribute__((unused)))
{
return false;
}

View File

@ -0,0 +1,69 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTGUI_H_
#define PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTGUI_H_
#include <QTimer>
#include <QWidget>
#include "plugin/plugininstancegui.h"
#include "util/messagequeue.h"
#include "soapysdroutput.h"
class DeviceSampleSink;
class DeviceUISet;
namespace Ui {
class SoapySDROutputGui;
}
class SoapySDROutputGui : public QWidget, public PluginInstanceGUI {
Q_OBJECT
public:
explicit SoapySDROutputGui(DeviceUISet *deviceUISet, QWidget* parent = 0);
virtual ~SoapySDROutputGui();
virtual void destroy();
void setName(const QString& name);
QString getName() const;
void resetToDefaults();
virtual qint64 getCenterFrequency() const;
virtual void setCenterFrequency(qint64 centerFrequency);
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
virtual MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
virtual bool handleMessage(const Message& message);
private:
Ui::SoapySDROutputGui* ui;
DeviceUISet* m_deviceUISet;
bool m_forceSettings;
bool m_doApplySettings;
QTimer m_updateTimer;
QTimer m_statusTimer;
SoapySDROutput* m_sampleSink;
int m_sampleRate;
quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState;
MessageQueue m_inputMessageQueue;
};
#endif /* PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTGUI_H_ */

View File

@ -0,0 +1,133 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QtPlugin>
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "device/devicesourceapi.h"
#include "soapysdr/devicesoapysdr.h"
#include "soapysdroutputplugin.h"
#ifdef SERVER_MODE
#include "soapysdroutput.h"
#else
#include "soapysdroutputgui.h"
#endif
const PluginDescriptor SoapySDROutputPlugin::m_pluginDescriptor = {
QString("SoapySDR Output"),
QString("4.3.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
QString("https://github.com/f4exb/sdrangel")
};
const QString SoapySDROutputPlugin::m_hardwareID = "SoapySDR";
const QString SoapySDROutputPlugin::m_deviceTypeID = SOAPYSDROUTPUT_DEVICE_TYPE_ID;
SoapySDROutputPlugin::SoapySDROutputPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& SoapySDROutputPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void SoapySDROutputPlugin::initPlugin(PluginAPI* pluginAPI)
{
pluginAPI->registerSampleSink(m_deviceTypeID, this);
}
PluginInterface::SamplingDevices SoapySDROutputPlugin::enumSampleSinks()
{
SamplingDevices result;
DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
const std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>& devicesEnumeration = deviceSoapySDR.getDevicesEnumeration();
qDebug("SoapySDRInputPlugin::enumSampleSources: found %lu devices", devicesEnumeration.size());
std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>::const_iterator it = devicesEnumeration.begin();
for (int idev = 0; it != devicesEnumeration.end(); ++it, idev++)
{
unsigned int nbTxChannels = it->m_nbTx;
for (unsigned int ichan = 0; ichan < nbTxChannels; ichan++)
{
qDebug("SoapySDROutputPlugin::enumSampleSinks: device #%d (%s) channel %u", idev, it->m_label, ichan);
QString displayedName(QString("SoapySDR[%1:%2] %3").arg(idev).arg(ichan).arg(it->m_label));
result.append(SamplingDevice(displayedName,
m_hardwareID,
m_deviceTypeID,
it->m_idValue,
idev,
PluginInterface::SamplingDevice::PhysicalDevice,
false,
nbTxChannels,
ichan));
}
}
return result;
}
#ifdef SERVER_MODE
PluginInstanceGUI* SoapySDROutputPlugin::createSampleSinkPluginInstanceGUI(
const QString& sinkId __attribute__((unused)),
QWidget **widget __attribute__((unused)),
DeviceUISet *deviceUISet __attribute__((unused)))
{
return 0;
}
#else
PluginInstanceGUI* SoapySDROutputPlugin::createSampleSinkPluginInstanceGUI(
const QString& sinkId,
QWidget **widget,
DeviceUISet *deviceUISet)
{
if(sinkId == m_deviceTypeID)
{
SoapySDROutputGui* gui = new SoapySDROutputGui(deviceUISet);
*widget = gui;
return gui;
}
else
{
return 0;
}
}
#endif
DeviceSampleSink* SoapySDROutputPlugin::createSampleSinkPluginInstanceOutput(const QString& sinkId, DeviceSinkAPI *deviceAPI)
{
if(sinkId == m_deviceTypeID)
{
SoapySDROutput* output = new SoapySDROutput(deviceAPI);
return output;
}
else
{
return 0;
}
}

View File

@ -0,0 +1,54 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTPLUGIN_H_
#define PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTPLUGIN_H_
#include <QObject>
#include "plugin/plugininterface.h"
class PluginAPI;
#define SOAPYSDROUTPUT_DEVICE_TYPE_ID "sdrangel.samplesink.soapysdroutput"
class SoapySDROutputPlugin : public QObject, public PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID SOAPYSDROUTPUT_DEVICE_TYPE_ID)
public:
explicit SoapySDROutputPlugin(QObject* parent = 0);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
virtual SamplingDevices enumSampleSinks();
virtual PluginInstanceGUI* createSampleSinkPluginInstanceGUI(
const QString& sinkId,
QWidget **widget,
DeviceUISet *deviceUISet);
virtual DeviceSampleSink* createSampleSinkPluginInstanceOutput(const QString& sinkId, DeviceSinkAPI *deviceAPI);
static const QString m_hardwareID;
static const QString m_deviceTypeID;
private:
static const PluginDescriptor m_pluginDescriptor;
};
#endif /* PLUGINS_SAMPLESINK_SOAPYSDROUTPUT_SOAPYSDROUTPUTPLUGIN_H_ */

View File

@ -97,6 +97,7 @@ if (BUILD_DEBIAN)
add_subdirectory(rtlsdr)
add_subdirectory(sdrdaemonsource)
add_subdirectory(sdrplay)
add_subdirectory(soapysdrinput)
endif (BUILD_DEBIAN)
add_subdirectory(filesource)

View File

@ -18,7 +18,8 @@
#include "soapysdrinput.h"
SoapySDRInput::SoapySDRInput(DeviceSourceAPI *deviceAPI)
SoapySDRInput::SoapySDRInput(DeviceSourceAPI *deviceAPI __attribute__((unused))) :
m_deviceDescription("SoapySDRInput")
{
}
@ -50,7 +51,7 @@ QByteArray SoapySDRInput::serialize() const
return s.final();
}
bool SoapySDRInput::deserialize(const QByteArray& data)
bool SoapySDRInput::deserialize(const QByteArray& data __attribute__((unused)))
{
return false;
}
@ -70,11 +71,11 @@ quint64 SoapySDRInput::getCenterFrequency() const
return 0;
}
void SoapySDRInput::setCenterFrequency(qint64 centerFrequency)
void SoapySDRInput::setCenterFrequency(qint64 centerFrequency __attribute__((unused)))
{
}
bool SoapySDRInput::handleMessage(const Message& message)
bool SoapySDRInput::handleMessage(const Message& message __attribute__((unused)))
{
return false;
}

View File

@ -69,6 +69,7 @@ PluginInterface::SamplingDevices SoapySDRInputPlugin::enumSampleSources()
for (unsigned int ichan = 0; ichan < nbRxChannels; ichan++)
{
qDebug("SoapySDRInputPlugin::enumSampleSources: device #%d (%s) channel %u", idev, it->m_label, ichan);
QString displayedName(QString("SoapySDR[%1:%2] %3").arg(idev).arg(ichan).arg(it->m_label));
result.append(SamplingDevice(displayedName,
m_hardwareID,