From 095b1cbab12794346e1c7b7f79e4d3b0f27fb401 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 8 Jan 2017 17:15:36 +0100 Subject: [PATCH] HackRF output plugin: fixed Tx output power setting --- .../samplesink/hackrfoutput/hackrfoutput.cpp | 23 +----- .../hackrfoutput/hackrfoutputgui.cpp | 17 +--- .../samplesink/hackrfoutput/hackrfoutputgui.h | 1 - .../hackrfoutput/hackrfoutputgui.ui | 77 +------------------ .../hackrfoutput/hackrfoutputsettings.cpp | 5 +- .../hackrfoutput/hackrfoutputsettings.h | 1 - 6 files changed, 7 insertions(+), 117 deletions(-) diff --git a/plugins/samplesink/hackrfoutput/hackrfoutput.cpp b/plugins/samplesink/hackrfoutput/hackrfoutput.cpp index 0578c1fb0..fc1600642 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutput.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutput.cpp @@ -313,34 +313,15 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc if (m_dev != 0) { - rc = (hackrf_error) hackrf_set_vga_gain(m_dev, m_settings.m_vgaGain); + rc = (hackrf_error) hackrf_set_txvga_gain(m_dev, m_settings.m_vgaGain); if(rc != HACKRF_SUCCESS) - { - qDebug("HackRFOutput::applySettings: hackrf_set_vga_gain failed: %s", hackrf_error_name(rc)); - } - else - { - qDebug() << "HackRFOutput:applySettings: VGA gain set to " << m_settings.m_vgaGain; - } - } - } - - if ((m_settings.m_txvgaGain != settings.m_txvgaGain) || force) - { - m_settings.m_txvgaGain = settings.m_txvgaGain; - - if (m_dev != 0) - { - rc = (hackrf_error) hackrf_set_txvga_gain(m_dev, m_settings.m_txvgaGain); - - if (rc != HACKRF_SUCCESS) { qDebug("HackRFOutput::applySettings: hackrf_set_txvga_gain failed: %s", hackrf_error_name(rc)); } else { - qDebug() << "HackRFOutput:applySettings: TxVGA gain set to " << m_settings.m_txvgaGain; + qDebug() << "HackRFOutput:applySettings: TxVGA gain set to " << m_settings.m_vgaGain; } } } diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp index 872f8dfd4..39084c7c9 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.cpp @@ -174,14 +174,11 @@ void HackRFOutputGui::displaySettings() ui->interp->setCurrentIndex(m_settings.m_log2Interp); ui->lnaExt->setChecked(m_settings.m_lnaExt); - ui->vgaGainText->setText(tr("%1dB").arg(m_settings.m_vgaGain)); - ui->vga->setValue(m_settings.m_vgaGain); + ui->txvgaGainText->setText(tr("%1dB").arg(m_settings.m_vgaGain)); + ui->txvga->setValue(m_settings.m_vgaGain); unsigned int bandwidthIndex = HackRFBandwidths::getBandwidthIndex(m_settings.m_bandwidth/1000); ui->bbFilter->setCurrentIndex(bandwidthIndex); - - ui->txvgaGainText->setText(tr("%1dB").arg(m_settings.m_txvgaGain)); - ui->txvga->setValue(m_settings.m_txvgaGain); } void HackRFOutputGui::displaySampleRates() @@ -283,16 +280,6 @@ void HackRFOutputGui::on_interp_currentIndexChanged(int index) sendSettings(); } -void HackRFOutputGui::on_vga_valueChanged(int value) -{ - if ((value < 0) || (value > 62)) - return; - - ui->vgaGainText->setText(tr("%1dB").arg(value)); - m_settings.m_vgaGain = value; - sendSettings(); -} - void HackRFOutputGui::on_txvga_valueChanged(int value) { if ((value < 0) || (value > 47)) diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.h b/plugins/samplesink/hackrfoutput/hackrfoutputgui.h index 8d0c525bd..e293d6ad6 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.h +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.h @@ -83,7 +83,6 @@ private slots: void on_biasT_stateChanged(int state); void on_interp_currentIndexChanged(int index); void on_lnaExt_stateChanged(int state); - void on_vga_valueChanged(int value); void on_bbFilter_currentIndexChanged(int index); void on_txvga_valueChanged(int value); void on_startStop_toggled(bool checked); diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui b/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui index ddc8277d5..9401b5b36 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui +++ b/plugins/samplesink/hackrfoutput/hackrfoutputgui.ui @@ -348,73 +348,6 @@ - - - - 3 - - - - - - 0 - 0 - - - - - 42 - 0 - - - - VGA - - - - - - - true - - - LNA gain dB - - - 62 - - - 2 - - - 2 - - - 30 - - - Qt::Horizontal - - - - - - - - 40 - 0 - - - - 0dB - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - @@ -422,14 +355,8 @@ - - - 42 - 0 - - - TxVGA + VGA @@ -464,7 +391,7 @@ - 0dB + 22 dB Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp index a664d4d86..5eb0a987c 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp +++ b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.cpp @@ -33,9 +33,8 @@ void HackRFOutputSettings::resetToDefaults() m_biasT = false; m_log2Interp = 0; m_lnaExt = false; - m_vgaGain = 30; + m_vgaGain = 22; m_bandwidth = 1750000; - m_txvgaGain = 22; } QByteArray HackRFOutputSettings::serialize() const @@ -49,7 +48,6 @@ QByteArray HackRFOutputSettings::serialize() const s.writeBool(5, m_lnaExt); s.writeU32(6, m_vgaGain); s.writeU32(7, m_bandwidth); - s.writeU32(8, m_txvgaGain); return s.final(); } @@ -75,7 +73,6 @@ bool HackRFOutputSettings::deserialize(const QByteArray& data) d.readBool(5, &m_lnaExt, false); d.readU32(6, &m_vgaGain, 30); d.readU32(7, &m_bandwidth, 1750000); - d.readU32(8, &m_txvgaGain, 22); return true; } diff --git a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h index 61301053d..0c387855c 100644 --- a/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h +++ b/plugins/samplesink/hackrfoutput/hackrfoutputsettings.h @@ -25,7 +25,6 @@ struct HackRFOutputSettings { quint32 m_devSampleRate; quint32 m_bandwidth; quint32 m_vgaGain; - quint32 m_txvgaGain; quint32 m_log2Interp; bool m_biasT; bool m_lnaExt;