From d816d27c7499695e314d593171f7a10d7cac87e2 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Fri, 12 Mar 2021 09:02:26 -0600 Subject: [PATCH] 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 --- rigs/dummy/flrig.c | 2 +- src/rig.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rigs/dummy/flrig.c b/rigs/dummy/flrig.c index 746e58feb..d564b13a9 100644 --- a/rigs/dummy/flrig.c +++ b/rigs/dummy/flrig.c @@ -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__, value); - RETURNFUNC(-(102 + RIG_EPROTO)); + RETURNFUNC(-RIG_EPROTO); } else { diff --git a/src/rig.c b/src/rig.c index c17518fbb..c719759d8 100644 --- a/src/rig.c +++ b/src/rig.c @@ -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); + // 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) { 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) { 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); } else @@ -1979,6 +1985,7 @@ int HAMLIB_API rig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) int rc2; vfo_t curr_vfo; + rig_debug(RIG_DEBUG_TRACE, "%s: not targetable need vfo swap\n", __func__); if (!caps->set_vfo) { RETURNFUNC(-RIG_ENAVAIL);