Fix set freq on Sub VFO return to Main

https://github.com/Hamlib/Hamlib/issues/670
pull/680/head
Mike Black W9MDB 2021-04-23 11:01:17 -05:00
rodzic b0e006ce6c
commit d0af094d39
1 zmienionych plików z 9 dodań i 27 usunięć

Wyświetl plik

@ -1691,6 +1691,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
const struct rig_caps *caps;
int retcode;
freq_t freq_new = freq;
vfo_t vfo_save;
rig_debug(RIG_DEBUG_VERBOSE, "%s called vfo=%s, freq=%.0f\n", __func__,
rig_strvfo(vfo), freq);
@ -1710,8 +1711,6 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
caps = rig->caps;
vfo = vfo_fixup(rig, vfo);
if (rig->state.lo_freq != 0.0)
{
freq -= rig->state.lo_freq;
@ -1728,6 +1727,9 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
RETURNFUNC(-RIG_ENAVAIL);
}
vfo_save = rig->state.current_vfo;
vfo = vfo_fixup(rig, vfo);
if ((caps->targetable_vfo & RIG_TARGETABLE_FREQ)
|| vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo)
{
@ -1735,6 +1737,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
rig_debug(RIG_DEBUG_TRACE, "%s: Ignoring set_freq due to VFO twiddling\n",
__func__);
if (vfo != vfo_save && vfo != RIG_VFO_CURR) rig_set_vfo(rig, vfo_save);
RETURNFUNC(
RIG_OK); // would be better as error but other software won't handle errors
}
@ -1752,7 +1755,7 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
set_cache_freq(rig, vfo, (freq_t)0);
#if 0 // this verification seems to be causing bad behavior on some reigs
#if 0 // this verification seems to be causing bad behavior on some rigs
if (caps->get_freq)
{
@ -1790,8 +1793,6 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
rig_debug(RIG_DEBUG_TRACE, "%s: not a TARGETABLE_FREQ vfo=%s\n", __func__,
rig_strvfo(vfo));
int rc2;
vfo_t curr_vfo;
if (!caps->set_vfo)
{
@ -1802,33 +1803,12 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
{
rig_debug(RIG_DEBUG_TRACE, "%s: Ignoring set_freq due to VFO twiddling\n",
__func__);
if (vfo != vfo_save && vfo != RIG_VFO_CURR) rig_set_vfo(rig, vfo_save);
RETURNFUNC(
RIG_OK); // would be better as error but other software won't handle errors
}
curr_vfo = rig->state.current_vfo;
retcode = caps->set_vfo(rig, vfo);
// why is the line below here?
// it's causing set_freq on the wrong vfo
//vfo = rig->state.current_vfo; // can't call get_vfo since Icoms don't have it
if (retcode != RIG_OK)
{
rig_debug(RIG_DEBUG_ERR, "%s: set_vfo(%s) err %.10000s\n", __func__,
rig_strvfo(vfo), rigerror(retcode));
RETURNFUNC(retcode);
}
retcode = caps->set_freq(rig, vfo, freq);
/* try and revert even if we had an error above */
rc2 = caps->set_vfo(rig, curr_vfo);
if (RIG_OK == retcode)
{
/* return the first error code */
retcode = rc2;
}
}
if (retcode == RIG_OK && caps->get_freq != NULL)
@ -1866,6 +1846,8 @@ int HAMLIB_API rig_set_freq(RIG *rig, vfo_t vfo, freq_t freq)
set_cache_freq(rig, vfo, freq_new);
if (vfo != vfo_save && vfo != RIG_VFO_CURR) rig_set_vfo(rig, vfo_save);
RETURNFUNC(retcode);
}