1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

HackRF: use software LO ppm correction since hardware correction does not work. Fixes #1443

This commit is contained in:
f4exb 2022-09-26 22:26:28 +02:00
parent c099a47327
commit 7a87155086
4 changed files with 18 additions and 16 deletions

View File

@ -316,12 +316,15 @@ bool HackRFOutput::handleMessage(const Message& message)
}
}
void HackRFOutput::setDeviceCenterFrequency(quint64 freq_hz)
void HackRFOutput::setDeviceCenterFrequency(quint64 freq_hz, int loPpmTenths)
{
if (!m_dev) {
return;
}
qint64 df = ((qint64)freq_hz * loPpmTenths) / 10000000LL;
freq_hz += df;
hackrf_error rc = (hackrf_error) hackrf_set_freq(m_dev, static_cast<uint64_t>(freq_hz));
if (rc != HACKRF_SUCCESS) {
@ -422,10 +425,8 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
reverseAPIKeys.append("centerFrequency");
}
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
{
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
reverseAPIKeys.append("LOppmTenths");
DeviceHackRF::setDevicePPMCorrection(m_dev, settings.m_LOppmTenths);
}
if ((m_settings.m_fcPos != settings.m_fcPos) || force) {
reverseAPIKeys.append("fcPos");
@ -442,7 +443,8 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
(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) || force)
(m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) ||
(m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
{
qint64 deviceCenterFrequency = DeviceSampleSink::calculateDeviceCenterFrequency(
settings.m_centerFrequency,
@ -451,7 +453,7 @@ bool HackRFOutput::applySettings(const HackRFOutputSettings& settings, bool forc
(DeviceSampleSink::fcPos_t) settings.m_fcPos,
settings.m_devSampleRate,
settings.m_transverterMode);
setDeviceCenterFrequency(deviceCenterFrequency);
setDeviceCenterFrequency(deviceCenterFrequency, settings.m_LOppmTenths);
if (m_deviceAPI->getSourceBuddies().size() > 0)
{

View File

@ -159,7 +159,7 @@ private:
void closeDevice();
bool applySettings(const HackRFOutputSettings& settings, bool force);
// hackrf_device *open_hackrf_from_sequence(int sequence);
void setDeviceCenterFrequency(quint64 freq_hz);
void setDeviceCenterFrequency(quint64 freq_hz, int loPpmTenths);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFOutputSettings& settings, bool force);
void webapiReverseSendStartStop(bool start);

View File

@ -329,12 +329,15 @@ bool HackRFInput::handleMessage(const Message& message)
}
}
void HackRFInput::setDeviceCenterFrequency(quint64 freq_hz)
void HackRFInput::setDeviceCenterFrequency(quint64 freq_hz, int loPpmTenths)
{
if (!m_dev) {
return;
}
qint64 df = ((qint64)freq_hz * loPpmTenths) / 10000000LL;
freq_hz += df;
hackrf_error rc = (hackrf_error) hackrf_set_freq(m_dev, static_cast<uint64_t>(freq_hz));
if (rc != HACKRF_SUCCESS) {
@ -421,13 +424,9 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
if (force || (m_settings.m_centerFrequency != settings.m_centerFrequency)) {
reverseAPIKeys.append("centerFrequency");
}
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
{
if ((m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force) {
reverseAPIKeys.append("LOppmTenths");
DeviceHackRF::setDevicePPMCorrection(m_dev, settings.m_LOppmTenths);
}
if ((m_settings.m_fcPos != settings.m_fcPos) || force) {
reverseAPIKeys.append("fcPos");
}
@ -443,7 +442,8 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
(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) || force)
(m_settings.m_transverterDeltaFrequency != settings.m_transverterDeltaFrequency) ||
(m_settings.m_LOppmTenths != settings.m_LOppmTenths) || force)
{
qint64 deviceCenterFrequency = DeviceSampleSource::calculateDeviceCenterFrequency(
settings.m_centerFrequency,
@ -453,7 +453,7 @@ bool HackRFInput::applySettings(const HackRFInputSettings& settings, bool force)
settings.m_devSampleRate,
DeviceSampleSource::FrequencyShiftScheme::FSHIFT_TXSYNC,
settings.m_transverterMode);
setDeviceCenterFrequency(deviceCenterFrequency);
setDeviceCenterFrequency(deviceCenterFrequency, settings.m_LOppmTenths);
if (m_deviceAPI->getSinkBuddies().size() > 0) // forward to buddy if necessary
{

View File

@ -159,7 +159,7 @@ private:
bool openDevice();
void closeDevice();
bool applySettings(const HackRFInputSettings& settings, bool force);
void setDeviceCenterFrequency(quint64 freq);
void setDeviceCenterFrequency(quint64 freq, int loPpmTenths);
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const HackRFInputSettings& settings, bool force);
void webapiReverseSendStartStop(bool start);