From b9b3d1d6f57cfbc8e73ab5ed5c0d7e1e29cf9a34 Mon Sep 17 00:00:00 2001 From: Uwe Risse Date: Tue, 3 May 2022 15:46:17 +0200 Subject: [PATCH] A slightly better solution to fix the 55 Hz problem with OmniRig v1.19 and later. --- Transceiver/OmniRigTransceiver.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Transceiver/OmniRigTransceiver.cpp b/Transceiver/OmniRigTransceiver.cpp index 0d16c9a02..4aa68994d 100644 --- a/Transceiver/OmniRigTransceiver.cpp +++ b/Transceiver/OmniRigTransceiver.cpp @@ -280,24 +280,30 @@ int OmniRigTransceiver::do_start () resolution = 2; // 20Hz rounded } } - QThread::msleep (200); // For Omnirig v1.19 or later we need a delay here, otherwise rig QRG stays at +55 Hz. - // 200 ms should do job for all modern transceivers. However, with very slow - // transceivers or receivers, rig QRG may still stay at +55 Hz. - // Because of the asynchronous nature of Omnirig commands, a better solution would be - // to implement an event handler for the OnParamChange event of OmniRig, - // and read the frequency inside that handler. + + // For OmniRig v1.19 or later we need a delay between GetRxFrequency () and SetFreq (f), + // otherwise rig QRG stays at f+55 Hz. 200 ms should do job for all modern transceivers. + // However, with very slow rigs, QRG may still stay at f+55 Hz. Such rigs should use v1.18. + // Due to the asynchronous nature of Omnirig commands, a better solution would be to implement + // an event handler for OmniRig's OnParamChange event and read the frequency inside that handler. if (OmniRig::PM_FREQ & writable_params_) { - rig_->SetFreq (f); + QTimer::singleShot (200, [=] { + rig_->SetFreq (f); + }); } else if (reversed_ && (OmniRig::PM_FREQB & writable_params_)) { - rig_->SetFreqB (f); + QTimer::singleShot (200, [=] { + rig_->SetFreqB (f); + }); } else if (!reversed_ && (OmniRig::PM_FREQA & writable_params_)) { - rig_->SetFreqA (f); + QTimer::singleShot (200, [=] { + rig_->SetFreqA (f); + }); } update_rx_frequency (f); CAT_TRACE ("started");