1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-03-23 12:48:49 -04:00

AirspyHF: use float version as default

This commit is contained in:
f4exb 2018-02-05 08:38:47 +01:00
parent 8a6ef95903
commit f426139e45
27 changed files with 363 additions and 362 deletions

View File

@ -40,7 +40,7 @@ endif(LIBUSB_FOUND AND LIBAIRSPY_FOUND)
find_package(LibAIRSPYHF)
if(LIBUSB_FOUND AND LIBAIRSPYHF_FOUND)
add_subdirectory(airspyhf)
add_subdirectory(airspyhff)
add_subdirectory(airspyhfi)
endif(LIBUSB_FOUND AND LIBAIRSPYHF_FOUND)
find_package(LibHACKRF)

View File

@ -19,8 +19,6 @@
#include <libairspyhf/airspyhf.h>
#include "airspyhfgui.h"
#include <device/devicesourceapi.h>
#include "device/deviceuiset.h"
#include <dsp/filerecord.h>
@ -30,6 +28,7 @@
#include "gui/glspectrum.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "airspyhfgui.h"
AirspyHFGui::AirspyHFGui(DeviceUISet *deviceUISet, QWidget* parent) :
QWidget(parent),
@ -219,7 +218,6 @@ void AirspyHFGui::displaySettings()
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->LOppm->setValue(m_settings.m_LOppmTenths);
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
ui->autoCorr->setCurrentIndex(m_settings.m_autoCorrOptions);
ui->sampleRate->setCurrentIndex(m_settings.m_devSampleRateIndex);
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
ui->band->blockSignals(false);
@ -278,16 +276,6 @@ void AirspyHFGui::on_resetLOppm_clicked()
ui->LOppm->setValue(0);
}
void AirspyHFGui::on_autoCorr_currentIndexChanged(int index)
{
if ((index < 0) || (index > AirspyHFSettings::AutoCorrLast)) {
return;
}
m_settings.m_autoCorrOptions = (AirspyHFSettings::AutoCorrOptions) index;
sendSettings();
}
void AirspyHFGui::on_sampleRate_currentIndexChanged(int index)
{
m_settings.m_devSampleRateIndex = index;

View File

@ -22,6 +22,7 @@
#include <QWidget>
#include "util/messagequeue.h"
#include "airspyhfinput.h"
class DeviceUISet;
@ -79,7 +80,6 @@ private slots:
void on_centerFrequency_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void on_resetLOppm_clicked();
void on_autoCorr_currentIndexChanged(int index);
void on_sampleRate_currentIndexChanged(int index);
void on_decim_currentIndexChanged(int index);
void on_startStop_toggled(bool checked);

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>324</width>
<height>174</height>
<height>132</height>
</rect>
</property>
<property name="sizePolicy">
@ -237,52 +237,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="autoCorrLayout">
<item>
<widget class="QLabel" name="autoCorrLabel">
<property name="text">
<string>Corr</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="autoCorr">
<property name="toolTip">
<string>DC offset and IQ correction options</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>DC</string>
</property>
</item>
<item>
<property name="text">
<string>DC+IQ</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_freq">
<property name="orientation">

View File

@ -21,14 +21,15 @@
#include "SWGDeviceSettings.h"
#include "SWGDeviceState.h"
#include "airspyhfgui.h"
#include "airspyhfinput.h"
#include "airspyhfplugin.h"
#include <device/devicesourceapi.h>
#include <dsp/filerecord.h>
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "airspyhfinput.h"
#include "airspyhfgui.h"
#include "airspyhfplugin.h"
#include "airspyhfsettings.h"
#include "airspyhfthread.h"
@ -87,12 +88,12 @@ bool AirspyHFInput::openDevice()
if ((m_dev = open_airspyhf_from_serial(m_deviceAPI->getSampleSourceSerial())) == 0)
{
qCritical("AirspyHFInput::start: could not open Airspy with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
qCritical("AirspyHFInput::start: could not open Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
return false;
}
else
{
qDebug("AirspyHFInput::start: opened Airspy with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
qDebug("AirspyHFInput::start: opened Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
}
uint32_t nbSampleRates;
@ -102,11 +103,11 @@ bool AirspyHFInput::openDevice()
if (rc == AIRSPYHF_SUCCESS)
{
qDebug("AirspyHFInput::start: %d sample rates for AirspyHF", nbSampleRates);
qDebug("AirspyHFInput::start: %d sample rates for Airspy HF", nbSampleRates);
}
else
{
qCritical("AirspyHFInput::start: could not obtain the number of AirspyHF sample rates");
qCritical("AirspyHFInput::start: could not obtain the number of Airspy HF sample rates");
return false;
}
@ -116,11 +117,11 @@ bool AirspyHFInput::openDevice()
if (rc == AIRSPYHF_SUCCESS)
{
qDebug("AirspyHFInput::start: obtained AirspyHF sample rates");
qDebug("AirspyHFInput::start: obtained Airspy HF sample rates");
}
else
{
qCritical("AirspyHFInput::start: could not obtain AirspyHF sample rates");
qCritical("AirspyHFInput::start: could not obtain Airspy HF sample rates");
return false;
}
@ -134,7 +135,7 @@ bool AirspyHFInput::openDevice()
delete[] sampleRates;
airspyhf_set_sample_type(m_dev, AIRSPYHF_SAMPLE_INT16_NDSP_IQ);
airspyhf_set_sample_type(m_dev, AIRSPYHF_SAMPLE_FLOAT32_IQ);
return true;
}
@ -349,23 +350,6 @@ bool AirspyHFInput::applySettings(const AirspyHFSettings& settings, bool force)
qDebug() << "AirspyHFInput::applySettings";
if ((m_settings.m_autoCorrOptions != settings.m_autoCorrOptions) || force)
{
switch(settings.m_autoCorrOptions)
{
case AirspyHFSettings::AutoCorrDC:
m_deviceAPI->configureCorrections(true, false);
break;
case AirspyHFSettings::AutoCorrDCAndIQ:
m_deviceAPI->configureCorrections(true, true);
break;
case AirspyHFSettings::AutoCorrNone:
default:
m_deviceAPI->configureCorrections(false, false);
break;
}
}
if ((m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex) || force)
{
forwardChange = true;

View File

@ -22,6 +22,7 @@
#include <libairspyhf/airspyhf.h>
#include <dsp/devicesamplesource.h>
#include "airspyhfsettings.h"
class DeviceSourceAPI;

View File

@ -18,12 +18,11 @@
#include <QAction>
#include <libairspyhf/airspyhf.h>
#include "airspyhfgui.h"
#include "airspyhfplugin.h"
#include <device/devicesourceapi.h>
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "airspyhfplugin.h"
#include "airspyhfgui.h"
const PluginDescriptor AirspyHFPlugin::m_pluginDescriptor = {
@ -84,7 +83,7 @@ PluginInterface::SamplingDevices AirspyHFPlugin::enumSampleSources()
1,
0));
qDebug("AirspyPlugin::enumSampleSources: enumerated Airspy device #%d", i);
qDebug("AirspyHFPlugin::enumSampleSources: enumerated Airspy HF device #%d", i);
}
else
{

View File

@ -50,4 +50,4 @@ private:
static const PluginDescriptor m_pluginDescriptor;
};
#endif // INCLUDE_AIRSPYPLUGIN_H
#endif // INCLUDE_AIRSPYHFPLUGIN_H

View File

@ -16,6 +16,7 @@
#include <QtGlobal>
#include "util/simpleserializer.h"
#include "airspyhfsettings.h"
AirspyHFSettings::AirspyHFSettings()
@ -32,7 +33,6 @@ void AirspyHFSettings::resetToDefaults()
m_transverterMode = false;
m_transverterDeltaFrequency = 0;
m_bandIndex = 0;
m_autoCorrOptions = AutoCorrNone;
}
QByteArray AirspyHFSettings::serialize() const
@ -42,7 +42,6 @@ QByteArray AirspyHFSettings::serialize() const
s.writeU32(1, m_devSampleRateIndex);
s.writeS32(2, m_LOppmTenths);
s.writeU32(3, m_log2Decim);
s.writeS32(4, (int) m_autoCorrOptions);
s.writeBool(7, m_transverterMode);
s.writeS64(8, m_transverterDeltaFrequency);
s.writeU32(9, m_bandIndex);
@ -69,13 +68,6 @@ bool AirspyHFSettings::deserialize(const QByteArray& data)
d.readS32(2, &m_LOppmTenths, 0);
d.readU32(3, &m_log2Decim, 0);
d.readS32(4, &intval, 0);
if (intval < 0 || intval > (int) AutoCorrLast) {
m_autoCorrOptions = AutoCorrNone;
} else {
m_autoCorrOptions = (AutoCorrOptions) intval;
}
d.readBool(7, &m_transverterMode, false);
d.readS64(8, &m_transverterDeltaFrequency, 0);
d.readU32(9, &uintval, 0);

View File

@ -14,18 +14,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef _AIRSPYHF_AIRSPYHFSETTINGS_H_
#define _AIRSPYHF_AIRSPYHFSETTINGS_H_
#ifndef _AIRSPYHFF_AIRSPYHFSETTINGS_H_
#define _AIRSPYHFF_AIRSPYHFSETTINGS_H_
struct AirspyHFSettings
{
typedef enum {
AutoCorrNone,
AutoCorrDC,
AutoCorrDCAndIQ,
AutoCorrLast,
} AutoCorrOptions;
quint64 m_centerFrequency;
qint32 m_LOppmTenths;
quint32 m_devSampleRateIndex;
@ -33,7 +26,6 @@ struct AirspyHFSettings
bool m_transverterMode;
qint64 m_transverterDeltaFrequency;
quint32 m_bandIndex;
AutoCorrOptions m_autoCorrOptions;
AirspyHFSettings();
void resetToDefaults();
@ -41,4 +33,4 @@ struct AirspyHFSettings
bool deserialize(const QByteArray& data);
};
#endif /* _AIRSPYHF_AIRSPYHFSETTINGS_H_ */
#endif /* _AIRSPYHFF_AIRSPYHFSETTINGS_H_ */

View File

@ -17,9 +17,8 @@
#include <stdio.h>
#include <errno.h>
#include "airspyhfthread.h"
#include "dsp/samplesinkfifo.h"
#include "airspyhfthread.h"
AirspyHFThread *AirspyHFThread::m_this = 0;
@ -78,7 +77,7 @@ void AirspyHFThread::run()
if (rc != AIRSPYHF_SUCCESS)
{
qCritical("AirspyHFThread::run: failed to start Airspy Rx");
qCritical("AirspyHFFThread::run: failed to start Airspy HF Rx");
}
else
{
@ -91,16 +90,16 @@ void AirspyHFThread::run()
rc = (airspyhf_error) airspyhf_stop(m_dev);
if (rc == AIRSPYHF_SUCCESS) {
qDebug("AirspyHFThread::run: stopped Airspy Rx");
qDebug("AirspyHFFThread::run: stopped Airspy HF Rx");
} else {
qDebug("AirspyHFThread::run: failed to stop Airspy Rx");
qDebug("AirspyHFFThread::run: failed to stop Airspy HF Rx");
}
m_running = false;
}
// Decimate according to specified log2 (ex: log2=4 => decim=16)
void AirspyHFThread::callback(const qint16* buf, qint32 len)
void AirspyHFThread::callback(const float* buf, qint32 len)
{
SampleVector::iterator it = m_convertBuffer.begin();
@ -137,7 +136,7 @@ void AirspyHFThread::callback(const qint16* buf, qint32 len)
int AirspyHFThread::rx_callback(airspyhf_transfer_t* transfer)
{
qint32 bytes_to_write = transfer->sample_count * sizeof(qint16);
m_this->callback((qint16 *) transfer->samples, bytes_to_write);
qint32 nbIAndQ = transfer->sample_count * 2;
m_this->callback((float *) transfer->samples, nbIAndQ);
return 0;
}

View File

@ -23,7 +23,7 @@
#include <libairspyhf/airspyhf.h>
#include "dsp/samplesinkfifo.h"
#include "dsp/decimators.h"
#include "dsp/decimatorsf.h"
#define AIRSPYHF_BLOCKSIZE (1<<17)
@ -53,14 +53,10 @@ private:
unsigned int m_log2Decim;
static AirspyHFThread *m_this;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 16> m_decimators;
#else
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16> m_decimators;
#endif
DecimatorsF m_decimators;
void run();
void callback(const qint16* buf, qint32 len);
void callback(const float* buf, qint32 len);
static int rx_callback(airspyhf_transfer_t* transfer);
};

View File

@ -1,25 +1,25 @@
project(airspyhff)
project(airspyhfi)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(airspyhff_SOURCES
airspyhffgui.cpp
airspyhffinput.cpp
airspyhffplugin.cpp
airspyhffsettings.cpp
airspyhffthread.cpp
set(airspyhfi_SOURCES
airspyhfigui.cpp
airspyhfiinput.cpp
airspyhfiplugin.cpp
airspyhfisettings.cpp
airspyhfithread.cpp
)
set(airspyhff_HEADERS
airspyhffgui.h
airspyhffinput.h
airspyhffplugin.h
airspyhffsettings.h
airspyhffthread.h
set(airspyhfi_HEADERS
airspyhfigui.h
airspyhfiinput.h
airspyhfiplugin.h
airspyhfisettings.h
airspyhfithread.h
)
set(airspyhff_FORMS
airspyhffgui.ui
set(airspyhfi_FORMS
airspyhfigui.ui
)
if (BUILD_DEBIAN)
@ -45,25 +45,25 @@ add_definitions("${QT_DEFINITIONS} -DLIBAIRSPY_DYN_RATES")
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
#qt4_wrap_cpp(airspyhff_HEADERS_MOC ${airspyhff_HEADERS})
qt5_wrap_ui(airspyhff_FORMS_HEADERS ${airspyhff_FORMS})
#qt4_wrap_cpp(airspyhf_HEADERS_MOC ${airspyhf_HEADERS})
qt5_wrap_ui(airspyhfi_FORMS_HEADERS ${airspyhfi_FORMS})
add_library(inputairspyhff SHARED
${airspyhff_SOURCES}
${airspyhff_HEADERS_MOC}
${airspyhff_FORMS_HEADERS}
add_library(inputairspyhfi SHARED
${airspyhfi_SOURCES}
${airspyhfi_HEADERS_MOC}
${airspyhfi_FORMS_HEADERS}
)
if (BUILD_DEBIAN)
target_link_libraries(inputairspyhff
target_link_libraries(inputairspyhfi
${QT_LIBRARIES}
airspyhff
airspyhf
sdrbase
sdrgui
swagger
)
else (BUILD_DEBIAN)
target_link_libraries(inputairspyhff
target_link_libraries(inputairspyhfi
${QT_LIBRARIES}
${LIBAIRSPYHF_LIBRARIES}
sdrbase
@ -73,6 +73,6 @@ target_link_libraries(inputairspyhff
endif (BUILD_DEBIAN)
qt5_use_modules(inputairspyhff Core Widgets)
qt5_use_modules(inputairspyhfi Core Widgets)
install(TARGETS inputairspyhff DESTINATION lib/plugins/samplesource)
install(TARGETS inputairspyhfi DESTINATION lib/plugins/samplesource)

View File

@ -9,7 +9,7 @@ CONFIG += plugin
QT += core gui widgets multimedia opengl
TARGET = inputairspyhff
TARGET = inputairspyhfi
CONFIG(MINGW32):LIBAIRSPYHFSRC = "D:\softs\airspyhf"
CONFIG(MINGW64):LIBAIRSPYHFSRC = "D:\softs\airspyhf"
@ -28,19 +28,19 @@ QMAKE_CXXFLAGS += -std=c++11
CONFIG(Release):build_subdir = release
CONFIG(Debug):build_subdir = debug
SOURCES += airspyhffgui.cpp\
airspyhffinput.cpp\
airspyhffplugin.cpp\
airspyhffsettings.cpp\
airspyhffthread.cpp
SOURCES += airspyhfigui.cpp\
airspyhfiinput.cpp\
airspyhfiplugin.cpp\
airspyhfisettings.cpp\
airspyhfithread.cpp
HEADERS += airspyhffgui.h\
airspyhffinput.h\
airspyhffplugin.h\
airspyhffsettings.h\
airspyhffthread.h
HEADERS += airspyhfigui.h\
airspyhfiinput.h\
airspyhfiplugin.h\
airspyhfisettings.h\
airspyhfithread.h
FORMS += airspyhffgui.ui
FORMS += airspyhfigui.ui
LIBS += -L../../../sdrbase/$${build_subdir} -lsdrbase
LIBS += -L../../../sdrgui/$${build_subdir} -lsdrgui

View File

@ -23,16 +23,16 @@
#include "device/deviceuiset.h"
#include <dsp/filerecord.h>
#include "ui_airspyhffgui.h"
#include "ui_airspyhfigui.h"
#include "gui/colormapper.h"
#include "gui/glspectrum.h"
#include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "airspyhffgui.h"
#include "airspyhfigui.h"
AirspyHFFGui::AirspyHFFGui(DeviceUISet *deviceUISet, QWidget* parent) :
AirspyHFIGui::AirspyHFIGui(DeviceUISet *deviceUISet, QWidget* parent) :
QWidget(parent),
ui(new Ui::AirspyHFFGui),
ui(new Ui::AirspyHFIGui),
m_deviceUISet(deviceUISet),
m_doApplySettings(true),
m_forceSettings(true),
@ -40,7 +40,7 @@ AirspyHFFGui::AirspyHFFGui(DeviceUISet *deviceUISet, QWidget* parent) :
m_sampleSource(0),
m_lastEngineState((DSPDeviceSourceEngine::State)-1)
{
m_sampleSource = (AirspyHFFInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
m_sampleSource = (AirspyHFIInput*) m_deviceUISet->m_deviceSourceAPI->getSampleSource();
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
@ -52,58 +52,58 @@ AirspyHFFGui::AirspyHFFGui(DeviceUISet *deviceUISet, QWidget* parent) :
displaySettings();
m_rates = ((AirspyHFFInput*) m_sampleSource)->getSampleRates();
m_rates = ((AirspyHFIInput*) m_sampleSource)->getSampleRates();
displaySampleRates();
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()), Qt::QueuedConnection);
sendSettings();
}
AirspyHFFGui::~AirspyHFFGui()
AirspyHFIGui::~AirspyHFIGui()
{
delete ui;
}
void AirspyHFFGui::destroy()
void AirspyHFIGui::destroy()
{
delete this;
}
void AirspyHFFGui::setName(const QString& name)
void AirspyHFIGui::setName(const QString& name)
{
setObjectName(name);
}
QString AirspyHFFGui::getName() const
QString AirspyHFIGui::getName() const
{
return objectName();
}
void AirspyHFFGui::resetToDefaults()
void AirspyHFIGui::resetToDefaults()
{
m_settings.resetToDefaults();
displaySettings();
sendSettings();
}
qint64 AirspyHFFGui::getCenterFrequency() const
qint64 AirspyHFIGui::getCenterFrequency() const
{
return m_settings.m_centerFrequency;
}
void AirspyHFFGui::setCenterFrequency(qint64 centerFrequency)
void AirspyHFIGui::setCenterFrequency(qint64 centerFrequency)
{
m_settings.m_centerFrequency = centerFrequency;
displaySettings();
sendSettings();
}
QByteArray AirspyHFFGui::serialize() const
QByteArray AirspyHFIGui::serialize() const
{
return m_settings.serialize();
}
bool AirspyHFFGui::deserialize(const QByteArray& data)
bool AirspyHFIGui::deserialize(const QByteArray& data)
{
if(m_settings.deserialize(data)) {
displaySettings();
@ -116,20 +116,20 @@ bool AirspyHFFGui::deserialize(const QByteArray& data)
}
}
bool AirspyHFFGui::handleMessage(const Message& message)
bool AirspyHFIGui::handleMessage(const Message& message)
{
if (AirspyHFFInput::MsgConfigureAirspyHF::match(message))
if (AirspyHFIInput::MsgConfigureAirspyHFI::match(message))
{
const AirspyHFFInput::MsgConfigureAirspyHF& cfg = (AirspyHFFInput::MsgConfigureAirspyHF&) message;
const AirspyHFIInput::MsgConfigureAirspyHFI& cfg = (AirspyHFIInput::MsgConfigureAirspyHFI&) message;
m_settings = cfg.getSettings();
blockApplySettings(true);
displaySettings();
blockApplySettings(false);
return true;
}
else if (AirspyHFFInput::MsgStartStop::match(message))
else if (AirspyHFIInput::MsgStartStop::match(message))
{
AirspyHFFInput::MsgStartStop& notif = (AirspyHFFInput::MsgStartStop&) message;
AirspyHFIInput::MsgStartStop& notif = (AirspyHFIInput::MsgStartStop&) message;
blockApplySettings(true);
ui->startStop->setChecked(notif.getStartStop());
blockApplySettings(false);
@ -142,7 +142,7 @@ bool AirspyHFFGui::handleMessage(const Message& message)
}
}
void AirspyHFFGui::handleInputMessages()
void AirspyHFIGui::handleInputMessages()
{
Message* message;
@ -170,14 +170,14 @@ void AirspyHFFGui::handleInputMessages()
}
}
void AirspyHFFGui::updateSampleRateAndFrequency()
void AirspyHFIGui::updateSampleRateAndFrequency()
{
m_deviceUISet->getSpectrum()->setSampleRate(m_sampleRate);
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000));
}
void AirspyHFFGui::updateFrequencyLimits()
void AirspyHFIGui::updateFrequencyLimits()
{
// values in kHz
qint64 deltaFrequency = m_settings.m_transverterMode ? m_settings.m_transverterDeltaFrequency/1000 : 0;
@ -188,13 +188,13 @@ void AirspyHFFGui::updateFrequencyLimits()
switch(m_settings.m_bandIndex)
{
case 1:
minLimit = AirspyHFFInput::loLowLimitFreqVHF/1000 + deltaFrequency;
maxLimit = AirspyHFFInput::loHighLimitFreqVHF/1000 + deltaFrequency;
minLimit = AirspyHFIInput::loLowLimitFreqVHF/1000 + deltaFrequency;
maxLimit = AirspyHFIInput::loHighLimitFreqVHF/1000 + deltaFrequency;
break;
case 0:
default:
minLimit = AirspyHFFInput::loLowLimitFreqHF/1000 + deltaFrequency;
maxLimit = AirspyHFFInput::loHighLimitFreqHF/1000 + deltaFrequency;
minLimit = AirspyHFIInput::loLowLimitFreqHF/1000 + deltaFrequency;
maxLimit = AirspyHFIInput::loHighLimitFreqHF/1000 + deltaFrequency;
break;
}
@ -206,7 +206,7 @@ void AirspyHFFGui::updateFrequencyLimits()
ui->centerFrequency->setValueRange(7, minLimit, maxLimit);
}
void AirspyHFFGui::displaySettings()
void AirspyHFIGui::displaySettings()
{
blockApplySettings(true);
ui->band->blockSignals(true);
@ -218,13 +218,14 @@ void AirspyHFFGui::displaySettings()
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
ui->LOppm->setValue(m_settings.m_LOppmTenths);
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
ui->autoCorr->setCurrentIndex(m_settings.m_autoCorrOptions);
ui->sampleRate->setCurrentIndex(m_settings.m_devSampleRateIndex);
ui->decim->setCurrentIndex(m_settings.m_log2Decim);
ui->band->blockSignals(false);
blockApplySettings(false);
}
void AirspyHFFGui::displaySampleRates()
void AirspyHFIGui::displaySampleRates()
{
unsigned int savedIndex = m_settings.m_devSampleRateIndex;
ui->sampleRate->blockSignals(true);
@ -252,37 +253,47 @@ void AirspyHFFGui::displaySampleRates()
}
}
void AirspyHFFGui::sendSettings()
void AirspyHFIGui::sendSettings()
{
if(!m_updateTimer.isActive())
m_updateTimer.start(100);
}
void AirspyHFFGui::on_centerFrequency_changed(quint64 value)
void AirspyHFIGui::on_centerFrequency_changed(quint64 value)
{
m_settings.m_centerFrequency = value * 1000;
sendSettings();
}
void AirspyHFFGui::on_LOppm_valueChanged(int value)
void AirspyHFIGui::on_LOppm_valueChanged(int value)
{
m_settings.m_LOppmTenths = value;
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
sendSettings();
}
void AirspyHFFGui::on_resetLOppm_clicked()
void AirspyHFIGui::on_resetLOppm_clicked()
{
ui->LOppm->setValue(0);
}
void AirspyHFFGui::on_sampleRate_currentIndexChanged(int index)
void AirspyHFIGui::on_autoCorr_currentIndexChanged(int index)
{
if ((index < 0) || (index > AirspyHFISettings::AutoCorrLast)) {
return;
}
m_settings.m_autoCorrOptions = (AirspyHFISettings::AutoCorrOptions) index;
sendSettings();
}
void AirspyHFIGui::on_sampleRate_currentIndexChanged(int index)
{
m_settings.m_devSampleRateIndex = index;
sendSettings();
}
void AirspyHFFGui::on_decim_currentIndexChanged(int index)
void AirspyHFIGui::on_decim_currentIndexChanged(int index)
{
if ((index < 0) || (index > 5))
return;
@ -290,16 +301,16 @@ void AirspyHFFGui::on_decim_currentIndexChanged(int index)
sendSettings();
}
void AirspyHFFGui::on_startStop_toggled(bool checked)
void AirspyHFIGui::on_startStop_toggled(bool checked)
{
if (m_doApplySettings)
{
AirspyHFFInput::MsgStartStop *message = AirspyHFFInput::MsgStartStop::create(checked);
AirspyHFIInput::MsgStartStop *message = AirspyHFIInput::MsgStartStop::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
}
}
void AirspyHFFGui::on_record_toggled(bool checked)
void AirspyHFIGui::on_record_toggled(bool checked)
{
if (checked) {
ui->record->setStyleSheet("QToolButton { background-color : red; }");
@ -307,11 +318,11 @@ void AirspyHFFGui::on_record_toggled(bool checked)
ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
}
AirspyHFFInput::MsgFileRecord* message = AirspyHFFInput::MsgFileRecord::create(checked);
AirspyHFIInput::MsgFileRecord* message = AirspyHFIInput::MsgFileRecord::create(checked);
m_sampleSource->getInputMessageQueue()->push(message);
}
void AirspyHFFGui::on_transverter_clicked()
void AirspyHFIGui::on_transverter_clicked()
{
m_settings.m_transverterMode = ui->transverter->getDeltaFrequencyAcive();
m_settings.m_transverterDeltaFrequency = ui->transverter->getDeltaFrequency();
@ -321,7 +332,7 @@ void AirspyHFFGui::on_transverter_clicked()
sendSettings();
}
void AirspyHFFGui::on_band_currentIndexChanged(int index)
void AirspyHFIGui::on_band_currentIndexChanged(int index)
{
if ((index < 0) || (index > 1)) {
return;
@ -334,16 +345,16 @@ void AirspyHFFGui::on_band_currentIndexChanged(int index)
sendSettings();
}
void AirspyHFFGui::updateHardware()
void AirspyHFIGui::updateHardware()
{
qDebug() << "AirspyHFGui::updateHardware";
AirspyHFFInput::MsgConfigureAirspyHF* message = AirspyHFFInput::MsgConfigureAirspyHF::create(m_settings, m_forceSettings);
AirspyHFIInput::MsgConfigureAirspyHFI* message = AirspyHFIInput::MsgConfigureAirspyHFI::create(m_settings, m_forceSettings);
m_sampleSource->getInputMessageQueue()->push(message);
m_forceSettings = false;
m_updateTimer.stop();
}
void AirspyHFFGui::updateStatus()
void AirspyHFIGui::updateStatus()
{
int state = m_deviceUISet->m_deviceSourceAPI->state();
@ -372,7 +383,7 @@ void AirspyHFFGui::updateStatus()
}
}
uint32_t AirspyHFFGui::getDevSampleRate(unsigned int rate_index)
uint32_t AirspyHFIGui::getDevSampleRate(unsigned int rate_index)
{
if (rate_index < m_rates.size())
{
@ -384,7 +395,7 @@ uint32_t AirspyHFFGui::getDevSampleRate(unsigned int rate_index)
}
}
int AirspyHFFGui::getDevSampleRateIndex(uint32_t sampeRate)
int AirspyHFIGui::getDevSampleRateIndex(uint32_t sampeRate)
{
for (unsigned int i=0; i < m_rates.size(); i++)
{

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AIRSPYHFFGUI_H
#define INCLUDE_AIRSPYHFFGUI_H
#ifndef INCLUDE_AIRSPYHFIGUI_H
#define INCLUDE_AIRSPYHFIGUI_H
#include <plugin/plugininstancegui.h>
#include <QTimer>
@ -23,21 +23,21 @@
#include "util/messagequeue.h"
#include "airspyhffinput.h"
#include "airspyhfiinput.h"
class DeviceUISet;
namespace Ui {
class AirspyHFFGui;
class AirspyHFFSampleRates;
class AirspyHFIGui;
class AirspyHFISampleRates;
}
class AirspyHFFGui : public QWidget, public PluginInstanceGUI {
class AirspyHFIGui : public QWidget, public PluginInstanceGUI {
Q_OBJECT
public:
explicit AirspyHFFGui(DeviceUISet *deviceUISet, QWidget* parent = 0);
virtual ~AirspyHFFGui();
explicit AirspyHFIGui(DeviceUISet *deviceUISet, QWidget* parent = 0);
virtual ~AirspyHFIGui();
virtual void destroy();
void setName(const QString& name);
@ -54,12 +54,12 @@ public:
int getDevSampleRateIndex(uint32_t sampleRate);
private:
Ui::AirspyHFFGui* ui;
Ui::AirspyHFIGui* ui;
DeviceUISet* m_deviceUISet;
bool m_doApplySettings;
bool m_forceSettings;
AirspyHFFSettings m_settings;
AirspyHFISettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<uint32_t> m_rates;
@ -80,6 +80,7 @@ private slots:
void on_centerFrequency_changed(quint64 value);
void on_LOppm_valueChanged(int value);
void on_resetLOppm_clicked();
void on_autoCorr_currentIndexChanged(int index);
void on_sampleRate_currentIndexChanged(int index);
void on_decim_currentIndexChanged(int index);
void on_startStop_toggled(bool checked);
@ -91,4 +92,4 @@ private slots:
void handleInputMessages();
};
#endif // INCLUDE_AIRSPYHFGUI_H
#endif // INCLUDE_AIRSPYHFIGUI_H

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AirspyHFFGui</class>
<widget class="QWidget" name="AirspyHFFGui">
<class>AirspyHFIGui</class>
<widget class="QWidget" name="AirspyHFIGui">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>132</height>
<height>174</height>
</rect>
</property>
<property name="sizePolicy">
@ -237,6 +237,52 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="autoCorrLayout">
<item>
<widget class="QLabel" name="autoCorrLabel">
<property name="text">
<string>Corr</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="autoCorr">
<property name="toolTip">
<string>DC offset and IQ correction options</string>
</property>
<item>
<property name="text">
<string>None</string>
</property>
</item>
<item>
<property name="text">
<string>DC</string>
</property>
</item>
<item>
<property name="text">
<string>DC+IQ</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_freq">
<property name="orientation">

View File

@ -26,28 +26,28 @@
#include "dsp/dspcommands.h"
#include "dsp/dspengine.h"
#include "airspyhffinput.h"
#include "airspyhfisettings.h"
#include "airspyhfiinput.h"
#include "airspyhffgui.h"
#include "airspyhffplugin.h"
#include "airspyhffsettings.h"
#include "airspyhffthread.h"
#include "airspyhfiplugin.h"
#include "airspyhfithread.h"
#include "airspyhfigui.h"
MESSAGE_CLASS_DEFINITION(AirspyHFFInput::MsgConfigureAirspyHF, Message)
MESSAGE_CLASS_DEFINITION(AirspyHFFInput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(AirspyHFFInput::MsgFileRecord, Message)
MESSAGE_CLASS_DEFINITION(AirspyHFIInput::MsgConfigureAirspyHFI, Message)
MESSAGE_CLASS_DEFINITION(AirspyHFIInput::MsgStartStop, Message)
MESSAGE_CLASS_DEFINITION(AirspyHFIInput::MsgFileRecord, Message)
const qint64 AirspyHFFInput::loLowLimitFreqHF = 9000L;
const qint64 AirspyHFFInput::loHighLimitFreqHF = 31000000L;
const qint64 AirspyHFFInput::loLowLimitFreqVHF = 60000000L;
const qint64 AirspyHFFInput::loHighLimitFreqVHF = 260000000L;
const qint64 AirspyHFIInput::loLowLimitFreqHF = 9000L;
const qint64 AirspyHFIInput::loHighLimitFreqHF = 31000000L;
const qint64 AirspyHFIInput::loLowLimitFreqVHF = 60000000L;
const qint64 AirspyHFIInput::loHighLimitFreqVHF = 260000000L;
AirspyHFFInput::AirspyHFFInput(DeviceSourceAPI *deviceAPI) :
AirspyHFIInput::AirspyHFIInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI(deviceAPI),
m_settings(),
m_dev(0),
m_airspyHFThread(0),
m_deviceDescription("AirspyHFF"),
m_deviceDescription("AirspyHFI"),
m_running(false)
{
openDevice();
@ -58,7 +58,7 @@ AirspyHFFInput::AirspyHFFInput(DeviceSourceAPI *deviceAPI) :
m_deviceAPI->addSink(m_fileSink);
}
AirspyHFFInput::~AirspyHFFInput()
AirspyHFIInput::~AirspyHFIInput()
{
if (m_running) { stop(); }
m_deviceAPI->removeSink(m_fileSink);
@ -66,12 +66,12 @@ AirspyHFFInput::~AirspyHFFInput()
closeDevice();
}
void AirspyHFFInput::destroy()
void AirspyHFIInput::destroy()
{
delete this;
}
bool AirspyHFFInput::openDevice()
bool AirspyHFIInput::openDevice()
{
if (m_dev != 0)
{
@ -82,18 +82,18 @@ bool AirspyHFFInput::openDevice()
if (!m_sampleFifo.setSize(1<<19))
{
qCritical("AirspyHFFInput::start: could not allocate SampleFifo");
qCritical("AirspyHFInput::start: could not allocate SampleFifo");
return false;
}
if ((m_dev = open_airspyhf_from_serial(m_deviceAPI->getSampleSourceSerial())) == 0)
{
qCritical("AirspyHFFInput::start: could not open Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
qCritical("AirspyHFInput::start: could not open Airspy with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
return false;
}
else
{
qDebug("AirspyHFFInput::start: opened Airspy HF with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
qDebug("AirspyHFInput::start: opened Airspy with serial %s", qPrintable(m_deviceAPI->getSampleSourceSerial()));
}
uint32_t nbSampleRates;
@ -103,11 +103,11 @@ bool AirspyHFFInput::openDevice()
if (rc == AIRSPYHF_SUCCESS)
{
qDebug("AirspyHFFInput::start: %d sample rates for Airspy HF", nbSampleRates);
qDebug("AirspyHFInput::start: %d sample rates for AirspyHF", nbSampleRates);
}
else
{
qCritical("AirspyHFFInput::start: could not obtain the number of Airspy HF sample rates");
qCritical("AirspyHFInput::start: could not obtain the number of AirspyHF sample rates");
return false;
}
@ -117,11 +117,11 @@ bool AirspyHFFInput::openDevice()
if (rc == AIRSPYHF_SUCCESS)
{
qDebug("AirspyHFFInput::start: obtained Airspy HF sample rates");
qDebug("AirspyHFInput::start: obtained AirspyHF sample rates");
}
else
{
qCritical("AirspyHFFInput::start: could not obtain Airspy HF sample rates");
qCritical("AirspyHFInput::start: could not obtain AirspyHF sample rates");
return false;
}
@ -130,22 +130,22 @@ bool AirspyHFFInput::openDevice()
for (unsigned int i = 0; i < nbSampleRates; i++)
{
m_sampleRates.push_back(sampleRates[i]);
qDebug("AirspyHFFInput::start: sampleRates[%d] = %u Hz", i, sampleRates[i]);
qDebug("AirspyHFInput::start: sampleRates[%d] = %u Hz", i, sampleRates[i]);
}
delete[] sampleRates;
airspyhf_set_sample_type(m_dev, AIRSPYHF_SAMPLE_FLOAT32_IQ);
airspyhf_set_sample_type(m_dev, AIRSPYHF_SAMPLE_INT16_NDSP_IQ);
return true;
}
void AirspyHFFInput::init()
void AirspyHFIInput::init()
{
applySettings(m_settings, true);
}
bool AirspyHFFInput::start()
bool AirspyHFIInput::start()
{
QMutexLocker mutexLocker(&m_mutex);
@ -155,7 +155,7 @@ bool AirspyHFFInput::start()
if (m_running) { stop(); }
if ((m_airspyHFThread = new AirspyHFFThread(m_dev, &m_sampleFifo)) == 0)
if ((m_airspyHFThread = new AirspyHFIThread(m_dev, &m_sampleFifo)) == 0)
{
qFatal("AirspyHFInput::start: out of memory");
stop();
@ -177,7 +177,7 @@ bool AirspyHFFInput::start()
return true;
}
void AirspyHFFInput::closeDevice()
void AirspyHFIInput::closeDevice()
{
if (m_dev != 0)
{
@ -189,7 +189,7 @@ void AirspyHFFInput::closeDevice()
m_deviceDescription.clear();
}
void AirspyHFFInput::stop()
void AirspyHFIInput::stop()
{
qDebug("AirspyHFInput::stop");
QMutexLocker mutexLocker(&m_mutex);
@ -204,12 +204,12 @@ void AirspyHFFInput::stop()
m_running = false;
}
QByteArray AirspyHFFInput::serialize() const
QByteArray AirspyHFIInput::serialize() const
{
return m_settings.serialize();
}
bool AirspyHFFInput::deserialize(const QByteArray& data)
bool AirspyHFIInput::deserialize(const QByteArray& data)
{
bool success = true;
@ -219,54 +219,54 @@ bool AirspyHFFInput::deserialize(const QByteArray& data)
success = false;
}
MsgConfigureAirspyHF* message = MsgConfigureAirspyHF::create(m_settings, true);
MsgConfigureAirspyHFI* message = MsgConfigureAirspyHFI::create(m_settings, true);
m_inputMessageQueue.push(message);
if (m_guiMessageQueue)
{
MsgConfigureAirspyHF* messageToGUI = MsgConfigureAirspyHF::create(m_settings, true);
MsgConfigureAirspyHFI* messageToGUI = MsgConfigureAirspyHFI::create(m_settings, true);
m_guiMessageQueue->push(messageToGUI);
}
return success;
}
const QString& AirspyHFFInput::getDeviceDescription() const
const QString& AirspyHFIInput::getDeviceDescription() const
{
return m_deviceDescription;
}
int AirspyHFFInput::getSampleRate() const
int AirspyHFIInput::getSampleRate() const
{
int rate = m_sampleRates[m_settings.m_devSampleRateIndex];
return (rate / (1<<m_settings.m_log2Decim));
}
quint64 AirspyHFFInput::getCenterFrequency() const
quint64 AirspyHFIInput::getCenterFrequency() const
{
return m_settings.m_centerFrequency;
}
void AirspyHFFInput::setCenterFrequency(qint64 centerFrequency)
void AirspyHFIInput::setCenterFrequency(qint64 centerFrequency)
{
AirspyHFFSettings settings = m_settings;
AirspyHFISettings settings = m_settings;
settings.m_centerFrequency = centerFrequency;
MsgConfigureAirspyHF* message = MsgConfigureAirspyHF::create(settings, false);
MsgConfigureAirspyHFI* message = MsgConfigureAirspyHFI::create(settings, false);
m_inputMessageQueue.push(message);
if (m_guiMessageQueue)
{
MsgConfigureAirspyHF* messageToGUI = MsgConfigureAirspyHF::create(settings, false);
MsgConfigureAirspyHFI* messageToGUI = MsgConfigureAirspyHFI::create(settings, false);
m_guiMessageQueue->push(messageToGUI);
}
}
bool AirspyHFFInput::handleMessage(const Message& message)
bool AirspyHFIInput::handleMessage(const Message& message)
{
if (MsgConfigureAirspyHF::match(message))
if (MsgConfigureAirspyHFI::match(message))
{
MsgConfigureAirspyHF& conf = (MsgConfigureAirspyHF&) message;
MsgConfigureAirspyHFI& conf = (MsgConfigureAirspyHFI&) message;
qDebug() << "MsgConfigureAirspyHF::handleMessage: MsgConfigureAirspyHF";
bool success = applySettings(conf.getSettings(), conf.getForce());
@ -318,7 +318,7 @@ bool AirspyHFFInput::handleMessage(const Message& message)
}
}
void AirspyHFFInput::setDeviceCenterFrequency(quint64 freq_hz, const AirspyHFFSettings& settings)
void AirspyHFIInput::setDeviceCenterFrequency(quint64 freq_hz, const AirspyHFISettings& settings)
{
switch(settings.m_bandIndex)
{
@ -340,7 +340,7 @@ void AirspyHFFInput::setDeviceCenterFrequency(quint64 freq_hz, const AirspyHFFSe
}
}
bool AirspyHFFInput::applySettings(const AirspyHFFSettings& settings, bool force)
bool AirspyHFIInput::applySettings(const AirspyHFISettings& settings, bool force)
{
QMutexLocker mutexLocker(&m_mutex);
@ -350,6 +350,23 @@ bool AirspyHFFInput::applySettings(const AirspyHFFSettings& settings, bool force
qDebug() << "AirspyHFInput::applySettings";
if ((m_settings.m_autoCorrOptions != settings.m_autoCorrOptions) || force)
{
switch(settings.m_autoCorrOptions)
{
case AirspyHFISettings::AutoCorrDC:
m_deviceAPI->configureCorrections(true, false);
break;
case AirspyHFISettings::AutoCorrDCAndIQ:
m_deviceAPI->configureCorrections(true, true);
break;
case AirspyHFISettings::AutoCorrNone:
default:
m_deviceAPI->configureCorrections(false, false);
break;
}
}
if ((m_settings.m_devSampleRateIndex != settings.m_devSampleRateIndex) || force)
{
forwardChange = true;
@ -439,7 +456,7 @@ bool AirspyHFFInput::applySettings(const AirspyHFFSettings& settings, bool force
return true;
}
airspyhf_device_t *AirspyHFFInput::open_airspyhf_from_serial(const QString& serialStr)
airspyhf_device_t *AirspyHFIInput::open_airspyhf_from_serial(const QString& serialStr)
{
airspyhf_device_t *devinfo;
bool ok;
@ -464,7 +481,7 @@ airspyhf_device_t *AirspyHFFInput::open_airspyhf_from_serial(const QString& seri
}
}
int AirspyHFFInput::webapiRunGet(
int AirspyHFIInput::webapiRunGet(
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused)))
{
@ -472,7 +489,7 @@ int AirspyHFFInput::webapiRunGet(
return 200;
}
int AirspyHFFInput::webapiRun(
int AirspyHFIInput::webapiRun(
bool run,
SWGSDRangel::SWGDeviceState& response,
QString& errorMessage __attribute__((unused)))

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AIRSPYHFFINPUT_H
#define INCLUDE_AIRSPYHFFINPUT_H
#ifndef INCLUDE_AIRSPYHFIINPUT_H
#define INCLUDE_AIRSPYHFIINPUT_H
#include <QString>
#include <QByteArray>
@ -23,31 +23,31 @@
#include <libairspyhf/airspyhf.h>
#include <dsp/devicesamplesource.h>
#include "airspyhffsettings.h"
#include "airspyhfisettings.h"
class DeviceSourceAPI;
class AirspyHFFThread;
class AirspyHFIThread;
class FileRecord;
class AirspyHFFInput : public DeviceSampleSource {
class AirspyHFIInput : public DeviceSampleSource {
public:
class MsgConfigureAirspyHF : public Message {
class MsgConfigureAirspyHFI : public Message {
MESSAGE_CLASS_DECLARATION
public:
const AirspyHFFSettings& getSettings() const { return m_settings; }
const AirspyHFISettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
static MsgConfigureAirspyHF* create(const AirspyHFFSettings& settings, bool force)
static MsgConfigureAirspyHFI* create(const AirspyHFISettings& settings, bool force)
{
return new MsgConfigureAirspyHF(settings, force);
return new MsgConfigureAirspyHFI(settings, force);
}
private:
AirspyHFFSettings m_settings;
AirspyHFISettings m_settings;
bool m_force;
MsgConfigureAirspyHF(const AirspyHFFSettings& settings, bool force) :
MsgConfigureAirspyHFI(const AirspyHFISettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
@ -92,8 +92,8 @@ public:
{ }
};
AirspyHFFInput(DeviceSourceAPI *deviceAPI);
virtual ~AirspyHFFInput();
AirspyHFIInput(DeviceSourceAPI *deviceAPI);
virtual ~AirspyHFIInput();
virtual void destroy();
virtual void init();
@ -129,19 +129,19 @@ public:
private:
bool openDevice();
void closeDevice();
bool applySettings(const AirspyHFFSettings& settings, bool force);
bool applySettings(const AirspyHFISettings& settings, bool force);
airspyhf_device_t *open_airspyhf_from_serial(const QString& serialStr);
void setDeviceCenterFrequency(quint64 freq, const AirspyHFFSettings& settings);
void setDeviceCenterFrequency(quint64 freq, const AirspyHFISettings& settings);
DeviceSourceAPI *m_deviceAPI;
QMutex m_mutex;
AirspyHFFSettings m_settings;
AirspyHFISettings m_settings;
airspyhf_device_t* m_dev;
AirspyHFFThread* m_airspyHFThread;
AirspyHFIThread* m_airspyHFThread;
QString m_deviceDescription;
std::vector<uint32_t> m_sampleRates;
bool m_running;
FileRecord *m_fileSink; //!< File sink to record device I/Q output
};
#endif // INCLUDE_AIRSPYHFFINPUT_H
#endif // INCLUDE_AIRSPYHFIINPUT_H

View File

@ -21,12 +21,13 @@
#include <device/devicesourceapi.h>
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include "airspyhffplugin.h"
#include "airspyhffgui.h"
#include "airspyhfiplugin.h"
#include "airspyhfigui.h"
const PluginDescriptor AirspyHFFPlugin::m_pluginDescriptor = {
QString("AirspyHF Input (float)"),
const PluginDescriptor AirspyHFIPlugin::m_pluginDescriptor = {
QString("AirspyHF Input (int)"),
QString("3.12.0"),
QString("(c) Edouard Griffiths, F4EXB"),
QString("https://github.com/f4exb/sdrangel"),
@ -34,26 +35,26 @@ const PluginDescriptor AirspyHFFPlugin::m_pluginDescriptor = {
QString("https://github.com/f4exb/sdrangel")
};
const QString AirspyHFFPlugin::m_hardwareID = "AirspyHFF";
const QString AirspyHFFPlugin::m_deviceTypeID = AIRSPYHFF_DEVICE_TYPE_ID;
const int AirspyHFFPlugin::m_maxDevices = 32;
const QString AirspyHFIPlugin::m_hardwareID = "AirspyHFI";
const QString AirspyHFIPlugin::m_deviceTypeID = AIRSPYHFI_DEVICE_TYPE_ID;
const int AirspyHFIPlugin::m_maxDevices = 32;
AirspyHFFPlugin::AirspyHFFPlugin(QObject* parent) :
AirspyHFIPlugin::AirspyHFIPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& AirspyHFFPlugin::getPluginDescriptor() const
const PluginDescriptor& AirspyHFIPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void AirspyHFFPlugin::initPlugin(PluginAPI* pluginAPI)
void AirspyHFIPlugin::initPlugin(PluginAPI* pluginAPI)
{
pluginAPI->registerSampleSource(m_deviceTypeID, this);
}
PluginInterface::SamplingDevices AirspyHFFPlugin::enumSampleSources()
PluginInterface::SamplingDevices AirspyHFIPlugin::enumSampleSources()
{
SamplingDevices result;
int nbDevices;
@ -63,7 +64,7 @@ PluginInterface::SamplingDevices AirspyHFFPlugin::enumSampleSources()
if (nbDevices < 0)
{
qCritical("AirspyHFPlugin::enumSampleSources: failed to list Airspy HF devices");
qCritical("AirspyHFIPlugin::enumSampleSources: failed to list Airspy HF devices");
}
for (int i = 0; i < nbDevices; i++)
@ -71,7 +72,7 @@ PluginInterface::SamplingDevices AirspyHFFPlugin::enumSampleSources()
if (deviceSerials[i])
{
QString serial_str = QString::number(deviceSerials[i], 16);
QString displayedName(QString("AirspyHF(float)[%1] %2").arg(i).arg(serial_str));
QString displayedName(QString("AirspyHF(int)[%1] %2").arg(i).arg(serial_str));
result.append(SamplingDevice(displayedName,
m_hardwareID,
@ -83,11 +84,11 @@ PluginInterface::SamplingDevices AirspyHFFPlugin::enumSampleSources()
1,
0));
qDebug("AirspyHFFPlugin::enumSampleSources: enumerated Airspy HF device #%d", i);
qDebug("AirspyHFIPlugin::enumSampleSources: enumerated Airspy device #%d", i);
}
else
{
qDebug("AirspyHFFPlugin::enumSampleSources: finished to enumerate Airspy HF. %d devices found", i);
qDebug("AirspyHFIPlugin::enumSampleSources: finished to enumerate Airspy HF. %d devices found", i);
break; // finished
}
}
@ -95,14 +96,14 @@ PluginInterface::SamplingDevices AirspyHFFPlugin::enumSampleSources()
return result;
}
PluginInstanceGUI* AirspyHFFPlugin::createSampleSourcePluginInstanceGUI(
PluginInstanceGUI* AirspyHFIPlugin::createSampleSourcePluginInstanceGUI(
const QString& sourceId,
QWidget **widget,
DeviceUISet *deviceUISet)
{
if (sourceId == m_deviceTypeID)
{
AirspyHFFGui* gui = new AirspyHFFGui(deviceUISet);
AirspyHFIGui* gui = new AirspyHFIGui(deviceUISet);
*widget = gui;
return gui;
}
@ -112,11 +113,11 @@ PluginInstanceGUI* AirspyHFFPlugin::createSampleSourcePluginInstanceGUI(
}
}
DeviceSampleSource *AirspyHFFPlugin::createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI)
DeviceSampleSource *AirspyHFIPlugin::createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI)
{
if (sourceId == m_deviceTypeID)
{
AirspyHFFInput* input = new AirspyHFFInput(deviceAPI);
AirspyHFIInput* input = new AirspyHFIInput(deviceAPI);
return input;
}
else

View File

@ -14,23 +14,23 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AIRSPYHFFPLUGIN_H
#define INCLUDE_AIRSPYHFFPLUGIN_H
#ifndef INCLUDE_AIRSPYHFIPLUGIN_H
#define INCLUDE_AIRSPYHFIPLUGIN_H
#include <QObject>
#include "plugin/plugininterface.h"
#define AIRSPYHFF_DEVICE_TYPE_ID "sdrangel.samplesource.airspyhff"
#define AIRSPYHFI_DEVICE_TYPE_ID "sdrangel.samplesource.airspyhfi"
class PluginAPI;
class AirspyHFFPlugin : public QObject, public PluginInterface {
class AirspyHFIPlugin : public QObject, public PluginInterface {
Q_OBJECT
Q_INTERFACES(PluginInterface)
Q_PLUGIN_METADATA(IID AIRSPYHFF_DEVICE_TYPE_ID)
Q_PLUGIN_METADATA(IID AIRSPYHFI_DEVICE_TYPE_ID)
public:
explicit AirspyHFFPlugin(QObject* parent = 0);
explicit AirspyHFIPlugin(QObject* parent = 0);
const PluginDescriptor& getPluginDescriptor() const;
void initPlugin(PluginAPI* pluginAPI);
@ -50,4 +50,4 @@ private:
static const PluginDescriptor m_pluginDescriptor;
};
#endif // INCLUDE_AIRSPYHFFPLUGIN_H
#endif // INCLUDE_AIRSPYHFIPLUGIN_H

View File

@ -16,15 +16,14 @@
#include <QtGlobal>
#include "util/simpleserializer.h"
#include "airspyhfisettings.h"
#include "airspyhffsettings.h"
AirspyHFFSettings::AirspyHFFSettings()
AirspyHFISettings::AirspyHFISettings()
{
resetToDefaults();
}
void AirspyHFFSettings::resetToDefaults()
void AirspyHFISettings::resetToDefaults()
{
m_centerFrequency = 7150*1000;
m_LOppmTenths = 0;
@ -33,15 +32,17 @@ void AirspyHFFSettings::resetToDefaults()
m_transverterMode = false;
m_transverterDeltaFrequency = 0;
m_bandIndex = 0;
m_autoCorrOptions = AutoCorrNone;
}
QByteArray AirspyHFFSettings::serialize() const
QByteArray AirspyHFISettings::serialize() const
{
SimpleSerializer s(1);
s.writeU32(1, m_devSampleRateIndex);
s.writeS32(2, m_LOppmTenths);
s.writeU32(3, m_log2Decim);
s.writeS32(4, (int) m_autoCorrOptions);
s.writeBool(7, m_transverterMode);
s.writeS64(8, m_transverterDeltaFrequency);
s.writeU32(9, m_bandIndex);
@ -49,7 +50,7 @@ QByteArray AirspyHFFSettings::serialize() const
return s.final();
}
bool AirspyHFFSettings::deserialize(const QByteArray& data)
bool AirspyHFISettings::deserialize(const QByteArray& data)
{
SimpleDeserializer d(data);
@ -68,6 +69,13 @@ bool AirspyHFFSettings::deserialize(const QByteArray& data)
d.readS32(2, &m_LOppmTenths, 0);
d.readU32(3, &m_log2Decim, 0);
d.readS32(4, &intval, 0);
if (intval < 0 || intval > (int) AutoCorrLast) {
m_autoCorrOptions = AutoCorrNone;
} else {
m_autoCorrOptions = (AutoCorrOptions) intval;
}
d.readBool(7, &m_transverterMode, false);
d.readS64(8, &m_transverterDeltaFrequency, 0);
d.readU32(9, &uintval, 0);

View File

@ -14,11 +14,18 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef _AIRSPYHFF_AIRSPYHFFSETTINGS_H_
#define _AIRSPYHFF_AIRSPYHFFSETTINGS_H_
#ifndef _AIRSPYHF_AIRSPYHFISETTINGS_H_
#define _AIRSPYHF_AIRSPYHFISETTINGS_H_
struct AirspyHFFSettings
struct AirspyHFISettings
{
typedef enum {
AutoCorrNone,
AutoCorrDC,
AutoCorrDCAndIQ,
AutoCorrLast,
} AutoCorrOptions;
quint64 m_centerFrequency;
qint32 m_LOppmTenths;
quint32 m_devSampleRateIndex;
@ -26,11 +33,12 @@ struct AirspyHFFSettings
bool m_transverterMode;
qint64 m_transverterDeltaFrequency;
quint32 m_bandIndex;
AutoCorrOptions m_autoCorrOptions;
AirspyHFFSettings();
AirspyHFISettings();
void resetToDefaults();
QByteArray serialize() const;
bool deserialize(const QByteArray& data);
};
#endif /* _AIRSPYHFF_AIRSPYHFFSETTINGS_H_ */
#endif /* _AIRSPYHF_AIRSPYHFISETTINGS_H_ */

View File

@ -18,15 +18,15 @@
#include <errno.h>
#include "dsp/samplesinkfifo.h"
#include "airspyhffthread.h"
#include "airspyhfithread.h"
AirspyHFFThread *AirspyHFFThread::m_this = 0;
AirspyHFIThread *AirspyHFIThread::m_this = 0;
AirspyHFFThread::AirspyHFFThread(airspyhf_device_t* dev, SampleSinkFifo* sampleFifo, QObject* parent) :
AirspyHFIThread::AirspyHFIThread(airspyhf_device_t* dev, SampleSinkFifo* sampleFifo, QObject* parent) :
QThread(parent),
m_running(false),
m_dev(dev),
m_convertBuffer(AIRSPYHFF_BLOCKSIZE),
m_convertBuffer(AIRSPYHFI_BLOCKSIZE),
m_sampleFifo(sampleFifo),
m_samplerate(10),
m_log2Decim(0)
@ -34,13 +34,13 @@ AirspyHFFThread::AirspyHFFThread(airspyhf_device_t* dev, SampleSinkFifo* sampleF
m_this = this;
}
AirspyHFFThread::~AirspyHFFThread()
AirspyHFIThread::~AirspyHFIThread()
{
stopWork();
m_this = 0;
}
void AirspyHFFThread::startWork()
void AirspyHFIThread::startWork()
{
m_startWaitMutex.lock();
start();
@ -49,24 +49,24 @@ void AirspyHFFThread::startWork()
m_startWaitMutex.unlock();
}
void AirspyHFFThread::stopWork()
void AirspyHFIThread::stopWork()
{
qDebug("AirspyThread::stopWork");
m_running = false;
wait();
}
void AirspyHFFThread::setSamplerate(uint32_t samplerate)
void AirspyHFIThread::setSamplerate(uint32_t samplerate)
{
m_samplerate = samplerate;
}
void AirspyHFFThread::setLog2Decimation(unsigned int log2_decim)
void AirspyHFIThread::setLog2Decimation(unsigned int log2_decim)
{
m_log2Decim = log2_decim;
}
void AirspyHFFThread::run()
void AirspyHFIThread::run()
{
airspyhf_error rc;
@ -77,7 +77,7 @@ void AirspyHFFThread::run()
if (rc != AIRSPYHF_SUCCESS)
{
qCritical("AirspyHFFThread::run: failed to start Airspy HF Rx");
qCritical("AirspyHFThread::run: failed to start Airspy Rx");
}
else
{
@ -90,16 +90,16 @@ void AirspyHFFThread::run()
rc = (airspyhf_error) airspyhf_stop(m_dev);
if (rc == AIRSPYHF_SUCCESS) {
qDebug("AirspyHFFThread::run: stopped Airspy HF Rx");
qDebug("AirspyHFThread::run: stopped Airspy Rx");
} else {
qDebug("AirspyHFFThread::run: failed to stop Airspy HF Rx");
qDebug("AirspyHFThread::run: failed to stop Airspy Rx");
}
m_running = false;
}
// Decimate according to specified log2 (ex: log2=4 => decim=16)
void AirspyHFFThread::callback(const float* buf, qint32 len)
void AirspyHFIThread::callback(const qint16* buf, qint32 len)
{
SampleVector::iterator it = m_convertBuffer.begin();
@ -134,9 +134,9 @@ void AirspyHFFThread::callback(const float* buf, qint32 len)
}
int AirspyHFFThread::rx_callback(airspyhf_transfer_t* transfer)
int AirspyHFIThread::rx_callback(airspyhf_transfer_t* transfer)
{
qint32 nbIAndQ = transfer->sample_count * 2;
m_this->callback((float *) transfer->samples, nbIAndQ);
qint32 bytes_to_write = transfer->sample_count * sizeof(qint16);
m_this->callback((qint16 *) transfer->samples, bytes_to_write);
return 0;
}

View File

@ -14,8 +14,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_AIRSPYHFFTHREAD_H
#define INCLUDE_AIRSPYHFFTHREAD_H
#ifndef INCLUDE_AIRSPYHFITHREAD_H
#define INCLUDE_AIRSPYHFITHREAD_H
#include <QThread>
#include <QMutex>
@ -23,16 +23,16 @@
#include <libairspyhf/airspyhf.h>
#include "dsp/samplesinkfifo.h"
#include "dsp/decimatorsf.h"
#include "dsp/decimators.h"
#define AIRSPYHFF_BLOCKSIZE (1<<17)
#define AIRSPYHFI_BLOCKSIZE (1<<17)
class AirspyHFFThread : public QThread {
class AirspyHFIThread : public QThread {
Q_OBJECT
public:
AirspyHFFThread(airspyhf_device_t* dev, SampleSinkFifo* sampleFifo, QObject* parent = 0);
~AirspyHFFThread();
AirspyHFIThread(airspyhf_device_t* dev, SampleSinkFifo* sampleFifo, QObject* parent = 0);
~AirspyHFIThread();
void startWork();
void stopWork();
@ -45,19 +45,23 @@ private:
bool m_running;
airspyhf_device_t* m_dev;
qint16 m_buf[2*AIRSPYHFF_BLOCKSIZE];
qint16 m_buf[2*AIRSPYHFI_BLOCKSIZE];
SampleVector m_convertBuffer;
SampleSinkFifo* m_sampleFifo;
int m_samplerate;
unsigned int m_log2Decim;
static AirspyHFFThread *m_this;
static AirspyHFIThread *m_this;
DecimatorsF m_decimators;
#ifdef SDR_RX_SAMPLE_24BIT
Decimators<qint64, qint16, SDR_RX_SAMP_SZ, 16> m_decimators;
#else
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 16> m_decimators;
#endif
void run();
void callback(const float* buf, qint32 len);
void callback(const qint16* buf, qint32 len);
static int rx_callback(airspyhf_transfer_t* transfer);
};
#endif // INCLUDE_AIRSPYHFFTHREAD_H
#endif // INCLUDE_AIRSPYHFITHREAD_H