From fca384dcd69c14fcd39535a6ac532c99ee1f2ffb Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Tue, 12 May 2020 12:16:12 -0400 Subject: [PATCH 1/2] Fix debug statement in icom.c --- rigs/icom/icom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rigs/icom/icom.c b/rigs/icom/icom.c index 3f11f92f5..81be142b1 100644 --- a/rigs/icom/icom.c +++ b/rigs/icom/icom.c @@ -3927,7 +3927,7 @@ int icom_get_split_freq(RIG *rig, vfo_t vfo, freq_t *tx_freq) return retval; } if (ptt) { - rig_debug(RIG_DEBUG_TRACE, "%s: split is on so returning last known freq\n", __func__); + rig_debug(RIG_DEBUG_TRACE, "%s: ptt is on so returning last known freq\n", __func__); *tx_freq = priv->vfob_freq; return RIG_OK; } From 28ce6d0b54b500fc8b7329eed58b725b94690d3d Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Tue, 12 May 2020 13:19:33 -0400 Subject: [PATCH 2/2] Fix ptt cache -- not specific to IC910 but was noticed during debugging this problem https://github.com/Hamlib/Hamlib/issues/237 --- src/rig.c | 106 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/src/rig.c b/src/rig.c index c3499f925..aa14d5a2e 100644 --- a/src/rig.c +++ b/src/rig.c @@ -1191,6 +1191,7 @@ static int twiddling(RIG *rig) return 1; // would be better as error but other software won't handle it } } + return 0; // } @@ -1364,7 +1365,9 @@ int HAMLIB_API rig_get_freq(RIG *rig, vfo_t vfo, freq_t *freq) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { retcode = caps->get_freq(rig, vfo, freq); - if (retcode == RIG_OK) { + + if (retcode == RIG_OK) + { rig->state.cache.freq = *freq; rig->state.cache.vfo_freq = vfo; } @@ -1820,7 +1823,8 @@ int HAMLIB_API rig_set_vfo(RIG *rig, vfo_t vfo) } else { - rig_debug(RIG_DEBUG_ERR, "%s: set_vfo %s failed with '%s'\n", __func__, rig_strvfo(vfo), rigerror(retcode)); + rig_debug(RIG_DEBUG_ERR, "%s: set_vfo %s failed with '%s'\n", __func__, + rig_strvfo(vfo), rigerror(retcode)); } // we need to update our internal freq to avoid getting detected as twiddling @@ -2158,9 +2162,15 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) || vfo == RIG_VFO_CURR || vfo == rig->state.current_vfo) { + retcode = caps->get_ptt(rig, vfo, ptt); - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return caps->get_ptt(rig, vfo, ptt); + if (retcode == RIG_OK) + { + rig->state.cache.ptt = *ptt; + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + } + + return retcode; } if (!caps->set_vfo) @@ -2184,6 +2194,7 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) { /* return the first error code */ retcode = rc2; + rig->state.cache.ptt = *ptt; elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); } @@ -2192,8 +2203,15 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) case RIG_PTT_SERIAL_RTS: if (caps->get_ptt) { - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return caps->get_ptt(rig, vfo, ptt); + retcode = caps->get_ptt(rig, vfo, ptt); + + if (retcode == RIG_OK) + { + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + rig->state.cache.ptt = *ptt; + } + + return retcode; } if (strcmp(rs->pttport.pathname, rs->rigport.pathname) @@ -2202,25 +2220,29 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) /* port is closed so assume PTT off */ *ptt = RIG_PTT_OFF; - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - rig->state.cache.ptt = *ptt; } else { retcode = ser_get_rts(&rig->state.pttport, &status); *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - rig->state.cache.ptt = *ptt; } + rig->state.cache.ptt = *ptt; elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); return retcode; case RIG_PTT_SERIAL_DTR: if (caps->get_ptt) { - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return caps->get_ptt(rig, vfo, ptt); + retcode = caps->get_ptt(rig, vfo, ptt); + + if (retcode == RIG_OK) + { + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + rig->state.cache.ptt = *ptt; + } + + return retcode; } if (strcmp(rs->pttport.pathname, rs->rigport.pathname) @@ -2229,46 +2251,78 @@ int HAMLIB_API rig_get_ptt(RIG *rig, vfo_t vfo, ptt_t *ptt) /* port is closed so assume PTT off */ *ptt = RIG_PTT_OFF; - rig->state.cache.ptt = *ptt; - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); } else { retcode = ser_get_dtr(&rig->state.pttport, &status); *ptt = status ? RIG_PTT_ON : RIG_PTT_OFF; - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - rig->state.cache.ptt = *ptt; } + rig->state.cache.ptt = *ptt; elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); return retcode; case RIG_PTT_PARALLEL: if (caps->get_ptt) { - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return caps->get_ptt(rig, vfo, ptt); + retcode = caps->get_ptt(rig, vfo, ptt); + + if (retcode == RIG_OK) + { + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + rig->state.cache.ptt = *ptt; + } + + return retcode; } - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return par_ptt_get(&rig->state.pttport, ptt); + retcode = par_ptt_get(&rig->state.pttport, ptt); + + if (retcode == RIG_OK) + { + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + rig->state.cache.ptt = *ptt; + } + + return retcode; case RIG_PTT_CM108: if (caps->get_ptt) { - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return caps->get_ptt(rig, vfo, ptt); + retcode = caps->get_ptt(rig, vfo, ptt); + + if (retcode == RIG_OK) + { + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + rig->state.cache.ptt = *ptt; + } + + return retcode; } - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return cm108_ptt_get(&rig->state.pttport, ptt); + retcode = cm108_ptt_get(&rig->state.pttport, ptt); + + if (retcode == RIG_OK) + { + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + rig->state.cache.ptt = *ptt; + } + + return retcode; case RIG_PTT_GPIO: case RIG_PTT_GPION: if (caps->get_ptt) { - elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); - return caps->get_ptt(rig, vfo, ptt); + retcode = caps->get_ptt(rig, vfo, ptt); + + if (retcode == RIG_OK) + { + elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET); + rig->state.cache.ptt = *ptt; + } + + return retcode; } elapsed_ms(&rig->state.cache.time_ptt, ELAPSED_SET);