1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 01:39:05 -05:00

HackRF input: Make settings assignments atomic. Part of #1329

This commit is contained in:
f4exb 2022-10-23 20:34:04 +02:00
parent 90cab1dfda
commit 203a50d224
6 changed files with 222 additions and 105 deletions

View File

@ -136,7 +136,7 @@ bool HackRFInput::openDevice()
void HackRFInput::init() void HackRFInput::init()
{ {
applySettings(m_settings, true); applySettings(m_settings, QList<QString>(), true);
} }
bool HackRFInput::start() bool HackRFInput::start()
@ -154,7 +154,7 @@ bool HackRFInput::start()
// mutexLocker.unlock(); // mutexLocker.unlock();
applySettings(m_settings, true); applySettings(m_settings, QList<QString>(), true);
m_hackRFThread->setSamplerate(m_settings.m_devSampleRate); m_hackRFThread->setSamplerate(m_settings.m_devSampleRate);
m_hackRFThread->setLog2Decimation(m_settings.m_log2Decim); m_hackRFThread->setLog2Decimation(m_settings.m_log2Decim);
@ -215,12 +215,12 @@ bool HackRFInput::deserialize(const QByteArray& data)
success = false; success = false;
} }
MsgConfigureHackRF* message = MsgConfigureHackRF::create(m_settings, true); MsgConfigureHackRF* message = MsgConfigureHackRF::create(m_settings, QList<QString>(), true);
m_inputMessageQueue.push(message); m_inputMessageQueue.push(message);
if (m_guiMessageQueue) if (m_guiMessageQueue)
{ {
MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(m_settings, true); MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(m_settings, QList<QString>(), true);
m_guiMessageQueue->push(messageToGUI); m_guiMessageQueue->push(messageToGUI);
} }
@ -247,12 +247,12 @@ void HackRFInput::setCenterFrequency(qint64 centerFrequency)
HackRFInputSettings settings = m_settings; HackRFInputSettings settings = m_settings;
settings.m_centerFrequency = centerFrequency; settings.m_centerFrequency = centerFrequency;
MsgConfigureHackRF* message = MsgConfigureHackRF::create(settings, false); MsgConfigureHackRF* message = MsgConfigureHackRF::create(settings, QList<QString>{"centerFrequency"}, false);
m_inputMessageQueue.push(message); m_inputMessageQueue.push(message);
if (m_guiMessageQueue) if (m_guiMessageQueue)
{ {
MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(settings, false); MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(settings, QList<QString>{"centerFrequency"}, false);
m_guiMessageQueue->push(messageToGUI); m_guiMessageQueue->push(messageToGUI);
} }
} }
@ -264,10 +264,9 @@ bool HackRFInput::handleMessage(const Message& message)
MsgConfigureHackRF& conf = (MsgConfigureHackRF&) message; MsgConfigureHackRF& conf = (MsgConfigureHackRF&) message;
qDebug() << "HackRFInput::handleMessage: MsgConfigureHackRF"; qDebug() << "HackRFInput::handleMessage: MsgConfigureHackRF";
bool success = applySettings(conf.getSettings(), conf.getForce()); bool success = applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce());
if (!success) if (!success) {
{
qDebug("HackRFInput::handleMessage: config error"); qDebug("HackRFInput::handleMessage: config error");
} }
@ -280,8 +279,7 @@ bool HackRFInput::handleMessage(const Message& message)
if (cmd.getStartStop()) if (cmd.getStartStop())
{ {
if (m_deviceAPI->initDeviceEngine()) if (m_deviceAPI->initDeviceEngine()) {
{
m_deviceAPI->startDeviceEngine(); m_deviceAPI->startDeviceEngine();
} }
} }
@ -312,7 +310,8 @@ bool HackRFInput::handleMessage(const Message& message)
if (m_guiMessageQueue) if (m_guiMessageQueue)
{ {
MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(settings, false); QList<QString> settingsKeys({"log2Decim", "fcPos", "devSampleRate", "centerFrequency"});
MsgConfigureHackRF* messageToGUI = MsgConfigureHackRF::create(settings, settingsKeys, false);
m_guiMessageQueue->push(messageToGUI); m_guiMessageQueue->push(messageToGUI);
} }
@ -347,32 +346,21 @@ void HackRFInput::setDeviceCenterFrequency(quint64 freq_hz, int loPpmTenths)
} }
} }
bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force) bool HackRFInput::applySettings(const HackRFInputSettings& settings, const QList<QString>& settingsKeys, bool force)
{ {
// QMutexLocker mutexLocker(&m_mutex); // QMutexLocker mutexLocker(&m_mutex);
qDebug() << "HackRFInput::applySettings: forcE: " << force << settings.getDebugString(settingsKeys, force);
bool forwardChange = false; bool forwardChange = false;
hackrf_error rc; hackrf_error rc;
QList<QString> reverseAPIKeys;
qDebug() << "HackRFInput::applySettings"; if (settingsKeys.contains("dcBlock") ||
settingsKeys.contains("iqCorrection") || force)
if ((m_settings.m_dcBlock != settings.m_dcBlock) || force) {
reverseAPIKeys.append("dcBlock");
}
if ((m_settings.m_iqCorrection != settings.m_iqCorrection) || force) {
reverseAPIKeys.append("iqCorrection");
}
if ((m_settings.m_dcBlock != settings.m_dcBlock) ||
(m_settings.m_iqCorrection != settings.m_iqCorrection) || force)
{ {
m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection); m_deviceAPI->configureCorrections(settings.m_dcBlock, settings.m_iqCorrection);
} }
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) if (settingsKeys.contains("devSampleRate") || force)
{ {
reverseAPIKeys.append("devSampleRate");
forwardChange = true; forwardChange = true;
if (m_dev != 0) if (m_dev != 0)
@ -400,9 +388,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
} }
} }
if ((m_settings.m_log2Decim != settings.m_log2Decim) || force) if (settingsKeys.contains("log2Decim") || force)
{ {
reverseAPIKeys.append("log2Decim");
forwardChange = true; forwardChange = true;
if (m_hackRFThread) if (m_hackRFThread)
@ -412,38 +399,20 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
} }
} }
if ((m_settings.m_iqOrder != settings.m_iqOrder) || force) if (settingsKeys.contains("iqOrder") || force)
{ {
reverseAPIKeys.append("iqOrder");
if (m_hackRFThread) { if (m_hackRFThread) {
m_hackRFThread->setIQOrder(settings.m_iqOrder); m_hackRFThread->setIQOrder(settings.m_iqOrder);
} }
} }
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)) { if (settingsKeys.contains("centerFrequency") ||
reverseAPIKeys.append("centerFrequency"); settingsKeys.contains("devSampleRate") ||
} settingsKeys.contains("log2Decim") ||
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) { settingsKeys.contains("fcPos") ||
reverseAPIKeys.append("LOppmTenths"); settingsKeys.contains("transverterMode") ||
} settingsKeys.contains("transverterDeltaFrequency") ||
if ((m_settings.m_fcPos != settings.m_fcPos) || force) { settingsKeys.contains("LOppmTenths") || force)
reverseAPIKeys.append("fcPos");
}
if ((m_settings.m_transverterMode != settings.m_transverterMode) || force) {
reverseAPIKeys.append("transverterMode");
}
if ((m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) || force) {
reverseAPIKeys.append("transverterDeltaFrequency");
}
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) ||
(m_settings.m_devSampleRate != settings.m_devSampleRate) ||
(m_settings.m_log2Decim != settings.m_log2Decim) ||
(m_settings.m_fcPos != settings.m_fcPos) ||
(m_settings.m_transverterMode != settings.m_transverterMode) ||
(m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) ||
(m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
{ {
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency( qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
settings.m_centerFrequency, settings.m_centerFrequency,
@ -465,7 +434,7 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
forwardChange = true; forwardChange = true;
} }
if ((m_settings.m_fcPos != settings.m_fcPos) || force) if (settingsKeys.contains("fcPos") || force)
{ {
if (m_hackRFThread) if (m_hackRFThread)
{ {
@ -474,10 +443,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
} }
} }
if ((m_settings.m_lnaGain != settings.m_lnaGain) || force) if (settingsKeys.contains("lnaGain") || force)
{ {
reverseAPIKeys.append("lnaGain");
if (m_dev != 0) if (m_dev != 0)
{ {
rc = (hackrf_error) hackrf_set_lna_gain(m_dev, settings.m_lnaGain); rc = (hackrf_error) hackrf_set_lna_gain(m_dev, settings.m_lnaGain);
@ -490,10 +457,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
} }
} }
if ((m_settings.m_vgaGain != settings.m_vgaGain) || force) if (settingsKeys.contains("vgaGain") || force)
{ {
reverseAPIKeys.append("vgaGain");
if (m_dev != 0) if (m_dev != 0)
{ {
rc = (hackrf_error) hackrf_set_vga_gain(m_dev, settings.m_vgaGain); rc = (hackrf_error) hackrf_set_vga_gain(m_dev, settings.m_vgaGain);
@ -506,10 +471,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
} }
} }
if ((m_settings.m_bandwidth != settings.m_bandwidth) || force) if (settingsKeys.contains("bandwidth") || force)
{ {
reverseAPIKeys.append("bandwidth");
if (m_dev != 0) if (m_dev != 0)
{ {
uint32_t bw_index = hackrf_compute_baseband_filter_bw_round_down_lt(settings.m_bandwidth + 1); // +1 so the round down to lower than yields desired bandwidth uint32_t bw_index = hackrf_compute_baseband_filter_bw_round_down_lt(settings.m_bandwidth + 1); // +1 so the round down to lower than yields desired bandwidth
@ -523,10 +486,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
} }
} }
if ((m_settings.m_biasT != settings.m_biasT) || force) if (settingsKeys.contains("biasT") || force)
{ {
reverseAPIKeys.append("biasT");
if (m_dev != 0) if (m_dev != 0)
{ {
rc = (hackrf_error) hackrf_set_antenna_enable(m_dev, (settings.m_biasT ? 1 : 0)); rc = (hackrf_error) hackrf_set_antenna_enable(m_dev, (settings.m_biasT ? 1 : 0));
@ -539,10 +500,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
} }
} }
if ((m_settings.m_lnaExt != settings.m_lnaExt) || force) if (settingsKeys.contains("lnaExt") || force)
{ {
reverseAPIKeys.append("lnaExt");
if (m_dev != 0) if (m_dev != 0)
{ {
rc = (hackrf_error) hackrf_set_amp_enable(m_dev, (settings.m_lnaExt ? 1 : 0)); rc = (hackrf_error) hackrf_set_amp_enable(m_dev, (settings.m_lnaExt ? 1 : 0));
@ -562,30 +521,20 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif); m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
} }
if (settings.m_useReverseAPI) if (settingsKeys.contains("useReverseAPI"))
{ {
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) || bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) || settingsKeys.contains("reverseAPIAddress") ||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) || settingsKeys.contains("reverseAPIPort") ||
(m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex); settingsKeys.contains("reverseAPIDeviceIndex");
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
} }
m_settings = settings; if (force) {
m_settings = settings;
qDebug() << "HackRFInput::applySettings: " } else {
<< " m_centerFrequency: " << m_settings.m_centerFrequency << " Hz" m_settings.applySettings(settingsKeys, settings);
<< " m_LOppmTenths: " << m_settings.m_LOppmTenths }
<< " m_bandwidth: " << m_settings.m_bandwidth
<< " m_lnaGain: " << m_settings.m_lnaGain
<< " m_vgaGain: " << m_settings.m_vgaGain
<< " m_log2Decim: " << m_settings.m_log2Decim
<< " m_iqOrder: " << m_settings.m_iqOrder
<< " m_fcPos: " << m_settings.m_fcPos
<< " m_devSampleRate: " << m_settings.m_devSampleRate
<< " m_biasT: " << m_settings.m_biasT
<< " m_lnaExt: " << m_settings.m_lnaExt
<< " m_dcBlock: " << m_settings.m_dcBlock;
return true; return true;
} }
@ -611,12 +560,12 @@ int HackRFInput::webapiSettingsPutPatch(
HackRFInputSettings settings = m_settings; HackRFInputSettings settings = m_settings;
webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response); webapiUpdateDeviceSettings(settings, deviceSettingsKeys, response);
MsgConfigureHackRF *msg = MsgConfigureHackRF::create(settings, force); MsgConfigureHackRF *msg = MsgConfigureHackRF::create(settings, deviceSettingsKeys, force);
m_inputMessageQueue.push(msg); m_inputMessageQueue.push(msg);
if (m_guiMessageQueue) // forward to GUI if any if (m_guiMessageQueue) // forward to GUI if any
{ {
MsgConfigureHackRF *msgToGUI = MsgConfigureHackRF::create(settings, force); MsgConfigureHackRF *msgToGUI = MsgConfigureHackRF::create(settings, deviceSettingsKeys, force);
m_guiMessageQueue->push(msgToGUI); m_guiMessageQueue->push(msgToGUI);
} }
@ -749,7 +698,7 @@ int HackRFInput::webapiRun(
return 200; return 200;
} }
void HackRFInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFInputSettings& settings, bool force) void HackRFInput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const HackRFInputSettings& settings, bool force)
{ {
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings(); SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
swgDeviceSettings->setDirection(0); // single Rx swgDeviceSettings->setDirection(0); // single Rx

View File

@ -42,20 +42,23 @@ public:
public: public:
const HackRFInputSettings& getSettings() const { return m_settings; } const HackRFInputSettings& getSettings() const { return m_settings; }
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
bool getForce() const { return m_force; } bool getForce() const { return m_force; }
static MsgConfigureHackRF* create(const HackRFInputSettings& settings, bool force = false) static MsgConfigureHackRF* create(const HackRFInputSettings& settings, const QList<QString>& settingsKeys, bool force = false)
{ {
return new MsgConfigureHackRF(settings, force); return new MsgConfigureHackRF(settings, settingsKeys, force);
} }
private: private:
HackRFInputSettings m_settings; HackRFInputSettings m_settings;
QList<QString> m_settingsKeys;
bool m_force; bool m_force;
MsgConfigureHackRF(const HackRFInputSettings& settings, bool force) : MsgConfigureHackRF(const HackRFInputSettings& settings, const QList<QString>& settingsKeys, bool force) :
Message(), Message(),
m_settings(settings), m_settings(settings),
m_settingsKeys(settingsKeys),
m_force(force) m_force(force)
{ } { }
}; };
@ -158,9 +161,9 @@ private:
bool openDevice(); bool openDevice();
void closeDevice(); void closeDevice();
bool applySettings(const HackRFInputSettings& settings, bool force); bool applySettings(const HackRFInputSettings& settings, const QList<QString>& settingsKeys, bool force);
void setDeviceCenterFrequency(quint64 freq, int loPpmTenths); void setDeviceCenterFrequency(quint64 freq, int loPpmTenths);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFInputSettings& settings, bool force); void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const HackRFInputSettings& settings, bool force);
void webapiReverseSendStartStop(bool start); void webapiReverseSendStartStop(bool start);
private slots: private slots:

