mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 01:39:05 -05:00
HackRF output: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
ba2e407f0c
commit
6499608195
@ -125,7 +125,7 @@ bool HackRFOutput::openDevice()
|
|||||||
|
|
||||||
void HackRFOutput::init()
|
void HackRFOutput::init()
|
||||||
{
|
{
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, QList<QString>(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HackRFOutput::start()
|
bool HackRFOutput::start()
|
||||||
@ -142,7 +142,7 @@ bool HackRFOutput::start()
|
|||||||
|
|
||||||
// mutexLocker.unlock();
|
// mutexLocker.unlock();
|
||||||
|
|
||||||
applySettings(m_settings, true);
|
applySettings(m_settings, QList<QString>(), true);
|
||||||
|
|
||||||
m_hackRFThread->setLog2Interpolation(m_settings.m_log2Interp);
|
m_hackRFThread->setLog2Interpolation(m_settings.m_log2Interp);
|
||||||
m_hackRFThread->setFcPos((int) m_settings.m_fcPos);
|
m_hackRFThread->setFcPos((int) m_settings.m_fcPos);
|
||||||
@ -202,12 +202,12 @@ bool HackRFOutput::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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,12 +235,12 @@ void HackRFOutput::setCenterFrequency(qint64 centerFrequency)
|
|||||||
HackRFOutputSettings settings = m_settings;
|
HackRFOutputSettings 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,10 +252,9 @@ bool HackRFOutput::handleMessage(const Message& message)
|
|||||||
MsgConfigureHackRF& conf = (MsgConfigureHackRF&) message;
|
MsgConfigureHackRF& conf = (MsgConfigureHackRF&) message;
|
||||||
qDebug() << "HackRFOutput::handleMessage: MsgConfigureHackRF";
|
qDebug() << "HackRFOutput::handleMessage: MsgConfigureHackRF";
|
||||||
|
|
||||||
bool success = applySettings(conf.getSettings(), conf.getForce());
|
bool success = applySettings(conf.getSettings(), conf.getSettingsKeys(), conf.getForce());
|
||||||
|
|
||||||
if (!success)
|
if (!success) {
|
||||||
{
|
|
||||||
qDebug("HackRFOutput::handleMessage: MsgConfigureHackRF: config error");
|
qDebug("HackRFOutput::handleMessage: MsgConfigureHackRF: config error");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,8 +267,7 @@ bool HackRFOutput::handleMessage(const Message& message)
|
|||||||
|
|
||||||
if (cmd.getStartStop())
|
if (cmd.getStartStop())
|
||||||
{
|
{
|
||||||
if (m_deviceAPI->initDeviceEngine())
|
if (m_deviceAPI->initDeviceEngine()) {
|
||||||
{
|
|
||||||
m_deviceAPI->startDeviceEngine();
|
m_deviceAPI->startDeviceEngine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +297,7 @@ bool HackRFOutput::handleMessage(const Message& 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,38 +332,20 @@ void HackRFOutput::setDeviceCenterFrequency(quint64 freq_hz, int loPpmTenths)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool force)
|
bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||||
{
|
{
|
||||||
// QMutexLocker mutexLocker(&m_mutex);
|
// QMutexLocker mutexLocker(&m_mutex);
|
||||||
|
qDebug() << "HackRFOutput::applySettings: force:" << force << settings.getDebugString(settingsKeys, force);
|
||||||
|
|
||||||
bool forwardChange = false;
|
bool forwardChange = false;
|
||||||
bool suspendThread = false;
|
bool suspendThread = false;
|
||||||
bool threadWasRunning = false;
|
bool threadWasRunning = false;
|
||||||
hackrf_error rc;
|
hackrf_error rc;
|
||||||
QList<QString> reverseAPIKeys;
|
|
||||||
|
|
||||||
qDebug() << "HackRFOutput::applySettings"
|
// if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
|
||||||
<< " m_centerFrequency: " << settings.m_centerFrequency
|
// (m_settings.m_log2Interp != settings.m_log2Interp) || force)
|
||||||
<< " m_LOppmTenths: " << settings.m_LOppmTenths
|
if (settingsKeys.contains("devSampleRate") ||
|
||||||
<< " m_bandwidth: " << settings.m_bandwidth
|
settingsKeys.contains("log2Interp") || force)
|
||||||
<< " m_devSampleRate: " << settings.m_devSampleRate
|
|
||||||
<< " m_log2Interp: " << settings.m_log2Interp
|
|
||||||
<< " m_fcPos: " << settings.m_fcPos
|
|
||||||
<< " m_biasT: " << settings.m_biasT
|
|
||||||
<< " m_lnaExt: " << settings.m_lnaExt
|
|
||||||
<< " m_vgaGain: " << settings.m_vgaGain
|
|
||||||
<< " m_useReverseAPI: " << settings.m_useReverseAPI
|
|
||||||
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
|
|
||||||
<< " m_reverseAPIPort: " << settings.m_reverseAPIPort
|
|
||||||
<< " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex
|
|
||||||
<< " force: " << force;
|
|
||||||
|
|
||||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force) {
|
|
||||||
reverseAPIKeys.append("devSampleRate");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) ||
|
|
||||||
(m_settings.m_log2Interp != settings.m_log2Interp) || force)
|
|
||||||
{
|
{
|
||||||
suspendThread = true;
|
suspendThread = true;
|
||||||
}
|
}
|
||||||
@ -382,7 +362,8 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || (m_settings.m_log2Interp != settings.m_log2Interp) || force)
|
if (settingsKeys.contains("devSampleRate") ||
|
||||||
|
settingsKeys.contains("log2Interp") || force)
|
||||||
{
|
{
|
||||||
forwardChange = true;
|
forwardChange = true;
|
||||||
unsigned int fifoRate = std::max(
|
unsigned int fifoRate = std::max(
|
||||||
@ -391,7 +372,7 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
m_sampleSourceFifo.resize(SampleSourceFifo::getSizePolicy(fifoRate));
|
m_sampleSourceFifo.resize(SampleSourceFifo::getSizePolicy(fifoRate));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_settings.m_devSampleRate != settings.m_devSampleRate) || force)
|
if (settingsKeys.contains("devSampleRate") || force)
|
||||||
{
|
{
|
||||||
if (m_dev != 0)
|
if (m_dev != 0)
|
||||||
{
|
{
|
||||||
@ -411,10 +392,8 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_settings.m_log2Interp != settings.m_log2Interp) || force)
|
if (settingsKeys.contains("log2Interp") || force)
|
||||||
{
|
{
|
||||||
reverseAPIKeys.append("log2Interp");
|
|
||||||
|
|
||||||
if (m_hackRFThread != 0)
|
if (m_hackRFThread != 0)
|
||||||
{
|
{
|
||||||
m_hackRFThread->setLog2Interpolation(settings.m_log2Interp);
|
m_hackRFThread->setLog2Interpolation(settings.m_log2Interp);
|
||||||
@ -422,29 +401,13 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
|
if (settingsKeys.contains("centerFrequency") ||
|
||||||
reverseAPIKeys.append("centerFrequency");
|
settingsKeys.contains("devSampleRate") ||
|
||||||
}
|
settingsKeys.contains("log2Interp") ||
|
||||||
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_log2Interp != settings.m_log2Interp) ||
|
|
||||||
(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 = DeviceSampleSink::calculateDeviceCenterFrequency(
|
qint64 deviceCenterFrequency = DeviceSampleSink::calculateDeviceCenterFrequency(
|
||||||
settings.m_centerFrequency,
|
settings.m_centerFrequency,
|
||||||
@ -465,17 +428,15 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
forwardChange = true;
|
forwardChange = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((m_settings.m_fcPos != settings.m_fcPos) || force)
|
if (settingsKeys.contains("fcPos") || force)
|
||||||
{
|
{
|
||||||
if (m_hackRFThread != 0) {
|
if (m_hackRFThread != 0) {
|
||||||
m_hackRFThread->setFcPos((int) settings.m_fcPos);
|
m_hackRFThread->setFcPos((int) settings.m_fcPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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_txvga_gain(m_dev, settings.m_vgaGain);
|
rc = (hackrf_error) hackrf_set_txvga_gain(m_dev, settings.m_vgaGain);
|
||||||
@ -488,10 +449,8 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -505,10 +464,8 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
@ -521,10 +478,8 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
@ -537,21 +492,24 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (threadWasRunning)
|
if (threadWasRunning) {
|
||||||
{
|
|
||||||
m_hackRFThread->startWork();
|
m_hackRFThread->startWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
} else {
|
||||||
|
m_settings.applySettings(settingsKeys, settings);
|
||||||
|
}
|
||||||
|
|
||||||
if (forwardChange)
|
if (forwardChange)
|
||||||
{
|
{
|
||||||
@ -584,12 +542,12 @@ int HackRFOutput::webapiSettingsPutPatch(
|
|||||||
HackRFOutputSettings settings = m_settings;
|
HackRFOutputSettings 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +664,7 @@ int HackRFOutput::webapiRun(
|
|||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HackRFOutput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force)
|
void HackRFOutput::webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force)
|
||||||
{
|
{
|
||||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||||
swgDeviceSettings->setDirection(1); // single Tx
|
swgDeviceSettings->setDirection(1); // single Tx
|
||||||
|
@ -41,20 +41,22 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
const HackRFOutputSettings& getSettings() const { return m_settings; }
|
const HackRFOutputSettings& 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 HackRFOutputSettings& settings, bool force)
|
static MsgConfigureHackRF* create(const HackRFOutputSettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||||
{
|
return new MsgConfigureHackRF(settings, settingsKeys, force);
|
||||||
return new MsgConfigureHackRF(settings, force);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HackRFOutputSettings m_settings;
|
HackRFOutputSettings m_settings;
|
||||||
|
QList<QString> m_settingsKeys;
|
||||||
bool m_force;
|
bool m_force;
|
||||||
|
|
||||||
MsgConfigureHackRF(const HackRFOutputSettings& settings, bool force) :
|
MsgConfigureHackRF(const HackRFOutputSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||||
Message(),
|
Message(),
|
||||||
m_settings(settings),
|
m_settings(settings),
|
||||||
|
m_settingsKeys(settingsKeys),
|
||||||
m_force(force)
|
m_force(force)
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
@ -157,10 +159,10 @@ private:
|
|||||||
|
|
||||||
bool openDevice();
|
bool openDevice();
|
||||||
void closeDevice();
|
void closeDevice();
|
||||||
bool applySettings(const HackRFOutputSettings& settings, bool force);
|
bool applySettings(const HackRFOutputSettings& settings, const QList<QString>& settingsKeys, bool force);
|
||||||
// hackrf_device *open_hackrf_from_sequence(int sequence);
|
// hackrf_device *open_hackrf_from_sequence(int sequence);
|
||||||
void setDeviceCenterFrequency(quint64 freq_hz, int loPpmTenths);
|
void setDeviceCenterFrequency(quint64 freq_hz, int loPpmTenths);
|
||||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force);
|
void webapiReverseSendSettings(const QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force);
|
||||||
void webapiReverseSendStartStop(bool start);
|
void webapiReverseSendStartStop(bool start);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -88,6 +88,7 @@ void HackRFOutputGui::resetToDefaults()
|
|||||||
{
|
{
|
||||||
m_settings.resetToDefaults();
|
m_settings.resetToDefaults();
|
||||||
displaySettings();
|
displaySettings();
|
||||||
|
m_forceSettings = true;
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,7 +130,13 @@ bool HackRFOutputGui::handleMessage(const Message& message)
|
|||||||
if (HackRFOutput::MsgConfigureHackRF::match(message))
|
if (HackRFOutput::MsgConfigureHackRF::match(message))
|
||||||
{
|
{
|
||||||
const HackRFOutput::MsgConfigureHackRF& cfg = (HackRFOutput::MsgConfigureHackRF&) message;
|
const HackRFOutput::MsgConfigureHackRF& cfg = (HackRFOutput::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);
|
||||||
@ -306,19 +313,22 @@ void HackRFOutputGui::displayBandwidths()
|
|||||||
|
|
||||||
void HackRFOutputGui::sendSettings()
|
void HackRFOutputGui::sendSettings()
|
||||||
{
|
{
|
||||||
if(!m_updateTimer.isActive())
|
if (!m_updateTimer.isActive()) {
|
||||||
m_updateTimer.start(100);
|
m_updateTimer.start(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HackRFOutputGui::on_centerFrequency_changed(quint64 value)
|
void HackRFOutputGui::on_centerFrequency_changed(quint64 value)
|
||||||
{
|
{
|
||||||
m_settings.m_centerFrequency = value * 1000;
|
m_settings.m_centerFrequency = value * 1000;
|
||||||
|
m_settingsKeys.append("centerFrequency");
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HackRFOutputGui::on_sampleRate_changed(quint64 value)
|
void HackRFOutputGui::on_sampleRate_changed(quint64 value)
|
||||||
{
|
{
|
||||||
m_settings.m_devSampleRate = value;
|
m_settings.m_devSampleRate = value;
|
||||||
|
m_settingsKeys.append("devSampleRate");
|
||||||
|
|
||||||
if (!m_sampleRateMode) {
|
if (!m_sampleRateMode) {
|
||||||
m_settings.m_devSampleRate <<= m_settings.m_log2Interp;
|
m_settings.m_devSampleRate <<= m_settings.m_log2Interp;
|
||||||
@ -332,6 +342,7 @@ void HackRFOutputGui::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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,18 +350,21 @@ void HackRFOutputGui::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;
|
||||||
|
m_settingsKeys.append("bandwidth");
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HackRFOutputGui::on_biasT_stateChanged(int state)
|
void HackRFOutputGui::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 HackRFOutputGui::on_lnaExt_stateChanged(int state)
|
void HackRFOutputGui::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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,6 +377,8 @@ void HackRFOutputGui::on_interp_currentIndexChanged(int index)
|
|||||||
m_settings.m_log2Interp = index;
|
m_settings.m_log2Interp = index;
|
||||||
displaySampleRate();
|
displaySampleRate();
|
||||||
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
|
m_settings.m_devSampleRate = ui->sampleRate->getValueNew();
|
||||||
|
m_settingsKeys.append("log2Interp");
|
||||||
|
m_settingsKeys.append("devSampleRate");
|
||||||
|
|
||||||
if (!m_sampleRateMode) {
|
if (!m_sampleRateMode) {
|
||||||
m_settings.m_devSampleRate <<= m_settings.m_log2Interp;
|
m_settings.m_devSampleRate <<= m_settings.m_log2Interp;
|
||||||
@ -374,6 +390,7 @@ void HackRFOutputGui::on_interp_currentIndexChanged(int index)
|
|||||||
void HackRFOutputGui::on_fcPos_currentIndexChanged(int index)
|
void HackRFOutputGui::on_fcPos_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
m_settings.m_fcPos = (HackRFOutputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index);
|
m_settings.m_fcPos = (HackRFOutputSettings::fcPos_t) (index < 0 ? 0 : index > 2 ? 2 : index);
|
||||||
|
m_settingsKeys.append("fcPos");
|
||||||
displayFcTooltip();
|
displayFcTooltip();
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
@ -385,6 +402,7 @@ void HackRFOutputGui::on_txvga_valueChanged(int value)
|
|||||||
|
|
||||||
ui->txvgaGainText->setText(tr("%1dB").arg(value));
|
ui->txvgaGainText->setText(tr("%1dB").arg(value));
|
||||||
m_settings.m_vgaGain = value;
|
m_settings.m_vgaGain = value;
|
||||||
|
m_settingsKeys.append("vgaGain");
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,6 +428,9 @@ void HackRFOutputGui::on_transverter_clicked()
|
|||||||
qDebug("HackRFOutputGui::on_transverter_clicked: %lld Hz %s", m_settings.m_transverterDeltaFrequency, m_settings.m_transverterMode ? "on" : "off");
|
qDebug("HackRFOutputGui::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("centerFrequency");
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -418,9 +439,10 @@ void HackRFOutputGui::updateHardware()
|
|||||||
if (m_doApplySettings)
|
if (m_doApplySettings)
|
||||||
{
|
{
|
||||||
qDebug() << "HackRFOutputGui::updateHardware";
|
qDebug() << "HackRFOutputGui::updateHardware";
|
||||||
HackRFOutput::MsgConfigureHackRF* message = HackRFOutput::MsgConfigureHackRF::create(m_settings, m_forceSettings);
|
HackRFOutput::MsgConfigureHackRF* message = HackRFOutput::MsgConfigureHackRF::create(m_settings, m_settingsKeys, m_forceSettings);
|
||||||
m_deviceSampleSink->getInputMessageQueue()->push(message);
|
m_deviceSampleSink->getInputMessageQueue()->push(message);
|
||||||
m_forceSettings = false;
|
m_forceSettings = false;
|
||||||
|
m_settingsKeys.clear();
|
||||||
m_updateTimer.stop();
|
m_updateTimer.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,6 +494,10 @@ void HackRFOutputGui::openDeviceSettingsDialog(const QPoint& p)
|
|||||||
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
m_settings.m_reverseAPIAddress = dialog.getReverseAPIAddress();
|
||||||
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
m_settings.m_reverseAPIPort = dialog.getReverseAPIPort();
|
||||||
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
m_settings.m_reverseAPIDeviceIndex = dialog.getReverseAPIDeviceIndex();
|
||||||
|
m_settingsKeys.append("useReverseAPI");
|
||||||
|
m_settingsKeys.append("reverseAPIAddress");
|
||||||
|
m_settingsKeys.append("reverseAPIPort");
|
||||||
|
m_settingsKeys.append("reverseAPIDeviceIndex");
|
||||||
|
|
||||||
sendSettings();
|
sendSettings();
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ private:
|
|||||||
|
|
||||||
bool m_forceSettings;
|
bool m_forceSettings;
|
||||||
HackRFOutputSettings m_settings;
|
HackRFOutputSettings 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
|
||||||
QTimer m_updateTimer;
|
QTimer m_updateTimer;
|
||||||
QTimer m_statusTimer;
|
QTimer m_statusTimer;
|
||||||
|
@ -114,3 +114,105 @@ bool HackRFOutputSettings::deserialize(const QByteArray& data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HackRFOutputSettings::applySettings(const QStringList& settingsKeys, const HackRFOutputSettings& 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("log2Interp")) {
|
||||||
|
m_log2Interp = settings.m_log2Interp;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("fcPos")) {
|
||||||
|
m_fcPos = settings.m_fcPos;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("lnaExt")) {
|
||||||
|
m_lnaExt = settings.m_lnaExt;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("vgaGain")) {
|
||||||
|
m_vgaGain = settings.m_vgaGain;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("bandwidth")) {
|
||||||
|
m_bandwidth = settings.m_bandwidth;
|
||||||
|
}
|
||||||
|
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("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 HackRFOutputSettings::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("log2Interp") || force) {
|
||||||
|
ostr << " m_log2Interp: " << m_log2Interp;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("fcPos") || force) {
|
||||||
|
ostr << " m_fcPos: " << m_fcPos;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("lnaExt") || force) {
|
||||||
|
ostr << " m_lnaExt: " << m_lnaExt;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("vgaGain") || force) {
|
||||||
|
ostr << " m_vgaGain: " << m_vgaGain;
|
||||||
|
}
|
||||||
|
if (settingsKeys.contains("bandwidth") || force) {
|
||||||
|
ostr << " m_bandwidth: " << m_bandwidth;
|
||||||
|
}
|
||||||
|
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("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());
|
||||||
|
}
|
||||||
|
@ -48,6 +48,8 @@ struct HackRFOutputSettings {
|
|||||||
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 HackRFOutputSettings& settings);
|
||||||
|
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _HACKRF_HACKRFOUTPUTSETTINGS_H_ */
|
#endif /* _HACKRF_HACKRFOUTPUTSETTINGS_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user