mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-13 11:51:47 -05:00
Review presets #1. Apply to HackRF
This commit is contained in:
parent
23b37c784b
commit
2d9c0bcfd2
@ -33,8 +33,8 @@ ENDIF()
|
||||
##############################################################################
|
||||
|
||||
#include(${QT_USE_FILE})
|
||||
set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
|
||||
#set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
|
||||
#set( QT_DEFINITIONS "${QT_DEFINITIONS} -DQT_NO_DEBUG_OUTPUT" )
|
||||
set( QT_DEFINITIONS "${QT_DEFINITIONS}" )
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
|
||||
if(MSVC)
|
||||
|
@ -34,9 +34,6 @@ public:
|
||||
void setSpectrumConfig(const QByteArray& data) { m_spectrumConfig = data; }
|
||||
const QByteArray& getSpectrumConfig() const { return m_spectrumConfig; }
|
||||
|
||||
void setShowScope(bool value) { m_showScope = value; }
|
||||
bool getShowScope() const { return m_showScope; }
|
||||
|
||||
void setLayout(const QByteArray& data) { m_layout = data; }
|
||||
const QByteArray& getLayout() const { return m_layout; }
|
||||
|
||||
@ -54,14 +51,12 @@ public:
|
||||
int getChannelCount() const { return m_channelConfigs.count(); }
|
||||
const ChannelConfig& getChannelConfig(int index) const { return m_channelConfigs.at(index); }
|
||||
|
||||
void setSourceConfig(const QString& source, const QByteArray& generalConfig, const QByteArray& config)
|
||||
void setSourceConfig(const QString& source, const QByteArray& config)
|
||||
{
|
||||
m_source = source;
|
||||
m_sourceGeneralConfig = generalConfig;
|
||||
m_sourceConfig = config;
|
||||
}
|
||||
const QString& getSource() const { return m_source; }
|
||||
const QByteArray& getSourceGeneralConfig() const { return m_sourceGeneralConfig; }
|
||||
const QByteArray& getSourceConfig() const { return m_sourceConfig; }
|
||||
|
||||
protected:
|
||||
@ -74,16 +69,12 @@ protected:
|
||||
QByteArray m_spectrumConfig;
|
||||
QByteArray m_scopeConfig;
|
||||
|
||||
// dc offset and i/q imbalance correction
|
||||
// dc offset and i/q imbalance correction TODO: move it into the source data
|
||||
bool m_dcOffsetCorrection;
|
||||
bool m_iqImbalanceCorrection;
|
||||
|
||||
// display scope dock
|
||||
bool m_showScope;
|
||||
|
||||
// sample source and sample source configuration
|
||||
QString m_source;
|
||||
QByteArray m_sourceGeneralConfig;
|
||||
QByteArray m_sourceConfig;
|
||||
|
||||
// channels and configurations
|
||||
|
@ -4,7 +4,7 @@ set(hackrf_SOURCES
|
||||
hackrfgui.cpp
|
||||
hackrfinput.cpp
|
||||
hackrfplugin.cpp
|
||||
hackrfserializer.cpp
|
||||
hackrfsettings.cpp
|
||||
hackrfthread.cpp
|
||||
)
|
||||
|
||||
@ -12,7 +12,7 @@ set(hackrf_HEADERS
|
||||
hackrfgui.h
|
||||
hackrfinput.h
|
||||
hackrfplugin.h
|
||||
hackrfserializer.h
|
||||
hackrfsettings.h
|
||||
hackrfthread.h
|
||||
)
|
||||
|
||||
|
@ -233,13 +233,13 @@ void HackRFGui::on_decim_valueChanged(int value)
|
||||
void HackRFGui::on_fcPos_currentIndexChanged(int index)
|
||||
{
|
||||
if (index == 0) {
|
||||
m_settings.m_fcPos = HackRFInput::FC_POS_INFRA;
|
||||
m_settings.m_fcPos = HackRFSettings::FC_POS_INFRA;
|
||||
sendSettings();
|
||||
} else if (index == 1) {
|
||||
m_settings.m_fcPos = HackRFInput::FC_POS_SUPRA;
|
||||
m_settings.m_fcPos = HackRFSettings::FC_POS_SUPRA;
|
||||
sendSettings();
|
||||
} else if (index == 2) {
|
||||
m_settings.m_fcPos = HackRFInput::FC_POS_CENTER;
|
||||
m_settings.m_fcPos = HackRFSettings::FC_POS_CENTER;
|
||||
sendSettings();
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
Ui::HackRFGui* ui;
|
||||
|
||||
PluginAPI* m_pluginAPI;
|
||||
HackRFInput::Settings m_settings;
|
||||
HackRFSettings m_settings;
|
||||
QTimer m_updateTimer;
|
||||
SampleSource* m_sampleSource;
|
||||
|
||||
|
@ -24,82 +24,11 @@
|
||||
#include "hackrfinput.h"
|
||||
|
||||
#include "hackrfgui.h"
|
||||
#include "hackrfserializer.h"
|
||||
#include "hackrfthread.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgConfigureHackRF, Message)
|
||||
MESSAGE_CLASS_DEFINITION(HackRFInput::MsgReportHackRF, Message)
|
||||
|
||||
HackRFInput::Settings::Settings() :
|
||||
m_centerFrequency(435000*1000),
|
||||
m_devSampleRateIndex(0),
|
||||
m_LOppmTenths(0),
|
||||
m_lnaGain(14),
|
||||
m_bandwidthIndex(0),
|
||||
m_vgaGain(4),
|
||||
m_log2Decim(0),
|
||||
m_fcPos(FC_POS_CENTER),
|
||||
m_biasT(false),
|
||||
m_lnaExt(false)
|
||||
{
|
||||
}
|
||||
|
||||
void HackRFInput::Settings::resetToDefaults()
|
||||
{
|
||||
m_centerFrequency = 435000*1000;
|
||||
m_devSampleRateIndex = 0;
|
||||
m_LOppmTenths = 0;
|
||||
m_lnaGain = 14;
|
||||
m_bandwidthIndex = 0;
|
||||
m_vgaGain = 4;
|
||||
m_log2Decim = 0;
|
||||
m_fcPos = FC_POS_CENTER;
|
||||
m_biasT = false;
|
||||
m_lnaExt = false;
|
||||
}
|
||||
|
||||
QByteArray HackRFInput::Settings::serialize() const
|
||||
{
|
||||
HackRFSerializer::HackRFData data;
|
||||
|
||||
data.m_data.m_frequency = m_centerFrequency;
|
||||
data.m_LOppmTenths = m_LOppmTenths;
|
||||
data.m_sampleRateIndex = m_devSampleRateIndex;
|
||||
data.m_log2Decim = m_log2Decim;
|
||||
data.m_fcPos = (qint32) m_fcPos;
|
||||
data.m_lnaGain = m_lnaGain;
|
||||
data.m_bandwidthIndex = m_bandwidthIndex;
|
||||
data.m_vgaGain = m_vgaGain;
|
||||
data.m_biasT = m_biasT;
|
||||
data.m_lnaExt = m_lnaExt;
|
||||
|
||||
QByteArray byteArray;
|
||||
|
||||
HackRFSerializer::writeSerializedData(data, byteArray);
|
||||
|
||||
return byteArray;
|
||||
}
|
||||
|
||||
bool HackRFInput::Settings::deserialize(const QByteArray& serializedData)
|
||||
{
|
||||
HackRFSerializer::HackRFData data;
|
||||
|
||||
bool valid = HackRFSerializer::readSerializedData(serializedData, data);
|
||||
|
||||
m_centerFrequency = data.m_data.m_frequency;
|
||||
m_LOppmTenths = data.m_LOppmTenths;
|
||||
m_devSampleRateIndex = data.m_sampleRateIndex;
|
||||
m_log2Decim = data.m_log2Decim;
|
||||
m_fcPos = (fcPos_t) data.m_fcPos;
|
||||
m_lnaGain = data.m_lnaGain;
|
||||
m_bandwidthIndex = data.m_bandwidthIndex;
|
||||
m_vgaGain = data.m_vgaGain;
|
||||
m_biasT = data.m_biasT;
|
||||
m_lnaExt = data.m_lnaExt;
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
HackRFInput::HackRFInput() :
|
||||
m_settings(),
|
||||
m_dev(0),
|
||||
@ -242,7 +171,7 @@ void HackRFInput::setCenterFrequency(quint64 freq_hz)
|
||||
}
|
||||
}
|
||||
|
||||
bool HackRFInput::applySettings(const Settings& settings, bool force)
|
||||
bool HackRFInput::applySettings(const HackRFSettings& settings, bool force)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
@ -313,19 +242,19 @@ bool HackRFInput::applySettings(const Settings& settings, bool force)
|
||||
m_settings.m_centerFrequency = settings.m_centerFrequency;
|
||||
m_settings.m_LOppmTenths = settings.m_LOppmTenths;
|
||||
|
||||
if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == FC_POS_CENTER))
|
||||
if ((m_settings.m_log2Decim == 0) || (m_settings.m_fcPos == HackRFSettings::FC_POS_CENTER))
|
||||
{
|
||||
deviceCenterFrequency = m_settings.m_centerFrequency;
|
||||
f_img = deviceCenterFrequency;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_settings.m_fcPos == FC_POS_INFRA)
|
||||
if (m_settings.m_fcPos == HackRFSettings::FC_POS_INFRA)
|
||||
{
|
||||
deviceCenterFrequency = m_settings.m_centerFrequency + (devSampleRate / 4);
|
||||
f_img = deviceCenterFrequency + devSampleRate/2;
|
||||
}
|
||||
else if (m_settings.m_fcPos == FC_POS_SUPRA)
|
||||
else if (m_settings.m_fcPos == HackRFSettings::FC_POS_SUPRA)
|
||||
{
|
||||
deviceCenterFrequency = m_settings.m_centerFrequency - (devSampleRate / 4);
|
||||
f_img = deviceCenterFrequency - devSampleRate/2;
|
||||
|
@ -19,51 +19,29 @@
|
||||
|
||||
#include "dsp/samplesource.h"
|
||||
#include "libhackrf/hackrf.h"
|
||||
#include "hackrfsettings.h"
|
||||
#include <QString>
|
||||
|
||||
class HackRFThread;
|
||||
|
||||
class HackRFInput : public SampleSource {
|
||||
public:
|
||||
typedef enum {
|
||||
FC_POS_INFRA = 0,
|
||||
FC_POS_SUPRA,
|
||||
FC_POS_CENTER
|
||||
} fcPos_t;
|
||||
|
||||
struct Settings {
|
||||
quint64 m_centerFrequency;
|
||||
qint32 m_LOppmTenths;
|
||||
quint32 m_devSampleRateIndex;
|
||||
quint32 m_bandwidthIndex;
|
||||
quint32 m_lnaGain;
|
||||
quint32 m_vgaGain;
|
||||
quint32 m_log2Decim;
|
||||
fcPos_t m_fcPos;
|
||||
bool m_biasT;
|
||||
bool m_lnaExt;
|
||||
|
||||
Settings();
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
};
|
||||
|
||||
class MsgConfigureHackRF : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const Settings& getSettings() const { return m_settings; }
|
||||
const HackRFSettings& getSettings() const { return m_settings; }
|
||||
|
||||
static MsgConfigureHackRF* create(const Settings& settings)
|
||||
static MsgConfigureHackRF* create(const HackRFSettings& settings)
|
||||
{
|
||||
return new MsgConfigureHackRF(settings);
|
||||
}
|
||||
|
||||
private:
|
||||
Settings m_settings;
|
||||
HackRFSettings m_settings;
|
||||
|
||||
MsgConfigureHackRF(const Settings& settings) :
|
||||
MsgConfigureHackRF(const HackRFSettings& settings) :
|
||||
Message(),
|
||||
m_settings(settings)
|
||||
{ }
|
||||
@ -100,12 +78,12 @@ public:
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
private:
|
||||
bool applySettings(const Settings& settings, bool force);
|
||||
bool applySettings(const HackRFSettings& settings, bool force);
|
||||
hackrf_device *open_hackrf_from_sequence(int sequence);
|
||||
void setCenterFrequency(quint64 freq);
|
||||
|
||||
QMutex m_mutex;
|
||||
Settings m_settings;
|
||||
HackRFSettings m_settings;
|
||||
struct hackrf_device* m_dev;
|
||||
HackRFThread* m_hackRFThread;
|
||||
QString m_deviceDescription;
|
||||
|
@ -33,6 +33,8 @@ const PluginDescriptor HackRFPlugin::m_pluginDescriptor = {
|
||||
QString("https://github.com/f4exb/sdrangel")
|
||||
};
|
||||
|
||||
const QString HackRFPlugin::m_deviceTypeID = HACKRF_DEVICE_TYPE_ID;
|
||||
|
||||
HackRFPlugin::HackRFPlugin(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_pluginAPI(0)
|
||||
@ -47,7 +49,7 @@ const PluginDescriptor& HackRFPlugin::getPluginDescriptor() const
|
||||
void HackRFPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
{
|
||||
m_pluginAPI = pluginAPI;
|
||||
m_pluginAPI->registerSampleSource("org.osmocom.sdr.samplesource.hackrf", this);
|
||||
m_pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
||||
}
|
||||
|
||||
PluginInterface::SampleSourceDevices HackRFPlugin::enumSampleSources()
|
||||
@ -96,7 +98,7 @@ PluginInterface::SampleSourceDevices HackRFPlugin::enumSampleSources()
|
||||
s.writeS32(1, i);
|
||||
s.writeString(2, serial_str);
|
||||
s.writeU64(3, serial_num);
|
||||
result.append(SampleSourceDevice(displayedName, "org.osmocom.sdr.samplesource.hackrf", s.final()));
|
||||
result.append(SampleSourceDevice(displayedName, m_deviceTypeID, s.final()));
|
||||
qDebug("HackRFPlugin::enumSampleSources: enumerated HackRF device #%d", i);
|
||||
|
||||
hackrf_close(hackrf_ptr);
|
||||
@ -120,7 +122,7 @@ PluginGUI* HackRFPlugin::createSampleSourcePluginGUI(const QString& sourceName,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(sourceName == "org.osmocom.sdr.samplesource.hackrf")
|
||||
if(sourceName == m_deviceTypeID)
|
||||
{
|
||||
HackRFGui* gui = new HackRFGui(m_pluginAPI);
|
||||
m_pluginAPI->setInputGUI(gui);
|
||||
|
@ -20,10 +20,12 @@
|
||||
#include <QObject>
|
||||
#include "plugin/plugininterface.h"
|
||||
|
||||
#define HACKRF_DEVICE_TYPE_ID "sdrangel.samplesource.hackrf"
|
||||
|
||||
class HackRFPlugin : public QObject, public PluginInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
Q_PLUGIN_METADATA(IID "org.osmocom.sdr.samplesource.hackrf")
|
||||
Q_PLUGIN_METADATA(IID HACKRF_DEVICE_TYPE_ID)
|
||||
|
||||
public:
|
||||
explicit HackRFPlugin(QObject* parent = NULL);
|
||||
@ -34,6 +36,8 @@ public:
|
||||
SampleSourceDevices enumSampleSources();
|
||||
PluginGUI* createSampleSourcePluginGUI(const QString& sourceName, const QByteArray& address);
|
||||
|
||||
static const QString m_deviceTypeID;
|
||||
|
||||
private:
|
||||
static const PluginDescriptor m_pluginDescriptor;
|
||||
|
||||
|
@ -1,89 +0,0 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 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 "hackrfserializer.h"
|
||||
|
||||
void HackRFSerializer::writeSerializedData(const HackRFData& data, QByteArray& serializedData)
|
||||
{
|
||||
QByteArray sampleSourceSerialized;
|
||||
SampleSourceSerializer::writeSerializedData(data.m_data, sampleSourceSerialized);
|
||||
|
||||
SimpleSerializer s(1);
|
||||
|
||||
s.writeBlob(1, sampleSourceSerialized);
|
||||
s.writeS32(2, data.m_LOppmTenths);
|
||||
s.writeU32(3, data.m_sampleRateIndex);
|
||||
s.writeU32(4, data.m_log2Decim);
|
||||
s.writeS32(5, data.m_fcPos);
|
||||
s.writeU32(6, data.m_lnaGain);
|
||||
s.writeU32(7, data.m_bandwidthIndex);
|
||||
s.writeU32(8, data.m_vgaGain);
|
||||
s.writeBool(9, data.m_biasT);
|
||||
s.writeBool(10, data.m_lnaExt);
|
||||
|
||||
serializedData = s.final();
|
||||
}
|
||||
|
||||
bool HackRFSerializer::readSerializedData(const QByteArray& serializedData, HackRFData& data)
|
||||
{
|
||||
bool valid = SampleSourceSerializer::readSerializedData(serializedData, data.m_data);
|
||||
|
||||
QByteArray sampleSourceSerialized;
|
||||
|
||||
SimpleDeserializer d(serializedData);
|
||||
|
||||
if (!d.isValid())
|
||||
{
|
||||
setDefaults(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d.getVersion() == SampleSourceSerializer::getSerializerVersion())
|
||||
{
|
||||
int intval;
|
||||
|
||||
d.readBlob(1, &sampleSourceSerialized);
|
||||
d.readS32(2, &data.m_LOppmTenths, 0);
|
||||
d.readU32(3, &data.m_sampleRateIndex, 0);
|
||||
d.readU32(4, &data.m_log2Decim, 0);
|
||||
d.readS32(5, &data.m_fcPos, 0);
|
||||
d.readU32(6, &data.m_lnaGain, 16);
|
||||
d.readU32(7, &data.m_bandwidthIndex, 0);
|
||||
d.readU32(8, &data.m_vgaGain, 16);
|
||||
d.readBool(9, &data.m_biasT, false);
|
||||
d.readBool(10, &data.m_lnaExt, false);
|
||||
|
||||
return SampleSourceSerializer::readSerializedData(sampleSourceSerialized, data.m_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
setDefaults(data);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void HackRFSerializer::setDefaults(HackRFData& data)
|
||||
{
|
||||
data.m_LOppmTenths = 0;
|
||||
data.m_sampleRateIndex = 0;
|
||||
data.m_log2Decim = 0;
|
||||
data.m_fcPos = 0;
|
||||
data.m_lnaGain = 16;
|
||||
data.m_bandwidthIndex = 0;
|
||||
data.m_vgaGain = 16;
|
||||
data.m_biasT = false;
|
||||
data.m_lnaExt = false;
|
||||
}
|
93
plugins/samplesource/hackrf/hackrfsettings.cpp
Normal file
93
plugins/samplesource/hackrf/hackrfsettings.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 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 <QtGlobal>
|
||||
#include "util/simpleserializer.h"
|
||||
#include "hackrfsettings.h"
|
||||
|
||||
HackRFSettings::HackRFSettings()
|
||||
{
|
||||
resetToDefaults();
|
||||
}
|
||||
|
||||
void HackRFSettings::resetToDefaults()
|
||||
{
|
||||
m_centerFrequency = 435000 * 1000;
|
||||
m_LOppmTenths = 0;
|
||||
m_devSampleRateIndex = 0;
|
||||
m_biasT = false;
|
||||
m_log2Decim = 0;
|
||||
m_fcPos = FC_POS_CENTER;
|
||||
m_lnaExt = false;
|
||||
m_lnaGain = 16;
|
||||
m_bandwidthIndex = 0;
|
||||
m_vgaGain = 16;
|
||||
m_dcBlock = false;
|
||||
m_iqCorrection = false;
|
||||
}
|
||||
|
||||
QByteArray HackRFSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
|
||||
s.writeS32(1, m_LOppmTenths);
|
||||
s.writeU32(2, m_devSampleRateIndex);
|
||||
s.writeBool(3, m_biasT);
|
||||
s.writeU32(4, m_log2Decim);
|
||||
s.writeS32(5, m_fcPos);
|
||||
s.writeBool(6, m_lnaExt);
|
||||
s.writeU32(7, m_lnaGain);
|
||||
s.writeU32(8, m_bandwidthIndex);
|
||||
s.writeU32(9, m_vgaGain);
|
||||
s.writeBool(10, m_dcBlock);
|
||||
s.writeBool(11, m_iqCorrection);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool HackRFSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
if (!d.isValid())
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (d.getVersion() == 1)
|
||||
{
|
||||
int intval;
|
||||
|
||||
d.readS32(1, &m_LOppmTenths, 0);
|
||||
d.readU32(2, &m_devSampleRateIndex, 0);
|
||||
d.readBool(3, &m_biasT, false);
|
||||
d.readU32(4, &m_log2Decim, 0);
|
||||
d.readS32(5, &intval, 0);
|
||||
m_fcPos = (fcPos_t) intval;
|
||||
d.readBool(6, &m_lnaExt, false);
|
||||
d.readU32(7, &m_lnaGain, 16);
|
||||
d.readU32(8, &m_bandwidthIndex, 0);
|
||||
d.readU32(9, &m_vgaGain, 16);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
resetToDefaults();
|
||||
return false;
|
||||
}
|
||||
}
|
@ -14,32 +14,33 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_SAMPLESOURCE_HACKRF_HACKRFSERIALIZER_H_
|
||||
#define PLUGINS_SAMPLESOURCE_HACKRF_HACKRFSERIALIZER_H_
|
||||
#ifndef _HACKRF_HACKRFSETTINGS_H_
|
||||
#define _HACKRF_HACKRFSETTINGS_H_
|
||||
|
||||
#include "util/samplesourceserializer.h"
|
||||
struct HackRFSettings {
|
||||
typedef enum {
|
||||
FC_POS_INFRA = 0,
|
||||
FC_POS_SUPRA,
|
||||
FC_POS_CENTER
|
||||
} fcPos_t;
|
||||
|
||||
class HackRFSerializer
|
||||
{
|
||||
public:
|
||||
struct HackRFData
|
||||
{
|
||||
SampleSourceSerializer::Data m_data;
|
||||
qint32 m_LOppmTenths;
|
||||
quint32 m_sampleRateIndex;
|
||||
quint32 m_log2Decim;
|
||||
qint32 m_fcPos;
|
||||
quint32 m_lnaGain;
|
||||
quint32 m_bandwidthIndex;
|
||||
quint32 m_vgaGain;
|
||||
bool m_biasT;
|
||||
bool m_lnaExt;
|
||||
};
|
||||
quint64 m_centerFrequency;
|
||||
qint32 m_LOppmTenths;
|
||||
quint32 m_devSampleRateIndex;
|
||||
quint32 m_bandwidthIndex;
|
||||
quint32 m_lnaGain;
|
||||
quint32 m_vgaGain;
|
||||
quint32 m_log2Decim;
|
||||
fcPos_t m_fcPos;
|
||||
bool m_biasT;
|
||||
bool m_lnaExt;
|
||||
bool m_dcBlock;
|
||||
bool m_iqCorrection;
|
||||
|
||||
static void writeSerializedData(const HackRFData& data, QByteArray& serializedData);
|
||||
static bool readSerializedData(const QByteArray& serializedData, HackRFData& data);
|
||||
static void setDefaults(HackRFData& data);
|
||||
HackRFSettings();
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
};
|
||||
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_HACKRF_HACKRFSERIALIZER_H_ */
|
||||
#endif /* _HACKRF_HACKRFSETTINGS_H_ */
|
@ -83,9 +83,7 @@ void PluginManager::registerSampleSource(const QString& sourceName, PluginInterf
|
||||
|
||||
void PluginManager::loadSettings(const Preset* preset)
|
||||
{
|
||||
qDebug() << "PluginManager::loadSettings";
|
||||
|
||||
fprintf(stderr, "Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
fprintf(stderr, "PluginManager::loadSettings: Loading preset [%s | %s]\n", qPrintable(preset->getGroup()), qPrintable(preset->getDescription()));
|
||||
|
||||
// copy currently open channels and clear list
|
||||
ChannelInstanceRegistrations openChannels = m_channelInstanceRegistrations;
|
||||
@ -100,11 +98,11 @@ void PluginManager::loadSettings(const Preset* preset)
|
||||
|
||||
for(int i = 0; i < openChannels.count(); i++)
|
||||
{
|
||||
qDebug(" - compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||
qDebug("PluginManager::loadSettings: channels compare [%s] vs [%s]", qPrintable(openChannels[i].m_channelName), qPrintable(channelConfig.m_channel));
|
||||
|
||||
if(openChannels[i].m_channelName == channelConfig.m_channel)
|
||||
{
|
||||
qDebug("channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
||||
qDebug("PluginManager::loadSettings: channel [%s] found", qPrintable(openChannels[i].m_channelName));
|
||||
reg = openChannels.takeAt(i);
|
||||
m_channelInstanceRegistrations.append(reg);
|
||||
break;
|
||||
@ -119,7 +117,7 @@ void PluginManager::loadSettings(const Preset* preset)
|
||||
{
|
||||
if(m_channelRegistrations[i].m_channelName == channelConfig.m_channel)
|
||||
{
|
||||
qDebug(" - creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
qDebug("PluginManager::loadSettings: creating new channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
reg = ChannelInstanceRegistration(channelConfig.m_channel, m_channelRegistrations[i].m_plugin->createChannel(channelConfig.m_channel));
|
||||
break;
|
||||
}
|
||||
@ -128,7 +126,7 @@ void PluginManager::loadSettings(const Preset* preset)
|
||||
|
||||
if(reg.m_gui != NULL)
|
||||
{
|
||||
qDebug(" - deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
qDebug("PluginManager::loadSettings: deserializing channel [%s]", qPrintable(channelConfig.m_channel));
|
||||
reg.m_gui->deserialize(channelConfig.m_config);
|
||||
}
|
||||
}
|
||||
@ -136,7 +134,7 @@ void PluginManager::loadSettings(const Preset* preset)
|
||||
// everything, that is still "available" is not needed anymore
|
||||
for(int i = 0; i < openChannels.count(); i++)
|
||||
{
|
||||
qDebug("destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||
qDebug("PluginManager::loadSettings: destroying spare channel [%s]", qPrintable(openChannels[i].m_channelName));
|
||||
openChannels[i].m_gui->destroy();
|
||||
}
|
||||
|
||||
@ -144,10 +142,12 @@ void PluginManager::loadSettings(const Preset* preset)
|
||||
|
||||
if(m_sampleSourcePluginGUI != 0)
|
||||
{
|
||||
qDebug("PluginManager::loadSettings: source compare [%s] vs [%s]", qPrintable(m_sampleSourceName), qPrintable(preset->getSource()));
|
||||
|
||||
// TODO: have one set of source presets per identified source (preset -> find source with name)
|
||||
if(m_sampleSourceName == preset->getSource())
|
||||
{
|
||||
qDebug() << " - deserializing source " << qPrintable(m_sampleSourceName);
|
||||
qDebug() << "PluginManager::loadSettings: deserializing source " << qPrintable(m_sampleSourceName);
|
||||
m_sampleSourcePluginGUI->deserialize(preset->getSourceConfig());
|
||||
}
|
||||
|
||||
@ -172,14 +172,20 @@ bool PluginManager::ChannelInstanceRegistration::operator<(const ChannelInstance
|
||||
|
||||
void PluginManager::saveSettings(Preset* preset)
|
||||
{
|
||||
if(m_sampleSourcePluginGUI != NULL) {
|
||||
//preset->setSourceConfig(m_sampleSourceName, m_sampleSourcePluginGUI->serializeGeneral(), m_sampleSourcePluginGUI->serialize());
|
||||
if(m_sampleSourcePluginGUI != NULL)
|
||||
{
|
||||
preset->setSourceConfig(m_sampleSourceName, m_sampleSourcePluginGUI->serialize());
|
||||
preset->setCenterFrequency(m_sampleSourcePluginGUI->getCenterFrequency());
|
||||
} else {
|
||||
preset->setSourceConfig(QString::null, QByteArray(), QByteArray());
|
||||
}
|
||||
else
|
||||
{
|
||||
preset->setSourceConfig(QString::null, QByteArray());
|
||||
}
|
||||
|
||||
qSort(m_channelInstanceRegistrations.begin(), m_channelInstanceRegistrations.end()); // sort by increasing delta frequency and type
|
||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++) {
|
||||
|
||||
for(int i = 0; i < m_channelInstanceRegistrations.count(); i++)
|
||||
{
|
||||
preset->addChannel(m_channelInstanceRegistrations[i].m_channelName, m_channelInstanceRegistrations[i].m_gui->serialize());
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ void Preset::resetToDefaults()
|
||||
m_scopeConfig.clear();
|
||||
m_dcOffsetCorrection = false;
|
||||
m_iqImbalanceCorrection = false;
|
||||
m_showScope = true;
|
||||
m_layout.clear();
|
||||
m_spectrumConfig.clear();
|
||||
m_channelConfigs.clear();
|
||||
@ -33,15 +32,13 @@ QByteArray Preset::serialize() const
|
||||
s.writeString(1, m_group);
|
||||
s.writeString(2, m_description);
|
||||
s.writeU64(3, m_centerFrequency);
|
||||
s.writeBool(4, m_showScope);
|
||||
s.writeBlob(5, m_layout);
|
||||
s.writeBlob(6, m_spectrumConfig);
|
||||
s.writeBool(7, m_dcOffsetCorrection);
|
||||
s.writeBool(8, m_iqImbalanceCorrection);
|
||||
s.writeBlob(9, m_scopeConfig);
|
||||
s.writeString(10, m_source);
|
||||
s.writeBlob(11, m_sourceGeneralConfig);
|
||||
s.writeBlob(12, m_sourceConfig);
|
||||
s.writeBlob(4, m_layout);
|
||||
s.writeBlob(5, m_spectrumConfig);
|
||||
s.writeBool(6, m_dcOffsetCorrection);
|
||||
s.writeBool(7, m_iqImbalanceCorrection);
|
||||
s.writeBlob(8, m_scopeConfig);
|
||||
s.writeString(9, m_source);
|
||||
s.writeBlob(10, m_sourceConfig);
|
||||
|
||||
s.writeS32(200, m_channelConfigs.size());
|
||||
|
||||
@ -69,15 +66,13 @@ bool Preset::deserialize(const QByteArray& data)
|
||||
d.readString(1, &m_group, "default");
|
||||
d.readString(2, &m_description, "no name");
|
||||
d.readU64(3, &m_centerFrequency, 0);
|
||||
d.readBool(4, &m_showScope, true);
|
||||
d.readBlob(5, &m_layout);
|
||||
d.readBlob(6, &m_spectrumConfig);
|
||||
d.readBool(7, &m_dcOffsetCorrection, false);
|
||||
d.readBool(8, &m_iqImbalanceCorrection, false);
|
||||
d.readBlob(9, &m_scopeConfig);
|
||||
d.readString(10, &m_source);
|
||||
d.readBlob(11, &m_sourceGeneralConfig);
|
||||
d.readBlob(12, &m_sourceConfig);
|
||||
d.readBlob(4, &m_layout);
|
||||
d.readBlob(5, &m_spectrumConfig);
|
||||
d.readBool(6, &m_dcOffsetCorrection, false);
|
||||
d.readBool(7, &m_iqImbalanceCorrection, false);
|
||||
d.readBlob(8, &m_scopeConfig);
|
||||
d.readString(9, &m_source);
|
||||
d.readBlob(10, &m_sourceConfig);
|
||||
|
||||
qDebug() << " m_group: " << m_group.toStdString().c_str();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user