View File

@ -93,6 +93,7 @@ void HackRFInputGui::resetToDefaults()
{ {
m_settings.resetToDefaults(); m_settings.resetToDefaults();
displaySettings(); displaySettings();
m_forceSettings = true;
sendSettings(); sendSettings();
} }
@ -128,7 +129,13 @@ bool HackRFInputGui::handleMessage(const Message& message)
if (HackRFInput::MsgConfigureHackRF::match(message)) if (HackRFInput::MsgConfigureHackRF::match(message))
{ {
const HackRFInput::MsgConfigureHackRF& cfg = (HackRFInput::MsgConfigureHackRF&) message; const HackRFInput::MsgConfigureHackRF& cfg = (HackRFInput::MsgConfigureHackRF&) message;
m_settings = cfg.getSettings();
if (cfg.getForce()) {
m_settings = cfg.getSettings();
} else {
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
}
blockApplySettings(true); blockApplySettings(true);
displaySettings(); displaySettings();
blockApplySettings(false); blockApplySettings(false);
@ -320,29 +327,35 @@ void HackRFInputGui::on_LOppm_valueChanged(int value)
{ {
m_settings.m_LOppmTenths = value; m_settings.m_LOppmTenths = value;
ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1))); ui->LOppmText->setText(QString("%1").arg(QString::number(m_settings.m_LOppmTenths/10.0, 'f', 1)));
m_settingsKeys.append("LOppmTenths");
sendSettings(); sendSettings();
} }
void HackRFInputGui::on_dcOffset_toggled(bool checked) void HackRFInputGui::on_dcOffset_toggled(bool checked)
{ {
m_settings.m_dcBlock = checked; m_settings.m_dcBlock = checked;
m_settingsKeys.append("dcBlock");
sendSettings(); sendSettings();
} }
void HackRFInputGui::on_iqImbalance_toggled(bool checked) void HackRFInputGui::on_iqImbalance_toggled(bool checked)
{ {
m_settings.m_iqCorrection = checked; m_settings.m_iqCorrection = checked;
m_settingsKeys.append("iqCorrection");
sendSettings(); sendSettings();
} }
void HackRFInputGui::on_autoBBF_toggled(bool checked) void HackRFInputGui::on_autoBBF_toggled(bool checked)
{ {
m_settings.m_autoBBF = checked; m_settings.m_autoBBF = checked;
if(checked){
if (checked)
{
m_settings.m_bandwidth = hackrf_compute_baseband_filter_bw(m_settings.m_devSampleRate); m_settings.m_bandwidth = hackrf_compute_baseband_filter_bw(m_settings.m_devSampleRate);
ui->bbFilter->blockSignals(true); ui->bbFilter->blockSignals(true);
displaySettings(); displaySettings();
ui->bbFilter->blockSignals(false); ui->bbFilter->blockSignals(false);
m_settingsKeys.append("bandwidth");
sendSettings(); sendSettings();
} }
} }
@ -352,24 +365,28 @@ void HackRFInputGui::on_bbFilter_currentIndexChanged(int index)
int newBandwidth = HackRFBandwidths::getBandwidth(index); int newBandwidth = HackRFBandwidths::getBandwidth(index);
m_settings.m_bandwidth = newBandwidth * 1000; m_settings.m_bandwidth = newBandwidth * 1000;
ui->autoBBF->setChecked(false); ui->autoBBF->setChecked(false);
m_settingsKeys.append("bandwidth");
sendSettings(); sendSettings();
} }
void HackRFInputGui::on_biasT_stateChanged(int state) void HackRFInputGui::on_biasT_stateChanged(int state)
{ {
m_settings.m_biasT = (state == Qt::Checked); m_settings.m_biasT = (state == Qt::Checked);
m_settingsKeys.append("biasT");
sendSettings(); sendSettings();
} }
void HackRFInputGui::on_lnaExt_stateChanged(int state) void HackRFInputGui::on_lnaExt_stateChanged(int state)
{ {
m_settings.m_lnaExt = (state == Qt::Checked); m_settings.m_lnaExt = (state == Qt::Checked);
m_settingsKeys.append("lnaExt");
sendSettings(); sendSettings();
} }
void HackRFInputGui::on_centerFrequency_changed(quint64 value) void HackRFInputGui::on_centerFrequency_changed(quint64 value)
{ {
m_settings.m_centerFrequency = value * 1000; m_settings.m_centerFrequency = value * 1000;
m_settingsKeys.append("centerFrequency");
sendSettings(); sendSettings();
} }
@ -377,12 +394,15 @@ void HackRFInputGui::on_sampleRate_changed(quint64 value)
{ {
m_settings.m_devSampleRate = value; m_settings.m_devSampleRate = value;
if (!m_sampleRateMode) { if (!m_sampleRateMode)
{
m_settings.m_devSampleRate <<= m_settings.m_log2Decim; m_settings.m_devSampleRate <<= m_settings.m_log2Decim;
m_settingsKeys.append("devSampleRate");
} }
if(m_settings.m_autoBBF){ if(m_settings.m_autoBBF){
m_settings.m_bandwidth = hackrf_compute_baseband_filter_bw(m_settings.m_devSampleRate); m_settings.m_bandwidth = hackrf_compute_baseband_filter_bw(m_settings.m_devSampleRate);
m_settingsKeys.append("bandwidth");
ui->bbFilter->blockSignals(true); ui->bbFilter->blockSignals(true);
displaySettings(); displaySettings();
ui->bbFilter->blockSignals(false); ui->bbFilter->blockSignals(false);
@ -406,12 +426,15 @@ void HackRFInputGui::on_decim_currentIndexChanged(int index)
m_settings.m_devSampleRate <<= m_settings.m_log2Decim; m_settings.m_devSampleRate <<= m_settings.m_log2Decim;
} }
m_settingsKeys.append("log2Decim");
m_settingsKeys.append("devSampleRate");
sendSettings(); sendSettings();
} }
void HackRFInputGui::on_fcPos_currentIndexChanged(int index) void HackRFInputGui::on_fcPos_currentIndexChanged(int index)
{ {
m_settings.m_fcPos = (HackRFInputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index); m_settings.m_fcPos = (HackRFInputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index);
m_settingsKeys.append("fcPos");
displayFcTooltip(); displayFcTooltip();
sendSettings(); sendSettings();
} }
@ -423,6 +446,7 @@ void HackRFInputGui::on_lna_valueChanged(int value)
ui->lnaGainText->setText(tr("%1dB").arg(value)); ui->lnaGainText->setText(tr("%1dB").arg(value));
m_settings.m_lnaGain = value; m_settings.m_lnaGain = value;
m_settingsKeys.append("lnaGain");
sendSettings(); sendSettings();
} }
@ -433,6 +457,7 @@ void HackRFInputGui::on_vga_valueChanged(int value)
ui->vgaText->setText(tr("%1dB").arg(value)); ui->vgaText->setText(tr("%1dB").arg(value));
m_settings.m_vgaGain = value; m_settings.m_vgaGain = value;
m_settingsKeys.append("vgaGain");
sendSettings(); sendSettings();
} }
@ -456,9 +481,10 @@ void HackRFInputGui::updateHardware()
if (m_doApplySettings) if (m_doApplySettings)
{ {
qDebug() << "HackRFGui::updateHardware"; qDebug() << "HackRFGui::updateHardware";
HackRFInput::MsgConfigureHackRF* message = HackRFInput::MsgConfigureHackRF::create(m_settings, m_forceSettings); HackRFInput::MsgConfigureHackRF* message = HackRFInput::MsgConfigureHackRF::create(m_settings, m_settingsKeys, m_forceSettings);
m_sampleSource->getInputMessageQueue()->push(message); m_sampleSource->getInputMessageQueue()->push(message);
m_forceSettings = false; m_forceSettings = false;
m_settingsKeys.clear();
m_updateTimer.stop(); m_updateTimer.stop();
} }
} }
@ -471,6 +497,10 @@ void HackRFInputGui::on_transverter_clicked()
qDebug("HackRFInputGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off"); qDebug("HackRFInputGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
updateFrequencyLimits(); updateFrequencyLimits();
m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000; m_settings.m_centerFrequency = ui->centerFrequency->getValueNew()*1000;
m_settingsKeys.append("transverterMode");
m_settingsKeys.append("transverterDeltaFrequency");
m_settingsKeys.append("iqOrder");
m_settingsKeys.append("centerFrequency");
sendSettings(); sendSettings();
} }

