Fix FlRig conditon where 0Hz can be returned on a network error

Was returning a bad error code
If any rig returns 0 Hz freq will be returned from cache instead
I don't think there's anytime we want a zero Hz frequency
pull/608/head
Michael Black W9MDB 2021-03-12 09:02:26 -06:00
rodzic 8202c86586
commit d816d27c74
2 zmienionych plików z 9 dodań i 2 usunięć

Wyświetl plik

@ -1072,7 +1072,7 @@ static int flrig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
{ {
rig_debug(RIG_DEBUG_ERR, "%s: freq==0??\nvalue=%s\n", __func__, rig_debug(RIG_DEBUG_ERR, "%s: freq==0??\nvalue=%s\n", __func__,
value); value);
RETURNFUNC(-(102 + RIG_EPROTO)); RETURNFUNC(-RIG_EPROTO);
} }
else else
{ {

Wyświetl plik

@ -1831,6 +1831,12 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq)
retcode = caps->get_freq(rig, vfo, freq); retcode = caps->get_freq(rig, vfo, freq);
// sometimes a network rig like FLRig will return freq=0
// so we'll just reuse the cache for that condition
if (*freq == 0) {
*freq = rig->state.cache.freq;
}
if (retcode == RIG_OK) if (retcode == RIG_OK)
{ {
rig->state.cache.freq = *freq; rig->state.cache.freq = *freq;
@ -1971,7 +1977,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
|| vfo == rig->state.current_vfo) || vfo == rig->state.current_vfo)
{ {
retcode = caps->set_mode(rig, vfo, mode, width); retcode = caps->set_mode(rig, vfo, mode, width);
rig_debug(RIG_DEBUG_TRACE, "%s: retcode after set_mode=%d\n", __func__, rig_debug(RIG_DEBUG_TRACE, "%s: targetable retcode after set_mode=%d\n", __func__,
retcode); retcode);
} }
else else
@ -1979,6 +1985,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width)
int rc2; int rc2;
vfo_t curr_vfo; vfo_t curr_vfo;
rig_debug(RIG_DEBUG_TRACE, "%s: not targetable need vfo swap\n", __func__);
if (!caps->set_vfo) if (!caps->set_vfo)
{ {
RETURNFUNC(-RIG_ENAVAIL); RETURNFUNC(-RIG_ENAVAIL);