mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-22 16:08:39 -05:00
PlutoSDR: very basic PlutoSDR input plugin
This commit is contained in:
parent
a8b318de62
commit
f0de558fd9
@ -55,6 +55,11 @@ if(LIBUSB_FOUND AND LIMESUITE_FOUND)
|
||||
add_subdirectory(limesdrinput)
|
||||
endif(LIBUSB_FOUND AND LIMESUITE_FOUND)
|
||||
|
||||
find_package(LibIIO)
|
||||
if(LIBUSB_FOUND AND LIBIIO_FOUND)
|
||||
add_subdirectory(plutosdrinput)
|
||||
endif(LIBUSB_FOUND AND LIBIIO_FOUND)
|
||||
|
||||
find_package(CM256cc)
|
||||
find_package(LibNANOMSG)
|
||||
if(CM256CC_FOUND AND LIBNANOMSG_FOUND)
|
||||
@ -71,6 +76,7 @@ if (BUILD_DEBIAN)
|
||||
add_subdirectory(bladerfinput)
|
||||
add_subdirectory(sdrplay)
|
||||
add_subdirectory(limesdrinput)
|
||||
add_subdirectory(plutosdrinput)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
add_subdirectory(filesource)
|
||||
|
72
plugins/samplesource/plutosdrinput/CMakeLists.txt
Normal file
72
plugins/samplesource/plutosdrinput/CMakeLists.txt
Normal file
@ -0,0 +1,72 @@
|
||||
project(plutosdrinput)
|
||||
|
||||
set(plutosdrinput_SOURCES
|
||||
plutosdrinputgui.cpp
|
||||
# plutosdrinput.cpp
|
||||
plutosdrinputplugin.cpp
|
||||
# plutosdrinputsettings.cpp
|
||||
# plutosdrinputthread.cpp
|
||||
)
|
||||
|
||||
set(plutosdrinput_HEADERS
|
||||
plutosdrinputgui.h
|
||||
# plutosdrinput.h
|
||||
plutosdrinputplugin.h
|
||||
# plutosdrinputsettings.h
|
||||
# plutosdrinputthread.h
|
||||
)
|
||||
|
||||
#set(plutosdrinput_FORMS
|
||||
# plutosdrinputgui.ui
|
||||
#)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/devices
|
||||
${LIBIIOSRC}
|
||||
)
|
||||
else (BUILD_DEBIAN)
|
||||
include_directories(
|
||||
.
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/devices
|
||||
${LIBIIO_INCLUDE_DIR}
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
#include(${QT_USE_FILE})
|
||||
#add_definitions(${QT_DEFINITIONS})
|
||||
add_definitions("${QT_DEFINITIONS} -DLIBHACKRF_DYN_RATES")
|
||||
add_definitions(-DQT_PLUGIN)
|
||||
add_definitions(-DQT_SHARED)
|
||||
|
||||
#qt4_wrap_cpp(plutosdrinput_HEADERS_MOC ${plutosdrinput_HEADERS})
|
||||
qt5_wrap_ui(plutosdrinput_FORMS_HEADERS ${plutosdrinput_FORMS})
|
||||
|
||||
add_library(inputplutosdr SHARED
|
||||
${plutosdrinput_SOURCES}
|
||||
${plutosdrinput_HEADERS_MOC}
|
||||
# ${plutosdrinput_FORMS_HEADERS}
|
||||
)
|
||||
|
||||
if (BUILD_DEBIAN)
|
||||
target_link_libraries(inputplutosdr
|
||||
${QT_LIBRARIES}
|
||||
iio
|
||||
sdrbase
|
||||
plutosdrdevice
|
||||
)
|
||||
else (BUILD_DEBIAN)
|
||||
target_link_libraries(inputplutosdr
|
||||
${QT_LIBRARIES}
|
||||
${LIBIIO_LIBRARIES}
|
||||
sdrbase
|
||||
plutosdrdevice
|
||||
)
|
||||
endif (BUILD_DEBIAN)
|
||||
|
||||
qt5_use_modules(inputplutosdr Core Widgets)
|
||||
|
||||
install(TARGETS inputplutosdr DESTINATION lib/plugins/samplesource)
|
85
plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp
Normal file
85
plugins/samplesource/plutosdrinput/plutosdrinputgui.cpp
Normal file
@ -0,0 +1,85 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 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 "device/devicesourceapi.h"
|
||||
#include "plutosdrinputgui.h"
|
||||
|
||||
PlutoSDRInputGui::PlutoSDRInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_settings()
|
||||
{
|
||||
}
|
||||
|
||||
PlutoSDRInputGui::~PlutoSDRInputGui()
|
||||
{
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::setName(const QString& name)
|
||||
{
|
||||
setObjectName(name);
|
||||
}
|
||||
|
||||
QString PlutoSDRInputGui::getName() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::resetToDefaults()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
qint64 PlutoSDRInputGui::getCenterFrequency() const
|
||||
{
|
||||
return m_settings.m_centerFrequency;
|
||||
}
|
||||
|
||||
void PlutoSDRInputGui::setCenterFrequency(qint64 centerFrequency)
|
||||
{
|
||||
m_settings.m_centerFrequency = centerFrequency;
|
||||
}
|
||||
|
||||
QByteArray PlutoSDRInputGui::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
}
|
||||
|
||||
bool PlutoSDRInputGui::deserialize(const QByteArray& data)
|
||||
{
|
||||
if(m_settings.deserialize(data))
|
||||
{
|
||||
// displaySettings();
|
||||
// m_forceSettings = true;
|
||||
// sendSettings();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool PlutoSDRInputGui::handleMessage(const Message& message)
|
||||
{
|
||||
return false;
|
||||
}
|
49
plugins/samplesource/plutosdrinput/plutosdrinputgui.h
Normal file
49
plugins/samplesource/plutosdrinput/plutosdrinputgui.h
Normal file
@ -0,0 +1,49 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 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_PLUTOSDRINPUT_PLUTOSDRINPUTGUI_H_
|
||||
#define PLUGINS_SAMPLESOURCE_PLUTOSDRINPUT_PLUTOSDRINPUTGUI_H_
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "plugin/plugingui.h"
|
||||
#include "plutosdrinputsettings.h"
|
||||
|
||||
class DeviceSourceAPI;
|
||||
|
||||
class PlutoSDRInputGui : public QWidget, public PluginGUI {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PlutoSDRInputGui(DeviceSourceAPI *deviceAPI, QWidget* parent = 0);
|
||||
virtual ~PlutoSDRInputGui();
|
||||
|
||||
virtual void destroy();
|
||||
virtual void setName(const QString& name);
|
||||
virtual 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 bool handleMessage(const Message& message);
|
||||
|
||||
private:
|
||||
DeviceSourceAPI* m_deviceAPI;
|
||||
PlutoSDRInputSettings m_settings;
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_PLUTOSDRINPUT_PLUTOSDRINPUTGUI_H_ */
|
95
plugins/samplesource/plutosdrinput/plutosdrinputplugin.cpp
Normal file
95
plugins/samplesource/plutosdrinput/plutosdrinputplugin.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 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 <QAction>
|
||||
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "plutosdr/deviceplutosdr.h"
|
||||
|
||||
#include "plutosdrinputgui.h"
|
||||
#include "plutosdrinputplugin.h"
|
||||
|
||||
class DeviceSourceAPI;
|
||||
|
||||
const PluginDescriptor PlutoSDRInputPlugin::m_pluginDescriptor = {
|
||||
QString("PlutoSDR Input"),
|
||||
QString("3.7.0"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
true,
|
||||
QString("https://github.com/f4exb/sdrangel")
|
||||
};
|
||||
|
||||
const QString PlutoSDRInputPlugin::m_hardwareID = "PlutosDR";
|
||||
const QString PlutoSDRInputPlugin::m_deviceTypeID = PLUTOSDR_DEVICE_TYPE_ID;
|
||||
|
||||
PlutoSDRInputPlugin::PlutoSDRInputPlugin(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const PluginDescriptor& PlutoSDRInputPlugin::getPluginDescriptor() const
|
||||
{
|
||||
return m_pluginDescriptor;
|
||||
}
|
||||
|
||||
void PlutoSDRInputPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
{
|
||||
pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
||||
DevicePlutoSDR::instance(); // create singleton
|
||||
}
|
||||
|
||||
PluginInterface::SamplingDevices PlutoSDRInputPlugin::enumSampleSources()
|
||||
{
|
||||
DevicePlutoSDR::instance().scan();
|
||||
std::vector<std::string> serials;
|
||||
DevicePlutoSDR::instance().getSerials(serials);
|
||||
|
||||
std::vector<std::string>::const_iterator it = serials.begin();
|
||||
int i;
|
||||
SamplingDevices result;
|
||||
|
||||
for (i = 0; it != serials.end(); ++it, ++i)
|
||||
{
|
||||
QString serial_str = QString::fromLocal8Bit(it->c_str());
|
||||
QString displayedName(QString("PlutoSDR[%1] %2").arg(i).arg(serial_str));
|
||||
|
||||
result.append(SamplingDevice(displayedName,
|
||||
m_hardwareID,
|
||||
m_deviceTypeID,
|
||||
serial_str,
|
||||
i));
|
||||
|
||||
qDebug("PlutoSDRInputPlugin::enumSampleSources: enumerated PlutoSDR device #%d", i);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
PluginGUI* PlutoSDRInputPlugin::createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceSourceAPI *deviceAPI)
|
||||
{
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
PlutoSDRInputGui* gui = new PlutoSDRInputGui(deviceAPI);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
48
plugins/samplesource/plutosdrinput/plutosdrinputplugin.h
Normal file
48
plugins/samplesource/plutosdrinput/plutosdrinputplugin.h
Normal file
@ -0,0 +1,48 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 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 INCLUDE_PLUTOSDRINPUTPLUGIN_H
|
||||
#define INCLUDE_PLUTOSDRINPUTPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include "plugin/plugininterface.h"
|
||||
|
||||
#define PLUTOSDR_DEVICE_TYPE_ID "sdrangel.samplesource.plutosdr"
|
||||
|
||||
class PluginAPI;
|
||||
|
||||
class PlutoSDRInputPlugin : public QObject, public PluginInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
Q_PLUGIN_METADATA(IID PLUTOSDR_DEVICE_TYPE_ID)
|
||||
|
||||
public:
|
||||
explicit PlutoSDRInputPlugin(QObject* parent = NULL);
|
||||
|
||||
const PluginDescriptor& getPluginDescriptor() const;
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
|
||||
virtual SamplingDevices enumSampleSources();
|
||||
virtual PluginGUI* createSampleSourcePluginGUI(const QString& sourceId, QWidget **widget, DeviceSourceAPI *deviceAPI);
|
||||
|
||||
static const QString m_hardwareID;
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
private:
|
||||
static const PluginDescriptor m_pluginDescriptor;
|
||||
};
|
||||
|
||||
#endif // INCLUDE_PLUTOSDRINPUTPLUGIN_H
|
67
plugins/samplesource/plutosdrinput/plutosdrinputsettings.cpp
Normal file
67
plugins/samplesource/plutosdrinput/plutosdrinputsettings.cpp
Normal file
@ -0,0 +1,67 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 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 "plutosdrinputsettings.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
|
||||
PlutoSDRInputSettings::PlutoSDRInputSettings()
|
||||
{
|
||||
resetToDefaults();
|
||||
}
|
||||
|
||||
void PlutoSDRInputSettings::resetToDefaults()
|
||||
{
|
||||
m_centerFrequency = 435000 * 1000;
|
||||
m_fcPos = FC_POS_CENTER;
|
||||
}
|
||||
|
||||
QByteArray PlutoSDRInputSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
|
||||
s.writeS32(5, m_fcPos);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool PlutoSDRInputSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
if (!d.isValid())
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d.getVersion() == 1)
|
||||
{
|
||||
int intval;
|
||||
|
||||
d.readS32(5, &intval, 0);
|
||||
m_fcPos = (fcPos_t) intval;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
38
plugins/samplesource/plutosdrinput/plutosdrinputsettings.h
Normal file
38
plugins/samplesource/plutosdrinput/plutosdrinputsettings.h
Normal file
@ -0,0 +1,38 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 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 _PLUTOSDR_PLUTOSDRINPUTSETTINGS_H_
|
||||
#define _PLUTOSDR_PLUTOSDRINPUTSETTINGS_H_
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
struct PlutoSDRInputSettings {
|
||||
typedef enum {
|
||||
FC_POS_INFRA = 0,
|
||||
FC_POS_SUPRA,
|
||||
FC_POS_CENTER
|
||||
} fcPos_t;
|
||||
|
||||
quint64 m_centerFrequency;
|
||||
fcPos_t m_fcPos;
|
||||
|
||||
PlutoSDRInputSettings();
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
};
|
||||
|
||||
#endif /* _PLUTOSDR_PLUTOSDRINPUTSETTINGS_H_ */
|
Loading…
Reference in New Issue
Block a user