1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-07 16:34:45 -04:00

SoapySDR support: build infrastructure and input plugin enumeration

This commit is contained in:
f4exb
2018-10-29 16:39:25 +01:00
parent 675ea97b87
commit c82d838708
19 changed files with 847 additions and 6 deletions
@@ -0,0 +1,78 @@
project(soapysdrinput)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(soapysdrinput_SOURCES
soapysdrinputgui.cpp
soapysdrinput.cpp
soapysdrinputplugin.cpp
# soapysdrinputsettings.cpp
# soapysdrinputthread.cpp
)
set(soapysdrinput_HEADERS
soapysdrinputgui.h
soapysdrinput.h
soapysdrinputplugin.h
# soapysdrinputsettings.h
# soapysdrinputthread.h
)
set(soapysdrinput_FORMS
# soapysdrinputgui.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(soapysdrinput_FORMS_HEADERS ${soapysdrinput_FORMS})
add_library(inputsoapysdr SHARED
${soapysdrinput_SOURCES}
${soapysdrinput_HEADERS_MOC}
${soapysdrinput_FORMS_HEADERS}
)
if (BUILD_DEBIAN)
target_link_libraries(inputsoapysdr
${QT_LIBRARIES}
bladerf
sdrbase
sdrgui
swagger
soapysdrdevice
)
else (BUILD_DEBIAN)
target_link_libraries(inputsoapysdr
${QT_LIBRARIES}
${SOAPYSDR_LIBRARY}
sdrbase
sdrgui
swagger
soapysdrdevice
)
endif (BUILD_DEBIAN)
target_link_libraries(inputsoapysdr Qt5::Core Qt5::Widgets)
install(TARGETS inputsoapysdr DESTINATION lib/plugins/samplesource)
@@ -0,0 +1,80 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 "soapysdrinput.h"
SoapySDRInput::SoapySDRInput(DeviceSourceAPI *deviceAPI)
{
}
SoapySDRInput::~SoapySDRInput()
{
}
void SoapySDRInput::destroy()
{
delete this;
}
void SoapySDRInput::init()
{
}
bool SoapySDRInput::start()
{
return false;
}
void SoapySDRInput::stop()
{
}
QByteArray SoapySDRInput::serialize() const
{
SimpleSerializer s(1);
return s.final();
}
bool SoapySDRInput::deserialize(const QByteArray& data)
{
return false;
}
const QString& SoapySDRInput::getDeviceDescription() const
{
return m_deviceDescription;
}
int SoapySDRInput::getSampleRate() const
{
return 0;
}
quint64 SoapySDRInput::getCenterFrequency() const
{
return 0;
}
void SoapySDRInput::setCenterFrequency(qint64 centerFrequency)
{
}
bool SoapySDRInput::handleMessage(const Message& message)
{
return false;
}
@@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////////
// 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_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_
#include <QString>
#include <QByteArray>
#include <stdint.h>
#include "dsp/devicesamplesource.h"
class DeviceSourceAPI;
class SoapySDRInput : public DeviceSampleSource
{
public:
SoapySDRInput(DeviceSourceAPI *deviceAPI);
virtual ~SoapySDRInput();
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_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUT_H_ */
@@ -0,0 +1,86 @@
///////////////////////////////////////////////////////////////////////////////////
// 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/devicesourceapi.h"
#include "device/deviceuiset.h"
#include "util/simpleserializer.h"
#include "soapysdrinputgui.h"
SoapySDRInputGui::SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent) :
QWidget(parent),
ui(0),
m_deviceUISet(deviceUISet),
m_forceSettings(true),
m_doApplySettings(true),
m_sampleSource(0),
m_sampleRate(0),
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted)
{
}
SoapySDRInputGui::~SoapySDRInputGui()
{
}
void SoapySDRInputGui::destroy()
{
delete this;
}
void SoapySDRInputGui::setName(const QString& name)
{
setObjectName(name);
}
QString SoapySDRInputGui::getName() const
{
return objectName();
}
void SoapySDRInputGui::resetToDefaults()
{
}
qint64 SoapySDRInputGui::getCenterFrequency() const
{
return 0;
}
void SoapySDRInputGui::setCenterFrequency(qint64 centerFrequency __attribute__((unused)))
{
}
QByteArray SoapySDRInputGui::serialize() const
{
SimpleSerializer s(1);
return s.final();
}
bool SoapySDRInputGui::deserialize(const QByteArray& data __attribute__((unused)))
{
return false;
}
bool SoapySDRInputGui::handleMessage(const Message& message __attribute__((unused)))
{
return false;
}
@@ -0,0 +1,70 @@
///////////////////////////////////////////////////////////////////////////////////
// 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_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTGUI_H_
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTGUI_H_
#include <QTimer>
#include <QWidget>
#include "plugin/plugininstancegui.h"
#include "util/messagequeue.h"
#include "soapysdrinput.h"
class DeviceUISet;
namespace Ui {
class SoapySDRInputGui;
}
class SoapySDRInputGui : public QWidget, public PluginInstanceGUI {
Q_OBJECT
public:
explicit SoapySDRInputGui(DeviceUISet *deviceUISet, QWidget* parent = 0);
virtual ~SoapySDRInputGui();
virtual void destroy();
void setName(const QString& name);
QString getName() const;
virtual 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::SoapySDRInputGui* ui;
DeviceUISet* m_deviceUISet;
bool m_forceSettings;
bool m_doApplySettings;
QTimer m_updateTimer;
QTimer m_statusTimer;
SoapySDRInput* m_sampleSource;
int m_sampleRate;
quint64 m_deviceCenterFrequency; //!< Center frequency in device
int m_lastEngineState;
MessageQueue m_inputMessageQueue;
};
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTGUI_H_ */
@@ -0,0 +1,132 @@
///////////////////////////////////////////////////////////////////////////////////
// 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/devicesoapysdrscan.h"
#include "soapysdrinputplugin.h"
#ifdef SERVER_MODE
#include "soapysdrinput.h"
#else
#include "soapysdrinputgui.h"
#endif
const PluginDescriptor SoapySDRInputPlugin::m_pluginDescriptor = {
QString("SoapySDR Input"),
QString("4.3.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
true,
QString("https://github.com/f4exb/sdrangel")
};
const QString SoapySDRInputPlugin::m_hardwareID = "SoapySDR";
const QString SoapySDRInputPlugin::m_deviceTypeID = SOAPYSDRINPUT_DEVICE_TYPE_ID;
SoapySDRInputPlugin::SoapySDRInputPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& SoapySDRInputPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void SoapySDRInputPlugin::initPlugin(PluginAPI* pluginAPI)
{
pluginAPI->registerSampleSource(m_deviceTypeID, this);
}
PluginInterface::SamplingDevices SoapySDRInputPlugin::enumSampleSources()
{
SamplingDevices result;
DeviceSoapySDRScan scanner;
scanner.scan();
const std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>& devicesEnumeration = scanner.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 nbRxChannels = it->m_nbRx;
for (unsigned int ichan = 0; ichan < nbRxChannels; 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,
true,
nbRxChannels,
ichan));
}
}
return result;
}
#ifdef SERVER_MODE
PluginInstanceGUI* SoapySDRInputPlugin::createSampleSourcePluginInstanceGUI(
const QString& sourceId __attribute__((unused)),
QWidget **widget __attribute__((unused)),
DeviceUISet *deviceUISet __attribute__((unused)))
{
return 0;
}
#else
PluginInstanceGUI* SoapySDRInputPlugin::createSampleSourcePluginInstanceGUI(
const QString& sourceId,
QWidget **widget,
DeviceUISet *deviceUISet)
{
if(sourceId == m_deviceTypeID)
{
SoapySDRInputGui* gui = new SoapySDRInputGui(deviceUISet);
*widget = gui;
return gui;
}
else
{
return 0;
}
}
#endif
DeviceSampleSource *SoapySDRInputPlugin::createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI)
{
if (sourceId == m_deviceTypeID)
{
SoapySDRInput *input = new SoapySDRInput(deviceAPI);
return input;
}
else
{
return 0;
}
}
@@ -0,0 +1,56 @@
///////////////////////////////////////////////////////////////////////////////////
// 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_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTPLUGIN_H_
#define PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTPLUGIN_H_
#include <QObject>
#include "plugin/plugininterface.h"
class PluginAPI;
class DeviceSourceAPI;
class DeviceUISet;
#define SOAPYSDRINPUT_DEVICE_TYPE_ID "sdrangel.samplesource.soapysdrinput"
class SoapySDRInputPlugin : public QObject, public PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID SOAPYSDRINPUT_DEVICE_TYPE_ID)
public:
explicit SoapySDRInputPlugin(QObject* parent = 0);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
virtual SamplingDevices enumSampleSources();
virtual PluginInstanceGUI* createSampleSourcePluginInstanceGUI(
const QString& sourceId,
QWidget **widget,
DeviceUISet *deviceUISet);
virtual DeviceSampleSource* createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI);
static const QString m_hardwareID;
static const QString m_deviceTypeID;
private:
static const PluginDescriptor m_pluginDescriptor;
};
#endif /* PLUGINS_SAMPLESOURCE_SOAPYSDRINPUT_SOAPYSDRINPUTPLUGIN_H_ */