View File

@ -62,6 +62,7 @@ private:
Ui::HackRFInputGui* ui; Ui::HackRFInputGui* ui;
HackRFInputSettings m_settings; HackRFInputSettings m_settings;
QList<QString> m_settingsKeys;
bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode bool m_sampleRateMode; //!< true: device, false: base band sample rate update mode
bool m_forceSettings; bool m_forceSettings;
bool m_doApplySettings; bool m_doApplySettings;

View File

@ -129,3 +129,135 @@ bool HackRFInputSettings::deserialize(const QByteArray& data)
return false; return false;
} }
} }
void HackRFInputSettings::applySettings(const QStringList& settingsKeys, const HackRFInputSettings& settings)
{
if (settingsKeys.contains("centerFrequency")) {
m_centerFrequency = settings.m_centerFrequency;
}
if (settingsKeys.contains("LOppmTenths")) {
m_LOppmTenths = settings.m_LOppmTenths;
}
if (settingsKeys.contains("biasT")) {
m_biasT = settings.m_biasT;
}
if (settingsKeys.contains("log2Decim")) {
m_log2Decim = settings.m_log2Decim;
}
if (settingsKeys.contains("fcPos")) {
m_fcPos = settings.m_fcPos;
}
if (settingsKeys.contains("lnaExt")) {
m_lnaExt = settings.m_lnaExt;
}
if (settingsKeys.contains("lnaGain")) {
m_lnaGain = settings.m_lnaGain;
}
if (settingsKeys.contains("bandwidth")) {
m_bandwidth = settings.m_bandwidth;
}
if (settingsKeys.contains("vgaGain")) {
m_vgaGain = settings.m_vgaGain;
}
if (settingsKeys.contains("dcBlock")) {
m_dcBlock = settings.m_dcBlock;
}
if (settingsKeys.contains("iqCorrection")) {
m_iqCorrection = settings.m_iqCorrection;
}
if (settingsKeys.contains("autoBBF")) {
m_autoBBF = settings.m_autoBBF;
}
if (settingsKeys.contains("devSampleRate")) {
m_devSampleRate = settings.m_devSampleRate;
}
if (settingsKeys.contains("transverterMode")) {
m_transverterMode = settings.m_transverterMode;
}
if (settingsKeys.contains("transverterDeltaFrequency")) {
m_transverterDeltaFrequency = settings.m_transverterDeltaFrequency;
}
if (settingsKeys.contains("iqOrder")) {
m_iqOrder = settings.m_iqOrder;
}
if (settingsKeys.contains("useReverseAPI")) {
m_useReverseAPI = settings.m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress")) {
m_reverseAPIAddress = settings.m_reverseAPIAddress;
}
if (settingsKeys.contains("reverseAPIPort")) {
m_reverseAPIPort = settings.m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex")) {
m_reverseAPIDeviceIndex = settings.m_reverseAPIDeviceIndex;
}
}
QString HackRFInputSettings::getDebugString(const QStringList& settingsKeys, bool force) const
{
std::ostringstream ostr;
if (settingsKeys.contains("centerFrequency") || force) {
ostr << " m_centerFrequency: " << m_centerFrequency;
}
if (settingsKeys.contains("LOppmTenths") || force) {
ostr << " m_LOppmTenths: " << m_LOppmTenths;
}
if (settingsKeys.contains("biasT") || force) {
ostr << " m_biasT: " << m_biasT;
}
if (settingsKeys.contains("log2Decim") || force) {
ostr << " m_log2Decim: " << m_log2Decim;
}
if (settingsKeys.contains("fcPos") || force) {
ostr << " m_fcPos: " << m_fcPos;
}
if (settingsKeys.contains("lnaExt") || force) {
ostr << " m_lnaExt: " << m_lnaExt;
}
if (settingsKeys.contains("lnaGain") || force) {
ostr << " m_lnaGain: " << m_lnaGain;
}
if (settingsKeys.contains("bandwidth") || force) {
ostr << " m_bandwidth: " << m_bandwidth;
}
if (settingsKeys.contains("vgaGain") || force) {
ostr << " m_vgaGain: " << m_vgaGain;
}
if (settingsKeys.contains("dcBlock") || force) {
ostr << " m_dcBlock: " << m_dcBlock;
}
if (settingsKeys.contains("iqCorrection") || force) {
ostr << " m_iqCorrection: " << m_iqCorrection;
}
if (settingsKeys.contains("autoBBF") || force) {
ostr << " m_autoBBF: " << m_autoBBF;
}
if (settingsKeys.contains("devSampleRate") || force) {
ostr << " m_devSampleRate: " << m_devSampleRate;
}
if (settingsKeys.contains("transverterMode") || force) {
ostr << " m_transverterMode: " << m_transverterMode;
}
if (settingsKeys.contains("transverterDeltaFrequency") || force) {
ostr << " m_transverterDeltaFrequency: " << m_transverterDeltaFrequency;
}
if (settingsKeys.contains("iqOrder") || force) {
ostr << " m_iqOrder: " << m_iqOrder;
}
if (settingsKeys.contains("useReverseAPI") || force) {
ostr << " m_useReverseAPI: " << m_useReverseAPI;
}
if (settingsKeys.contains("reverseAPIAddress") || force) {
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
}
if (settingsKeys.contains("reverseAPIPort") || force) {
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
}
if (settingsKeys.contains("reverseAPIDeviceIndex") || force) {
ostr << " m_reverseAPIDeviceIndex: " << m_reverseAPIDeviceIndex;
}
return QString(ostr.str().c_str());
}

View File

@ -53,6 +53,8 @@ struct HackRFInputSettings {
void resetToDefaults(); void resetToDefaults();
QByteArray serialize() const; QByteArray serialize() const;
bool deserialize(const QByteArray& data); bool deserialize(const QByteArray& data);
void applySettings(const QStringList& settingsKeys, const HackRFInputSettings& settings);
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
}; };
#endif /* _HACKRF_HACKRFINPUTSETTINGS_H_ */ #endif /* _HACKRF_HACKRFINPUTSETTINGS_H_ */